31 m_screenHeight = 1080;
41 for(
unsigned char i=0;i<255;i++)
45 m_mouseVisible =
false;
59 DEVMODE dmScreenSettings;
60 ZeroMemory( &dmScreenSettings,
sizeof( dmScreenSettings ) );
62 dmScreenSettings.dmSize =
sizeof( dmScreenSettings );
63 dmScreenSettings.dmPelsWidth =
getWidth();
64 dmScreenSettings.dmPelsHeight =
getHeight();
65 dmScreenSettings.dmBitsPerPel = m_bpp;
66 dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
68 if( ChangeDisplaySettings( &dmScreenSettings, CDS_FULLSCREEN )!= DISP_CHANGE_SUCCESSFUL ) {
82 bool OpenGLWindow::create(
const char * windowTitle,
bool fullscreen,
const char * className, HINSTANCE hInstance, LPVOID lpParam ) {
87 m_fullscreen = fullscreen;
91 if( MessageBox( NULL,
"The requested fullscreen mode is not supported by\nyour video card. Use windowed mode instead?",
"Question", MB_YESNO | MB_ICONEXCLAMATION ) == IDYES ) {
94 MessageBox( NULL,
"Program will now close.",
"ERROR", MB_OK | MB_ICONSTOP );
103 dwExStyle = WS_EX_APPWINDOW | WS_EX_TOPMOST;
107 dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
108 dwStyle = WS_OVERLAPPEDWINDOW;
110 AdjustWindowRectEx( &windowRect, dwStyle,
false, dwExStyle );
112 if (windowRect.left < 0) {
113 windowRect.right -= windowRect.left;
116 if (windowRect.top < 0) {
117 windowRect.bottom -= windowRect.top;
123 if ( !(m_hWnd=CreateWindowEx( dwExStyle,
127 WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
128 windowRect.left, windowRect.top,
129 windowRect.right - windowRect.left,
130 windowRect.bottom - windowRect.top,
137 MessageBox( NULL,
"Window creation error.",
"ERROR", MB_OK | MB_ICONEXCLAMATION );
142 static PIXELFORMATDESCRIPTOR pfd;
143 ZeroMemory( &pfd,
sizeof( pfd ) );
144 pfd.nSize =
sizeof( PIXELFORMATDESCRIPTOR );
146 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
147 pfd.iPixelType = PFD_TYPE_RGBA;
148 pfd.cColorBits = m_bpp;
150 pfd.iLayerType = PFD_MAIN_PLANE;
152 if( !(m_hDC=GetDC( m_hWnd )) ) {
154 MessageBox( NULL,
"Can't create a GL Device Context.",
"ERROR", MB_OK | MB_ICONEXCLAMATION );
157 if( !(PixelFormat = ChoosePixelFormat( m_hDC, &pfd )) ) {
159 MessageBox( NULL,
"Can't find a suitable PixelFormat.",
"ERROR", MB_OK | MB_ICONEXCLAMATION );
162 if( !SetPixelFormat( m_hDC, PixelFormat, &pfd ) ) {
164 MessageBox( NULL,
"Can't set the PixelFormat.",
"ERROR", MB_OK | MB_ICONEXCLAMATION );
167 if( !(m_hRC = wglCreateContext( m_hDC )) ) {
169 MessageBox( NULL,
"Can't create a GL Rendering Context.",
"ERROR", MB_OK | MB_ICONEXCLAMATION );
172 if( !wglMakeCurrent( m_hDC, m_hRC ) ) {
174 MessageBox( m_hWnd,
"Can't activate the GL Rendering Context.",
"ERROR", MB_OK | MB_ICONEXCLAMATION );
179 ShowWindow( m_hWnd, SW_SHOW );
202 return m_screenHeight;
214 return m_screenWidth;
264 ChangeDisplaySettings( NULL, 0 );
269 if( !wglMakeCurrent( NULL, NULL ) )
270 MessageBox( NULL,
"Release of DC and RC failed.",
"SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION );
271 if( !wglDeleteContext( m_hRC ) )
272 MessageBox( NULL,
"Release rendering context failed.",
"SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION );
275 if( m_hDC && !ReleaseDC( m_hWnd, m_hDC ) ) {
276 MessageBox( NULL,
"Release device context failed.",
"SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION );
279 if( m_hWnd && !DestroyWindow( m_hWnd ) ) {
280 MessageBox( NULL,
"Could not release hWnd.",
"SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION );
296 m_frustum.
aspect = (float)width / (
float)height;
297 glViewport( 0, 0, width, height );
298 glMatrixMode(GL_PROJECTION);
308 glMatrixMode( GL_MODELVIEW );
337 m_screenHeight = height;
349 m_screenWidth = width;
380 m_mouseClick = click;
400 m_mouseVisible = mouseVisible;
402 ShowCursor( mouseVisible );