feat: basic improvements, unused includes
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
#ifndef APPLICATION_H_
|
||||
#define APPLICATION_H_
|
||||
|
||||
#include "window/event.h"
|
||||
|
||||
class IApplication {
|
||||
public:
|
||||
virtual ~IApplication() = default;
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef RENDERER_DEBUG_
|
||||
#define RENDERER_DEBUG_
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
void MessageCallback(GLenum source,
|
||||
|
@ -12,8 +12,6 @@
|
||||
class Engine {
|
||||
public:
|
||||
static void Run(std::unique_ptr<IApplication> app);
|
||||
private:
|
||||
void HandleWindowResized(const WindowResized& event);
|
||||
private:
|
||||
static std::unique_ptr<IApplication> s_app;
|
||||
static std::shared_ptr<Window> s_window;
|
||||
|
@ -13,9 +13,9 @@ public: // TODO: abstract away
|
||||
std::vector<Vertex> m_vertexBuffer;
|
||||
std::vector<unsigned int> m_indexBuffer;
|
||||
public: // TODO: abstract away
|
||||
void Bind() { glBindVertexArray(m_vao); }
|
||||
void Bind() const { glBindVertexArray(m_vao); }
|
||||
void Unbind() { glBindVertexArray(0); }
|
||||
void Upload();
|
||||
void Upload() const;
|
||||
public:
|
||||
std::string materialName;
|
||||
public:
|
||||
|
@ -1,10 +1,8 @@
|
||||
#ifndef SHADER_H
|
||||
#define SHADER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class Shader
|
||||
|
@ -4,14 +4,13 @@
|
||||
#include <memory>
|
||||
|
||||
class Texture {
|
||||
private:
|
||||
unsigned int m_id;
|
||||
private:
|
||||
public:
|
||||
Texture() {}
|
||||
Texture() : m_id(0) {}
|
||||
static std::unique_ptr<Texture> LoadFile(const std::string& filename);
|
||||
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_
|
||||
|
@ -8,24 +8,13 @@
|
||||
#include <memory>
|
||||
|
||||
#include "shader.h"
|
||||
#include "texture.h"
|
||||
#include "renderer/material.h"
|
||||
#include "renderer/basics.h"
|
||||
#include "renderer/mesh.h"
|
||||
|
||||
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 };
|
||||
|
||||
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:
|
||||
static inline int NormalizeIndex(int idx, int baseCount);
|
||||
|
||||
@ -46,6 +35,15 @@ private:
|
||||
void CreateNewMesh(const std::string& materialName);
|
||||
public:
|
||||
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_
|
@ -6,7 +6,6 @@
|
||||
#include <typeindex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <typeindex>
|
||||
|
||||
class EventDispatcher {
|
||||
using Type = std::type_index;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#ifdef WIN32
|
||||
#include <corecrt_math_defines.h>
|
||||
#endif
|
||||
#include <GL/glew.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext/matrix_clip_space.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "renderer/debug.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void MessageCallback(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
@ -19,4 +21,4 @@ void MessageCallback(GLenum source,
|
||||
// std::cerr << "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
|
||||
// (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""),
|
||||
// type, severity, message);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include "renderer/engine.h"
|
||||
#include "window/event.h"
|
||||
|
||||
#include "IO/file_manager.h"
|
||||
#include "renderer/shader.h"
|
||||
#include "renderer/wavefront.h"
|
||||
|
||||
std::unique_ptr<IApplication> Engine::s_app = nullptr;
|
||||
|
@ -1,6 +1,10 @@
|
||||
#include "renderer/mesh.h"
|
||||
|
||||
Mesh::Mesh() {
|
||||
m_vao = 0;
|
||||
m_vbo = 0;
|
||||
m_ebo = 0;
|
||||
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
glGenBuffers(1, &m_vbo);
|
||||
glGenBuffers(1, &m_ebo);
|
||||
@ -21,8 +25,7 @@ Mesh::Mesh() {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void Mesh::Upload()
|
||||
{
|
||||
void Mesh::Upload() const {
|
||||
glBindVertexArray(m_vao);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <GL/glew.h>
|
||||
#include "renderer/shader.h"
|
||||
|
||||
Shader::Shader()
|
||||
|
Reference in New Issue
Block a user