This code is for setting up an OPENGL-ready window. I honestly don't see why it doesn't work. I get one warning when I compile and I cannot execute the program (or maybe I am executing the program but maybe the window isn't visible for some reason). The warning says that not all control paths in WinMain return a value, I've been scrutinizing this but I just don't see what is wrong. I wasn't sure whether or not to include the entire code...
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
HDC hDc;
PAINTSTRUCT ps;
switch(message) {
case WM_CREATE:
return 0;
break;
case WM_QUIT:
PostQuitMessage(0);
return 0;
break;
case WM_PAINT:
hDc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return 0;
break;
default:
break;
}
return (DefWindowProc(hwnd, message, wparam, lparam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nShowCmd) {
HWND hwnd; //window
MSG msg; //message
bool done;
WNDCLASSEX WindowClass;
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style = CS_HREDRAW| CS_VREDRAW;
WindowClass.lpfnWndProc = WndProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = LoadIcon(hInstance, IDI_ERROR);
WindowClass.hCursor = LoadCursor(hInstance, IDC_CROSS);
WindowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WindowClass.lpszMenuName = "My first real application";
WindowClass.lpszClassName = "This is my window class";
WindowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
if(!RegisterClassEx(&WindowClass))
return 0;
hwnd = CreateWindowEx(
NULL,
"My Class",
"My Window Name",
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU,
0, 0,
1024, 768,
NULL,
NULL,
hInstance,
NULL);
if(!hwnd)
return 0;
done = false;
while(!done) {
PeekMessage(&msg, hwnd, NULL, NULL, PM_REMOVE);
if(msg.message == WM_QUIT)
done = true;
else
TranslateMessage(&msg);
DispatchMessage(&msg);
return msg.wParam;
}
}
This compiles with just one warning. Usually when I get one warning I can still execute the program but when I try to execute this code nothing happens. WeIrD1!1!0
thanks in advanced if you can help me