Hey there, I'm setting up a default program to use as a template for my future DirectX applications. The program compiled fine but I'm getting a run time error in my WinMain() function.
Here is the WinMain() function.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prev,
LPSTR cmd, int show) {
MSG msg;
// Describes a window
WNDCLASSEX windowClass;
memset(&windowClass, 0 ,sizeof(WNDCLASSEX));
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = WndProc;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.lpszClassName = "DX10CLASS";
windowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&windowClass)) return 0;
//Create window
HWND hwnd = CreateWindowEx(NULL, "DX10CLASS", WINDOW_NAME,
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 100, 100,
WINDOW_WIDTH, WINDOW_HEIGHT, 0, 0, hInstance, NULL);
if(!hwnd) return 0;
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
//If initialize fails don't run the program.
if(InitializeD3D10(hwnd) == true) {
if(Initialize() == true) {
while(1) {
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
if(msg.message == WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else {
Update();
RenderScene();
}
}
}
}
Shutdown();
UnregisterClass("DX10CLASS", windowClass.hInstance);
return msg.wParam;
}
And this is the run time error:
Run-Time Check Failure #3 - The variable 'msg' is being used without being initialized.
Not sure why it is saying it is not initialized, I have never had this happen before unless I'm missing something that I'm not seeing.
Any advice is welcomed.