Coder's Guild Mailing List

Re: help : OpenGL in Win 98

Posted by Thomas Mathys on 2000-05-09

tcg@xxxx.xx.xx wrote:
> 
> Contents:
> help : OpenGL in Win 98 (DaRKFoRCe <darkforce@xxxxxxxxxxx.xxx>)
> 
> > 
> Date: Tue, 9 May 2000 18:08:29 +0700
> From: DaRKFoRCe <darkforce@xxxxxxxxxxx.xxx>
> Subject: help : OpenGL in Win 98
> 
> 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

I'm not sure, but i think you mustn't use glFlush(), only
SwapBuffers(). At least some example program I've seen in
a book didn't use glFlush

Tom