Jump to content
  • Advertisement
Sign in to follow this  
kcauwert2

glViewport question.

This topic is 4304 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, glViewport is used to go from normalised coords (-1.0..+1.0) to window coords (0..500 in my case). But why does my code (see below) display the point glVertex2f( 0, 0.9 ) in normalised coords and not in window coords lik I want it to. Thanks, Example code: void displayFunction() { glClear(GL_COLOR_BUFFER_BIT); // clear the display // 1. Modelview transformation. glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // 2. Projection transformation. glMatrixMode( GL_PROJECTION ); glLoadIdentity(); // 3. Defining the viewport. glViewport( 0, 0, 500, 500 ); glColor3f(0.0f, 0.0f, 1.0f); glPointSize(5.0f); glBegin(GL_POINTS); glVertex2f( 0, 0.9 ); glEnd(); glFinish(); } int _tmain(int argc, _TCHAR* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB); glutInitWindowSize( 500, 500) ); glutCreateWindow("GLUT WINDOW"); glClearColor(0.0,0.0,0.0,0.0); glutDisplayFunc( displayFunction ); glutMainLoop(); return 0; }

Share this post


Link to post
Share on other sites
Advertisement
If i understand it right you want to display points in window coords, then i would say you need glOrtho. Cause in 3d you have different coordinate system.

Share this post


Link to post
Share on other sites
I think glViewport just locates your drawing inside the window. You should use gluOrtho2D or glOrtho in addition to glViewport.

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!