update
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(3dviewer)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
include_directories(.)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
include_directories(.)
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
@@ -15,17 +18,29 @@ add_executable(
|
||||
camera.h
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
glfw3
|
||||
OpenGL::GL
|
||||
X11
|
||||
Xrandr
|
||||
Xi
|
||||
Xcursor
|
||||
Xinerama
|
||||
pthread
|
||||
dl
|
||||
m
|
||||
)
|
||||
if(WIN32)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
glfw3
|
||||
)
|
||||
elseif(APPLE)
|
||||
|
||||
elseif(UNIX)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
glfw3
|
||||
OpenGL::GL
|
||||
X11
|
||||
Xrandr
|
||||
Xi
|
||||
Xcursor
|
||||
Xinerama
|
||||
pthread
|
||||
dl
|
||||
m
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
41
main.cpp
41
main.cpp
@@ -8,8 +8,10 @@
|
||||
#include <glm/trigonometric.hpp>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <print>
|
||||
|
||||
|
||||
class GLWidget {
|
||||
@@ -47,6 +49,12 @@ public:
|
||||
if (bgVbo_) {
|
||||
glDeleteBuffers(1, &bgVbo_);
|
||||
}
|
||||
if (heatmapVao_) {
|
||||
glDeleteVertexArrays(1, &heatmapVao_);
|
||||
}
|
||||
if (heatmapVbo_) {
|
||||
glDeleteBuffers(1, &heatmapVbo_);
|
||||
}
|
||||
deinit_ = true;
|
||||
}
|
||||
|
||||
@@ -58,7 +66,7 @@ public:
|
||||
|
||||
bool initGeometry() {
|
||||
if (!glfwInit()) {
|
||||
std::cout << "Failed to initialize GLFW" << std::endl;
|
||||
std::cout << "Failed to initialize GLFW\n";
|
||||
return false;
|
||||
}
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
@@ -69,13 +77,13 @@ public:
|
||||
#endif
|
||||
window_.reset(glfwCreateWindow(viewport_.width, viewport_.height, "3dviewer", nullptr, nullptr));
|
||||
if (!window_) {
|
||||
std::cout << "Failed to create GLFW window" << std::endl;
|
||||
std::cout << "Failed to create GLFW window\n";
|
||||
glfwTerminate();
|
||||
return false;
|
||||
}
|
||||
glfwMakeContextCurrent(window_.get());
|
||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
||||
std::cout << "Failed to initialize GLAD" << std::endl;
|
||||
std::cout << "Failed to initialize GLAD\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -282,7 +290,32 @@ private:
|
||||
bool initHeatmapProgram() {
|
||||
auto vshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Vertex);
|
||||
auto fshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Fragment);
|
||||
if (!vshader->compileShaderFromFile(heatmapVertShaderPath_)) {
|
||||
std::cout << "Vertex shader compile failed: " << heatmapVertShaderPath_ << "\n" << vshader->Log() << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (!fshader->compileShaderFromFile(heatmapFragShaderPath_)) {
|
||||
std::cout << "Fragment shader compile failed: " << heatmapFragShaderPath_ << "\n" << fshader->Log() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
heatmapProg_ = std::make_unique<LOpenGLProgram>();
|
||||
if (!heatmapProg_->addShader(std::move(vshader))) {
|
||||
std::cout << "Failed to attach vertex shader\n";
|
||||
return false;
|
||||
}
|
||||
if (!heatmapProg_->addShader(std::move(fshader))) {
|
||||
std::cout << "Failed to attach vertex shader\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = panelProg_->Link();
|
||||
if (!ret) {
|
||||
std::cout << "Failed to link heatmap program\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void drawBg() {
|
||||
@@ -452,7 +485,7 @@ private:
|
||||
unsigned int heatmapVbo_ = 0;
|
||||
|
||||
ViewPort viewport_{800, 600};
|
||||
Camera camera_{glm::vec3(0.0f, 0.0f, 2.0f)};
|
||||
Camera camera_{glm::vec3(0.0F, 0.0F, 2.0F)};
|
||||
|
||||
bool firstMouse_ = true;
|
||||
float lastX_;
|
||||
|
||||
Reference in New Issue
Block a user