Sfoglia il codice sorgente

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

Ivan Safrin 12 anni fa
parent
commit
a616933765

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

@@ -238,6 +238,9 @@ public:
 		void moveDiskItem(const String& itemPath, const String& destItemPath);
 		void removeDiskItem(const String& itemPath);
 
+		Number getBackingXRes();
+		Number getBackingYRes();
+
 		void setCursor(int cursorType);
 
 		void copyStringToClipboard(const String& str);
@@ -253,6 +256,7 @@ public:
 
 	private:
 
+		Number scaleFactor;
 		bool checkSpecialKeyEvents(PolyKEY key);
 
 		unsigned int nextDeviceID;
@@ -268,6 +272,7 @@ public:
 		int lastMouseY;
 
 		bool isFullScreen;
+		bool retinaSupport;
 
 		HDC hDC;
 		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);
 	break;
 	case WM_KEYDOWN:
+	case WM_SYSKEYDOWN:
 		if(core) {
 				wchar_t unicodeChar = 0;
 				MSG m;
@@ -133,6 +134,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 		}
 	break;
 	case WM_KEYUP:
+	case WM_SYSKEYUP:
 		if(core)
 			core->handleKeyUp(lParam,wParam);
 	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() {
 
-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.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;
 	hasCopyDataString = false;
 
+	scaleFactor = 1.0;
+
 	char *buffer = _getcwd(NULL, 0);
 	defaultWorkingDirectory = String(buffer);
 	free(buffer);
@@ -115,6 +117,8 @@ Win32Core::Win32Core(PolycodeViewBase *view, int _xRes, int _yRes, bool fullScre
 	renderer = new OpenGLRenderer();
 	services->setRenderer(renderer);
 
+	renderer->setBackingResolutionScale(scaleFactor, scaleFactor);
+
 	setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel);
 		
 	WSADATA WsaData;
@@ -136,6 +140,14 @@ Win32Core::Win32Core(PolycodeViewBase *view, int _xRes, int _yRes, bool fullScre
 	CoreServices::getInstance()->installModule(new GLSLShaderModule());	
 }
 
+Number Win32Core::getBackingXRes() {
+	return getXRes() *scaleFactor;
+}
+
+Number Win32Core::getBackingYRes() {
+	return getYRes() *scaleFactor;
+}
+
 Win32Core::~Win32Core() {
 	shutdownGamepad();
 	destroyContext();