Posted by DaRKFoRCe on 2000-05-09
Hi,
I'm new with and still learning OpenGL. I'm trying to make a simple
OpenGL apps, but the 'OpenGL window' always blank. Here's the code
snippet (only WM_CREATE message handler) :
in the window callback function (hdc & hrc is a global variable) :
case WM_CREATE :
hdc = GetDC(hwnd);
preparePixelFormat(hdc) // my own function, setting the hdc's
// pixel format to RGBA 24 bit color,
// with 32 bit depth z-buffer and
// double buffering
hrc = wglCreateContext(hdc);
wglMakeCurrent(hdc,hrc);
draw_triangle();
SwapBuffers(hdc);
return 0;
the draw_triangle() function :
void draw_triangle(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity()
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glColor3f(1.0, 0.0, 0.0, 0.0);
glBegin(GL_TRIANGLES)
glVertex2f(0.25, 0.25);
glVertex2f(0.75, 0.25);
glVertex2f(0.75, 0.75);
glEnd();
glFlush();
}
I have tested each API's return values and error codes, and
everything runs fine/no error, except for the rendering context
returned by wglCreateContext() that always 0xFF. Is this a valid
handle? In comparison, the hdc range from 1916 to 1918 in every test
runs. I have also checked with wglGetCurrentContext() and
wglGetCurrentDC(), both return the exact value of the previous hdc
and hrc (that is, the hrc is also 0xFF).
What mistake do I make? Why the window always blank? Do I miss some
initialization step?
DaRKFoRCe
darkforce@xxxxxxxxxxx.xxx
Previous post | Next post | Timeline | Home