X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FOpenGL_Windows.cpp;h=82364c1a3a4b162739e2ee0dc12963ef4ae90634;hb=250e2a61f24154d8eebff5b2b403f926ca24a543;hp=b68c60bcfd37bc3d4e03960d401d03430aa5ddea;hpb=1a0ad4362ed618c1a25508530dfeeb4a0f6ef345;p=lugaru.git diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index b68c60b..82364c1 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -196,10 +196,7 @@ static void GLAPIENTRY glDeleteTextures_doNothing(GLsizei n, const GLuint *textu void sdlGetCursorPos(POINT *pt) { - int x, y; - SDL_GetMouseState(&x, &y); - pt->x = x; - pt->y = y; + SDL_GetMouseState(&(pt->x), &(pt->y)); } #define GetCursorPos(x) sdlGetCursorPos(x) #define SetCursorPos(x, y) SDL_WarpMouse(x, y) @@ -796,9 +793,9 @@ void DoFrameRate (int update) deltaTime /= 1000.0; multiplier=deltaTime; - if(multiplier<.001)multiplier=.001; - if(multiplier>10)multiplier=10; - if(update)frametime = currTime; // reset for next time interval + if(multiplier<.001) multiplier=.001; + if(multiplier>10) multiplier=10; + if(update) frametime = currTime; // reset for next time interval deltaTime = (float) AbsoluteDeltaToDuration (currTime, time); @@ -1117,7 +1114,12 @@ int main(int argc, char **argv) } // game is not in focus, give CPU time to other apps by waiting for messages instead of 'peeking' - STUBBED("give up CPU but sniff the event queue"); + SDL_ActiveEvent evt; + SDL_WaitEvent((SDL_Event*)&evt); + if (evt.type == SDL_ACTIVEEVENT && evt.gain == 1) + gameFocused = true; + else if (evt.type == SDL_QUIT) + gDone = true; } } @@ -1236,25 +1238,15 @@ int main(int argc, char **argv) bool LoadImage(const char * fname, TGAImageRec & tex) { - bool res = true; - if ( tex.data == NULL ) - { return false; - } - - - res = load_image(fname, tex); - - - return res; + else + return load_image(fname, tex); } void ScreenShot(const char * fname) { - save_image(fname); - }