here is my code:
#include <windows.h>#include <gl/gl.h>LRESULT CALLBACK WindowHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){ switch(msg){ case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); }}int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ WNDCLASSEX wincl; wincl.cbSize = sizeof(WNDCLASSEX); wincl.style = CS_OWNDC; wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hInstance = hThisInstance; wincl.lpszMenuName = NULL; wincl.lpszClassName = "MyWindowClass"; wincl.lpfnWndProc = WindowHandler; RegisterClassEx(&wincl); HWND hwnd; hwnd = CreateWindow( "MyWindowClass", "OpenGl", WS_POPUPWINDOW | WS_VISIBLE, 70, 70, 700, 510, NULL, NULL, hThisInstance, NULL ); HDC hDc; HGLRC hRc; PIXELFORMATDESCRIPTOR pfd; int iFormat; hDc = GetDC(hwnd); ZeroMemory(&pfd, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER | 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); /*Create & enable rendering context*/ hRc = wglCreateContext(hDc); wglMakeCurrent(hDc, hRc); BOOL bQuit = false; MSG msg; while(!bQuit){ if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){ if(msg.message == WM_QUIT){ bQuit = true; } else{ TranslateMessage(&msg); DispatchMessage(&msg); } } else{ /*Drawing scene goes here*/ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glVertex2f(0.2f, 0.2f); glEnd(); SwapBuffers(hDc); } } wglMakeCurrent(NULL, NULL); wglDeleteContext(hRc); ReleaseDC(hwnd, hDc); DestroyWindow(hwnd); }
But when i compile and run the code, nothing happens, no window appear but the program itself is running on the system.
Where did i make an error in the code?? Please helpp
Thanks and have a nice day! :p