Browse Source

Fix packer and ConstructAuto in windows

Pabloader 5 years ago
parent
commit
13c2500b6c
6 changed files with 98 additions and 29 deletions
  1. 40
    0
      .vscode/launch.json
  2. 5
    4
      Makefile
  3. 9
    4
      packer/Makefile
  4. 3
    0
      pge/include/olcPGE_Common.h
  5. 16
    0
      pge/src/olcPGE_Common.cpp
  6. 25
    21
      pge/src/olcPixelGameEngine.cpp

+ 40
- 0
.vscode/launch.json View File

@@ -4,6 +4,46 @@
4 4
     // Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
5 5
     "version": "0.2.0",
6 6
     "configurations": [
7
+        {
8
+            "name": "(gdb-win) Launch Packer",
9
+            "type": "cppdbg",
10
+            "request": "launch",
11
+            "program": "${workspaceFolder}\\packer\\packer.exe",
12
+            "args": ["--convert", "C:\\Projects\\AwoorwaOLC\\res\\awoorwa.png", "res\\awoorwa.spr"],
13
+            "stopAtEntry": false,
14
+            "cwd": "${workspaceFolder}",
15
+            "environment": [],
16
+            "externalConsole": false,
17
+            "MIMode": "gdb",
18
+            "miDebuggerPath": "C:\\MinGW\\mingw32\\bin\\gdb.exe",
19
+            "setupCommands": [
20
+                {
21
+                    "description": "Enable pretty-printing for gdb",
22
+                    "text": "-enable-pretty-printing",
23
+                    "ignoreFailures": true
24
+                }
25
+            ]
26
+        },
27
+        {
28
+            "name": "(gdb-win) Launch Awoorwae",
29
+            "type": "cppdbg",
30
+            "request": "launch",
31
+            "program": "${workspaceFolder}\\awoorwae.exe",
32
+            "args": [],
33
+            "stopAtEntry": false,
34
+            "cwd": "${workspaceFolder}",
35
+            "environment": [],
36
+            "externalConsole": false,
37
+            "MIMode": "gdb",
38
+            "miDebuggerPath": "C:\\MinGW\\mingw32\\bin\\gdb.exe",
39
+            "setupCommands": [
40
+                {
41
+                    "description": "Enable pretty-printing for gdb",
42
+                    "text": "-enable-pretty-printing",
43
+                    "ignoreFailures": true
44
+                }
45
+            ]
46
+        },
7 47
         {
8 48
             "name": "(gdb) Launch",
9 49
             "type": "cppdbg",

+ 5
- 4
Makefile View File

@@ -3,17 +3,18 @@
3 3
 CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z
4 4
 LDFLAGS=
5 5
 INCLUDES=-Ipge/include
6
-EXECUTABLE=awoorwae
7
-PACKER=packer/packer
8 6
 ifeq ($(OS),Windows_NT)
9 7
 	LIBRARIES=-luser32 -lgdi32 -lopengl32 -lgdiplus -lwinmm
10
-	EXECUTABLE+=.exe
11
-	PACKER+=.exe
8
+	EXECUTABLE=awoorwae.exe
9
+	PACKER=packer/packer.exe
12 10
 	LDFLAGS+=--machine=windows
13 11
 	CPP=i686-w64-mingw32-g++
14 12
 	CC=i686-w64-mingw32-gcc
13
+	MAKE=mingw32-make
15 14
 else
16 15
 	LIBRARIES=-lX11 -lGL -lpthread -lpng -lasound
16
+	EXECUTABLE=awoorwae
17
+	PACKER=packer/packer
17 18
 	CC=gcc
18 19
 	CPP=g++
19 20
 endif

+ 9
- 4
packer/Makefile View File

@@ -1,18 +1,23 @@
1
-CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z -O3 -flto
1
+CPPFLAGS=-Wall -Wno-misleading-indentation -Werror --std=c++1z
2 2
 LDFLAGS=
3 3
 INCLUDES=-I../pge/include
4
-EXECUTABLE=packer
5 4
 ifeq ($(OS),Windows_NT)
6 5
 	LIBRARIES=-luser32 -lgdi32 -lgdiplus
7
-	EXECUTABLE+=.exe
6
+	EXECUTABLE=packer.exe
8 7
 	CPP=i686-w64-mingw32-g++
9 8
 	CC=i686-w64-mingw32-gcc
10 9
 else
10
+	EXECUTABLE=packer
11 11
 	LIBRARIES=-lpng
12 12
 	CC=gcc
13 13
 	CPP=g++
14 14
 endif
15
-SOURCES=packer.cpp ../pge/src/olcPGE_ResourcePack.cpp ../pge/src/olcPGE_Sprite.cpp ../pge/src/olcPGE_Pixel.cpp
15
+ifeq ($(DEBUG),1)
16
+	CPPFLAGS+=-g -Og
17
+else
18
+	CPPFLAGS+=-flto -O3
19
+endif
20
+SOURCES=packer.cpp ../pge/src/olcPGE_ResourcePack.cpp ../pge/src/olcPGE_Sprite.cpp ../pge/src/olcPGE_Pixel.cpp ../pge/src/olcPGE_Common.cpp
16 21
 OBJECTS=$(SOURCES:.cpp=.o)
17 22
 
18 23
 all: $(SOURCES) $(EXECUTABLE)

+ 3
- 0
pge/include/olcPGE_Common.h View File

@@ -5,6 +5,8 @@
5 5
 	// Link to libraries
6 6
 #ifndef __MINGW32__
7 7
 	#pragma comment(lib, "user32.lib")
8
+	#pragma comment(lib, "gdi32.lib")
9
+	#pragma comment(lib, "gdiplus.lib")
8 10
 #else
9 11
 	// In Code::Blocks, Select C++14 in your build options, and add the
10 12
 	// following libs to your linker: user32 gdi32 opengl32 gdiplus
@@ -18,6 +20,7 @@
18 20
 #endif
19 21
 	// Include WinAPI
20 22
 	#include <windows.h>
23
+    #include <gdiplus.h>
21 24
 #else
22 25
 #endif
23 26
 

+ 16
- 0
pge/src/olcPGE_Common.cpp View File

@@ -14,4 +14,20 @@ namespace olc {
14 14
 		return L"SVN FTW!";
15 15
 #endif
16 16
 	}
17
+	
18
+#ifdef _WIN32
19
+	// Thanks @MaGetzUb for this, which allows sprites to be defined
20
+	// at construction, by initialising the GDI subsystem
21
+	static class GDIPlusStartup
22
+	{
23
+	public:
24
+		GDIPlusStartup()
25
+		{
26
+			Gdiplus::GdiplusStartupInput startupInput;
27
+			ULONG_PTR	token;
28
+			Gdiplus::GdiplusStartup(&token, &startupInput, NULL);
29
+		};
30
+	} gdistartup;
31
+#endif
32
+
17 33
 }

+ 25
- 21
pge/src/olcPixelGameEngine.cpp View File

@@ -686,10 +686,31 @@ namespace olc
686 686
 			nMousePosYcache = 0;
687 687
 	}
