feat: basic improvements, unused includes

This commit is contained in:
2025-10-05 16:39:20 +02:00
parent 431d723afc
commit 6cef3efbbc
13 changed files with 25 additions and 33 deletions

View File

@ -1,8 +1,6 @@
#ifndef APPLICATION_H_ #ifndef APPLICATION_H_
#define APPLICATION_H_ #define APPLICATION_H_
#include "window/event.h"
class IApplication { class IApplication {
public: public:
virtual ~IApplication() = default; virtual ~IApplication() = default;

View File

@ -1,8 +1,6 @@
#ifndef RENDERER_DEBUG_ #ifndef RENDERER_DEBUG_
#define RENDERER_DEBUG_ #define RENDERER_DEBUG_
#include <iostream>
#include <GL/glew.h> #include <GL/glew.h>
void MessageCallback(GLenum source, void MessageCallback(GLenum source,

View File

@ -12,8 +12,6 @@
class Engine { class Engine {
public: public:
static void Run(std::unique_ptr<IApplication> app); static void Run(std::unique_ptr<IApplication> app);
private:
void HandleWindowResized(const WindowResized& event);
private: private:
static std::unique_ptr<IApplication> s_app; static std::unique_ptr<IApplication> s_app;
static std::shared_ptr<Window> s_window; static std::shared_ptr<Window> s_window;

View File

@ -13,9 +13,9 @@ public: // TODO: abstract away
std::vector<Vertex> m_vertexBuffer; std::vector<Vertex> m_vertexBuffer;
std::vector<unsigned int> m_indexBuffer; std::vector<unsigned int> m_indexBuffer;
public: // TODO: abstract away public: // TODO: abstract away
void Bind() { glBindVertexArray(m_vao); } void Bind() const { glBindVertexArray(m_vao); }
void Unbind() { glBindVertexArray(0); } void Unbind() { glBindVertexArray(0); }
void Upload(); void Upload() const;
public: public:
std::string materialName; std::string materialName;
public: public:

View File

@ -1,10 +1,8 @@
#ifndef SHADER_H #ifndef SHADER_H
#define SHADER_H #define SHADER_H
#include <iostream>
#include <string> #include <string>
#include <GL/glew.h>
#include <glm/glm.hpp> #include <glm/glm.hpp>
class Shader class Shader

View File

@ -4,14 +4,13 @@
#include <memory> #include <memory>
class Texture { class Texture {
private:
unsigned int m_id;
private:
public: public:
Texture() {} Texture() : m_id(0) {}
static std::unique_ptr<Texture> LoadFile(const std::string& filename); static std::unique_ptr<Texture> LoadFile(const std::string& filename);
public: public:
inline const unsigned int GetID() const { return m_id; } [[nodiscard]] unsigned int GetID() const { return m_id; }
private:
unsigned int m_id;
}; };
#endif // TEXTURE_H_ #endif // TEXTURE_H_

View File

@ -8,24 +8,13 @@
#include <memory> #include <memory>
#include "shader.h" #include "shader.h"
#include "texture.h"
#include "renderer/material.h" #include "renderer/material.h"
#include "renderer/basics.h"
#include "renderer/mesh.h" #include "renderer/mesh.h"
enum ObjElement { OHASH, MTLLIB, USEMTL, O, V, VN, VT, F, OUNKNOWN }; enum ObjElement { OHASH, MTLLIB, USEMTL, O, V, VN, VT, F, OUNKNOWN };
enum MtlElement { MHASH, NEWMTL, NS, KA, KS, KD, NI, D, ILLUM, MAP_KD, MAP_KA, MUNKNOWN }; enum MtlElement { MHASH, NEWMTL, NS, KA, KS, KD, NI, D, ILLUM, MAP_KD, MAP_KA, MUNKNOWN };
class Object { class Object {
private:
std::string m_name;
std::vector<glm::vec3> m_vertices;
std::vector<glm::vec3> m_normals;
std::vector<glm::vec2> m_texCoords;
std::vector<Mesh> m_meshes;
std::unordered_map<std::string, std::shared_ptr<Material>> m_materials;
private: private:
static inline int NormalizeIndex(int idx, int baseCount); static inline int NormalizeIndex(int idx, int baseCount);
@ -46,6 +35,15 @@ private:
void CreateNewMesh(const std::string& materialName); void CreateNewMesh(const std::string& materialName);
public: public:
void Render(Shader& shader); void Render(Shader& shader);
private:
std::string m_name;
std::vector<glm::vec3> m_vertices;
std::vector<glm::vec3> m_normals;
std::vector<glm::vec2> m_texCoords;
std::vector<Mesh> m_meshes;
std::unordered_map<std::string, std::shared_ptr<Material>> m_materials;
}; };
#endif // MODEL_H_ #endif // MODEL_H_

View File

@ -6,7 +6,6 @@
#include <typeindex> #include <typeindex>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <typeindex>
class EventDispatcher { class EventDispatcher {
using Type = std::type_index; using Type = std::type_index;

View File

@ -8,7 +8,6 @@
#ifdef WIN32 #ifdef WIN32
#include <corecrt_math_defines.h> #include <corecrt_math_defines.h>
#endif #endif
#include <GL/glew.h>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/ext/matrix_clip_space.hpp> #include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp> #include <glm/ext/matrix_transform.hpp>

View File

@ -1,5 +1,7 @@
#include "renderer/debug.h" #include "renderer/debug.h"
#include <iostream>
void MessageCallback(GLenum source, void MessageCallback(GLenum source,
GLenum type, GLenum type,
GLuint id, GLuint id,
@ -19,4 +21,4 @@ void MessageCallback(GLenum source,
// std::cerr << "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n", // std::cerr << "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
// (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), // (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
// type, severity, message); // type, severity, message);
} }

View File

@ -3,8 +3,6 @@
#include "renderer/engine.h" #include "renderer/engine.h"
#include "window/event.h" #include "window/event.h"
#include "IO/file_manager.h"
#include "renderer/shader.h"
#include "renderer/wavefront.h" #include "renderer/wavefront.h"
std::unique_ptr<IApplication> Engine::s_app = nullptr; std::unique_ptr<IApplication> Engine::s_app = nullptr;

View File

@ -1,6 +1,10 @@
#include "renderer/mesh.h" #include "renderer/mesh.h"
Mesh::Mesh() { Mesh::Mesh() {
m_vao = 0;
m_vbo = 0;
m_ebo = 0;
glGenVertexArrays(1, &m_vao); glGenVertexArrays(1, &m_vao);
glGenBuffers(1, &m_vbo); glGenBuffers(1, &m_vbo);
glGenBuffers(1, &m_ebo); glGenBuffers(1, &m_ebo);
@ -21,8 +25,7 @@ Mesh::Mesh() {
glBindVertexArray(0); glBindVertexArray(0);
} }
void Mesh::Upload() void Mesh::Upload() const {
{
glBindVertexArray(m_vao); glBindVertexArray(m_vao);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo); glBindBuffer(GL_ARRAY_BUFFER, m_vbo);

View File

@ -1,3 +1,5 @@
#include <iostream>
#include <GL/glew.h>
#include "renderer/shader.h" #include "renderer/shader.h"
Shader::Shader() Shader::Shader()