OpenGL with WIN 32
I'm learning OpenGL, but I have lots of troubles at startup!
I want to draw some stuff in a window, so I "create" rendering context and make it corrent.After all I release and delete the device, but it don't work. I do this all in the window procedure as follows:
If somebody can help me, I'l be happy.
hDC = ::GetDC(hwnd);
ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat( hDC, &pfd );
SetPixelFormat( hDC, iFormat, &pfd );
hRC = wglCreateContext( NULL );
hRC = wglCreateContext( hDC );
if(!wglMakeCurrent( hDC, hRC ))
MessageBox (NULL, "Main Window Initialization ERROR!",
glColor3f(1, 0, 0);
glColor3f(0, 0, 1);
wglMakeCurrent( NULL, NULL );
wglDeleteContext( hRC );
::ReleaseDC( hwnd, hDC );
return 0; // return zero when processed
Thank you in advance!
Dont rely on WM_PAINT for OpenGL......create a Render() function (or whatever), place your drawing code here and call it once in each messageloop......lookup NEHE over @ gamedev.net for ideas
How can I do that?
This procedure is called while the window is creating and it will call this render() function before hDC ad hRC are ready and before call of the stuff in WM_CREATE at all.
As I said - have a look at nehe