feat: basic improvements, unused includes
This commit is contained in:
@ -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;
|
||||||
|
@ -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,
|
||||||
|
@ -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;
|
||||||
|
@ -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:
|
||||||
|
@ -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
|
||||||
|
@ -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_
|
||||||
|
@ -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_
|
@ -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;
|
||||||
|
@ -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>
|
||||||
|
@ -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,
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <GL/glew.h>
|
||||||
#include "renderer/shader.h"
|
#include "renderer/shader.h"
|
||||||
|
|
||||||
Shader::Shader()
|
Shader::Shader()
|
||||||
|
Reference in New Issue
Block a user