Просмотр исходного кода

Made Alt key work correctly on Windows, OpenGL buffer will not scale now on higher DPI settings in Windows

Ivan Safrin 12 лет назад
Родитель
Сommit
a616933765

+ 5 - 0
Core/Contents/Include/PolyWinCore.h

@@ -238,6 +238,9 @@ public:
 		void moveDiskItem(const String& itemPath, const String& destItemPath);
 		void moveDiskItem(const String& itemPath, const String& destItemPath);
 		void removeDiskItem(const String& itemPath);
 		void removeDiskItem(const String& itemPath);
 
 
+		Number getBackingXRes();
+		Number getBackingYRes();
+
 		void setCursor(int cursorType);
 		void setCursor(int cursorType);
 
 
 		void copyStringToClipboard(const String& str);
 		void copyStringToClipboard(const String& str);
@@ -253,6 +256,7 @@ public:
 
 
 	private:
 	private:
 
 
+		Number scaleFactor;
 		bool checkSpecialKeyEvents(PolyKEY key);
 		bool checkSpecialKeyEvents(PolyKEY key);
 
 
 		unsigned int nextDeviceID;
 		unsigned int nextDeviceID;
@@ -268,6 +272,7 @@ public:
 		int lastMouseY;
 		int lastMouseY;
 
 
 		bool isFullScreen;
 		bool isFullScreen;
+		bool retinaSupport;
 
 
 		HDC hDC;
 		HDC hDC;
 		HGLRC hRC;
 		HGLRC hRC;

+ 10 - 1
Core/Contents/PolycodeView/MSVC/PolycodeView.cpp

@@ -116,6 +116,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 			core->handleMouseUp(CoreInput::MOUSE_BUTTON3, lParam,wParam);
 			core->handleMouseUp(CoreInput::MOUSE_BUTTON3, lParam,wParam);
 	break;
 	break;
 	case WM_KEYDOWN:
 	case WM_KEYDOWN:
+	case WM_SYSKEYDOWN:
 		if(core) {
 		if(core) {
 				wchar_t unicodeChar = 0;
 				wchar_t unicodeChar = 0;
 				MSG m;
 				MSG m;
@@ -133,6 +134,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 		}
 		}
 	break;
 	break;
 	case WM_KEYUP:
 	case WM_KEYUP:
+	case WM_SYSKEYUP:
 		if(core)
 		if(core)
 			core->handleKeyUp(lParam,wParam);
 			core->handleKeyUp(lParam,wParam);
 	break;
 	break;
@@ -158,7 +160,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
 
 PolycodeView::PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable, bool showDebugConsole) : PolycodeViewBase() {
 PolycodeView::PolycodeView(HINSTANCE hInstance, int nCmdShow, LPCTSTR windowTitle, bool resizable, bool showDebugConsole) : PolycodeViewBase() {
 
 
-WNDCLASSEX wcex;
+
+	typedef BOOL(WINAPI *SetProcessDPIAwarePtr)(VOID);
+	SetProcessDPIAwarePtr set_process_dpi_aware_func = GetProcAddress(GetModuleHandleA("user32.dll"), "SetProcessDPIAware");
+	if (set_process_dpi_aware_func) {
+		set_process_dpi_aware_func();
+	}
+
+	WNDCLASSEX wcex;
 
 
 	wcex.cbSize = sizeof(WNDCLASSEX);
 	wcex.cbSize = sizeof(WNDCLASSEX);
 	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
 	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;

+ 12 - 0
Core/Contents/Source/PolyWinCore.cpp

@@ -85,6 +85,8 @@ Win32Core::Win32Core(PolycodeViewBase *view, int _xRes, int _yRes, bool fullScre
 	core = this;
 	core = this;
 	hasCopyDataString = false;
 	hasCopyDataString = false;
 
 
+	scaleFactor = 1.0;
+
 	char *buffer = _getcwd(NULL, 0);
 	char *buffer = _getcwd(NULL, 0);
 	defaultWorkingDirectory = String(buffer);
 	defaultWorkingDirectory = String(buffer);
 	free(buffer);
 	free(buffer);
@@ -115,6 +117,8 @@ Win32Core::Win32Core(PolycodeViewBase *view, int _xRes, int _yRes, bool fullScre
 	renderer = new OpenGLRenderer();
 	renderer = new OpenGLRenderer();
 	services->setRenderer(renderer);
 	services->setRenderer(renderer);
 
 
+	renderer->setBackingResolutionScale(scaleFactor, scaleFactor);
+
 	setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel);
 	setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel);
 		
 		
 	WSADATA WsaData;
 	WSADATA WsaData;
@@ -136,6 +140,14 @@ Win32Core::Win32Core(PolycodeViewBase *view, int _xRes, int _yRes, bool fullScre
 	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
 	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
 }
 }
 
 
+Number Win32Core::getBackingXRes() {
+	return getXRes() *scaleFactor;
+}
+
+Number Win32Core::getBackingYRes() {
+	return getYRes() *scaleFactor;
+}
+
 Win32Core::~Win32Core() {
 Win32Core::~Win32Core() {
 	shutdownGamepad();
 	shutdownGamepad();
 	destroyContext();
 	destroyContext();