Jump to content
  • Advertisement
Sign in to follow this  
LinkOfTime

OpenGL Beginners question: Can't get OpenGL to draw outside coordinates -1 - 1. Why?

This topic is 2349 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've been studing OpenGL at the uni' and I'm a bit stuck on this topic.
No matter how I define the gluOrtho2D coordinates, or the glViewport, I just can't seem to draw anything outside of coordinates -1.0 - 1.0. Anything I draw outside of these coordinates is just not shown.

Here's a test code I've been trying to play with:

void myMouseFunc(int button, int state, int x, int y) {
if (state == GLUT_DOWN)
exit(0);
}

void myDispFunc() {
glClearColor(1.0f, 1.0f, 0.0f, 0.0);
glClear(GL_COLOR_BUFFER_BIT);

glRectf(0, 0, 1, 1);

glFlush();
}

void testFunc(int* argc, char** argv) {
glutInit(argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(800,600);
glutInitWindowPosition(0,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 15, 0, 15);
glViewport(0,0,800,600);
glutCreateWindow("Test window!");
glutMouseFunc(myMouseFunc);
glutDisplayFunc(myDispFunc);

glutMainLoop();
}


Thank you all in advance for trying to help smile.png

Share this post


Link to post
Share on other sites
Advertisement
You need to move the OpenGL code to after glutCreateWindow. No window means no rendering context, and no rendering context means no OpenGL.

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!