Realized I had forgotten to initialize the UserInput struct to 0.

This commit is contained in:
Fatbag 2012-03-21 21:31:46 -05:00
parent 551f3c834f
commit 705da4ba5c
8 changed files with 17 additions and 18 deletions

View file

@ -19,4 +19,5 @@
namespace Audio {
int Initialize();
void Shutdown();
}

View file

@ -24,8 +24,6 @@ HANDLE Thread;
IXAudio2 *pXAudio2 = NULL;
IXAudio2MasteringVoice *MasterVoice = NULL;
void Shutdown();
int Initialize(){
HRESULT result;

View file

@ -74,13 +74,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
return ERROR_INIT | ERROR_INIT_LOGIC | ERROR_LOGIC_CREATE_SCENE;
}
LARGE_INTEGER PreviousTime;
QueryPerformanceCounter(&PreviousTime);
ShowWindow(Window::hWnd, SW_SHOW);
SetForegroundWindow(Window::hWnd);
SetFocus(Window::hWnd);
LARGE_INTEGER PreviousTime;
QueryPerformanceCounter(&PreviousTime);
while(true){
MSG msg;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
@ -102,18 +102,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
PreviousTime.QuadPart = CurrentTime.QuadPart;
QueryPerformanceCounter(&CurrentTime);
unsigned SleepDuration = (unsigned)
((System::FramePeriod - (float)(CurrentTime.QuadPart-PreviousTime.QuadPart)/System::ClockFreq.QuadPart) * 1000);
if(SleepDuration > 1) Sleep(SleepDuration);
}
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
float SleepDuration =
(System::FramePeriod - (float)(CurrentTime.QuadPart-PreviousTime.QuadPart)/System::ClockFreq.QuadPart) * 1000;
if(SleepDuration > 1) Sleep((unsigned) SleepDuration);
}
ShowWindow(Window::hWnd, SW_HIDE);
Audio::Shutdown();
Graphics::Shutdown();
Shutdown();
return 0;
}

View file

@ -21,6 +21,7 @@
//Graphics/Startup.cpp
namespace Graphics {
int Initialize();
void Shutdown();
extern HDC hDC;
extern HGLRC hRC;

View file

@ -23,8 +23,6 @@ HANDLE Thread;
HDC hDC;
HGLRC hRC;
void Shutdown();
int Initialize(){
hDC = GetDC(Window::hWnd);
if(hDC == NULL){

View file

@ -44,6 +44,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return 0;
case WM_CLOSE:
System::UserInput.CloseWindow = true;
PostQuitMessage(0);
return 0;

View file

@ -51,8 +51,9 @@ class LoginScreen : public Scene {
int Run(float){
if(System::UserInput.CloseWindow){
System::Shutdown = true;
return 0;
}
return 0;
return 1;
}
public:

View file

@ -27,6 +27,8 @@ namespace System {
UserInput_t UserInput;
int Initialize(){
memset(&UserInput, 0, sizeof(UserInput));
QueryPerformanceFrequency(&ClockFreq);
DEVMODE dm;