OpenGL & Win32 Dialog Box

hey, I made a win32 dialog box and put a frame on it. In the WM_INITDIALOG message handler, I got the handle to the frame’s window, got the size, and created an opengl context for it. It works sort of, because when I clear, the frame’s background changes to my clear color, but I can’t draw anything in it. I tried doing a GL_QUAD but I couldn’t see it. Any suggestions?

Check on my website, I’ve the example likes yours.

I appreciate the help, but after browsing through your website, you don’t have an example of what I’m trying to do. Here’s a look at what i’m trying to do:

[This message has been edited by Laz (edited 05-29-2003).]

If it cleared, you probably got the OpenGL stuff initialized correctly. If your quad isn’t being drawn, it could be due to any number of things. How did you setup your PROJECTION and MODELVIEW matrices? Where do you draw the Quad? One of the most likely reasons you don’t see your quad is because you are drawing it outside of the viewing frustum. (e.g. in front of the near clip plane, behind the back clip plane, etc.)

Check out chapter 3 of the red book. There is a section in it about debugging transformations, and it lists the most common causes of the “blank screen” effect. You can find it online with a Google search.

As far as I know, the rendering code is correct. I’ve had a few people look at it, but here it is in case you guys see any blatant errors that I missed:

////////////////////////////////////////////////////////////////////////////////
// Function: DrawScene();
//
// Last Modified: April 07, 2003
//
// Purpose: Renders opengl things
////////////////////////////////////////////////////////////////////////////////
void DrawScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();
glTranslatef(0.0f, 0.0f, -50.0f);

  glColor3f(1.0f, 1.0f, 1.0f);
  glBegin(GL_QUADS);
  	glVertex3f(-100.0f, 100.0f, 0.0f);
  	glVertex3f(-100.0f, -100.0f, 0.0f);
  	glVertex3f(100.0f, -100.0f, 0.0f);
  	glVertex3f(100.0f, 100.0f, 0.0f);
  glEnd();

glPopMatrix();

// Swap the buffers
SwapBuffers(hDC);
}

I’m about to try something a bit different, so we’ll see how that turns out. I’ll post an update if I get it working. Thanks for the help guys.

and how is your projection matrix set up? is the modelview matrix the identity when you call DrawScene()? if not, what is it? is lighting disabled?

// Set the Matrix mode
glMatrixMode(GL_PROJECTION);

// Load the Identity Matrix
glLoadIdentity();

// Set the perspective
gluPerspective(35.0f, fAspect, 1.0f, 500.0f);

// Reset back to the Modelview Matrix so we can do some drawing
glMatrixMode(GL_MODELVIEW);

// Load the identity matrix … again …
glLoadIdentity();

As far as I know, I’m doing this correctly. I copied and pasted code from a previous applcation that worked fine. The only difference is the dialog box.

Oh my god, I’m an idiot. This whole time, I had nWidth set to rRect.left instead of rRect.right, so my aspect radio was always 0 (since rRect.left is 0 as well)

Thanks you guys, for the help. I’m going to go flush my head town a toilet now.