Sign in to follow this  
kcauwert2

glViewport question.

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

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