View Full Version : My Triangle Is'nt Showing Up??

Cloaked Coder
04-09-2009, 12:14 AM
I am using OpenGL and i am trying to get this simple program to work, here is my code;

void DrawScene ( void )

glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ( );

glPushMatrix ( );
glTranslatef ( -1.0f, 1.0f, 0.0f );
glBegin ( GL_TRIANGLES );

glVertex3f ( 0.5f, -0.5f, 0.0f );
glVertex3f ( 0.0f, 0.5f, 0.0f );
glVertex3f ( -0.5f, -0.5f, 0.0f );

glPopMatrix ( );
//end of triangle

glutSwapBuffers ( );

I dont get any errors, the triangle just doesnt show up.

any help would be greatly appreciated

Cloaked Coder
04-09-2009, 12:33 AM
I am using Visual Studio C++ 2008 Express Edition and i have Windows XP.

04-09-2009, 06:59 AM
Make sure the back face culling is set correctly.

If not texturing make sure you disable texture stages.

Projection matrix is set correctly before rendering with the viewport.

Your geometry have to be inside the view frustum, and make sure they lay after the near clipping plane.

Try to check for gl errors before every command if the above did not work.

04-09-2009, 08:16 AM
what colour is your clear colour
what colour are you giving the vertices when you draw ?

it's possible you are drawing them in black lol

04-09-2009, 09:28 AM
don't glTranslate. If projection matrix is identity you are effectively moving the triangle outside the view frustum.

Cloaked Coder
04-09-2009, 02:57 PM
Thanks guys!