Jump to content
  • Advertisement
Sign in to follow this  
ktuluorion

OpenGL setting (0,0) to be in the center of the screen

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

Hey all, i'm an OpenGL newbie, and I am trying to set the coordinate system so that (0,0,0) is located in the center of the window, instead of the top left corner. Here's my source, can anyone help me get how to do this? I've been tweaking #'s in the GLOrtho2d and GLViewport calls, but haven't quite been able to get it.
glutInit (&argc, argv);                         // Initialize GLUT.
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);   // Set display mode.
    glutInitWindowPosition (50, 100);   // Set top-left display-window position.
    glutInitWindowSize (400, 300);      // Set display-window width and height.
    glutCreateWindow ("Boxes"); // Create display window.
    glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0,400,0,300);
	glViewport(0,0,400,300);


Edit: I'm working in 2d, BTW.

Share this post


Link to post
Share on other sites
Advertisement
.\main.cpp(18) : error C3861: 'gluOrtho': identifier not found

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho(-200,200,-150,150);

Share this post


Link to post
Share on other sites
Just look at the parameters of the function you are calling.

Quote:

void gluOrtho2D(GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top)


The earlier poster was right and if you wanted 400 width and 300 height with 0,0 in the middle you would use:

gluOrtho2D(-200, 200, -150, 150);

Where -x is left and -y is down.

Share this post


Link to post
Share on other sites
Yes, but it doesn't seem to change anything when I change the values to those, or any other ones.

It just seems like the function is doing nothing.

Share this post


Link to post
Share on other sites
Yes, but it doesn't seem to change anything when I change the values to those, or any other ones.

It just seems like the function is doing nothing.

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!