Sign in to follow this  

Ortho Camera and 2D image

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

This topic is 3863 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this