mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
refactor: warp everything in Cubed namespace
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <Cubed/tools/log.hpp>
|
||||
#include <Cubed/tools/shader_tools.hpp>
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
|
||||
Font::Font() {
|
||||
|
||||
@@ -121,4 +123,6 @@ std::vector<Vertex2D> Font::vertices(const std::string &text, float x, float y,
|
||||
|
||||
GLuint Font::text_texture() {
|
||||
return m_text_texture;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
#include <Cubed/tools/log.hpp>
|
||||
|
||||
namespace Logger {
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
|
||||
namespace Math {
|
||||
void extract_frustum_planes(const glm::mat4& mvp_matrix, std::vector<glm::vec4>& planes) {
|
||||
if (planes.size() != 6) {
|
||||
@@ -29,4 +32,7 @@ namespace Math {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <numeric>
|
||||
#include <random>
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
|
||||
void PerlinNoise::init() {
|
||||
p.resize(256);
|
||||
std::iota(p.begin(), p.end(), 0);
|
||||
@@ -19,7 +22,7 @@ void PerlinNoise::init() {
|
||||
}
|
||||
|
||||
float PerlinNoise::noise(float x, float y, float z) {
|
||||
CUBED_ASSERT_MSG(is_init, "The PerlinNoise don't init!");
|
||||
ASSERT_MSG(is_init, "The PerlinNoise don't init!");
|
||||
int ix = static_cast<int>(std::floor(x)) & 255;
|
||||
int iy = static_cast<int>(std::floor(y)) & 255;
|
||||
int iz = static_cast<int>(std::floor(z)) & 255;
|
||||
@@ -68,4 +71,6 @@ float PerlinNoise::grad(int hash, float x, float y, float z) {
|
||||
float v = h < 4 ? y : h == 12 || h == 14 ? x : z;
|
||||
|
||||
return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,9 @@
|
||||
#include <Cubed/tools/shader_tools.hpp>
|
||||
#include <Cubed/tools/log.hpp>
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Tools {
|
||||
@@ -29,7 +32,7 @@ namespace Tools {
|
||||
if (vc != 1) {
|
||||
Logger::error("vertex compilation failed");
|
||||
Tools::print_shader_log(v_shader);
|
||||
CUBED_ASSERT(0);
|
||||
ASSERT(0);
|
||||
}
|
||||
glCompileShader(f_shader);
|
||||
Tools::check_opengl_error();
|
||||
@@ -37,7 +40,7 @@ namespace Tools {
|
||||
if (fc != 1) {
|
||||
Logger::error("vertex compilation failed");
|
||||
Tools::print_shader_log(f_shader);
|
||||
CUBED_ASSERT(0);
|
||||
ASSERT(0);
|
||||
}
|
||||
GLuint vf_program = glCreateProgram();
|
||||
glAttachShader(vf_program, v_shader);
|
||||
@@ -50,7 +53,7 @@ namespace Tools {
|
||||
if (linked != 1) {
|
||||
Logger::error("linking failed");
|
||||
Tools::print_program_info(vf_program);
|
||||
CUBED_ASSERT(0);
|
||||
ASSERT(0);
|
||||
}
|
||||
glDeleteShader(v_shader);
|
||||
glDeleteShader(f_shader);
|
||||
@@ -123,13 +126,15 @@ 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());
|
||||
ASSERT_MSG(fs::is_regular_file(path), path.c_str());
|
||||
unsigned char* data = nullptr;
|
||||
int width, height, channels;
|
||||
data = SOIL_load_image(path.string().c_str(), &width, &height, &channels, SOIL_LOAD_AUTO);
|
||||
CUBED_ASSERT_MSG(data, "Could not load texture" + path.string());
|
||||
ASSERT_MSG(data, "Could not load texture" + path.string());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user