Browse Source

Fixed some windows platform problems

Michael Lemaire 3 years ago
parent
commit
6b805459e8

+ 1 - 0
.gitignore

@@ -26,4 +26,5 @@ ui_*.h
 /config.vim
 /callgrind.out.*
 *.p3d
+/build-paysages-*/
 

+ 1 - 1
src/common.pri

@@ -1,3 +1,3 @@
 CONFIG(release, debug|release): DEFINES += NDEBUG QT_NO_DEBUG_OUTPUT
 
-QMAKE_CXXFLAGS += -std=c++14
+CONFIG += c++14

+ 1 - 1
src/render/opengl/OpenGLVariable.h

@@ -13,7 +13,7 @@ namespace opengl {
 /**
  * OpenGL variable that can be bound to a uniform for shaders.
  */
-class OpenGLVariable final {
+class OPENGLSHARED_EXPORT OpenGLVariable final {
   public:
     OpenGLVariable(const string &name);
     ~OpenGLVariable();

+ 1 - 1
src/render/opengl/OpenGLVertexArray.h

@@ -11,7 +11,7 @@ namespace opengl {
  *
  * This will handle VAOs and VBOs automatically.
  */
-class OpenGLVertexArray {
+class OPENGLSHARED_EXPORT OpenGLVertexArray {
   public:
     OpenGLVertexArray(bool has_uv, bool strip = false);
     ~OpenGLVertexArray();

+ 6 - 0
src/system/System.h

@@ -24,4 +24,10 @@ class SYSTEMSHARED_EXPORT System {
 }
 }
 
+#ifdef PLATFORM_WIN
+#define TMP_DIRECTORY "c:/temp/"
+#else
+#define TMP_DIRECTORY "/tmp/"
+#endif
+
 #endif // SYSTEM_H

+ 3 - 1
src/system/system_global.h

@@ -1,12 +1,14 @@
 #ifndef SYSTEM_GLOBAL_H
 #define SYSTEM_GLOBAL_H
 
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_WIN32)
 #define DECL_EXPORT __declspec(dllexport)
 #define DECL_IMPORT __declspec(dllimport)
+#define PLATFORM_WIN 1
 #else
 #define DECL_EXPORT __attribute__((visibility("default")))
 #define DECL_IMPORT __attribute__((visibility("default")))
+#define PLATFORM_UNIX 1
 #endif
 
 #if defined(SYSTEM_LIBRARY)

+ 3 - 2
src/tests/DefinitionNode_Test.cpp

@@ -1,5 +1,6 @@
 #include "BaseTestCase.h"
 
+#include "System.h"
 #include "DefinitionNode.h"
 #include "IntNode.h"
 #include "FloatNode.h"
@@ -77,7 +78,7 @@ TEST(DefinitionNode, saveLoadCopy) {
     new FloatNode(before, "before3", 6.7);
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack", true);
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack", true);
     before->save(stream);
     stream->write(&check_in);
     delete stream;
@@ -91,7 +92,7 @@ TEST(DefinitionNode, saveLoadCopy) {
     FloatNode *after4 = new FloatNode(after, "before4");
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack");
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack");
     after->load(stream);
     stream->read(&check_out);
     delete stream;

+ 3 - 2
src/tests/Layers_Test.cpp

@@ -1,5 +1,6 @@
 #include "BaseTestCase.h"
 
+#include "System.h"
 #include "Layers.h"
 #include "PackStream.h"
 #include "DiffManager.h"
@@ -88,14 +89,14 @@ TEST(Layers, saveLoad) {
     ASSERT_EQ(2, layers1.getLayerCount());
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack", true);
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack", true);
     layers1.save(stream);
     delete stream;
 
     Layers layers2(NULL, "test", _construc1);
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack");
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack");
     layers2.load(stream);
     delete stream;
 

+ 7 - 6
src/tests/PackStream_Test.cpp

@@ -1,5 +1,6 @@
 #include "BaseTestCase.h"
 
+#include "System.h"
 #include "PackStream.h"
 
 TEST(PackStream, All) {
@@ -12,7 +13,7 @@ TEST(PackStream, All) {
 
     /* Writing to pack */
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack", true);
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack", true);
     for (i = 0; i < 5; i++) {
         data_i = i;
         stream->write(&data_i);
@@ -29,7 +30,7 @@ TEST(PackStream, All) {
 
     /* Reading from pack */
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack");
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack");
     for (i = 0; i < 5; i++) {
         stream->read(&data_i);
         ASSERT_EQ(i, data_i);
@@ -53,7 +54,7 @@ TEST(PackStream, Skip) {
     double d1 = 1.1, d2 = 2.2;
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack", true);
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack", true);
 
     stream->write(&i1);
     stream->write(&i2);
@@ -67,21 +68,21 @@ TEST(PackStream, Skip) {
     double resd;
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack");
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack");
     stream->skip(i1, 1);
     stream->read(&resi);
     EXPECT_EQ(2, resi);
     delete stream;
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack");
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack");
     stream->skip(i1, 2);
     stream->read(&resd);
     EXPECT_DOUBLE_EQ(1.1, resd);
     delete stream;
 
     stream = new PackStream();
-    stream->bindToFile("/tmp/test_paysages_pack");
+    stream->bindToFile(TMP_DIRECTORY "test_paysages_pack");
     stream->skip(i1, 2);
     stream->skip(d1, 2);
     stream->read(&resi);

+ 3 - 2
src/tests/Scenery_Test.cpp

@@ -1,5 +1,6 @@
 #include "BaseTestCase.h"
 
+#include "System.h"
 #include "Scenery.h"
 #include "Logs.h"
 #include "TerrainDefinition.h"
@@ -12,11 +13,11 @@ TEST(Scenery, saveGlobal) {
     scenery1.getTerrain()->propWaterHeight()->setValue(0.2);
     scenery1.getAtmosphere()->setDayTime(0.53);
 
-    Scenery::FileOperationResult result = scenery1.saveGlobal("/tmp/test_paysages_scenery");
+    Scenery::FileOperationResult result = scenery1.saveGlobal(TMP_DIRECTORY "test_paysages_scenery");
     EXPECT_EQ(Scenery::FILE_OPERATION_OK, result);
 
     Scenery scenery2;
-    result = scenery2.loadGlobal("/tmp/test_paysages_scenery");
+    result = scenery2.loadGlobal(TMP_DIRECTORY "test_paysages_scenery");
     EXPECT_EQ(Scenery::FILE_OPERATION_OK, result);
 
     EXPECT_DOUBLE_EQ(0.2, scenery2.getTerrain()->propWaterHeight()->getValue());