/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/GLWin32.cpp
ViewVC logotype

Diff of /branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/GLWin32.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/GLWin32.cpp	2010/12/26 16:21:07	313
+++ branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/GLWin32.cpp	2010/12/26 18:56:19	314
@@ -18,11 +18,11 @@
  */
 
 #include "GS.h"
-#include "zerogs.h"
 #include "GLWin.h"
 
 #ifdef GL_WIN32_WINDOW
 
+HWND		GShwnd = NULL;
 HDC			hDC = NULL;	 // Private GDI Device Context
 HGLRC		hRC = NULL;	 // Permanent Rendering Context
 
@@ -47,14 +47,14 @@
 		case WM_SIZE:
 			nWindowWidth = lParam & 0xffff;
 			nWindowHeight = lParam >> 16;
-			ZeroGS::ChangeWindowSize(nWindowWidth, nWindowHeight);
+			GLWin.UpdateWindowSize(nWindowWidth, nWindowHeight);
 			break;
 
 		case WM_SIZING:
 			// if button is 0, then just released so can resize
 			if (GetSystemMetrics(SM_SWAPBUTTON) ? !GetAsyncKeyState(VK_RBUTTON) : !GetAsyncKeyState(VK_LBUTTON))
 			{
-				ZeroGS::SetChangeDeviceSize(nWindowWidth, nWindowHeight);
+				SetDeviceSize(nWindowWidth, nWindowHeight);
 			}
 			break;
 
@@ -122,7 +122,11 @@
 					hInstance,				// Instance
 					NULL);					// Don't Pass Anything To WM_CREATE
 
-	if (GShwnd == NULL) return false;
+	if (GShwnd == NULL) 
+	{
+		ZZLog::Error_Log("Failed to create window. Exiting...");
+		return false;
+	}
 
 	if (pDisplay != NULL) *(HWND*)pDisplay = GShwnd;
 
@@ -135,6 +139,7 @@
 
 	SetFocus(GShwnd);
 
+	if (pDisplay == NULL) ZZLog::Error_Log("Failed to create window. Exiting...");
 	return (pDisplay != NULL);
 }
 
@@ -184,8 +189,8 @@
 
 	if (conf.fullscreen())
 	{
-		nBackbufferWidth = rcdesktop.right - rcdesktop.left;
-		nBackbufferHeight = rcdesktop.bottom - rcdesktop.top;
+		backbuffer.w = rcdesktop.right - rcdesktop.left;
+		backbuffer.h = rcdesktop.bottom - rcdesktop.top;
 
 		dwExStyle = WS_EX_APPWINDOW;
 		dwStyle = WS_POPUP;
@@ -195,6 +200,8 @@
 	{
 		dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
 		dwStyle = WS_OVERLAPPEDWINDOW;
+		backbuffer.w = _width;
+		backbuffer.h = _height;
 	}
 	dwStyle |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
 
@@ -202,8 +209,8 @@
 
 	rc.left = 0;
 	rc.top = 0;
-	rc.right = nBackbufferWidth;
-	rc.bottom = nBackbufferHeight;
+	rc.right = backbuffer.h;
+	rc.bottom = backbuffer.h;
 	AdjustWindowRectEx(&rc, dwStyle, false, dwExStyle);
 	int X = (rcdesktop.right - rcdesktop.left) / 2 - (rc.right - rc.left) / 2;
 	int Y = (rcdesktop.bottom - rcdesktop.top) / 2 - (rc.bottom - rc.top) / 2;
@@ -218,8 +225,8 @@
 		DEVMODE dmScreenSettings;
 		memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
 		dmScreenSettings.dmSize = sizeof(dmScreenSettings);
-		dmScreenSettings.dmPelsWidth	= nBackbufferWidth;
-		dmScreenSettings.dmPelsHeight   = nBackbufferHeight;
+		dmScreenSettings.dmPelsWidth	= backbuffer.w;
+		dmScreenSettings.dmPelsHeight   = backbuffer.h;
 		dmScreenSettings.dmBitsPerPel   = 32;
 		dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
 
@@ -300,8 +307,10 @@
 void GLWindow::SwapGLBuffers()
 {
 	static u32 lastswaptime = 0;
+
+	if (glGetError() != GL_NO_ERROR) ZZLog::Debug_Log("glError before swap!");
+
 	SwapBuffers(hDC);
-	//glClear(GL_COLOR_BUFFER_BIT);
 	lastswaptime = timeGetTime();
 }
 
@@ -315,4 +324,74 @@
 
 }
 
+
+extern void ChangeDeviceSize(int nNewWidth, int nNewHeight);
+
+void GLWindow::ProcessEvents()
+{
+	MSG msg;
+
+	ZeroMemory(&msg, sizeof(msg));
+
+	while (1)
+	{
+		if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
+		{
+			switch (msg.message)
+			{
+				case WM_KEYDOWN :
+					int my_KeyEvent = msg.wParam;
+					bool my_bShift = !!(GetKeyState(VK_SHIFT) & 0x8000);
+
+					switch (msg.wParam)
+					{
+						case VK_F5:
+						case VK_F6:
+						case VK_F7:
+						case VK_F9:
+							OnFKey(msg.wParam - VK_F1 + 1, my_bShift);
+							break;
+
+						case VK_ESCAPE:
+
+							if (conf.fullscreen())
+							{
+								// destroy that msg
+								conf.setFullscreen(false);
+								ChangeDeviceSize(conf.width, conf.height);
+								UpdateWindow(GShwnd);
+								continue; // so that msg doesn't get sent
+							}
+							else
+							{
+								SendMessage(GShwnd, WM_DESTROY, 0, 0);
+								return;
+							}
+
+							break;
+					}
+
+					break;
+			}
+
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
+		else
+		{
+			break;
+		}
+	}
+
+	if ((GetKeyState(VK_MENU) & 0x8000) && (GetKeyState(VK_RETURN) & 0x8000))
+	{
+		conf.zz_options.fullscreen = !conf.zz_options.fullscreen;
+
+		SetDeviceSize(
+			(conf.fullscreen()) ? 1280 : conf.width,
+			(conf.fullscreen()) ? 960 : conf.height);
+	}
+}
+
+
 #endif

 

  ViewVC Help
Powered by ViewVC 1.1.22