OpenGL笔记十九之相机系统
—— 2024-10-02 晚上
bilibili赵新政老师的教程看后笔记
code review!
文章目录
- OpenGL笔记十九之相机系统
- 1.运行
- 1.1.游戏相机
- 1.2.轨迹球相机
- 2.游戏相机与轨迹球相机切换
- 3.博主笔记本要运行需要更改的文件
- 更改1:28_OpenGL_CameraSystem/application/Application.cpp
- 更改2:28_OpenGL_CameraSystem/application/CMakeLists.txt
- 更改3:28_OpenGL_CameraSystem/assets/shaders/fragment.glsl
- 更改4:28_OpenGL_CameraSystem/assets/shaders/vertex.glsl
- 更改5:28_OpenGL_CameraSystem/CMakeLists.txt
- 更改6:28_OpenGL_CameraSystem/main.cpp
1.运行
1.1.游戏相机
鼠标右键按住可控制旋转
1.2.轨迹球相机
2.游戏相机与轨迹球相机切换
注意代码文件中是拼写错误的GameCameraControl.h,应该是小写g
#include "application/camera/trackBallCameraControl.h"
#include "application/camera/gameCameraControl.h"// GameCameraControl* cameraControl = nullptr;
TrackBallCameraControl* cameraControl = nullptr;cameraControl = new TrackBallCameraControl();
// cameraControl = new GameCameraControl();
3.博主笔记本要运行需要更改的文件
Files 28_OpenGL_CameraSystem/application/Application.cpp and diff_temp/28_OpenGL_CameraSystem/application/Application.cpp differ
Files 28_OpenGL_CameraSystem/application/CMakeLists.txt and diff_temp/28_OpenGL_CameraSystem/application/CMakeLists.txt differ
Files 28_OpenGL_CameraSystem/assets/shaders/fragment.glsl and diff_temp/28_OpenGL_CameraSystem/assets/shaders/fragment.glsl differ
Files 28_OpenGL_CameraSystem/assets/shaders/vertex.glsl and diff_temp/28_OpenGL_CameraSystem/assets/shaders/vertex.glsl differ
Files 28_OpenGL_CameraSystem/CMakeLists.txt and diff_temp/28_OpenGL_CameraSystem/CMakeLists.txt differ
更改1:28_OpenGL_CameraSystem/application/Application.cpp
更改2:28_OpenGL_CameraSystem/application/CMakeLists.txt
#递归将本文件夹下所有cpp
file(GLOB_RECURSE APP ./ *.cpp)add_library(app ${APP} )target_include_directories(app PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(app PRIVATE glfw)
更改3:28_OpenGL_CameraSystem/assets/shaders/fragment.glsl
更改4:28_OpenGL_CameraSystem/assets/shaders/vertex.glsl
更改5:28_OpenGL_CameraSystem/CMakeLists.txt
# 指定 CMake 最低版本
cmake_minimum_required(VERSION 3.12)
add_definitions (-DDEBUG)# 项目名称
project(OpenGL_Lecture)# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 17)file(GLOB ASSETS "./assets" )file(COPY ${ASSETS} DESTINATION ${CMAKE_BINARY_DIR})# 包含头文件目录
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdParty/include/usr/include
)# 包含库文件目录
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdParty/lib/usr/lib/x86_64-linux-gnu
)# 设置 CMAKE_PREFIX_PATH 以找到 GLFW
set(CMAKE_PREFIX_PATH "/usr/local/lib/cmake/glfw3")
set(GLFW_DIR "/usr/local/lib/cmake/glfw3")# 查找 GLFW3 库
find_package(glfw3 REQUIRED CONFIG)add_subdirectory(wrapper)
add_subdirectory(application)
add_subdirectory(glframework)# 添加可执行文件
add_executable(openglStudy "main.cpp" "glad.c")# 链接库
target_link_libraries(openglStudy glfw wrapper app fw)