static GLUSvoid glusInternalReshape(GLFWwindow* window, GLUSint width, GLUSint height) { if (width < 1) { width = 1; } if (height < 1) { height = 1; } if (glusReshape && g_initdone) { glusReshape(width, height); } }
GLUSvoid _glusWindowInternalReshape(GLUSint width, GLUSint height) { if (width < 1) { width = 1; } if (height < 1) { height = 1; } if (glusReshape && g_initdone) { glusReshape(width, height); } }
GLUSboolean GLUSAPIENTRY glusRun(GLUSvoid) { // Init Engine if (glusInit) { if (!glusInit()) { glusDestroyWindow(); // Destroy The Window return GLUS_FALSE; // Exit The Program } } g_initdone = GLUS_TRUE; // Do the first reshape if (glusReshape) { glusReshape(g_width, g_height); } while (!g_done) // Loop That Runs While done=FALSE { if (glusUpdate) { g_done = !glusUpdate(glusGetElapsedTime()); } eglSwapBuffers(g_eglDisplay, g_eglSurface); // Swap Buffers (Double Buffering) _glusPollEvents(); } // Terminate Game if (glusTerminate) { glusTerminate(); } // Shutdown glusDestroyWindow(); // Destroy The Window return GLUS_TRUE; // Exit The Program }
GLUSboolean GLUSAPIENTRY glusStartup(GLUSvoid) { // Init Engine if (glusInit) { if (!glusInit()) { glusShutdown(); return GLUS_FALSE; // Exit The Program } } g_initdone = GLUS_TRUE; // Do the first reshape if (glusReshape) { glusReshape(g_width, g_height); } return GLUS_TRUE; }
GLUSboolean GLUSAPIENTRY glusRun(GLUSvoid) { MSG msg; // Windows Message Structure GLUSboolean done = GLUS_FALSE; // Bool Variable To Exit Loop // Init Engine if (glusInit) { if (!glusInit()) { glusDestroyWindow(); // Destroy The Window return GLUS_FALSE; // Exit The Program } } g_initdone = GLUS_TRUE; // Do the first reshape if (glusReshape) { glusReshape(g_width, g_height); } while(!done) // Loop That Runs While done=FALSE { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (msg.message==WM_QUIT) // Have We Received A Quit Message? { done = GLUS_TRUE; // If So done=TRUE } else // If Not, Deal With Window Messages { TranslateMessage(&msg); // Translate The Message DispatchMessage(&msg); // Dispatch The Message } } else // If There Are No Messages { // Draw The Scene. Watch For ESC Key if (g_active) // Program Active? { if (glusUpdate) { done = !glusUpdate(glusGetElapsedTime()); } if (!done) { SwapBuffers(g_hDC); // Swap Buffers (Double Buffering) } } } } // Terminate Game if (glusTerminate) { glusTerminate(); } // Shutdown glusDestroyWindow(); // Destroy The Window return GLUS_TRUE; // Exit The Program }
LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window UINT uMsg, // Message For This Window WPARAM wParam, // Additional Message Information LPARAM lParam) // Additional Message Information { switch (uMsg) // Check For Windows Messages { case WM_ACTIVATE: // Watch For Window Activate Message { if (!HIWORD(wParam)) // Check Minimization State { g_active = GLUS_TRUE; // Program Is Active } else { g_active = GLUS_FALSE; // Program Is No Longer Active } return 0; // Return To The Message Loop } case WM_SYSCOMMAND: // Intercept System Commands { switch (wParam) // Check System Calls { case SC_SCREENSAVE: // Screensaver Trying To Start? case SC_MONITORPOWER: // Monitor Trying To Enter Powersave? return 0; // Prevent From Happening } break; // Exit } case WM_CLOSE: // Did We Receive A Close Message? { PostQuitMessage(0); // Send A Quit Message return 0; // Jump Back } case WM_KEYDOWN: // Is A Key Being Held Down? { if (wParam == VK_ESCAPE) { PostQuitMessage(0); // Send A Quit Message } else { if(glusKey && g_initdone) { glusKey(GLUS_TRUE, wParam); } } return 0; // Jump Back } case WM_KEYUP: { if (wParam == VK_ESCAPE) { // Do nothing } else { if(glusKey && g_initdone) { glusKey(GLUS_FALSE, wParam); } } return 0; // Jump Back } case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: { if(glusMouse && g_initdone) { GLUSuint button = 0; if (uMsg == WM_LBUTTONDOWN) { button = 1; } else if (uMsg == WM_MBUTTONDOWN) { button = 2; } else if (uMsg == WM_RBUTTONDOWN) { button = 4; } glusMouse(GLUS_TRUE, button, LOWORD( lParam ), HIWORD( lParam ) ); } return 0; } case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: { if(glusMouse && g_initdone) { GLUSuint button = 0; if (uMsg == WM_LBUTTONUP) { button = 1; } else if (uMsg == WM_MBUTTONUP) { button = 2; } else if (uMsg == WM_RBUTTONUP) { button = 4; } glusMouse(GLUS_FALSE, button, LOWORD( lParam ), HIWORD( lParam ) ); } return 0; } case WM_MOUSEMOVE: { if(glusMouseMove && g_initdone) { GLUSuint buttons = 0; if (LOWORD(wParam) & MK_LBUTTON) { buttons |= 1; } if (LOWORD(wParam) & MK_MBUTTON) { buttons |= 2; } if (LOWORD(wParam) & MK_RBUTTON) { buttons |= 4; } glusMouseMove(buttons, LOWORD( lParam ), HIWORD( lParam ) ); } return 0; } case WM_MOUSEWHEEL: { if(glusMouseWheel && g_initdone) { GLUSuint buttons = 0; if (LOWORD(wParam) & MK_LBUTTON) { buttons |= 1; } if (LOWORD(wParam) & MK_MBUTTON) { buttons |= 2; } if (LOWORD(wParam) & MK_RBUTTON) { buttons |= 4; } glusMouseWheel(buttons, GET_WHEEL_DELTA_WPARAM(wParam)/WHEEL_DELTA, LOWORD( lParam ), HIWORD( lParam )); } return 0; } case WM_SIZE: // Resize The OpenGL Window { g_width = LOWORD(lParam); // LoWord=Width, HiWord=Height g_height = HIWORD(lParam); if (glusReshape && g_initdone) { glusReshape(g_width, g_height); } return 0; // Jump Back } } // Pass All Unhandled Messages To DefWindowProc return DefWindowProc(hWnd, uMsg, wParam, lParam); }