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;
|
||||
std::string ip{"127.0.0.1"};
|
||||
std::string player{"Unknown"};
|
||||
bool debug_on = true;
|
||||
};
|
||||
|
||||
App();
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
const TextureManager& texture_manager, DevPanel& dev_panel);
|
||||
~Renderer();
|
||||
void hot_reload();
|
||||
void init();
|
||||
void init(bool debug_on);
|
||||
const Shader& get_shader(const std::string& name) const;
|
||||
void render();
|
||||
void update(float delta_time);
|
||||
|
||||
@@ -63,7 +63,7 @@ void App::init(int argc, char** argv) {
|
||||
|
||||
ChunkGenerator::init();
|
||||
BlockManager::init();
|
||||
m_renderer.init();
|
||||
m_renderer.init(m_argument.debug_on);
|
||||
Logger::info("Renderer Init Success");
|
||||
m_window.update_viewport();
|
||||
// MapTable::init_map();
|
||||
@@ -127,6 +127,12 @@ void App::handle_argument(int argc, char** argv) {
|
||||
[&](ArgParser) {
|
||||
std::cout << CUBED_VERSION << "\n";
|
||||
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"));
|
||||
}
|
||||
|
||||
void Renderer::init() {
|
||||
void Renderer::init(bool debug_on) {
|
||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
||||
Logger::error("Failed to initialize glad");
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -118,14 +118,18 @@ void Renderer::init() {
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(
|
||||
[](GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar* message,
|
||||
const void*) {
|
||||
Logger::log(Logger::Level::L_DEBUG, std::source_location::current(),
|
||||
"GL Debug: {}", reinterpret_cast<const char*>(message));
|
||||
},
|
||||
nullptr);
|
||||
if (debug_on) {
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(
|
||||
[](GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar* message,
|
||||
const void*) {
|
||||
Logger::log(Logger::Level::L_DEBUG,
|
||||
std::source_location::current(), "GL Debug: {}",
|
||||
reinterpret_cast<const char*>(message));
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
m_vao.resize(NUM_VAO);
|
||||
|
||||
Reference in New Issue
Block a user