Hello,
Im having trouble with a graident background on an MFC View. Basically I need to get the size of the view and then pass that to the Vertexs that draw the quad. Ic an seem to make anything work.
GLdouble modelMatrix[16];
GLdouble projMatrix[16];
// Map the OpenGL coordinates.
glViewport(0, 0, cx, cy);
// Projection view
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set our current view perspective
double aspect = double(cx)/double(cy);
if( aspect > (4.0 / 3.0) ) {
// short fat view
m_height = tan( 35.0 / 360.0 * PI ) * 0.01;
m_width = m_height * aspect;
} else {
// tall skinny view
m_width = tan( 50.0 / 360.0 * PI ) * 0.01;
m_height = m_width / aspect;
}
if( !upsidedown ) {
glFrustum( -m_width, m_width, -m_height, m_height, 0.01, 2000.0 );
} else {
glFrustum( -m_width, m_width, m_height, -m_height, 0.01, 2000.0 );
}
// Model view
glMatrixMode(GL_MODELVIEW);
and to render the quad:
glPushMatrix();
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBegin(GL_QUADS); // Start Drawing A Quad
glColor4d(0.2, 0.2, 0.6, 1.0);
glVertex3d(-2.0, 1.0, -3.0); // Top Left Of The Quad
glVertex3d( 2.0, 1.0, -3.0); // Top Right Of The Quad
glColor4d(0.9, 0.9, 1.0, 1.0);
glVertex3d( 2.0,-1.0, -3.0); // Bottom Right Of The Quad
glVertex3d(-2.0,-1.0, -3.0); // Bottom Left Of The Quad
glEnd();
glPopMatrix();
Im guessing that i need to use the viewport but Im lost.
Thanks
-Derrek