mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -33,24 +33,13 @@ if(WIN32)
|
|||||||
set(LIBS glfw3 opengl32 glew32s SOIL assimp)
|
set(LIBS glfw3 opengl32 glew32s SOIL assimp)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
||||||
# Linux packages native to CMake
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
set(LIBS ${OPENGL_gl_LIBRARY}) # setting LIBS for the first time
|
|
||||||
add_definitions(${OPENGL_DEFINITIONS})
|
add_definitions(${OPENGL_DEFINITIONS})
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
list(APPEND LIBS ${X11_Xrandr_LIB} ${X11_Xxf86vm_LIB} ${X11_Xi_LIB})
|
# note that the order is important for setting the libs
|
||||||
find_library(RT_LIB rt)
|
# use pkg-config --libs $(pkg-config --print-requires --print-requires-private glfw3) in a terminal to confirm
|
||||||
list(APPEND LIBS ${RT_LIB})
|
set(LIBS glfw3 X11 Xrandr Xinerama Xi Xxf86vm Xcursor GL dl pthread GLEW SOIL assimp)
|
||||||
# append non-native packages
|
elseif(APPLE)
|
||||||
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)
|
|
||||||
INCLUDE_DIRECTORIES(/System/Library/Frameworks)
|
INCLUDE_DIRECTORIES(/System/Library/Frameworks)
|
||||||
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
|
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
|
||||||
FIND_LIBRARY(OpenGL_LIBRARY OpenGL)
|
FIND_LIBRARY(OpenGL_LIBRARY OpenGL)
|
||||||
@@ -59,7 +48,9 @@ IF(APPLE)
|
|||||||
SET(APPLE_LIBS ${COCOA_LIBRARY} ${IOKit_LIBRARY} ${OpenGL_LIBRARY})
|
SET(APPLE_LIBS ${COCOA_LIBRARY} ${IOKit_LIBRARY} ${OpenGL_LIBRARY})
|
||||||
SET(APPLE_LIBS ${APPLE_LIBS} /usr/local/lib/libglfw.a)
|
SET(APPLE_LIBS ${APPLE_LIBS} /usr/local/lib/libglfw.a)
|
||||||
set(LIBS ${LIBS} ${APPLE_LIBS})
|
set(LIBS ${LIBS} ${APPLE_LIBS})
|
||||||
ENDIF(APPLE)
|
else()
|
||||||
|
set(LIBS )
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
set(CHAPTERS
|
set(CHAPTERS
|
||||||
1.getting_started
|
1.getting_started
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ int main()
|
|||||||
// Then calculate radius of light volume/sphere
|
// Then calculate radius of light volume/sphere
|
||||||
const GLfloat lightThreshold = 5.0; // 5 / 256
|
const GLfloat lightThreshold = 5.0; // 5 / 256
|
||||||
const GLfloat maxBrightness = std::fmaxf(std::fmaxf(lightColors[i].r, lightColors[i].g), lightColors[i].b);
|
const GLfloat maxBrightness = std::fmaxf(std::fmaxf(lightColors[i].r, lightColors[i].g), lightColors[i].b);
|
||||||
GLfloat radius = (-linear + std::sqrt(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);
|
glUniform1f(glGetUniformLocation(shaderLightingPass.Program, ("lights[" + std::to_string(i) + "].Radius").c_str()), radius);
|
||||||
}
|
}
|
||||||
glUniform3fv(glGetUniformLocation(shaderLightingPass.Program, "viewPos"), 1, &camera.Position[0]);
|
glUniform3fv(glGetUniformLocation(shaderLightingPass.Program, "viewPos"), 1, &camera.Position[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user