Skip to main content
GameDev.net gamedev.net
🔒 Locked

glViewport question.

Started by kcauwert2 Oct 6, 2006 at 1:45 PM 1 replies 750+ views
Original Post
kcauwert2
kcauwert2
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; }
Red_falcon
Red_falcon
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.
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish
vermilion_wizard
vermilion_wizard
I think glViewport just locates your drawing inside the window. You should use gluOrtho2D or glOrtho in addition to glViewport.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.