mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
feat: add DEBUG_MODE and ASSETS_PATH macro
This commit is contained in:
@@ -63,7 +63,7 @@ void Renderer::init() {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef DEBUG_MODE
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* user_param) {
|
||||
Logger::log(Logger::Level::DEBUG, std::source_location::current(),"GL Debug: {}", reinterpret_cast<const char*>(message));
|
||||
|
||||
@@ -32,7 +32,7 @@ GLuint TextureManager::get_ui_array() const{
|
||||
void TextureManager::load_block_status(unsigned id) {
|
||||
|
||||
CUBED_ASSERT_MSG(id < MAX_BLOCK_STATUS, "Exceed the max status sum limit");
|
||||
std::string path = "assets/texture/status/" + std::to_string(id) + ".png";
|
||||
std::string path = "texture/status/" + std::to_string(id) + ".png";
|
||||
unsigned char* image_data = nullptr;
|
||||
image_data = (Tools::load_image_data(path));
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_block_status_array);
|
||||
@@ -54,7 +54,7 @@ void TextureManager::load_block_texture(unsigned id) {
|
||||
}
|
||||
unsigned char* image_data[6];
|
||||
|
||||
std::string block_texture_path = "assets/texture/block/" + name;
|
||||
std::string block_texture_path = "texture/block/" + name;
|
||||
image_data[0] = (Tools::load_image_data(block_texture_path + "/front.png"));
|
||||
image_data[1] = (Tools::load_image_data(block_texture_path + "/right.png"));
|
||||
image_data[2] = (Tools::load_image_data(block_texture_path + "/back.png"));
|
||||
@@ -80,7 +80,7 @@ void TextureManager::load_block_texture(unsigned id) {
|
||||
void TextureManager::load_ui_texture(unsigned id) {
|
||||
CUBED_ASSERT_MSG(id < MAX_UI_NUM, "Exceed the max ui sum limit");
|
||||
|
||||
std::string path = "assets/texture/ui/" + std::to_string(id) + ".png";
|
||||
std::string path = "texture/ui/" + std::to_string(id) + ".png";
|
||||
unsigned char* image_data = nullptr;
|
||||
image_data = (Tools::load_image_data(path));
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_ui_array);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#include <Cubed/config.hpp>
|
||||
#include <Cubed/tools/cubed_assert.hpp>
|
||||
#include <Cubed/tools/shader_tools.hpp>
|
||||
#include <Cubed/tools/log.hpp>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Tools {
|
||||
|
||||
@@ -119,11 +121,12 @@ namespace Tools {
|
||||
}
|
||||
|
||||
unsigned char* load_image_data(const std::string& tex_image_path) {
|
||||
fs::path path = ASSETS_PATH + tex_image_path;
|
||||
CUBED_ASSERT_MSG(fs::is_regular_file(path), path.c_str());
|
||||
unsigned char* data = nullptr;
|
||||
int width, height, channels;
|
||||
data = SOIL_load_image(tex_image_path.c_str(), &width, &height, &channels, SOIL_LOAD_AUTO);
|
||||
std::string error_info = "Could not load texture " + tex_image_path;
|
||||
CUBED_ASSERT_MSG(data, error_info.c_str());
|
||||
data = SOIL_load_image(path.c_str(), &width, &height, &channels, SOIL_LOAD_AUTO);
|
||||
CUBED_ASSERT_MSG(data, "Could not load texture" + path.string());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user