From bebe39c0bee61d9cbe431a94855fd81fcdef40a7 Mon Sep 17 00:00:00 2001 From: zryan3 Date: Sun, 2 Aug 2015 00:40:56 -0700 Subject: [PATCH] refactored CMakeLists to build for Linux Mint 17.2, and removed std::sqrtf which is not apart of GCC C++ libraries apparently --- CMakeLists.txt | 23 ++++++------------- .../8.deferred_shading/deferred_shading.cpp | 4 ++-- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77ed568..9bc55fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/5.advanced_lighting/8.deferred_shading/deferred_shading.cpp b/src/5.advanced_lighting/8.deferred_shading/deferred_shading.cpp index 5ebc22d..ca67aa4 100644 --- a/src/5.advanced_lighting/8.deferred_shading/deferred_shading.cpp +++ b/src/5.advanced_lighting/8.deferred_shading/deferred_shading.cpp @@ -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(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); -} \ No newline at end of file +}