For the windows version, if running with fullscreen disabled, center the main window instead of creating it top-left all the time.
Also renamed WindowRect to windowRect & PixelFormat to pixelFormat for consistency with other locally declared variables. (Uppercase should be reserved for class names, ie WindowRect is the class/struct, windowRect is an local object in your code.)
This commit is contained in:
+21
-12
@@ -357,15 +357,24 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
|
||||
actualHeight = height;
|
||||
|
||||
|
||||
GLuint PixelFormat; // Holds The Results After Searching For A Match
|
||||
GLuint pixelFormat; // Holds The Results After Searching For A Match
|
||||
WNDCLASS wc; // Windows Class Structure
|
||||
DWORD dwExStyle; // Window Extended Style
|
||||
DWORD dwStyle; // Window Style
|
||||
RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
|
||||
WindowRect.left=(long)0; // Set Left Value To 0
|
||||
WindowRect.right=(long)width; // Set Right Value To Requested Width
|
||||
WindowRect.top=(long)0; // Set Top Value To 0
|
||||
WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
|
||||
RECT windowRect; // Grabs Rectangle Upper Left / Lower Right Values
|
||||
|
||||
windowRect.left = (long) 0;
|
||||
windowRect.top = (long) 0;
|
||||
|
||||
if (fullscreenflag == false)
|
||||
{
|
||||
windowRect.left = (::GetSystemMetrics(SM_CXSCREEN) - width) / 2;
|
||||
windowRect.top = (::GetSystemMetrics(SM_CYSCREEN) - height) / 2;
|
||||
}
|
||||
|
||||
windowRect.right = windowRect.left + (long)width; // Set Right Value To Requested Width
|
||||
windowRect.bottom = windowRect.top + (long)height; // Set Bottom Value To Requested Height
|
||||
|
||||
|
||||
fullscreen=fullscreenflag; // Set The Global Fullscreen Flag
|
||||
|
||||
@@ -434,7 +443,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
|
||||
//WS_THICKFRAME ;
|
||||
}
|
||||
|
||||
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
|
||||
AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
|
||||
|
||||
// Create The Window
|
||||
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
|
||||
@@ -443,9 +452,9 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
|
||||
dwStyle | // Defined Window Style
|
||||
WS_CLIPSIBLINGS | // Required Window Style
|
||||
WS_CLIPCHILDREN, // Required Window Style
|
||||
0, 0, // Window Position
|
||||
WindowRect.right-WindowRect.left, // Calculate Window Width
|
||||
WindowRect.bottom-WindowRect.top, // Calculate Window Height
|
||||
windowRect.left, windowRect.top, // Window Position
|
||||
windowRect.right-windowRect.left, // Calculate Window Width
|
||||
windowRect.bottom-windowRect.top, // Calculate Window Height
|
||||
NULL, // No Parent Window
|
||||
NULL, // No Menu
|
||||
hInstance, // Instance
|
||||
@@ -485,14 +494,14 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
|
||||
return FALSE; // Return FALSE
|
||||
}
|
||||
|
||||
if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
|
||||
if (!(pixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
|
||||
{
|
||||
KillGLWindow(); // Reset The Display
|
||||
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return FALSE; // Return FALSE
|
||||
}
|
||||
|
||||
if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
|
||||
if(!SetPixelFormat(hDC,pixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
|
||||
{
|
||||
KillGLWindow(); // Reset The Display
|
||||
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
|
||||
Reference in New Issue
Block a user