56 lines
1.3 KiB
Plaintext
56 lines
1.3 KiB
Plaintext
|
|
这个package文件夹主要是装一些OpenGL的第三方库
|
|||
|
|
主要包括:
|
|||
|
|
GLAD:用于链接OpenGL函数指针到GPU硬件驱动上
|
|||
|
|
GLFW:用于跨平台的窗口创建和事件处理
|
|||
|
|
GLM:OpenGL的第三方数学库
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
在配置项目的时候主要是用CMake来配置
|
|||
|
|
需要做以下几件事:
|
|||
|
|
1),需要定位头文件的查询地址:
|
|||
|
|
方便后期头文件导入,需要用到的头文件有:
|
|||
|
|
|
|||
|
|
package/include/glad/glad.h
|
|||
|
|
package/include/GLFW/glfw3.h
|
|||
|
|
package/glm/glm/glm.hpp
|
|||
|
|
|
|||
|
|
2),需要加载静态库glfw3.lib
|
|||
|
|
|
|||
|
|
3),需要将glad.c文件添加到项目的可执行文件里
|
|||
|
|
|
|||
|
|
4),需要将Shader资源文件复制到exe所在目录下
|
|||
|
|
|
|||
|
|
|
|||
|
|
示例:
|
|||
|
|
CMakeLists.txt
|
|||
|
|
#需求的最低cmake程序版本
|
|||
|
|
cmake_minimum_required(VERSION 3.12)
|
|||
|
|
|
|||
|
|
#项目名称
|
|||
|
|
project("XCRender")
|
|||
|
|
|
|||
|
|
#本工程支持的C++版本
|
|||
|
|
set(CMAKE_CXX_STANDARD 17)
|
|||
|
|
|
|||
|
|
#定位头文件查询位置
|
|||
|
|
include_directories(../package/include/)
|
|||
|
|
include_directories(../package/glm/)
|
|||
|
|
|
|||
|
|
#加载lib静态库
|
|||
|
|
link_directories(../package/lib/)
|
|||
|
|
|
|||
|
|
#把shaders资源文件拷贝到exe所在目录下
|
|||
|
|
file(GLOB copyResources "./Shaders")
|
|||
|
|
file(COPY ${copyResources} DESTINATION ${CMAKE_BINARY_DIR})
|
|||
|
|
|
|||
|
|
#将源代码添加到此项目的可执行文件
|
|||
|
|
add_executable(
|
|||
|
|
XCRender
|
|||
|
|
"main.cpp"
|
|||
|
|
"../package/src/glad.c"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
#从第11行的路径下加载静态库
|
|||
|
|
target_link_libraries(XCRender glfw3.lib)
|