Problems Drawing a Tilted Quad at specified distance....

I know I am doing something really silly, but I don’t see the problem…

I am trying to draw a quad which covers the entire viewport, at some distance tilted at some specified angle to the LOS. For example, a quad at z=-10000, tilted back 30 deg. All is well, until I tilt the quad. I think instead of rotating about teh quads center, I must be rotating about the origin and thus swinging the quad outof the fov. Can someone point out my error? Thanks,
CD

void RenderScene()
{
	// Clear the screen and the depth buffer
	glClearColor( 0.0f, 0.0f, 1.0f, 1.0f );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );


	//	save current matrix mode
	GLint matrixMode;
	glGetIntegerv(GL_MATRIX_MODE, &matrixMode);  


	// Switch to Project Matrix Mode
	glMatrixMode(GL_PROJECTION);
	// save current projection matrix
	glPushMatrix();
	// reset projection matrix
	glLoadIdentity();


	//	set orthographic projection
	glOrtho(-1.0, 1.0, -1.0, 1.0, g_Hither, g_Yon);


	// switch to model-view matrix
	glMatrixMode(GL_MODELVIEW);
	// save current model-view matrix
	glPushMatrix();
	// reset model-view matrix
	glLoadIdentity();


	//	Draw tilted quad
	glLoadIdentity();
	glTranslatef(0.0, 0.0, -10000.0);
	glRotatef(30.0, 1.0, 0.0, 0.0);
	glPushAttrib(GL_COLOR_BUFFER_BIT | GL_LINE_BIT);
		glColor3f(1.0, 0.0, 1.0);
		glBegin(GL_QUADS);
			glVertex3f(-1.0, -1.0, -10000.0);
			glVertex3f( 1.0, -1.0, -10000.0);
			glVertex3f( 1.0,  1.0, -10000.0);
			glVertex3f(-1.0,  1.0, -10000.0);
		glEnd();
	glPopAttrib();

	// restore model-view matrix
	glPopMatrix();

	// switch to projection mode
	glMatrixMode(GL_PROJECTION);
	// restore projection matrix
	glPopMatrix();

	// restore original matrix mode
	glMatrixMode(matrixMode);


	glFlush();
    glutSwapBuffers();
}

Find my comments in the code:

void RenderScene()
{
  // Clear the screen and the depth buffer
  glClearColor( 0.0f, 0.0f, 1.0f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  //  save current matrix mode
  GLint matrixMode;
  glGetIntegerv(GL_MATRIX_MODE, &matrixMode);  

  // Switch to Project Matrix Mode
  glMatrixMode(GL_PROJECTION);
  // save current projection matrix
  glPushMatrix();
  // reset projection matrix
  glLoadIdentity();
  //  set orthographic projection
  glOrtho(-1.0, 1.0, -1.0, 1.0, g_Hither, g_Yon); 
  // If the rotated quad ends up at z values outside your near and far setting it gets clipped.
  // That is, if g_Yon is at 10000 then the below rotation will clip it definitely.
  // (Don't get confused by the sign, model space is right-handed, zFar is in the negative direction.
  //  Screen space is left-handed and zFar needs to be specified bigger than zNear there.)

  // switch to model-view matrix
  glMatrixMode(GL_MODELVIEW);
  // save current model-view matrix
  glPushMatrix();
  // reset model-view matrix
  glLoadIdentity();

  //  Draw tilted quad
  // glLoadIdentity(); // redundant
  
  // Matrices are left-multiplied in OpenGL, the one nearest to the glVertex call is done first.
  // You have to read these from the vertex call upwards to understand OpenGL's transformations.
  glTranslatef(0.0, 0.0, -10000.0); // Move object back to it's original position.
  glRotatef(30.0, 1.0, 0.0, 0.0); // This rotates around the origin but your object was far away before.
  // If the object should end up rotated around its local x-axis and positioned at -10000 you need to add this
  glTranslatef(0.0, 0.0, 10000.0); // Move the object into the origin.
 
  glPushAttrib(GL_COLOR_BUFFER_BIT | GL_LINE_BIT); // You probably only wanted GL_CURRENT_BIT to save the color?
    glColor3f(1.0, 0.0, 1.0);
    glBegin(GL_QUADS);
      glVertex3f(-1.0, -1.0, -10000.0);
      glVertex3f( 1.0, -1.0, -10000.0);
      glVertex3f( 1.0,  1.0, -10000.0);
      glVertex3f(-1.0,  1.0, -10000.0);
    glEnd();
  glPopAttrib();

  // restore model-view matrix
  glPopMatrix();

  // switch to projection mode
  glMatrixMode(GL_PROJECTION);
  // restore projection matrix
  glPopMatrix();

  // restore original matrix mode
  glMatrixMode(matrixMode);

  // glFlush(); // Not needed for double buffered OpenGL rendering before swap buffers.
  glutSwapBuffers();
}

Thanks,
That straightened me out…

CD