Archived

This topic is now archived and is closed to further replies.

No show for GL_TRIANGLES

This topic is 5097 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I haven''t had the opportunity to work with OpenGL in a while so I think I may be forgetting something for rendering. When I try to render a triangle, it cannot be seen. I''ve been using integers instead of floats for color and vertex. Rendering calls: glMatrixMode(GL_MODELVIEW); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBegin(GL_TRIANGLES); glColor3i(255,255,255); glVertex3i(1,1,-2);glVertex3i(0,-1,-2);glVertex3i(-1,1,-2); glEnd(); My initial GL calls were: glShadeModel (GL_SMOOTH); glClearColor (1.0f, 0.0f, 0.0f, 0.0f); glClearDepth (1.0f); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL); glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glViewport(0,0,640,480); gluPerspective( 45.0, (GLfloat)(640)/(GLfloat)(480), 0.1f, 500.0); The window is create with SDL and has GL_DOUBLEBUFFERING. I call glFlush() SDL_SwapBuffers() at the end of the Render function. At first glance, it seems like a white triangle should be visible infront of the camera... Not sure what''s missing. Also, what ways could I use to generate verteces of a certain number in a patter that would cause most hidden surface remove methods to be forced to render most triangles(spacing them so that a maximum amount is visible). I''m trying to compare differences with HSR methods by generate large sets of triangles to test them with and the experiment is more effective if a very large number of triangles need to be rendered. Thanks.

Share this post


Link to post
Share on other sites
Well, right off, calls to gluPerspective should be made to the projection matrix (not the modelview matrix as you are using here).

If you don't remember how to switch matrices just look below:

//...

glViewPort (0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective( 45.0, (GLfloat)(640)/(GLfloat)(480), 0.1f, 500.0);
glMatrixMode(GL_MODELVIEW);
//...



BTW, I don't see any need to load the modelview matrix every frame (as long as you always switch it back whenever you change it).

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________


[edited by - Thunder_Hawk on January 4, 2004 2:14:21 AM]

Share this post


Link to post
Share on other sites
I really want to help you. It looks like you recently started on OpenGL. I''m also learning/doing OpenGL through SDL. Do you have an AIM SN? Mine is Leiarchy9. Please IM me so we could thoroughly work through this so I could help you with not only this problem, but with future problems.

--------
"Do you believe in Ghost?"

Share this post


Link to post
Share on other sites
Thunder_Hawk: I''m well aware that the GL_MODELVIEW does not have to be set every frame.
Leiarchy9: I definately did not just start OpenGL, I just haven''t touched it in quite a while.

Now that glLoadIdentity() is before gluPerspective(), the text is no longer visible

Share this post


Link to post
Share on other sites