[Clean] Tab formatting cleanup.. again......

This commit is contained in:
Rtch90 2012-04-07 01:23:17 +01:00
parent d557c1ae30
commit 8834fcc762

View File

@ -10,75 +10,75 @@ typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL;
GLWindow::GLWindow(HINSTANCE hInstance) :
_isRunning(false),
_game(NULL),
_hinstance(hInstance),
_lastTime(0)
{}
_isRunning(false),
_game(NULL),
_hinstance(hInstance),
_lastTime(0)
{}
bool GLWindow::Create(int width, int height, int bpp, bool fullscreen) {
DWORD dwExStyle; // Window extended style.
DWORD dwStyle; // Window style.
DWORD dwExStyle; // Window extended style.
DWORD dwStyle; // Window style.
_isFullscreen = fullscreen; // Store the fullscreen flag.
_isFullscreen = fullscreen; // Store the fullscreen flag.
_windowRect.left = (long)0; // Set left value to zero.
_windowRect.right = (long)width; // Set right value to the requested width.
_windowRect.top = (long)0; // Set top value to zero.
_windowRect.bottom = (long)height; // Set bottom value to the requested height.
_windowRect.left = (long)0; // Set left value to zero.
_windowRect.right = (long)width; // Set right value to the requested width.
_windowRect.top = (long)0; // Set top value to zero.
_windowRect.bottom = (long)height; // Set bottom value to the requested height.
// Fill out the class structure.
_windowClass.cbSize = sizeof(WNDCLASSEX);
_windowClass.style = CS_HREDRAW | CS_VREDRAW;
_windowClass.lpfnWndProc = GLWindow::StaticWNDProc; // Set out static method as the next event.
_windowClass.cbClsExtra = 0;
_windowClass.cbWndExtra = 0;
_windowClass.hInstance = _hinstance;
_windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); // Default icon.
_windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); // Default arrow.
_windowClass.hbrBackground = NULL; // Don't need a background.
_windowClass.lpszMenuName = NULL; // No menu.
_windowClass.lpszClassName = "LibD";
_windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); // Windows logo, small icon.
// Fill out the class structure.
_windowClass.cbSize = sizeof(WNDCLASSEX);
_windowClass.style = CS_HREDRAW | CS_VREDRAW;
_windowClass.lpfnWndProc = GLWindow::StaticWNDProc; // Set out static method as the next event.
_windowClass.cbClsExtra = 0;
_windowClass.cbWndExtra = 0;
_windowClass.hInstance = _hinstance;
_windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); // Default icon.
_windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); // Default arrow.
_windowClass.hbrBackgroun = NULL; // Don't need a background.
_windowClass.lpszMenuName = NULL; // No menu.
_windowClass.lpszClassName = "LibD";
_windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); // Windows logo, small icon.
// Register the window class.
if(!RegisterClassEx(&_windowClass)) {
return false;
}
if(_isFullscreen) {
// Then we need to change the display mode.
DEVMODE dmScreenSettings; // Device mode.
// Register the window class.
if(!RegisterClassEx(&_windowClass)) {
return false;
}
if(_isFullscreen) {
// Then we need to change the display mode.
DEVMODE dmScreenSettings; // Device mode.
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPellsWidth = width; // Screen width.
dmScreenSettings.dmPellsHeight = height; // Screen height.
dmScreenSettings.dmBitsPerPel = bpp; // Bits per pixel.
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
// Setting the display mode failed, so switch to windowed mode.
MessageBox(NULL, "Display mode failed", NULL, MB_OK);
_isFullscreen = false;
}
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPellsWidth = width; // Screen width.
dmScreenSettings.dmPellsHeight = height; // Screen height.
dmScreenSettings.dmBitsPerPel = bpp; // Bits per pixel.
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
// Setting the display mode failed, so switch to windowed mode.
MessageBox(NULL, "Display mode failed", NULL, MB_OK);
_isFullscreen = false;
}
}
// Are we still in fullscreen mode?
if(_isFullscreen) {
dwExStyle = WS_EX_APPWINDOW; // Window extended style.
dwStyle = WS_POPUP; // Windows style.
ShowCursor(false); // Might as well hide the mouse cursor.
dwExStyle = WS_EX_APPWINDOW; // Window extended style.
dwStyle = WS_POPUP; // Windows style.
ShowCursor(false); // Might as well hide the mouse cursor.
} else {
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window extended style.
dwStyle = WS_OVERLAPPEDWINDOW; // Windows style.
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window extended style.
dwStyle = WS_OVERLAPPEDWINDOW; // Windows style.
}
AdjustWindowRectEx(&_windowRect, dwStyle, false, dwExStyle); // Adjust window to true requested size.
AdjustWindowRectEx(&_windowRect, dwStyle, false, dwExStyle); // Adjust window to true requested size.
// The class is registered, so now we can create our window.
_hwnd = CreateWindowEx(NULL, "GLClass", "LibD", dwStyle, | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0, 0, _windowRect.right - _windowRect.left,
_windowRect.bottom - _windowRect.top, NULL, NULL, _hinstance, this);
0, 0, _windowRect.right - _windowRect.left,
_windowRect.bottom - _windowRect.top, NULL, NULL, _hinstance, this);
// Check if the window creation failed - hwnd would be NULL.
if(!_hwnd)
@ -86,10 +86,10 @@ bool GLWindow::Create(int width, int height, int bpp, bool fullscreen) {
_hdc = GetDC(_hwnd);
ShowWindow(_hwnd, SW_SHOW); // Display the window.
UpdateWindow(_hwnd); // Update the window.
ShowWindow(_hwnd, SW_SHOW); // Display the window.
UpdateWindow(_hwnd); // Update the window.
_lastTime = GetTickCount() / 1000.0f; // Initialize the time.
_lastTime = GetTickCount() / 1000.0f; // Initialize the time.
return true;
}
@ -97,7 +97,7 @@ void GLWindow::Destroy(void) {
if(_isFullscreen) {
// Change back to the desktop.
ChangeDisplaySettings(NULL, 0);
ShowCursor(true); // Show us the mouse cursor again.
ShowCursor(true); // Show us the mouse cursor again.
}
}
@ -116,24 +116,24 @@ void GLWindow::SetPixelFormat(void) {
int pixelFormat;
PIXELFORMATDESCRIPTOR fpd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size.
1, // Version.
PFD_SUPPORT_OPENGL | // OpenGL window.
PFD_DRAW_TO_WINDOW | // Render to window.
PFD_DOUBLEBUFFER, // Support double-buffering.
PFD_TYPE_RGBA, // Color type.
32, // Prefered color depth.
0, 0, 0, 0, 0, 0, // Color bits (ignored).
0, // No alpha buffer.
0, // Alpha bits (ignored).
0, // No accumulation buffer.
0, 0, 0, 0, // Accumulation bits (ignored).
16, // Depth buffer.
0, // No stencil buffer.
0, // No auxiliary buffers.
PFD_MAIN_PLANE, // Main layer.
0, // Reserverd.
0, 0, 0, // No layer, visibility, damage masks.
sizeof(PIXELFORMATDESCRIPTOR), // Size.
1, // Version.
PFD_SUPPORT_OPENGL | // OpenGL window.
PFD_DRAW_TO_WINDOW | // Render to window.
PFD_DOUBLEBUFFER, // Support double-buffering.
PFD_TYPE_RGBA, // Color type.
32, // Prefered color depth.
0, 0, 0, 0, 0, 0, // Color bits (ignored).
0, // No alpha buffer.
0, // Alpha bits (ignored).
0, // No accumulation buffer.
0, 0, 0, 0, // Accumulation bits (ignored).
16, // Depth buffer.
0, // No stencil buffer.
0, // No auxiliary buffers.
PFD_MAIN_PLANE, // Main layer.
0, // Reserverd.
0, 0, 0, // No layer, visibility, damage masks.
};
pixelFormat = ChoosePixelFormat(&_hdc, pixelFormat, &pfd);
@ -142,7 +142,7 @@ void GLWindow::SetPixelFormat(void) {
LRESULT GLWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch uMsg) {
case WM_CREATE: { // Window creation.
case WM_CREATE: { // Window creation.
_hdc = GetDC(hWnd);
SetupPixelFormat();
@ -172,21 +172,21 @@ LRESULT GLWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
// Make the GL3 context current.
wglMakeCurrent(_hdc, _hglrc);
_isRunning = true; // Mark our window as running now.
_isRunning = true; // Mark our window as running now.
}
break;
case WM_DESTROY: // Destroy window.
case WM_CLOSE: // Windows is closing.
case WM_DESTROY: // Destroy window.
case WM_CLOSE: // Windows is closing.
wglMakeCurrent(_hdc, NULL);
wglDeleteContext(_hglrc);
_isRunning = false; // Stop the main loop.
PostQuitMessage(0); // Send a WM_QUIT message.
_isRunning = false; // Stop the main loop.
PostQuitMessage(0); // Send a WM_QUIT message.
return 0;
break;
case WM_SIZE: {
int height = HIWORD(lParam); // Retrieve width and height.
int height = HIWORD(lParam); // Retrieve width and height.
int width = LOWORD(lParam);
GetAttachedGame()->OnResize(width, height); // Call the games resize method.
GetAttachedGame()->OnResize(width, height); // Call the games resize method.
}
break;
case WM_KEYDOWN: