Browse Source

Improved Windows support

Thomas Buck 10 years ago
parent
commit
129604f2cf

+ 9
- 0
CMakeLists.txt View File

70
 
70
 
71
 #################################################################
71
 #################################################################
72
 
72
 
73
+if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles")
74
+
75
+	# Target for running the setup
76
+    add_custom_target (setup "${PROJECT_SOURCE_DIR}/cmake/setup_win.bat"
77
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
78
+    )
79
+
80
+endif (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles") 
81
+
73
 if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
82
 if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
74
 
83
 
75
     # Target for running the setup
84
     # Target for running the setup

+ 5
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+	[ 20140702 ]
6
+	* Compiled successfully in Windows 7 using MinGW
7
+	* Added Windows setup script
8
+	* FontTRLE lps parser no longer using std::stoi
9
+
5
     [ 20140626 ]
10
     [ 20140626 ]
6
     * ColorMode enum now global
11
     * ColorMode enum now global
7
     * Entities setAngles now sets all three angles
12
     * Entities setAngles now sets all three angles

+ 17
- 0
cmake/setup_win.bat View File

1
+@echo off
2
+
3
+if not exist "%UserProfile%\.OpenRaider" (
4
+	echo Setting up for %UserName%...
5
+	mkdir "%UserProfile%\.OpenRaider"
6
+	copy data\OpenRaider.ini %UserProfile%\.OpenRaider
7
+	mkdir %UserProfile%\.OpenRaider\paks
8
+	mkdir %UserProfile%\.OpenRaider\music
9
+	mkdir %UserProfile%\.OpenRaider\data
10
+	mkdir %UserProfile%\.OpenRaider\sshots
11
+	copy data\*.tga %UserProfile%\.OpenRaider\data
12
+	copy data\*.ttf %UserProfile%\.OpenRaider\data
13
+	copy data\*.pc %UserProfile%\.OpenRaider\data
14
+	echo Done!
15
+) else (
16
+	echo Already done
17
+)

+ 0
- 1
include/WindowSDL.h View File

9
 #define _WINDOW_SDL_H_
9
 #define _WINDOW_SDL_H_
10
 
10
 
11
 #include "SDL.h"
11
 #include "SDL.h"
12
-#include "SDL_ttf.h"
13
 
12
 
14
 #include "Window.h"
13
 #include "Window.h"
15
 
14
 

+ 1
- 0
include/global.h View File

102
 #include <windows.h>
102
 #include <windows.h>
103
 #endif
103
 #endif
104
 #include <GL/gl.h>
104
 #include <GL/gl.h>
105
+#include <GL/glext.h>
105
 #endif
106
 #endif
106
 
107
 
107
 // If available, use our own assert that prints the call stack
108
 // If available, use our own assert that prints the call stack

+ 4
- 1
src/FontManager.cpp View File

9
 #include "utils/strings.h"
9
 #include "utils/strings.h"
10
 #include "FontManager.h"
10
 #include "FontManager.h"
11
 #include "Font.h"
11
 #include "Font.h"
12
-#include "FontSDL.h"
13
 #include "FontTRLE.h"
12
 #include "FontTRLE.h"
14
 
13
 
14
+#ifdef USING_SDL_FONT
15
+#include "FontSDL.h"
16
+#endif
17
+
15
 FontManager::FontManager() {
18
 FontManager::FontManager() {
16
     add(new FontTRLE(), ".pc");
19
     add(new FontTRLE(), ".pc");
17
 
20
 

+ 2
- 0
src/FontSDL.cpp View File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
+#include <stdio.h>
9
+
8
 #include "global.h"
10
 #include "global.h"
9
 #include "FontSDL.h"
11
 #include "FontSDL.h"
10
 
12
 

+ 17
- 26
src/FontTRLE.cpp View File

72
 
72
 
73
     for (std::string line; std::getline(file, line);) {
73
     for (std::string line; std::getline(file, line);) {
74
         std::istringstream stream(line);
74
         std::istringstream stream(line);
75
-        std::string tok1, tok2;
76
-        std::getline(stream, tok1, '=');
77
-        std::getline(stream, tok2);
78
-
79
-        // we are only interested in lines starting with
80
-        // xxx=
81
-        // Where xxx is a 3 digit number
82
-        try {
83
-            int index = std::stoi(tok1);
84
-            if ((index >= 0) && (index <= 105)) {
85
-                std::istringstream row(tok2);
86
-                std::string a, b, c, d, e;
87
-                std::getline(row, a, ',');
88
-                std::getline(row, b, ',');
89
-                std::getline(row, c, ',');
90
-                std::getline(row, d, ',');
91
-                std::getline(row, e);
92
-                offsets[index][0] = std::stoi(a);
93
-                offsets[index][1] = std::stoi(b);
94
-                offsets[index][2] = std::stoi(c);
95
-                offsets[index][3] = std::stoi(d);
96
-                offsets[index][4] = std::stoi(e);
97
-            }
98
-        } catch (std::invalid_argument) {
99
-
100
-        }
75
+		int index;
76
+		stream >> index;
77
+		if (stream.get() != '=')
78
+			return;
79
+		stream >> offsets[index][0];
80
+		if (stream.get() != ',')
81
+			return;
82
+		stream >> offsets[index][1];
83
+		if (stream.get() != ',')
84
+			return;
85
+		stream >> offsets[index][2];
86
+		if (stream.get() != ',')
87
+			return;
88
+		stream >> offsets[index][3];
89
+		if (stream.get() != ',')
90
+			return;
91
+		stream >> offsets[index][4];
101
     }
92
     }
102
 }
93
 }
103
 
94
 

+ 1
- 1
src/Menu.cpp View File

17
 #if defined(HAVE_DIRENT_H) && defined(HAVE_OPENDIR) && defined(HAVE_READDIR_R) && defined(HAVE_CLOSEDIR) && defined(HAVE_DT_DIR)
17
 #if defined(HAVE_DIRENT_H) && defined(HAVE_OPENDIR) && defined(HAVE_READDIR_R) && defined(HAVE_CLOSEDIR) && defined(HAVE_DT_DIR)
18
 #include <dirent.h>
18
 #include <dirent.h>
19
 #define USE_DIRENT
19
 #define USE_DIRENT
20
-#elif defined(HAVE_WINDOWS_H) && defined(HAVE_FINDFIRSTFILE) && defined(HAVE_FINDNEXTFILE) && defined(HAVE_FINDCLOSE)
20
+#elif (defined(HAVE_WINDOWS_H) && defined(HAVE_FINDFIRSTFILE) && defined(HAVE_FINDNEXTFILE) && defined(HAVE_FINDCLOSE)) || defined (_WIN32)
21
 #include <windows.h>
21
 #include <windows.h>
22
 #define USE_FINDFILE
22
 #define USE_FINDFILE
23
 #else
23
 #else

+ 7
- 1
src/TextureManager.cpp View File

45
     delete [] image;
45
     delete [] image;
46
 
46
 
47
     //! \fixme Temporary
47
     //! \fixme Temporary
48
-    char *filename = bufferString("%s/tr2/TITLE.PCX", getOpenRaider().mPakDir);
48
+    char *filename;// = bufferString("%s/tr2/TITLE.PCX", getOpenRaider().mPakDir);
49
     if (loadPCX(filename) < 0) {
49
     if (loadPCX(filename) < 0) {
50
         delete [] filename;
50
         delete [] filename;
51
         //! \fixme Error Checking. Return negative error code, check in calling place too
51
         //! \fixme Error Checking. Return negative error code, check in calling place too
72
 void TextureManager::disableMultiTexture() {
72
 void TextureManager::disableMultiTexture() {
73
     mFlags &= ~fUseMultiTexture;
73
     mFlags &= ~fUseMultiTexture;
74
 
74
 
75
+#ifdef MULTITEXTURE
75
     glDisable(GL_TEXTURE_2D);
76
     glDisable(GL_TEXTURE_2D);
76
     glActiveTextureARB(GL_TEXTURE0_ARB);
77
     glActiveTextureARB(GL_TEXTURE0_ARB);
78
+#endif
77
 }
79
 }
78
 
80
 
79
 void TextureManager::useMultiTexture(float aU, float aV, float bU, float bV) {
81
 void TextureManager::useMultiTexture(float aU, float aV, float bU, float bV) {
80
     if (!(mFlags & fUseMultiTexture))
82
     if (!(mFlags & fUseMultiTexture))
81
         return;
83
         return;
82
 
84
 
85
+#ifdef MULTITEXTURE
83
     glMultiTexCoord2fARB(GL_TEXTURE0_ARB, aU, aV);
86
     glMultiTexCoord2fARB(GL_TEXTURE0_ARB, aU, aV);
84
     glMultiTexCoord2fARB(GL_TEXTURE1_ARB, bU, bV);
87
     glMultiTexCoord2fARB(GL_TEXTURE1_ARB, bU, bV);
88
+#endif
85
 }
89
 }
86
 
90
 
87
 void TextureManager::bindMultiTexture(int texture0, int texture1) {
91
 void TextureManager::bindMultiTexture(int texture0, int texture1) {
92
 
96
 
93
     mFlags |= fUseMultiTexture;
97
     mFlags |= fUseMultiTexture;
94
 
98
 
99
+#ifdef MULTITEXTURE
95
     glActiveTextureARB(GL_TEXTURE0_ARB);
100
     glActiveTextureARB(GL_TEXTURE0_ARB);
96
     glEnable(GL_TEXTURE_2D);
101
     glEnable(GL_TEXTURE_2D);
97
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture0));
102
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture0));
99
     glActiveTextureARB(GL_TEXTURE1_ARB);
104
     glActiveTextureARB(GL_TEXTURE1_ARB);
100
     glEnable(GL_TEXTURE_2D);
105
     glEnable(GL_TEXTURE_2D);
101
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture1));
106
     glBindTexture(GL_TEXTURE_2D, mTextureIds.at(texture1));
107
+#endif
102
 }
108
 }
103
 
109
 
104
 int TextureManager::loadBufferSlot(unsigned char *image,
110
 int TextureManager::loadBufferSlot(unsigned char *image,

+ 2
- 2
src/WindowSDL.cpp View File

25
     mWindow = NULL;
25
     mWindow = NULL;
26
     mGLContext = NULL;
26
     mGLContext = NULL;
27
 
27
 
28
-#ifdef WIN32
28
+#ifdef _WIN32
29
     setDriver("libGL32.dll");
29
     setDriver("libGL32.dll");
30
 #elif !defined(__APPLE__)
30
 #elif !defined(__APPLE__)
31
     setDriver("/usr/lib/libGL.so.1");
31
     setDriver("/usr/lib/libGL.so.1");
84
         return -1;
84
         return -1;
85
     }
85
     }
86
 
86
 
87
-#ifndef __APPLE__
87
+#if !(defined(__APPLE__) || defined(_WIN32))
88
     assert(mDriver != NULL);
88
     assert(mDriver != NULL);
89
     assert(mDriver[0] != '\0');
89
     assert(mDriver[0] != '\0');
90
 
90
 

+ 11
- 9
src/utils/strings.cpp View File

12
 
12
 
13
 #if defined(unix) || defined(__APPLE__) || defined(__linux__)
13
 #if defined(unix) || defined(__APPLE__) || defined(__linux__)
14
 #include <wordexp.h>
14
 #include <wordexp.h>
15
-#elif defined(WIN32)
15
+#elif defined(_WIN32)
16
 #include <Windows.h>
16
 #include <Windows.h>
17
 #include <shlobj.h>
17
 #include <shlobj.h>
18
 #ifndef va_copy
18
 #ifndef va_copy
171
         }
171
         }
172
 
172
 
173
         wordfree(&word);
173
         wordfree(&word);
174
-#elif defined(WIN32)
175
-        WCHAR newPath[MAX_PATH];
176
-        if (SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, newPath) == S_OK) {
177
-            lenPath = strlen((const char *)newPath);
174
+#elif defined(_WIN32)
175
+        char newPath[MAX_PATH];
176
+        if (SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, 0, newPath) == S_OK) {
177
+            lenPath = strlen(newPath);
178
             unsigned int lenPath2 = strlen(path);
178
             unsigned int lenPath2 = strlen(path);
179
             dir = new char[lenPath + lenPath2 + 2]; // space for end char
179
             dir = new char[lenPath + lenPath2 + 2]; // space for end char
180
-            strncpy(dir, (const char *)newPath, lenPath);
181
-            dir[lenPath] = '\\';
182
-            strncpy((dir + lenPath + 1), (path + 1), lenPath2 - 1);
183
-            lenPath += lenPath2;
180
+            strncpy(dir, newPath, lenPath);
181
+            strncpy((dir + lenPath), (path + 1), lenPath2 - 1);
182
+            lenPath += lenPath2 - 1;
183
+			for (unsigned int i = 0; i < lenPath; i++)
184
+				if(dir[i] == '\\')
185
+					dir[i] = '/';
184
         } else {
186
         } else {
185
             printf("WARNING: Could not get home folder location for tilde expansion!\n");
187
             printf("WARNING: Could not get home folder location for tilde expansion!\n");
186
             lenPath = strlen(path);
188
             lenPath = strlen(path);

+ 1
- 1
src/utils/time.cpp View File

26
     gettimeofday(&system_timer_start, &system_timer_zone);
26
     gettimeofday(&system_timer_start, &system_timer_zone);
27
 }
27
 }
28
 
28
 
29
-#elif defined(WIN32)
29
+#elif defined(_WIN32)
30
 
30
 
31
 #include <Windows.h>
31
 #include <Windows.h>
32
 
32
 

Loading…
Cancel
Save