Skip to content

Commit

Permalink
Fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Sep 30, 2015
1 parent 48f7494 commit b9afc8b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
34 changes: 20 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ list(APPEND CMAKE_LIBRARY_PATH "${EXTERNAL_LIB_PATH}")
# Find up and set up core dependency libs

set(GLFW_INCLUDE_DIR "external/include")
set(GLFW_LIBRARY_DIR "${CMAKE_LIBRARY_PATH}")
set(GLFW_LIBRARY_DIR "${EXTERNAL_LIB_PATH}")
find_library(GLFW_LIBRARY "glfw3" HINTS "${GLFW_LIBRARY_DIR}")

set(GLEW_INCLUDE_DIR "external/include")
set(GLEW_LIBRARY_DIR "${CMAKE_LIBRARY_PATH}")
set(GLEW_LIBRARY_DIR "${EXTERNAL_LIB_PATH}")
add_definitions(-DGLEW_STATIC)
find_package(GLEW)

Expand All @@ -42,25 +42,31 @@ set(CORELIBS
set(CMAKE_CXX_STANDARD 11)

# Set up different build configurations
set(CMAKE_CONFIGURATION_TYPES Debug DebugNDEBUG Release)
set(CMAKE_CONFIGURATION_TYPES Debug;RelWithDebInfo;Release
CACHE STRING "Set configuration types" FORCE)
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_DEBUGNDEBUG "-O0 -g -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUGFAST "-O2 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
list(APPEND CUDA_NVCC_FLAGS_DEBUG -O0 -g -G)
list(APPEND CUDA_NVCC_FLAGS_DEBUGNDEBUG -O0 -g -G -DNDEBUG)
list(APPEND CUDA_NVCC_FLAGS_DEBUGFAST -O2 -g -lineinfo)
list(APPEND CUDA_NVCC_FLAGS_RELEASE -O3 -DNDEBUG)

# OS X linker options
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
list(APPEND CUDA_NVCC_FLAGS_DEBUG -O0 -g -G)
list(APPEND CUDA_NVCC_FLAGS_RELWITHDEBINFO -O2 -g -lineinfo)
list(APPEND CUDA_NVCC_FLAGS_RELEASE -O3 -DNDEBUG)
if (WIN32)
set(CUDA_PROPAGATE_HOST_FLAGS ON)
set(CMAKE_CXX_FLAGS "/MD /EHsc /D _CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Zi")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Zi")
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /D NDEBUG")
endif()

# OS X options
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list(APPEND CORELIBS "-framework IOKit")
list(APPEND CORELIBS "-framework Cocoa")
list(APPEND CORELIBS "-framework CoreVideo")
endif()

# Linux linker options
# Linux options
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND CMAKE_EXE_LINKER_FLAGS "-lX11 -lXxf86vm -lXrandr -lXi")
endif()
Expand Down
9 changes: 3 additions & 6 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ CMAKE := $(shell \
([ -e ${CMAKE_ALT2} ] && echo "${CMAKE_ALT2}") \
)

all: DebugFast
all: RelWithDebInfo


Debug: build
(cd build && ${CMAKE} -DCMAKE_BUILD_TYPE=$@ .. && make)

DebugFast: build
(cd build && ${CMAKE} -DCMAKE_BUILD_TYPE=$@ .. && make)

DebugNDEBUG: build
RelWithDebInfo: build
(cd build && ${CMAKE} -DCMAKE_BUILD_TYPE=$@ .. && make)

Release: build
Expand All @@ -31,4 +28,4 @@ build:
clean:
((cd build && make clean) 2>&- || true)

