mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
feat: initialize OpenGL
This commit is contained in:
29
include/Cubed/camera.hpp
Normal file
29
include/Cubed/camera.hpp
Normal 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);
|
||||
49
include/Cubed/tools/log.hpp
Normal file
49
include/Cubed/tools/log.hpp
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
14
include/Cubed/tools/shader_tools.hpp
Normal file
14
include/Cubed/tools/shader_tools.hpp
Normal 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);
|
||||
Reference in New Issue
Block a user