No show for GL_TRIANGLES

Started by
5 comments, last by tk05 20 years, 3 months ago
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.
Advertisement
EDIT: Look below...He is right

[edited by - tHiSiSbOb on January 4, 2004 1:42:13 AM]
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
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]
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
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?"
--------"Do you believe in Ghost?"
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
Ummmm, what text???

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
OGL newb.....
--------"Do you believe in Ghost?"

This topic is closed to new replies.

Advertisement