688 688
 
689
+#ifdef _WIN32
690
+	static int minWidth;
691
+	static int minHeight;
692
+	static WINAPI BOOL MonitorInfoProc(HMONITOR mon, HDC dc, LPRECT rect, LPARAM param) {
693
+		MONITORINFO info;
694
+		info.cbSize = sizeof(MONITORINFO);
695
+		GetMonitorInfo(mon, &info);
696
+		int w = info.rcWork.right - info.rcWork.left;
697
+		int h = info.rcWork.bottom - info.rcWork.top;
698
+		if (w < minWidth) {
699
+			minWidth = w;
700
+		}
701
+		if (h < minHeight) {
702
+			minHeight = h;
703
+		}
704
+		return TRUE;
705
+	}
706
+#endif
707
+
689 708
 	uint32_t PixelGameEngine::olc_GetMaximumPixelSize(uint32_t width, uint32_t height) 
690 709
 	{
691 710
 #ifdef _WIN32
692
-		return 1; // TODO
711
+		minWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
712
+		minHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
713
+		EnumDisplayMonitors(NULL, NULL, &MonitorInfoProc, 0);
693 714
 #else
694 715
 		Display* d = XOpenDisplay(NULL);
695 716
 		int defaultScreen = DefaultScreen(d);
@@ -705,13 +726,12 @@ namespace olc
705 726
 			if (HeightOfScreen(s) < minHeight) {
706 727
 				minHeight = HeightOfScreen(s);
707 728
 			}
708
-		}
709
-
729
+		}		
730
+#endif
710 731
 		uint32_t pixelWidth = minWidth / width;
711 732
 		uint32_t pixelHeight = minHeight / height;
712 733
 
713
-		return std::min(pixelWidth, pixelHeight);		
714
-#endif
734
+		return std::min(pixelWidth, pixelHeight);
715 735
 	}
716 736
 
717 737
 	void PixelGameEngine::EngineThread()
@@ -959,22 +979,6 @@ namespace olc
959 979
 
960 980
 	}
961 981
 
962
-#ifdef _WIN32
963
-	// Thanks @MaGetzUb for this, which allows sprites to be defined
964
-	// at construction, by initialising the GDI subsystem
965
-	static class GDIPlusStartup
966
-	{
967
-	public:
968
-		GDIPlusStartup()
969
-		{
970
-			Gdiplus::GdiplusStartupInput startupInput;
971
-			ULONG_PTR	token;
972
-			Gdiplus::GdiplusStartup(&token, &startupInput, NULL);
973
-		};
974
-	} gdistartup;
975
-#endif
976
-
977
-
978 982
 	void PixelGameEngine::olc_ConstructFontSheet()
979 983
 	{
980 984
 		std::string data;

Loading…
Cancel
Save