Archived

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

zotya

Problem with drawing

Recommended Posts

Hi! I have a (strange?) problem when drawing triangles, quads, etc. If I draw something, I have to do a glLoadIdentity() or a glTranslatef() after the glEnd() or I won''t see it. I''m using opengl with SDL under linux. It worked fine, but I updated my X window to 4.3 and from that on this problem occurs. It is not really a big trouble yet, because I only have to do 1 extra glLoadId. or glTrans., but I don''t want it to later turn into bigger errors. Anybody could help me?

Share this post


Link to post
Share on other sites
OK: here is it(it is from NeHe's tutorial)

void InitOpenGL()
{
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}

void DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-1.5f,0.0f,-6.0f);

glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();

glTranslatef(3.0f,0.0f,0.0f);

glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();

glLoadIdentity(); // if I don't put this here, it won't draw

// the quadrangle!!!!!!!!!!!!!

SDL_GL_SwapBuffers();
}

If you need some more, ask me for it(e.g. ResizeWindow)!

[edited by - zotya on November 15, 2003 11:01:30 AM]

[edited by - zotya on November 15, 2003 11:02:40 AM]

Share this post


Link to post
Share on other sites
Try pushing the matrix at the start and then popping it at the end.

EDIT: A bit more information

Do that in the DrawGLScene() function.
You're translating but not restoring the translation matrix afterwards which will lead to weird things.

[edited by - Wormy Hellcar on November 15, 2003 11:31:57 AM]

Share this post


Link to post
Share on other sites