mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
feat(renderer): add --no-debug flag to disable OpenGL debug output
This commit is contained in:
@@ -18,6 +18,7 @@ public:
|
|||||||
int port = 25530;
|
int port = 25530;
|
||||||
std::string ip{"127.0.0.1"};
|
std::string ip{"127.0.0.1"};
|
||||||
std::string player{"Unknown"};
|
std::string player{"Unknown"};
|
||||||
|
bool debug_on = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
App();
|
App();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
const TextureManager& texture_manager, DevPanel& dev_panel);
|
const TextureManager& texture_manager, DevPanel& dev_panel);
|
||||||
~Renderer();
|
~Renderer();
|
||||||
void hot_reload();
|
void hot_reload();
|
||||||
void init();
|
void init(bool debug_on);
|
||||||
const Shader& get_shader(const std::string& name) const;
|
const Shader& get_shader(const std::string& name) const;
|
||||||
void render();
|
void render();
|
||||||
void update(float delta_time);
|
void update(float delta_time);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void App::init(int argc, char** argv) {
|
|||||||
|
|
||||||
ChunkGenerator::init();
|
ChunkGenerator::init();
|
||||||
BlockManager::init();
|
BlockManager::init();
|
||||||
m_renderer.init();
|
m_renderer.init(m_argument.debug_on);
|
||||||
Logger::info("Renderer Init Success");
|
Logger::info("Renderer Init Success");
|
||||||
m_window.update_viewport();
|
m_window.update_viewport();
|
||||||
// MapTable::init_map();
|
// MapTable::init_map();
|
||||||
@@ -127,6 +127,12 @@ void App::handle_argument(int argc, char** argv) {
|
|||||||
[&](ArgParser) {
|
[&](ArgParser) {
|
||||||
std::cout << CUBED_VERSION << "\n";
|
std::cout << CUBED_VERSION << "\n";
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
}},
|
||||||
|
|
||||||
|
{"--no-debug",
|
||||||
|
[&](ArgParser) {
|
||||||
|
m_argument.debug_on = false;
|
||||||
|
Logger::info("Switch off opengl debug out put");
|
||||||
}}
|
}}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void Renderer::hot_reload() {
|
|||||||
update_fov(config.get<double>("player.fov"));
|
update_fov(config.get<double>("player.fov"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::init() {
|
void Renderer::init(bool debug_on) {
|
||||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
||||||
Logger::error("Failed to initialize glad");
|
Logger::error("Failed to initialize glad");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@@ -118,14 +118,18 @@ void Renderer::init() {
|
|||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
#ifdef DEBUG_MODE
|
#ifdef DEBUG_MODE
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
if (debug_on) {
|
||||||
glDebugMessageCallback(
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
[](GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar* message,
|
glDebugMessageCallback(
|
||||||
const void*) {
|
[](GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar* message,
|
||||||
Logger::log(Logger::Level::L_DEBUG, std::source_location::current(),
|
const void*) {
|
||||||
"GL Debug: {}", reinterpret_cast<const char*>(message));
|
Logger::log(Logger::Level::L_DEBUG,
|
||||||
},
|
std::source_location::current(), "GL Debug: {}",
|
||||||
nullptr);
|
reinterpret_cast<const char*>(message));
|
||||||
|
},
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_vao.resize(NUM_VAO);
|
m_vao.resize(NUM_VAO);
|
||||||
|
|||||||
Reference in New Issue
Block a user