Graphics Engine is now part of the whole engine instead, Project will
actually compile #9
This commit is contained in:
26
BarinkEngine/Include/AssetManager/ModelImporter.h
Normal file
26
BarinkEngine/Include/AssetManager/ModelImporter.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#define TINYGLTF_IMPLEMENTATION
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#define TINYGLTF_NO_EXTERNAL_IMAGE
|
||||
|
||||
#include "Graphics/Mesh.h"
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <string>
|
||||
|
||||
class ModelImporter {
|
||||
private:
|
||||
void ImportFBX(std::string path);
|
||||
void ImportBlend(std::string path);
|
||||
void ImportGLTF(std::string path);
|
||||
void ImportOBJ(std::string path);
|
||||
static BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene);
|
||||
static std::vector<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene);
|
||||
|
||||
public:
|
||||
void Import(std::string path);
|
||||
|
||||
static std::vector<BarinkEngine::Mesh> Test();
|
||||
};
|
@ -2,21 +2,19 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
#include "Engine.h"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
/*
|
||||
#include "../MemoryManager.h"
|
||||
#include <glm/glm.hpp>
|
||||
#include "glm/glm.hpp"
|
||||
|
||||
|
||||
#include <MyGraphicsEngine/Shader.h>
|
||||
#include <MyGraphicsEngine/Window.h>
|
||||
#include <MyGraphicsEngine/Camera.h>
|
||||
#include <MyGraphicsEngine/Renderable.h>
|
||||
|
||||
#include "graphics/Shader.h"
|
||||
#include "graphics/Window.h"
|
||||
#include "graphics/Camera.h"
|
||||
#include "graphics/Renderable.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#include "MemoryManager.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -24,5 +22,4 @@ extern "C"
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
}
|
||||
|
||||
*/
|
||||
void WARN(std::string message);
|
12
BarinkEngine/Include/Editor/EditorWindow.h
Normal file
12
BarinkEngine/Include/Editor/EditorWindow.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class EditorWindow {
|
||||
protected:
|
||||
std::string WindowTitle;
|
||||
|
||||
public:
|
||||
|
||||
virtual void Show() = 0;
|
||||
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
namespace BarinkEngine {
|
||||
|
||||
static class Engine {
|
||||
class Engine {
|
||||
public:
|
||||
static void Startup();
|
||||
static void Shutdown();
|
||||
|
19
BarinkEngine/Include/Graphics/Buffer.h
Normal file
19
BarinkEngine/Include/Graphics/Buffer.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <glad/glad.h>
|
||||
class Buffer {
|
||||
private:
|
||||
unsigned int id;
|
||||
public:
|
||||
|
||||
int getBufferID();
|
||||
|
||||
void createBuffer();
|
||||
|
||||
void setBufferData(void* data, size_t dataSize, bool elementBuffer );
|
||||
|
||||
void Bind(bool elementBuffer);
|
||||
void Unbind(bool elementBuffer);
|
||||
|
||||
void Delete();
|
||||
|
||||
};
|
22
BarinkEngine/Include/Graphics/Camera.h
Normal file
22
BarinkEngine/Include/Graphics/Camera.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Rotation;
|
||||
float Zoom;
|
||||
|
||||
Camera(glm::vec3 position, glm::vec3 rotation, float zoom );
|
||||
~Camera();
|
||||
|
||||
glm::mat4 GetViewMatrix();
|
||||
|
||||
|
||||
private:
|
||||
glm::vec3 Front;
|
||||
glm::vec3 Right;
|
||||
glm::vec3 Up;
|
||||
|
||||
};
|
13
BarinkEngine/Include/Graphics/Mesh.h
Normal file
13
BarinkEngine/Include/Graphics/Mesh.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace BarinkEngine{
|
||||
|
||||
class Mesh {
|
||||
public:
|
||||
std::vector<glm::vec3> vertices;
|
||||
std::vector<unsigned int > elements;
|
||||
std::vector<glm::vec2> uv;
|
||||
};
|
||||
}
|
30
BarinkEngine/Include/Graphics/Renderable.h
Normal file
30
BarinkEngine/Include/Graphics/Renderable.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "Mesh.h"
|
||||
#include "Transform.h"
|
||||
#include "Buffer.h"
|
||||
#include "VertexArray.h"
|
||||
|
||||
/*
|
||||
#include <MyGraphicsEngine/AssetManager/ModelImporter.h>
|
||||
#include <MyGraphicsEngine/MyGraphicsEngine/Buffer.h>
|
||||
#include <MyGraphicsEngine/MyGraphicsEngine/VertexArray.h>
|
||||
|
||||
*/
|
||||
|
||||
class Renderable {
|
||||
private:
|
||||
std::vector<BarinkEngine::Mesh> meshes;
|
||||
Renderable();
|
||||
|
||||
public:
|
||||
Buffer vertexBuffer;
|
||||
Buffer elementBuffer;
|
||||
VertexArray VAO;
|
||||
Transform transform;
|
||||
~Renderable();
|
||||
|
||||
static Renderable Load();
|
||||
void Draw();
|
||||
|
||||
};
|
26
BarinkEngine/Include/Graphics/Shader.h
Normal file
26
BarinkEngine/Include/Graphics/Shader.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
|
||||
class Shader {
|
||||
private:
|
||||
int id;
|
||||
char* readFile (const char* filePath);
|
||||
public:
|
||||
Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath);
|
||||
void Use();
|
||||
void setUniformMat4(std::string uniformName, glm::mat4 matrix4);
|
||||
void setUniformVec4(std::string uniformName, glm::vec4 vector4);
|
||||
void setUniformVec3(std::string uniformName, glm::vec3 vector3);
|
||||
void setUniformVec2(std::string uniformName, glm::vec2 vector2);
|
||||
void setUniformFloat(std::string uniformName, float value);
|
||||
void setUniformInt(std::string uniformName, int value);
|
||||
|
||||
|
||||
};
|
8
BarinkEngine/Include/Graphics/Transform.h
Normal file
8
BarinkEngine/Include/Graphics/Transform.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
struct Transform {
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Rotation;
|
||||
glm::vec3 Scale;
|
||||
};
|
18
BarinkEngine/Include/Graphics/VertexArray.h
Normal file
18
BarinkEngine/Include/Graphics/VertexArray.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
class VertexArray{
|
||||
private:
|
||||
unsigned int id;
|
||||
|
||||
|
||||
public:
|
||||
void Create();
|
||||
void Bind();
|
||||
void Unbind();
|
||||
|
||||
void Delete();
|
||||
|
||||
void AttachAttribute(unsigned int index, int size, int stride);
|
||||
|
||||
|
||||
};
|
33
BarinkEngine/Include/Graphics/Window.h
Normal file
33
BarinkEngine/Include/Graphics/Window.h
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#define GLFW_STATIC
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BarinkWindow{
|
||||
private:
|
||||
GLFWwindow* window;
|
||||
bool FullScreen;
|
||||
bool VulkanSupported;
|
||||
int Width, Height;
|
||||
|
||||
static bool InitGLFW();
|
||||
|
||||
|
||||
public:
|
||||
BarinkWindow(const int width, const int height);
|
||||
~BarinkWindow();
|
||||
|
||||
GLFWwindow* windowptr();
|
||||
|
||||
bool WindowShouldClose();
|
||||
|
||||
void Poll();
|
||||
void SwapBuffers();
|
||||
|
||||
|
||||
};
|
17
BarinkEngine/Include/MemoryManager.h
Normal file
17
BarinkEngine/Include/MemoryManager.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int HeapAllocations = 0;
|
||||
static int HeapDeallocations = 0;
|
||||
|
||||
inline void* operator new(std::size_t sz) {
|
||||
HeapAllocations++;
|
||||
return std::malloc(sz);
|
||||
}
|
||||
|
||||
inline void operator delete(void* ptr) noexcept {
|
||||
HeapDeallocations++;
|
||||
std::free(ptr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user