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;
|
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
|
WNDCLASS wc; // Windows Class Structure
|
||||||
DWORD dwExStyle; // Window Extended Style
|
DWORD dwExStyle; // Window Extended Style
|
||||||
DWORD dwStyle; // Window Style
|
DWORD dwStyle; // Window Style
|
||||||
RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
|
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.left = (long) 0;
|
||||||
WindowRect.top=(long)0; // Set Top Value To 0
|
windowRect.top = (long) 0;
|
||||||
WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
|
|
||||||
|
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
|
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 ;
|
//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
|
// Create The Window
|
||||||
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For 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
|
dwStyle | // Defined Window Style
|
||||||
WS_CLIPSIBLINGS | // Required Window Style
|
WS_CLIPSIBLINGS | // Required Window Style
|
||||||
WS_CLIPCHILDREN, // Required Window Style
|
WS_CLIPCHILDREN, // Required Window Style
|
||||||
0, 0, // Window Position
|
windowRect.left, windowRect.top, // Window Position
|
||||||
WindowRect.right-WindowRect.left, // Calculate Window Width
|
windowRect.right-windowRect.left, // Calculate Window Width
|
||||||
WindowRect.bottom-WindowRect.top, // Calculate Window Height
|
windowRect.bottom-windowRect.top, // Calculate Window Height
|
||||||
NULL, // No Parent Window
|
NULL, // No Parent Window
|
||||||
NULL, // No Menu
|
NULL, // No Menu
|
||||||
hInstance, // Instance
|
hInstance, // Instance
|
||||||
@@ -485,14 +494,14 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
|
|||||||
return FALSE; // Return FALSE
|
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
|
KillGLWindow(); // Reset The Display
|
||||||
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||||
return FALSE; // Return FALSE
|
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
|
KillGLWindow(); // Reset The Display
|
||||||
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||||
|
|||||||
Reference in New Issue
Block a user