Sunday, 15 July 2012

c++ - How to design a plane to be in the center of the viewport at any window size -



c++ - How to design a plane to be in the center of the viewport at any window size -

i need draw plane (with gl_quads) in opengl (c++, os: windows) aligned center of screen.

what mean origin in center of plane @ window resize.

i know have utilize viewport coordinates , sizes, cannot configure how utilize them.

also, using gluperspective.

the origin has nil window size. when resize window, recalculate aspect ratio of window (window.width / window.height) , reset projection matrix phone call gluperspective using new aspect.

after this, long glloadidentity() modelview matrix should able draw quad @ center of screen using

glbegin(gl_quads); glvertex3f(-.5f,.5f,-1); glvertex3f(-.5f,-.5f,-1); glvertex3f(.5f,-.5f,-1); glvertex3f(.5f,.5f,-1); glend();

that should place unit sized quad @ center of screen.

c++ opengl

No comments:

Post a Comment