Jump to content
  • Advertisement
Sign in to follow this  
Hacksaw2201

Ortho Camera and 2D image

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

Any ideas as to why my camera isn't drawing a "simple" 2D quad? glOrtho(0, 640, 480, 0, 1, 100); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glBegin(GL_QUADS); glColor3f(1.0, 1.0, 1.0); glVertex2d(0, 0); glVertex2d(64,0); glVertex2d(64,64); glVertex2d(0,64); glEnd(); glPopMatrix();

Share this post


Link to post
Share on other sites
Advertisement
A quick guess would be that you've defined your depth range to be 1 to 100, but Vertex2d defaults to a z coord of 0 meaning it's clipped by the near plane.

(disclaimer: I'm half asleep and can't be bothered looking up the order of args for glOrtho. I could be completely wrong).

Share this post


Link to post
Share on other sites
Nevermind. Found a previous post about it.

void glEnable2D()
{
int vPort[4];

glGetIntegerv(GL_VIEWPORT, vPort);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

glOrtho(0, vPort[2], 0, vPort[3], -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}

void glDisable2D()
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}

glEnable2D();
glBegin(GL_TRIANGLES);
glColor3ub(255, 0, 0);
glVertex2d(0, 0);
glColor3ub(0, 255, 0);
glVertex2d(100,0);
glColor3ub(0, 0, 255);
glVertex2d(50, 50);
glEnd();
glDisable2D();

Works like a charm ...... now onto bigger and better stuff. :-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!