Fixed some windows platform problems

This commit is contained in:
Michaël Lemaire 2016-07-08 00:19:45 +02:00
parent b3787ed7ea
commit 6b805459e8
10 changed files with 29 additions and 16 deletions

1
.gitignore vendored
View file

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

View file

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

View file

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

View file

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

View file

@ -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 #endif // SYSTEM_H

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,6 @@
#include "BaseTestCase.h" #include "BaseTestCase.h"
#include "System.h"
#include "Scenery.h" #include "Scenery.h"
#include "Logs.h" #include "Logs.h"
#include "TerrainDefinition.h" #include "TerrainDefinition.h"
@ -12,11 +13,11 @@ TEST(Scenery, saveGlobal) {
scenery1.getTerrain()->propWaterHeight()->setValue(0.2); scenery1.getTerrain()->propWaterHeight()->setValue(0.2);
scenery1.getAtmosphere()->setDayTime(0.53); 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); EXPECT_EQ(Scenery::FILE_OPERATION_OK, result);
Scenery scenery2; 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_EQ(Scenery::FILE_OPERATION_OK, result);
EXPECT_DOUBLE_EQ(0.2, scenery2.getTerrain()->propWaterHeight()->getValue()); EXPECT_DOUBLE_EQ(0.2, scenery2.getTerrain()->propWaterHeight()->getValue());