feat: initialize OpenGL

This commit is contained in:
2026-03-05 17:01:01 +08:00
parent 83c271ec8f
commit 9fe1eaec24
21 changed files with 5866 additions and 0 deletions

29
include/Cubed/camera.hpp Normal file
View File

@@ -0,0 +1,29 @@
#pragma once
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
struct MoveState {
bool forward = false;
bool back = false;
bool left = false;
bool right = false;
bool down = false;
bool up = false;
};
void updateMoveCamera();
void cameraInit();
void changeView(float offsetX, float offsetY);
void updateCursorPositionCamera(double xpos, double ypos);
glm::mat4 getCameraLookAt();
void updateCameraKey(int key, int action);

View File

@@ -0,0 +1,49 @@
#pragma once
#include <iostream>
#include <chrono>
#include <format>
#include <string>
namespace LOG {
template<typename... Args>
void info(const char * fmt, Args&&... args) {
auto now_time = std::chrono::
time_point_cast<std::chrono::seconds>
(std::chrono::system_clock::now());
std::string msg = std::vformat(fmt, std::make_format_args(args...));
std::cout << "\033[1;32m"
<< std::format("[INFO][{:%Y-%m-%d %H:%M:%S}]", now_time)
<< msg
<< "\033[0m"
<< std::endl;
}
template<typename... Args>
void error(const char * fmt, Args&&... args) {
auto now_time = std::chrono::
time_point_cast<std::chrono::seconds>
(std::chrono::system_clock::now());
std::string msg = std::vformat(fmt, std::make_format_args(args...));
std::cout << "\033[1;31m"
<< std::format("[ERROR][{:%Y-%m-%d %H:%M:%S}]", now_time)
<< msg
<< "\033[0m"
<< std::endl;
}
template<typename... Args>
void warn(const char * fmt, Args&&... args) {
auto now_time = std::chrono::
time_point_cast<std::chrono::seconds>
(std::chrono::system_clock::now());
std::string msg = std::vformat(fmt, std::make_format_args(args...));
std::cout << "\033[1;33m"
<< std::format("[WARN][{:%Y-%m-%d %H:%M:%S}]", now_time)
<< msg
<< "\033[0m"
<< std::endl;
}
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <glad/glad.h>
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <SOIL2.h>
void printShaderLog(GLuint shader);
void printProgramInfo(int prog);
bool checkOpenGLError();
std::string readShaderSource(const char* filePath);
GLuint loadTexture(const char* texImagePath);