Hello,
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.Code:.... case WM_CREATE: PIXELFORMATDESCRIPTOR pfd; hDC = ::GetDC(hwnd); ZeroMemory( &pfd, sizeof( pfd ) ); pfd.nSize = sizeof( pfd ); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; 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!", "OpenGL Tester",MB_DEFBUTTON1); case WM_PAINT: glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glColor3f(1, 0, 0); glVertex2f(-5, -5); glVertex2f(-5, 5); glColor3f(0, 0, 1); glVertex2f(5, 5); glVertex2f(5, -5); glEnd(); glFlush(); break; case WM_DESTROY: wglMakeCurrent( NULL, NULL ); wglDeleteContext( hRC ); ::ReleaseDC( hwnd, hDC ); ::PostQuitMessage (0); return 0; // return zero when processed
Thank you in advance!



LinkBack URL
About LinkBacks


