HRESULT GLWindow::OnSize(WPARAM wParam, LPARAM lParam) { auto a = LOWORD(lParam); auto b = HIWORD(lParam); ResizeGLScene(LOWORD(lParam), HIWORD(lParam)); return 0; }
void glWindow::OpenGLDefaults () { // Setup some 'nice' defaults ResizeGLScene (m_width, m_height); // Projection matrix // Setup a default viewport glViewport(0,0,m_width,m_height); // Reset The Current Viewport // Set some default OpenGL matrices. Basic 3D perspective projection glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix gluPerspective(m_fov,(GLfloat)m_width/(GLfloat)m_height, m_nearClip, m_farClip); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix try { glShadeModel(GL_SMOOTH); } catch (...) { ; } try { glClearColor(0.0f, 0.0f, 0.0f, 0.5f); } catch (...) { ; } try { glClearDepth(1.0f); } catch (...) { ; } try { glEnable (GL_DEPTH_TEST); } catch (...) { ; } try { glDepthFunc (GL_LEQUAL); } catch (...) { ; } try { glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } catch (...) { ; } try { glDisable (GL_TEXTURE_2D); } catch (...) { ; } glClear (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); SwapBuffers (); glClear (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) //消息循环 { switch (uMsg) { case WM_ACTIVATE: if (!HIWORD(wParam)) //检测最小化状态 active = true; else active = false; //最小化时不再激活 return 0; case WM_SYSCOMMAND: // 系统中断命令 switch (wParam) // 检查系统调用 { case SC_SCREENSAVE: // 屏保要运行? case SC_MONITORPOWER: // 显示器要进入节电模式? return 0; // 阻止发生 } break; // 退出 case WM_CLOSE: // 收到Close消息 PostQuitMessage(0); // 发出退出消息 return 0; // 返回 case WM_KEYDOWN: // 有键按下么? keys[wParam] = TRUE; // 如果是,设为TRUE return 0; // 返回 case WM_KEYUP: // 有键放开么? keys[wParam] = FALSE; // 如果是,设为FALSE return 0; // 返回 case WM_SIZE: // 调整OpenGL窗口大小 ResizeGLScene(LOWORD(lParam), HIWORD(lParam)); // LoWord=Width,HiWord=Height return 0; // 返回 } return DefWindowProc(hWnd, uMsg, wParam, lParam);// 向 DefWindowProc传递所有未处理的消息。 }
ERRCODE CRenderer::SetupOpenGL() { PIXELFORMATDESCRIPTOR pfd; memset(&pfd, 0, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; if(!(hDC = GetDC(hWnd))) return ERR_GETDEVICECONTEXT; int iFormat = 0; if(!(iFormat = ChoosePixelFormat(hDC, &pfd))) return ERR_CHOOSEPIXFMT; if(!SetPixelFormat(hDC, iFormat, &pfd)) return ERR_SETPIXFMT; if(!(hRC = wglCreateContext(hDC))) return ERR_CREATECONTEXT; if(!wglMakeCurrent(hDC, hRC)) return ERR_MAKECURRENTCONTEXT; ResizeGLScene(854, 480); InitGL(); if(GLEW_OK!=glewInit()) return ERR_GLEWINIT; Log("-------------------------------------------------------------\n\n"); Log("Generic OpenGL Renderer has been started and initialized.\n\n"); Log("-------------------------------------------------------------\n"); return ERR_OK; }
// 创建opengl窗口 BOOL GLWindow::CreateGlWnd(const char* title, int x, int y, int width, int height) { m_width = width; m_height = height; RECT windowRect = { 0, 0, width, height }; DWORD windowStyle = WS_OVERLAPPEDWINDOW; // 预留做全屏 DWORD windowExStyle = WS_EX_APPWINDOW; // 扩展样式 // 全屏处理 - 预留 // 窗口样式 //windowStyle = WS_POPUP; //windowExStyle |= WS_EX_TOPMOST; ::AdjustWindowRectEx(&windowRect, windowStyle, 0, windowExStyle); // 调整窗口 CreateEx(0, "OpenGL", title, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, x, y, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, NULL, NULL); if (!(m_hDc = GetDC(m_hWnd))) // 获取DC { DestroyGL(); // 销毁 return FALSE; // 不能获取DC } m_timerFrame = 1000; // 初始化 GLuint PixelFormat; static PIXELFORMATDESCRIPTOR pdf = { sizeof(PIXELFORMATDESCRIPTOR), // 结构体大小 1, // 版本号 PFD_DRAW_TO_WINDOW | // 支持窗口 PFD_SUPPORT_OPENGL | // 支持opengl PFD_DOUBLEBUFFER, // 支持双缓冲 PFD_TYPE_RGBA, // 申请RGBA格式 32, // 色彩深度 0, 0, 0, 0, 0, 0, // 忽略的色彩位 0, // 无alpha缓存 0, // 无shift Bit 0, // 无累加缓存 0, 0, 0, 0, // 忽略聚集位 24, // 16位Z-缓存 8, // 无蒙版缓存 0, // 无辅助缓存 PFD_MAIN_PLANE, // 主绘图层 0, // Reserved 0, 0, 0 // 忽略层遮罩 }; if (!(PixelFormat = ChoosePixelFormat(m_hDc, &pdf))) // 寻找相应像素格式 { DestroyGL(); // 销毁 // printf("1====error choose===="); return FALSE; } if (!SetPixelFormat(m_hDc, PixelFormat, &pdf)) { DestroyGL(); // printf("1====error choose===="); return FALSE; // 不能设置像素格式 } HGLRC tempContext; if (!(tempContext = wglCreateContext(m_hDc))) { DestroyGL(); // printf("2====error create context===="); return FALSE; // 不能获得着色描述表 } if (!wglMakeCurrent(m_hDc, tempContext)) // 开启低版本opengl { DestroyGL(); // printf("3========"); return FALSE; // 不能激活当前opengl渲染描述表 } if (GLEW_OK != glewInit()) { DestroyGL(); return FALSE; // glew初始化失败 } // 开启 opengl 4.3 支持 GLint attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 4, // 主版本4 WGL_CONTEXT_MINOR_VERSION_ARB, 3, // 次版本号3 WGL_CONTEXT_PROFILE_MASK_ARB,WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,//要求返回兼容模式环境,如果不指定或指定为WGL_CONTEXT_CORE_PROFILE_BIT_ARB会返回只包含核心功能的环境 0 }; if (wglewIsSupported("WGL_ARB_create_context") == 1) { m_hRc = wglCreateContextAttribsARB(m_hDc, 0, attribs); wglMakeCurrent(NULL, NULL); wglDeleteContext(tempContext); int result = wglMakeCurrent(m_hDc, m_hRc); // 设置opengl 4.3 if (result != 1) { return FALSE; } } else { // 不支持opengl4.X 还原为opengl 2.1 m_hRc = tempContext; } //RECT rect; // 客户区大小 //::GetClientRect(m_hWnd, &rect); //ResizeGLScene(rect.right - rect.left, rect.bottom - rect.top); // 设置GL屏幕 (注意,这里只使用客户区计算) ResizeGLScene(width, height); if (!initGL()) // 初始化opengl { DestroyGL(); return FALSE; } // 设定计时器 每秒刷新60次 SetTimer(m_hWnd, m_timerFrame, 1000 / 60, NULL); return TRUE; }
// // main // int main(int argc, char **argv) { int i; char buffer[80]; XEvent event; KeySym key; done = False; // default to windowed mode GLWin.fs = FULLSCREEN_MODE; CreateGLWindow("glAnts", SCREEN_WIDTH, SCREEN_HEIGHT, 24, GLWin.fs); /* wait for events*/ while (!done) { /* handle the events in the queue */ while (XPending(GLWin.dpy) > 0) { XNextEvent(GLWin.dpy, &event); switch (event.type) { case Expose: if (event.xexpose.count != 0) break; Run_Anim(); break; case ConfigureNotify: /* call resizeGLScene only if our window-size changed */ if ((event.xconfigure.width != GLWin.width) || (event.xconfigure.height != GLWin.height)) { GLWin.width = event.xconfigure.width; GLWin.height = event.xconfigure.height; printf("Resize event\n"); ResizeGLScene(event.xconfigure.width, event.xconfigure.height); } break; case ButtonPress: // exit on mouse press // done = True; break; case KeyPress: if (ant_globals->menu_mode == MENU_SETTINGS_MODE) { key = XLookupKeysym(&event.xkey, 0); Cmd_KeyPress(key); // handle fullscreen press differently if (key == XK_F1) break; // process the key Cmd_Keys(key); XLookupString(&event, buffer, 10, &key, 0 ) ; Alpha_Keys(buffer); } else { key = XLookupKeysym(&event.xkey, 0); keyPressed(key); keys[event.xkey.keycode] = true; } // end of the if break; case KeyRelease: if (ant_globals->menu_mode == MENU_SETTINGS_MODE) { } else { keys[event.xkey.keycode] = false; } // end of the - if break; case ClientMessage: if (*XGetAtomName(GLWin.dpy, event.xclient.message_type) == *"WM_PROTOCOLS") { printf("Exiting glants...\n"); done = True; } break; default: break; } } // Check for key pressed in the camera HandleCameraKeys(keys); // run the gambit------ Run_Anim(); } KillGLWindow(); return 0; } // end of main //
bool GL_Init(HWND window) { hWnd = window; GLuint PixelFormat; // Holds The Results After Searching For A Match hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 32, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(hDC = GetDC(hWnd))) // Did We Get A Device Context? { MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; // Return FALSE } if (!(PixelFormat = ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? { MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; } if (!(hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? { MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; } if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context { MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return false; } setVSync(0); glewInit(); ResizeGLScene(); // Set Up Our Perspective GL Screen return true; // Success }
BOOL CreateGLWindow(TCHAR* Title, int width, int height, int bits, bool fullscreenflag) { GLuint PixelFormat; //保存查找匹配的结果 RECT rect; rect.left = 0; rect.right = width; rect.top = 0; rect.bottom = height; fullscreen = fullscreenflag; WNDCLASS wc; DWORD dwExStyle; //扩展窗口风格 DWORD dwStyle; //窗口风格 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = TEXT("OpenGL"); wc.hInstance = GetModuleHandle(NULL); if (!RegisterClass(&wc)) { MessageBox(NULL, TEXT("register failed"), TEXT("wrong"), MB_OK | MB_ICONEXCLAMATION); return FALSE; } if (fullscreen) //设置全屏模式 { DEVMODE dm; //设备模式 memset(&dm, 0, sizeof(dm)); dm.dmSize = sizeof(dm); dm.dmPelsWidth = width; //屏幕宽度 dm.dmPelsHeight = height; //屏幕高度 dm.dmBitsPerPel = bits; //色彩深度 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { if (MessageBox(NULL, TEXT("全屏失败!\n 使用窗口模式吗?"), TEXT("错误"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) { fullscreen = false; } else { return false; } } } if (fullscreen) //全屏模式 { dwExStyle = WS_EX_APPWINDOW; dwStyle = WS_POPUP; ShowCursor(false); } else { dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle = WS_OVERLAPPEDWINDOW; } AdjustWindowRectEx(&rect, dwStyle, false, dwExStyle); //根据类型调整窗口达到真正要求的大小 if (!(hWnd = CreateWindowEx(dwExStyle, TEXT("OpenGL"), Title, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dwStyle, 0, 0, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, GetModuleHandle(NULL), NULL))) { KillGLWindow(); MessageBox(NULL, TEXT("窗口创建失败"), TEXT("错误"), MB_OK | MB_ICONEXCLAMATION); return false; } static PIXELFORMATDESCRIPTOR pfd = //pfd告诉窗口我们所希望的东东,即窗口使用的像素格式 { sizeof(PIXELFORMATDESCRIPTOR), 1, //版本号 PFD_DRAW_TO_WINDOW | //格式支持窗口 PFD_SUPPORT_OPENGL | //格式必须支持OpenGL PFD_DOUBLEBUFFER, //必须支持双缓冲 PFD_TYPE_RGBA, //申请 RGBA格式 bits, //选定色彩深度 0, 0, 0, 0, 0, 0, //忽略的色彩位 0, //无alpha缓存 0, //忽略shift bit 0, //无累加缓存 0, 0, 0, 0, //忽略聚集位 16, //16位 Z-缓存 (深度缓存) 0, //无蒙版缓存 0, //无辅助缓存 PFD_MAIN_PLANE, //主绘图层 0, //Reserved 0, 0, 0 //忽略层遮罩 }; if (!(hDC = GetDC(hWnd))) { KillGLWindow(); MessageBox(NULL, TEXT("无法获得设备环境"), TEXT("错误"), MB_OK | MB_ICONEXCLAMATION); return false; } if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) // Windows 找到相应的象素格式了吗? { KillGLWindow(); MessageBox(NULL, TEXT("不能设置像素格式"), TEXT("错误"), MB_OK | MB_ICONEXCLAMATION); return false; } if (!SetPixelFormat(hDC, PixelFormat, &pfd)) // 能够设置象素格式么? { KillGLWindow(); MessageBox(NULL, TEXT("不能设置像素格式"), TEXT("错误"), MB_OK | MB_ICONEXCLAMATION); return false; } if (!(hRc = wglCreateContext(hDC))) // 能否取得着色描述表? { KillGLWindow(); // 重置显示区 MessageBox(NULL, TEXT("不能创建OpenGL渲染描述表"), TEXT("错误"), MB_OK | MB_ICONEXCLAMATION); return FALSE; // 返回 FALSE } if (!wglMakeCurrent(hDC, hRc)) // 尝试激活着色描述表 { KillGLWindow(); // 重置显示区 MessageBox(NULL, TEXT("不能激活当前的OpenGL渲然描述表"), TEXT("错误"), MB_OK | MB_ICONEXCLAMATION); return FALSE; // 返回 FALSE } ShowWindow(hWnd, SW_SHOW); // 显示窗口 SetForegroundWindow(hWnd); // 略略提高优先级 SetFocus(hWnd); // 设置键盘的焦点至此窗口 ResizeGLScene(width, height); // 设置透视 GL 屏幕 if (!InitGL()) // 初始化新建的GL窗口 { KillGLWindow(); // 重置显示区 MessageBox(NULL, TEXT("Initialization Failed."), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION); return FALSE; // 返回 FALSE } return true; }
void axVstCoreMac::ResizeFrame(const axSize& size) { axCocoaResizeFrame(size); ResizeGLScene(size.x, size.y); }
bool Display::CreateNewWindow() { RegisterWindowClass(); // Center Window on Display int posX = ( GetSystemMetrics(SM_CXSCREEN) / 2 ) - ( mScreenWidth / 2 ); int posY = ( GetSystemMetrics(SM_CYSCREEN) / 2 ) - ( mScreenHeight / 2 ); DWORD wndStyle = WS_OVERLAPPEDWINDOW; if ( mFullscreen == 1 ){ DEVMODE fsSettings; memset( &fsSettings, 0, sizeof( DEVMODE ) ); fsSettings.dmSize = sizeof( DEVMODE ); fsSettings.dmPelsHeight = mScreenHeight; fsSettings.dmPelsWidth = mScreenWidth; fsSettings.dmBitsPerPel = mScreenDepth; fsSettings.dmDisplayFrequency = 60; fsSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; long result = ChangeDisplaySettings( &fsSettings, CDS_FULLSCREEN ); if ( result != DISP_CHANGE_SUCCESSFUL ) { DebugMessage( "Error: Could not initialize fullscreen mode.", 1 ); if ( result == DISP_CHANGE_BADDUALVIEW ) DebugMessage( "Fullscreen was unsuccessful: System is DualView capable.", 1 ); if ( result == DISP_CHANGE_BADFLAGS ) DebugMessage( "Fullscreen was unsuccessful: An invalid set of flags were passed in.", 1 ); if ( result == DISP_CHANGE_BADMODE ) DebugMessage( "Fullscreen was unsuccessful: The system does not support Fullscreen.", 1 ); if ( result == DISP_CHANGE_BADPARAM ) DebugMessage( "Fullscreen was unsuccessful: An invalid parameter was passed in.", 1 ); if ( result == DISP_CHANGE_FAILED ) DebugMessage( "Fullscreen was unsuccessful: The GPU does not support Fullscreen.", 1 ); if ( result == DISP_CHANGE_NOTUPDATED ) DebugMessage( "Fullscreen was unsuccessful: Unable to write settings to the registry.", 1 ); if ( result == DISP_CHANGE_RESTART ) DebugMessage( "Fullscreen was unsuccessful: Restart Required for changes to take effect.", 1 ); } else { wndStyle = WS_POPUP; posX = 0; posY = 0; } } DebugMessage( "Creating Window...", 3 ); hWnd = CreateWindowEx( NULL, mWinClassName, mWinTitle, wndStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, posX, posY, mScreenWidth, mScreenHeight, NULL, NULL, hInstance, NULL ); if ( !hWnd ) FatalError( "Could Not Create Window." ); DebugMessage( "Showing Window...", 3 ); PIXELFORMATDESCRIPTOR pfd = { sizeof( PIXELFORMATDESCRIPTOR ), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, mScreenDepth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 1, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; hDC = GetDC( hWnd ); if ( !hDC ) FatalError( "Could not create a GL Device Context." ); int pixelFormat = ChoosePixelFormat( hDC, &pfd ); if ( !pixelFormat ) FatalError( "Pixel Format Invalid." ); if ( !SetPixelFormat( hDC, pixelFormat, &pfd ) ) FatalError( "Could not set Pixel Format." ); hRC = wglCreateContext( hDC ); if( !hRC ) FatalError( "Could not create a GL rendering Context." ); if( !wglMakeCurrent( hDC, hRC ) ) FatalError( "Could not set Rendering Context" ); ShowWindow( hWnd, SW_SHOW ); SetForegroundWindow( hWnd ); SetFocus( hWnd ); ResizeGLScene(); InitializeOpenGL(); return true; }
void CoreMac::ResizeFrame(const ax::Size& size) { axCocoaResizeFrame(size); ResizeGLScene(size); }
LRESULT CALLBACK glWindow::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) // Check For Windows Messages { case WM_ACTIVATE: // Watch For Window Activate Message { if (!HIWORD(wParam)) // Check minimized state { m_active=TRUE; // Program Is Active } else { m_active=FALSE; // Program Is No Longer Active } m_focused = LOWORD(wParam); if (!m_focused) { m_mouseCentred = false; if (!m_fullScreen) DoShowCursor (); } 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? { m_closing = true; BufferScanKey (VK_ESCAPE); // Generate an escape keypress return 0; } case WM_SIZE: // Resize The OpenGL Window { ResizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height return 0; // Jump Back } case WM_KEYDOWN: { if (wParam == VK_PAUSE) m_pausePressed = true; else { m_keyDown [wParam & 0xff] |= 1; BufferScanKey (wParam & 0xff); } return 0; } case WM_KEYUP: { m_keyDown [wParam & 0xff] &= ~1; return 0; } case WM_CHAR: { if (wParam == 27) // Esc closes window m_closing = true; int end = m_bufEnd; IncEnd (); // Check for room in buffer if (m_bufEnd != m_bufStart) m_keyBuffer [end] = wParam; else m_bufEnd = end; // No room. Restore buffer pointers return 0; } case WM_PAINT: { if (!m_painting && !FullScreen () && !m_dontPaint) { m_painting = true; SwapBuffers (); m_painting = false; } break; } case WM_MOUSEMOVE: { m_mouseX = lParam & 0xffff; m_mouseY = lParam >> 16; break; } case WM_LBUTTONDOWN: m_mouseButton [0] = true; break; case WM_LBUTTONUP: m_mouseButton [0] = false; break; case WM_RBUTTONDOWN: m_mouseButton [1] = true; break; case WM_RBUTTONUP: m_mouseButton [1] = false; break; case WM_MBUTTONDOWN: m_mouseButton [2] = true; break; case WM_MBUTTONUP: m_mouseButton [2] = false; break; case WM_MOUSEWHEEL: { m_mouseWheelDelta += ((long)wParam) >> 16; while (m_mouseWheelDelta >= WHEEL_DELTA) { m_mouseWheelDelta -= WHEEL_DELTA; m_mouseWheel++; } while (m_mouseWheelDelta < 0) { m_mouseWheelDelta += WHEEL_DELTA; m_mouseWheel--; } break; } } // Pass All Unhandled Messages To DefWindowProc return DefWindowProc(hWnd,uMsg,wParam,lParam); }