cmake_minimum_required (VERSION 3.0)
cmake_policy(VERSION 3.0)
project (LearnOpenGL)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
if(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
endif(WIN32)
link_directories(${CMAKE_SOURCE_DIR}/lib)
list(APPEND CMAKE_CXX_FLAGS "-std=c++11")
# find the required packages
find_package(GLM REQUIRED)
message(STATUS "GLM included at ${GLM_INCLUDE_DIR}")
find_package(GLFW3 REQUIRED)
message(STATUS "Found GLFW3 in ${GLFW3_INCLUDE_DIR}")
find_package(ASSIMP REQUIRED)
message(STATUS "Found ASSIMP in ${ASSIMP_INCLUDE_DIR}")
# find_package(SOIL REQUIRED)
# message(STATUS "Found SOIL in ${SOIL_INCLUDE_DIR}")
# find_package(GLEW REQUIRED)
# message(STATUS "Found GLEW in ${GLEW_INCLUDE_DIR}")
if(WIN32)
set(LIBS glfw3 opengl32 assimp freetype irrKlang)
elseif(UNIX AND NOT APPLE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
find_package(OpenGL REQUIRED)
add_definitions(${OPENGL_DEFINITIONS})
find_package(X11 REQUIRED)
# 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_LIBRARY} X11 Xrandr Xinerama Xi Xxf86vm Xcursor GL dl pthread freetype ${ASSIMP_LIBRARY})
set (CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
elseif(APPLE)
INCLUDE_DIRECTORIES(/System/Library/Frameworks)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
FIND_LIBRARY(OpenGL_LIBRARY OpenGL)
FIND_LIBRARY(IOKit_LIBRARY IOKit)
FIND_LIBRARY(CoreVideo_LIBRARY CoreVideo)
MARK_AS_ADVANCED(COCOA_LIBRARY OpenGL_LIBRARY)
SET(APPLE_LIBS ${COCOA_LIBRARY} ${IOKit_LIBRARY} ${OpenGL_LIBRARY} ${CoreVideo_LIBRARY})
SET(APPLE_LIBS ${APPLE_LIBS} ${GLFW3_LIBRARY} ${ASSIMP_LIBRARY})
set(LIBS ${LIBS} ${APPLE_LIBS})
else()
set(LIBS )
endif(WIN32)
set(CHAPTERS
1.getting_started
2.lighting
3.model_loading
4.advanced_opengl
5.advanced_lighting
6.pbr
7.in_practice
)
set(1.getting_started
1.1.hello_window
1.2.hello_window_clear
2.1.hello_triangle
2.2.hello_triangle_indexed
2.3.hello_triangle_exercise1
2.4.hello_triangle_exercise2
2.5.hello_triangle_exercise3
3.1.shaders_uniform
3.2.shaders_interpolation
3.3.shaders_class
4.1.textures
4.2.textures_combined
4.4.textures_exercise2
4.5.textures_exercise3
4.6.textures_exercise4
5.1.transformations
5.2.transformations_exercise2
6.1.coordinate_systems
6.2.coordinate_systems_depth
6.3.coordinate_systems_multiple
7.1.camera_circle
7.2.camera_keyboard_dt
7.3.camera_mouse_zoom
7.4.camera_class
)
set(2.lighting
1.colors
2.1.basic_lighting_diffuse
2.2.basic_lighting_specular
3.1.materials
3.2.materials_exercise1
4.1.lighting_maps_diffuse_map
4.2.lighting_maps_specular_map
4.4.lighting_maps_exercise4
5.1.light_casters_directional
5.2.light_casters_point
5.3.light_casters_spot
5.4.light_casters_spot_soft
6.multiple_lights
)
set(3.model_loading
1.model_loading
)
set(4.advanced_opengl
1.1.depth_testing
1.2.depth_testing_view
2.stencil_testing
3.1.blending_discard
3.2.blending_sort
5.1.framebuffers
5.2.framebuffers_exercise1
6.1.cubemaps_skybox
6.2.cubemaps_environment_mapping
8.advanced_glsl_ubo
9.1.geometry_shader_houses
9.2.geometry_shader_exploding
9.3.geometry_shader_normals
10.1.instancing_quads
10.2.asteroids
10.3.asteroids_instanced
11.1.anti_aliasing_msaa
11.2.anti_aliasing_offscreen
)
set(5.advanced_lighting
1.advanced_lighting
2.gamma_correction
3.1.1.shadow_mapping_depth
3.1.2.shadow_mapping_base
3.1.3.shadow_mapping
3.2.1.point_shadows
3.2.2.point_shadows_soft
4.normal_mapping
5.1.parallax_mapping
5.2.steep_parallax_mapping
5.3.parallax_occlusion_mapping
6.hdr
7.bloom
8.1.deferred_shading
8.2.deferred_shading_volumes
9.ssao
)
set(6.pbr
1.1.lighting
1.2.lighting_textured
2.1.1.ibl_irradiance_conversion
2.1.2.ibl_irradiance
2.2.1.ibl_specular
2.2.2.ibl_specular_textured
)
set(7.in_practice
1.debugging
2.text_rendering
#3.2d_game
)
configure_file(configuration/root_directory.h.in configuration/root_directory.h)
include_directories(${CMAKE_BINARY_DIR}/configuration)
# first create relevant static libraries requried for other projects
add_library(STB_IMAGE "src/stb_image.cpp")
set(LIBS ${LIBS} STB_IMAGE)
add_library(GLAD "src/glad.c")
set(LIBS ${LIBS} GLAD)
macro(makeLink src dest target)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${src} ${dest} DEPENDS ${dest} COMMENT "mklink ${src} -> ${dest}")
endmacro()
# then create a project file per tutorial
foreach(CHAPTER ${CHAPTERS})
foreach(DEMO ${${CHAPTER}})
file(GLOB SOURCE
"src/${CHAPTER}/${DEMO}/*.h"
"src/${CHAPTER}/${DEMO}/*.cpp"
"src/${CHAPTER}/${DEMO}/*.vs"
"src/${CHAPTER}/${DEMO}/*.fs"
"src/${CHAPTER}/${DEMO}/*.gs"
)
set(NAME "${CHAPTER}__${DEMO}")
add_executable(${NAME} ${SOURCE})
target_link_libraries(${NAME} ${LIBS})
if(WIN32)
set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}")
set_target_properties(${NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}/Debug")
elseif(UNIX AND NOT APPLE)
set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}")
elseif(APPLE)
set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}")
set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}")
set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin/${CHAPTER}")
endif(WIN32)
# copy shader files to build directory
file(GLOB SHADERS
"src/${CHAPTER}/${DEMO}/*.vs"
# "src/${CHAPTER}/${DEMO}/*.frag"
"src/${CHAPTER}/${DEMO}/*.fs"
"src/${CHAPTER}/${DEMO}/*.gs"
)
foreach(SHADER ${SHADERS})
if(WIN32)
# configure_file(${SHADER} "test")
add_custom_command(TARGET ${NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SHADER} $<TARGET_FILE_DIR:${NAME}>)
elseif(UNIX AND NOT APPLE)
file(COPY ${SHADER} DESTINATION ${CMAKE_SOURCE_DIR}/bin/${CHAPTER})
elseif(APPLE)
# create symbolic link for *.vs *.fs *.gs
get_filename_component(SHADERNAME ${SHADER} NAME)
makeLink(${SHADER} ${CMAKE_SOURCE_DIR}/bin/${CHAPTER}/${SHADERNAME} ${NAME})
endif(WIN32)
endforeach(SHADER)
# if compiling for visual studio, also use configure file for each project (specifically to set up working directory)
if(MSVC)
configure_file(${CMAKE_SOURCE_DIR}/configuration/visualstudio.vcxproj.user.in ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj.user @ONLY)
endif(MSVC)
endforeach(DEMO)
endforeach(CHAPTER)
include_directories(${CMAKE_SOURCE_DIR}/includes)
没有合适的资源?快使用搜索试试~ 我知道了~
LearnOpenGL-master 源代码
共1148个文件
hpp:240个
h:194个
fs:144个
需积分: 7 0 下载量 129 浏览量
2022-09-12
11:46:06
上传
评论
收藏 179.2MB ZIP 举报
温馨提示
LearnOpenGL-master 源代码
资源详情
资源评论
资源推荐
收起资源包目录
LearnOpenGL-master 源代码 (1148个子文件)
cyborg.blend 1.12MB
cyborg.blend1 1.12MB
glad.c 142KB
stb_image_aug.c 111KB
glad.c 98KB
SOIL.c 55KB
image_DXT.c 16KB
image_helper.c 10KB
FindGLM.cmake 2KB
FindGLFW3.cmake 1KB
FindASSIMP.cmake 865B
ibl_specular_textured.cpp 36KB
ibl_specular.cpp 29KB
shadow_mapping.cpp 25KB
ibl_irradiance.cpp 23KB
multiple_lights_exercise1.cpp 22KB
bloom.cpp 22KB
game.cpp 22KB
ibl_irradiance_conversion.cpp 21KB
ssao.cpp 21KB
deferred_shading_volumes.cpp 19KB
shadow_mapping.cpp 19KB
9.game.cpp 19KB
deferred_shading.cpp 19KB
8.game.cpp 18KB
shadow_mapping_base.cpp 18KB
multiple_lights.cpp 17KB
point_shadows.cpp 17KB
point_shadows_soft.cpp 17KB
shadow_mapping_depth.cpp 17KB
hdr.cpp 17KB
framebuffers_exercise1.cpp 16KB
framebuffers.cpp 15KB
light_casters_spot_soft.cpp 14KB
light_casters_spot.cpp 14KB
cubemaps_environment_mapping.cpp 14KB
light_casters_point.cpp 14KB
light_casters_directional.cpp 14KB
cubemaps_skybox.cpp 14KB
blending_sorted.cpp 14KB
parallax_mapping.cpp 14KB
parallax_occlusion_mapping.cpp 14KB
steep_parallax_mapping.cpp 14KB
stencil_testing.cpp 13KB
lighting_textured.cpp 13KB
blending_discard.cpp 13KB
lighting_maps_exercise4.cpp 13KB
weighted_blended.cpp 13KB
lighting.cpp 13KB
lighting_maps_specular.cpp 13KB
camera_mouse_zoom.cpp 13KB
debugging.cpp 13KB
lighting_maps_diffuse.cpp 13KB
normal_mapping.cpp 12KB
camera_class.cpp 12KB
7.game.cpp 12KB
anti_aliasing_offscreen.cpp 11KB
depth_testing.cpp 11KB
depth_testing_view.cpp 11KB
camera_keyboard_dt.cpp 11KB
materials.cpp 11KB
6.game.cpp 11KB
materials_exercise1.cpp 10KB
gamma_correction.cpp 10KB
camera_circle.cpp 10KB
coordinate_systems_multiple.cpp 10KB
csm.cpp 10KB
5.game.cpp 10KB
basic_lighting_specular.cpp 10KB
basic_lighting_diffuse.cpp 10KB
advanced_glsl_ubo.cpp 10KB
asteroids_instanced.cpp 10KB
coordinate_systems_depth.cpp 10KB
advanced_lighting.cpp 9KB
colors.cpp 9KB
text_rendering.cpp 9KB
textures_exercise4.cpp 9KB
transformations_exercise2.cpp 9KB
coordinate_systems.cpp 9KB
glm.cpp 8KB
textures_exercise3.cpp 8KB
textures_exercise2.cpp 8KB
textures_combined.cpp 8KB
transformations.cpp 8KB
hello_triangle_exercise3.cpp 8KB
asteroids.cpp 7KB
hello_triangle_indexed.cpp 7KB
hello_triangle_exercise2.cpp 7KB
anti_aliasing_msaa.cpp 7KB
hello_triangle_exercise1.cpp 7KB
frustum_culling.cpp 7KB
shaders_uniform.cpp 7KB
hello_triangle.cpp 7KB
shaders_interpolation.cpp 7KB
scene_graph.cpp 7KB
textures.cpp 6KB
model_loading.cpp 6KB
skeletal_animation.cpp 6KB
normal_visualization.cpp 6KB
geometry_shader_exploding.cpp 6KB
共 1148 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
qiuwenwei105240
- 粉丝: 4
- 资源: 44
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0