Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

render unit sphere 2D, OpenGL

Posted on 2008-10-07
4
Medium Priority
?
1,279 Views
Last Modified: 2013-12-06
Hey people, I need help rendering a unit sphere to a 2d img. by using the setpixel f'n. It is a 256 x 256.

This below only helps by covering all pixels and shading it white...

for (int x=0; x < 256; x++) {
            for (int y = 0; y < 256; y++) {
              int Px = ((x/128) - 1);
                   int Py = ((y/128) - 1);
              int Pz = sqrt(Px*Px);
                    if (sqrt(Px*Px + Py*Py) < 1)
                  img.setPixel(x, y, Pixel(1.0, 1.0, 1.0));
            
            }

      }

I also have to do lighting to shade this to make it look 3D..
Any help will be greatly appreciated! Thanks!
0
Comment
Question by:MANNYWOOD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:jose_juan
ID: 22666726
Hi MANNYWOOD,

to simulate 2D render use a glOrtho proyection matrix, in any case, you must use 3D real objects to compund your scene.

Before scene are rendered then get all viewport pixels with glReadPixels.

I think you don't need a realtime execution, in other case, (this way not is bad but) better (and complex) methods are available.

Do you need a explained example?

Good luck!
0
 

Author Comment

by:MANNYWOOD
ID: 22666840
I'm not too sure still...
The form/ skeleton is already given with the projection, viewing and drawing of the matrix.
I guess when I mean the below only helps by covering all pixels and shading it white, that is the top left box in openGL which has a 256x256 setting and also allows mouse controls to cover pixels in the area. I guess representing a circle really isn't that easy in openGL.

An explained example will defenitley help!, that is.. if you don't mind.
Thanks again jose_juan!
0
 
LVL 5

Accepted Solution

by:
jose_juan earned 375 total points
ID: 22666891
Uhm... ;-)

in OpenGL, all objects must be 3D (really not, but suppose it) if you like a circle then, Draw a toroids!

I recommend to you don't think in pixels units, better in frustum (or viewport) units.

Here a good page for create toroids at runtime.

http://www.gamedev.net/reference/articles/article1172.asp

Good luck!
0
 

Author Comment

by:MANNYWOOD
ID: 22666927
Thanks~ Hopefully I could understand this.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question