Jump to content
  • Advertisement

Archived

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

zotya

Problem with drawing

This topic is 5484 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

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!