.PHONY: all Debug DebugFast DebugNDEBUG Release clean
.PHONY: all Debug RelWithDebInfo Release clean
24 changes: 12 additions & 12 deletions util/obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ obj::obj() {

obj::~obj() {
delete boundingbox;
for (int i = 0; i < faceboxes.size(); i++) {
for (int i = 0; i < (int) faceboxes.size(); i++) {
delete faceboxes[i];
}

Expand All @@ -48,18 +48,18 @@ void obj::buildBufPoss() {
vector<int> BufIdxvec;
int index = 0;
bool genNormals = false;
if (faces.size() != facenormals.size()) {
if (faces.size() != (int) facenormals.size()) {
genNormals = true;
}
for (int k = 0; k < faces.size(); k++) {
for (int k = 0; k < (int) faces.size(); k++) {

if (isConvex(faces[k]) == true) {
//if(0==0){
vector<int> face = faces[k];

glm::vec4 p0 = points[face[0]];

for (int i = 2; i < face.size(); i++) {
for (int i = 2; i < (int) face.size(); i++) {
glm::vec4 p1 = points[face[i - 1]];
glm::vec4 p2 = points[face[i]];
BufPosvec.push_back(p0[0]) ;
Expand Down Expand Up @@ -114,13 +114,13 @@ void obj::buildBufPoss() {
vbosize = (int)BufPosvec.size();
nbosize = (int)BufNorvec.size();
ibosize = (int)BufIdxvec.size();
for (int i = 0; i < BufPosvec.size(); i++) {
for (int i = 0; i < (int) BufPosvec.size(); i++) {
vbo[i] = BufPosvec[i];
}
for (int i = 0; i < BufNorvec.size(); i++) {
for (int i = 0; i < (int) BufNorvec.size(); i++) {
nbo[i] = BufNorvec[i];
}
for (int i = 0; i < BufIdxvec.size(); i++) {
for (int i = 0; i < (int) BufIdxvec.size(); i++) {
ibo[i] = BufIdxvec[i];
}
setColor(glm::vec3(1, 1, 1));
Expand Down Expand Up @@ -202,7 +202,7 @@ bool obj::isConvex(vector<int> face) {
glm::vec3 b = glm::vec3(points[face[0]][0], points[face[0]][1], points[face[0]][2]) - glm::vec3(points[face[1]][0], points[face[1]][1], points[face[1]][2]);
glm::vec3 n = glm::normalize(glm::cross(a, b));

for (int i = 2; i < face.size(); i++) {
for (int i = 2; i < (int) face.size(); i++) {
glm::vec3 c = glm::vec3(points[face[i - 1]][0], points[face[i - 1]][1], points[face[i - 1]][2]) - glm::vec3(points[face[i - 2]][0], points[face[i - 2]][1], points[face[i - 2]][2]);
glm::vec3 d = glm::vec3(points[face[i - 1]][0], points[face[i - 1]][1], points[face[i - 1]][2]) - glm::vec3(points[face[i]][0], points[face[i]][1], points[face[i]][2]);
glm::vec3 m = glm::normalize(glm::cross(c, d));
Expand Down Expand Up @@ -245,7 +245,7 @@ void obj::addFace(vector<int> face) {
float facexmin = points[face[0]][0];
float faceymin = points[face[0]][1];
float facezmin = points[face[0]][2];
for (int i = 0; i < face.size(); i++) {
for (int i = 0; i < (int) face.size(); i++) {
if (points[face[i]][0] > facexmax) {
facexmax = points[face[i]][0];
}
Expand Down Expand Up @@ -334,14 +334,14 @@ void obj::recenter() {
zmax = points[0][2] - center[2];
zmin = points[0][2] - center[2];
top = 0;
for (int i = 0; i < points.size(); i++) {
for (int i = 0; i < (int) points.size(); i++) {
points[i][0] = points[i][0] - center[0];
points[i][1] = points[i][1] - center[1];
points[i][2] = points[i][2] - center[2];
compareMaxMin(points[i][0], points[i][1], points[i][2]);
}

for (int i = 0; i < faceboxes.size(); i++) {
for (int i = 0; i < (int) faceboxes.size(); i++) {

vector<int> face = faces[i];

Expand All @@ -352,7 +352,7 @@ void obj::recenter() {
float faceymin = points[face[0]][1];
float facezmin = points[face[0]][2];

for (int j = 0; j < face.size(); j++) {
for (int j = 0; j < (int) face.size(); j++) {
if (points[face[j]][0] > facexmax) {
facexmax = points[face[j]][0];
}
Expand Down
12 changes: 6 additions & 6 deletions util/objloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ objLoader::objLoader(string filename, obj *newMesh) {
istringstream facestring(v);
string f;
getline(facestring, f, '/');
pointList.push_back(::atof(f.c_str()) - 1);
pointList.push_back(::atoi(f.c_str()) - 1);

getline(facestring, f, '/');
getline(facestring, f, ' ');
normalList.push_back(::atof(f.c_str()) - 1);
normalList.push_back(::atoi(f.c_str()) - 1);

}
geomesh->addFace(pointList);
Expand All @@ -93,11 +93,11 @@ objLoader::objLoader(string filename, obj *newMesh) {
int i = 0;
while (getline(facestring, f, '/')) {
if (i == 0) {
pointList.push_back(::atof(f.c_str()) - 1);
pointList.push_back(::atoi(f.c_str()) - 1);
} else if (i == 1) {
texturecoordList.push_back(::atof(f.c_str()) - 1);
texturecoordList.push_back(::atoi(f.c_str()) - 1);
} else if (i == 2) {
normalList.push_back(::atof(f.c_str()) - 1);
normalList.push_back(::atoi(f.c_str()) - 1);
}
i++;
}
Expand All @@ -109,7 +109,7 @@ objLoader::objLoader(string filename, obj *newMesh) {
string v;
vector<int> pointList;
while (getline(liness, v, ' ')) {
pointList.push_back(::atof(v.c_str()) - 1);
pointList.push_back(::atoi(v.c_str()) - 1);
}
geomesh->addFace(pointList);
//std::cout << "Vertex Format" << std::endl;
Expand Down

0 comments on commit b9afc8b

Please sign in to comment.