Merge pull request #14 from zryan3/bugfix/linux_cmake

refactored CMakeLists to build for Linux Mint 17.2, and ...
This commit is contained in:
JoeyDeVries
2015-08-02 11:29:25 +02:00
2 changed files with 9 additions and 18 deletions

View File

@@ -33,24 +33,13 @@ if(WIN32)
set(LIBS glfw3 opengl32 glew32s SOIL assimp)
elseif(UNIX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
# Linux packages native to CMake
find_package(OpenGL REQUIRED)
set(LIBS ${OPENGL_gl_LIBRARY}) # setting LIBS for the first time
add_definitions(${OPENGL_DEFINITIONS})
find_package(X11 REQUIRED)
list(APPEND LIBS ${X11_Xrandr_LIB} ${X11_Xxf86vm_LIB} ${X11_Xi_LIB})
find_library(RT_LIB rt)
list(APPEND LIBS ${RT_LIB})
# append non-native packages
list(APPEND LIBS ${GLFW3_LIBRARY})
list(APPEND LIBS ${GLEW_LIBRARY})
list(APPEND LIBS ${SOIL_LIBRARY})
list(APPEND LIBS ${ASSIMP_LIBRARY})
else()
set(LIBS )
endif(WIN32)
IF(APPLE)
# note that the order is important for setting the libs
# use pkg-config --libs $(pkg-config --print-requires --print-requires-private glfw3) in a terminal to confirm
set(LIBS glfw3 X11 Xrandr Xinerama Xi Xxf86vm Xcursor GL dl pthread GLEW SOIL assimp)
elseif(APPLE)
INCLUDE_DIRECTORIES(/System/Library/Frameworks)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
FIND_LIBRARY(OpenGL_LIBRARY OpenGL)
@@ -59,7 +48,9 @@ IF(APPLE)
SET(APPLE_LIBS ${COCOA_LIBRARY} ${IOKit_LIBRARY} ${OpenGL_LIBRARY})
SET(APPLE_LIBS ${APPLE_LIBS} /usr/local/lib/libglfw.a)
set(LIBS ${LIBS} ${APPLE_LIBS})
ENDIF(APPLE)
else()
set(LIBS )
endif(WIN32)
set(CHAPTERS
1.getting_started

View File

@@ -219,7 +219,7 @@ int main()
// Then calculate radius of light volume/sphere
const GLfloat lightThreshold = 5.0; // 5 / 256
const GLfloat maxBrightness = std::fmaxf(std::fmaxf(lightColors[i].r, lightColors[i].g), lightColors[i].b);
GLfloat radius = (-linear + std::sqrtf(linear * linear - 4 * quadratic * (constant - (256.0 / lightThreshold) * maxBrightness))) / (2 * quadratic);
GLfloat radius = (-linear + static_cast<float>(std::sqrt(linear * linear - 4 * quadratic * (constant - (256.0 / lightThreshold) * maxBrightness)))) / (2 * quadratic);
glUniform1f(glGetUniformLocation(shaderLightingPass.Program, ("lights[" + std::to_string(i) + "].Radius").c_str()), radius);
}
glUniform3fv(glGetUniformLocation(shaderLightingPass.Program, "viewPos"), 1, &camera.Position[0]);
@@ -434,4 +434,4 @@ void mouse_callback(GLFWwindow* window, double xpos, double ypos)
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{
camera.ProcessMouseScroll(yoffset);
}
}