From 030a136e8bb2e196af2c145ab1f72441ec72bb4f Mon Sep 17 00:00:00 2001 From: jancoow Date: Mon, 20 Jun 2016 20:00:58 +0200 Subject: [PATCH] Working version for linux --- CMakeLists.txt | 7 ++++--- Cursor.cpp | 2 +- HeightMap.cpp | 3 ++- Interface.cpp | 2 +- Model.cpp | 4 ++-- Sound.cpp | 9 +++++++++ Sound.h | 2 +- SoundSystem.cpp | 6 ------ SoundSystem.h | 9 ++++++++- Vertex.cpp | 8 ++++---- Vertex.h | 8 ++++---- 11 files changed, 36 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 180810f..abebe75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(CrystalPoint ${SOURCE_FILES}) find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) -include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ) -target_link_libraries(CrystalPoint ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall ") +find_package(OpenAL REQUIRED) +include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIRS} ) +target_link_libraries(CrystalPoint ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${OPENAL_LIBRARY} ) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -lpthread") \ No newline at end of file diff --git a/Cursor.cpp b/Cursor.cpp index 69895a3..6f2d5b2 100644 --- a/Cursor.cpp +++ b/Cursor.cpp @@ -1,5 +1,5 @@ #include "Cursor.h" -#include +#include #include #include "CrystalPoint.h" diff --git a/HeightMap.cpp b/HeightMap.cpp index 99e4924..61aef40 100644 --- a/HeightMap.cpp +++ b/HeightMap.cpp @@ -1,6 +1,6 @@ #include "HeightMap.h" #include "stb_image.h" -#include "vector.h" +#include "Vector.h" #include "LevelObject.h" @@ -127,6 +127,7 @@ float HeightMap::GetHeight(float x, float y) float labda3 = 1 - labda1 - labda2; Vertex z = a * labda1 + b * labda2 + c * labda3; +// Vertex z = (a * labda1) + (b * labda2) ; return z.y; } diff --git a/Interface.cpp b/Interface.cpp index c5ee6ba..a1d83e4 100644 --- a/Interface.cpp +++ b/Interface.cpp @@ -1,5 +1,5 @@ #include "Interface.h" -#include +#include #include "CrystalPoint.h" #include diff --git a/Model.cpp b/Model.cpp index 48c91a5..caf7979 100644 --- a/Model.cpp +++ b/Model.cpp @@ -138,7 +138,7 @@ Model::Model(std::string fileName) radius = fmax(radius, (center.x - v.x) * (center.x - v.x) + (center.z - v.z) * (center.z - v.z)); radius = sqrt(radius); - for each(ObjGroup *group in groups) + for (ObjGroup *group : groups) { Optimise(group); } @@ -148,7 +148,7 @@ void Model::Optimise(ObjGroup *t) { for (Face &face : t->faces) { - for each(auto &vertex in face.vertices) + for (auto &vertex : face.vertices) { t->VertexArray.push_back(Vertex(vertices[vertex.position].x, vertices[vertex.position].y, vertices[vertex.position].z, normals[vertex.normal].x, normals[vertex.normal].y, normals[vertex.normal].z, diff --git a/Sound.cpp b/Sound.cpp index cc990da..237b63c 100644 --- a/Sound.cpp +++ b/Sound.cpp @@ -1,8 +1,17 @@ #include "Sound.h" #include +#ifdef WIN32 #include #include +#else +#include +typedef unsigned long DWORD; +typedef unsigned short WORD; +typedef unsigned int UNINT32; +typedef unsigned char BYTE; +#endif + Sound::Sound(const char* inWavPath, bool inLooping): buffer_id(0), diff --git a/Sound.h b/Sound.h index 74e2f9f..baf9246 100644 --- a/Sound.h +++ b/Sound.h @@ -1,6 +1,6 @@ #pragma once -#include "vector.h" +#include "Vector.h" class Sound { diff --git a/SoundSystem.cpp b/SoundSystem.cpp index bd207be..f57a526 100644 --- a/SoundSystem.cpp +++ b/SoundSystem.cpp @@ -1,11 +1,5 @@ #include "SoundSystem.h" -#include -#include -#include - - - SoundSystem::SoundSystem(): device(nullptr), context(nullptr) diff --git a/SoundSystem.h b/SoundSystem.h index d6908ce..b9e289b 100644 --- a/SoundSystem.h +++ b/SoundSystem.h @@ -1,9 +1,16 @@ #pragma once #include + +#ifdef WIN32 #include #include -#include "vector.h" +#else +#include +#include +#endif + +#include "Vector.h" #include "Sound.h" diff --git a/Vertex.cpp b/Vertex.cpp index 8afd8a1..35591cf 100644 --- a/Vertex.cpp +++ b/Vertex.cpp @@ -18,22 +18,22 @@ Vertex::~Vertex() { } -Vertex Vertex::operator/(float &other) +Vertex Vertex::operator/(const float &other) const { return Vertex(x / other, y / other, z / other, normalX, normalY, normalZ, texX, texY); } -Vertex Vertex::operator*(Vertex & other) +Vertex Vertex::operator*(const Vertex & other) const { return Vertex(x*other.x, y*other.y, z*other.z, normalX, normalY, normalZ, texX, texY); } -Vertex Vertex::operator*(float & other) +Vertex Vertex::operator*(const float & other) const { return Vertex(x*other, y*other, z*other, normalX, normalY, normalZ, texX, texY); } -Vertex Vertex::operator+(Vertex & other) +Vertex Vertex::operator+(const Vertex & other) const { return Vertex(x+other.x, y+other.y, z+other.z, normalX, normalY, normalZ, texX, texY); } diff --git a/Vertex.h b/Vertex.h index 3411000..ff3b2cc 100644 --- a/Vertex.h +++ b/Vertex.h @@ -16,9 +16,9 @@ public: float texX; float texY; - Vertex operator/(float &other); - Vertex operator*(Vertex &other); - Vertex operator*(float &other); - Vertex operator+(Vertex &other); + Vertex operator/(const float &other) const; + Vertex operator*(const Vertex &other) const; + Vertex operator*(const float &other) const; + Vertex operator+(const Vertex &other) const; };