diff --git a/.gitmodules b/.gitmodules index 6679e3d..f8db3ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,10 +8,6 @@ [submodule "spdlog"] path = libs/spdlog url = https://github.com/nigelbarink/spdlog.git -[submodule "tinygltf"] - path = libs/tinygltf - url = https://github.com/syoyo/tinygltf.git - ignore = untracked [submodule "GorrillaAudio"] path = libs/GorillaAudio url = https://github.com/mewspring/gorilla-audio.git diff --git a/BarinkEngine/src/AssetManager/ModelImporter.cpp b/BarinkEngine/src/AssetManager/ModelImporter.cpp deleted file mode 100644 index 5866ca6..0000000 --- a/BarinkEngine/src/AssetManager/ModelImporter.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "ModelImporter.h" -#include "spdlog/spdlog.h" - -BarinkEngine::SceneObject* BarinkEngine::ModelImporter::Import(const std::string path) -{ - SceneObject* root = new SceneObject(std::string(path), nullptr); - - Assimp::Importer importer; - const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs); - - aiNode* currentNode = scene->mRootNode; - - std::vector meshes = processNode(currentNode, scene); - - std::cout << "[DEBUG]: Loaded "<< meshes.size() << " meshes!" << std::endl; - - // create a renderable (per mesh ?? ) - root->renderable = new Renderable(); - root->renderable->mesh = new Mesh(meshes[0]); - - return root; - -} - -std::vector BarinkEngine::ModelImporter::processNode(aiNode* node, const aiScene* scene) -{ - - std::vector meshes; - - for (unsigned int i = 0; i < node->mNumMeshes; i++) { - aiMesh* mesh = scene->mMeshes[node->mMeshes[i]]; - meshes.push_back(processMesh(mesh, scene)); - } - - for (unsigned int i = 0; i < node->mNumChildren; i++) { - auto m2 = processNode(node->mChildren[i], scene); - - for(auto m : m2) { - meshes.push_back(m); - } - } - - return meshes; -} - -BarinkEngine::Mesh BarinkEngine::ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene) { - std::vector indices; - std::vector vertices; - - ProcessVertices(mesh, vertices); - - ProcessIndices(mesh, indices); - - BarinkEngine::Mesh result; - result.vertices = vertices; - result.elements = indices; - - - return result; - -} - -void ProcessVertices(aiMesh* mesh, std::vector& out_vertices) { - // Process vertices - for (unsigned int i = 0; i < mesh->mNumVertices; i++) { - BarinkEngine::Vertex v{}; - glm::vec3 vector; - vector.x = mesh->mVertices[i].x; - vector.y = mesh->mVertices[i].y; - vector.z = mesh->mVertices[i].z; - - v.vertices = vector; - - if (mesh->mTextureCoords[0]) { - - glm::vec2 texCoord; - - texCoord.x = mesh->mTextureCoords[0][i].x; - texCoord.y = mesh->mTextureCoords[0][i].y; - - v.uv = texCoord; - - } - - out_vertices.push_back(v); - } -} - -void ProcessIndices(aiMesh* mesh, std::vector& out_indices) { - // Process Indices - for (unsigned int i = 0; i < mesh->mNumFaces; i++) { - aiFace face = mesh->mFaces[i]; - if (face.mNumIndices < 3) - continue; - for (unsigned int j = 0; j < face.mNumIndices; j++) { - out_indices.push_back(face.mIndices[j]); - } - } -} \ No newline at end of file diff --git a/BarinkEngine/src/AssetManager/ModelImporter.h b/BarinkEngine/src/AssetManager/ModelImporter.h deleted file mode 100644 index afae7ae..0000000 --- a/BarinkEngine/src/AssetManager/ModelImporter.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#define STB_IMAGE_IMPLEMENTATION -#define STB_IMAGE_WRITE_IMPLEMENTATION - -#define TINYGLTF_IMPLEMENTATION -#define TINYGLTF_NO_EXTERNAL_IMAGE - -#include "../Graphics/Primitives/Mesh.h" -#include -#include -#include -#include -#include "../Scene/TransformTree/SceneNodeTypes.h" - - -void ProcessVertices(aiMesh* mesh, std::vector& out_vertices); -void ProcessIndices(aiMesh* mesh, std::vector& out_indices); - -namespace BarinkEngine { - class ModelImporter { - - public: - - BarinkEngine::SceneObject* Import(const std::string path); - - - private: - - static BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene); - static std::vector ModelImporter::processNode(aiNode* node, const aiScene* scene); - - - - }; -} diff --git a/BarinkEngine/src/EventSystem/Event.h b/BarinkEngine/src/EventSystem/Event.h deleted file mode 100644 index a11eaeb..0000000 --- a/BarinkEngine/src/EventSystem/Event.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include - -struct Event -{ - public: - std::string name; - int argc; - void** argv; - -}; \ No newline at end of file diff --git a/BarinkEngine/src/EventSystem/EventEmitter.cpp b/BarinkEngine/src/EventSystem/EventEmitter.cpp deleted file mode 100644 index e38b54f..0000000 --- a/BarinkEngine/src/EventSystem/EventEmitter.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "EventEmitter.h" - - -void EventEmitter::Subscribe(EventListener& subscriber) -{ - subscribers.push_back(&subscriber); -} - -void EventEmitter::Unsubscribe(EventListener& subscriber) -{ - subscribers.remove(&subscriber); -} - -void EventEmitter::EmitEvent(Event& incident) -{ - // Notify all subscribers an event has taken place - for (auto it = subscribers.begin(); it != subscribers.end(); ++it) - { - (*it)->ReceiveEvent(incident); - } -} - -EventEmitter::EventEmitter() { - subscribers = std::list{}; -} \ No newline at end of file diff --git a/BarinkEngine/src/EventSystem/EventEmitter.h b/BarinkEngine/src/EventSystem/EventEmitter.h deleted file mode 100644 index aa3144c..0000000 --- a/BarinkEngine/src/EventSystem/EventEmitter.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "Event.h" -#include "EventListener.h" - -class EventEmitter { -public: - void Subscribe (EventListener& subscriber); - void Unsubscribe(EventListener& subscriber); - -protected: - std::list subscribers; - void EmitEvent(Event& incident); - - EventEmitter(); - -}; \ No newline at end of file diff --git a/BarinkEngine/src/EventSystem/EventListener.h b/BarinkEngine/src/EventSystem/EventListener.h deleted file mode 100644 index eb23e72..0000000 --- a/BarinkEngine/src/EventSystem/EventListener.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include -#include - -#include "spdlog/spdlog.h" -#include "Event.h" - -class EventListener{ - public: - virtual void ReceiveEvent(Event& incident) = 0 ; - -}; \ No newline at end of file diff --git a/BarinkEngine/src/GUI/GUIManager.cpp b/BarinkEngine/src/GUI/GUIManager.cpp deleted file mode 100644 index ebb5fa0..0000000 --- a/BarinkEngine/src/GUI/GUIManager.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "GUIManager.h" -#include "imgui.h" -#include "backends/imgui_impl_opengl3.h" -#include -#include "../../libs/guizmo/ImGuizmo.h" -#include "../BarinkEngine.h" - -GUIManager::GUIManager(BarinkWindow* window) - : currentwindow(window) -{ - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable; - io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable; - - ImGui::StyleColorsDark(); - - ImGui_ImplGlfw_InitForOpenGL(currentwindow->windowptr(), true); - ImGui_ImplOpenGL3_Init("#version 440"); - - -} - -GUIManager::~GUIManager() -{ - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - ImGui::DestroyContext(); -} - -void GUIManager::Render() -{ - ImGui_ImplGlfw_NewFrame(); - ImGui_ImplOpenGL3_NewFrame(); - - ImGui::NewFrame(); - - ImGuizmo::SetOrthographic(true); - ImGuizmo::BeginFrame(); - - - - ImmediateGraphicsDraw(); - - - - ImGui::EndFrame(); - - - ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - - if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) - { - GLFWwindow* last_context = glfwGetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); - glfwMakeContextCurrent(last_context); - } -} diff --git a/BarinkEngine/src/GUI/GUIManager.h b/BarinkEngine/src/GUI/GUIManager.h deleted file mode 100644 index 7706753..0000000 --- a/BarinkEngine/src/GUI/GUIManager.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "../Platform/Window.h" - - -class GUIManager { -public: - GUIManager(BarinkWindow* window); - ~GUIManager(); - - void Render(); - - -private: - BarinkWindow* currentwindow; -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Memory/Buffer.cpp b/BarinkEngine/src/Graphics/Memory/Buffer.cpp deleted file mode 100644 index d1fb554..0000000 --- a/BarinkEngine/src/Graphics/Memory/Buffer.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "Buffer.h" - - -int Buffer::getBufferID() { - return id; -} - -void Buffer::createBuffer() { - glGenBuffers(1, (GLuint*) &id); -} - -void Buffer::setBufferData(void* data, size_t dataSize, bool elementBuffer = false ) { - - if (elementBuffer) { - glBufferData(GL_ELEMENT_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW); - - } - else { - glBufferData(GL_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW); - } - -} - -void Buffer::Bind(bool elementBuffer = false ) { - if (elementBuffer) { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id); - - } - else { - glBindBuffer(GL_ARRAY_BUFFER, id); - - } -} - -void Buffer::Unbind(bool elementBuffer = false) { - if (elementBuffer) { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - else { - glBindBuffer(GL_ARRAY_BUFFER, 0); - - } -} - -void Buffer::Delete() { - glDeleteBuffers(1, (GLuint*) &id); -} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Memory/Buffer.h b/BarinkEngine/src/Graphics/Memory/Buffer.h deleted file mode 100644 index f4e8816..0000000 --- a/BarinkEngine/src/Graphics/Memory/Buffer.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -class Buffer { - -public: - - int getBufferID(); - - void createBuffer(); - - void setBufferData(void* data, size_t dataSize, bool elementBuffer ); - - void Bind(bool elementBuffer); - void Unbind(bool elementBuffer); - - void Delete(); - -private: - unsigned int id; - -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Memory/FrameBuffer.cpp b/BarinkEngine/src/Graphics/Memory/FrameBuffer.cpp deleted file mode 100644 index d57281f..0000000 --- a/BarinkEngine/src/Graphics/Memory/FrameBuffer.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "Framebuffer.h" -#include - -Framebuffer::Framebuffer() -{ - glGenFramebuffers(1, &Id); - glBindFramebuffer(GL_FRAMEBUFFER, Id); - - // Create a colour texture! - glGenTextures(1, &ColourAttachment); - glBindTexture(GL_TEXTURE_2D, ColourAttachment); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 800, 600, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glBindTexture(GL_TEXTURE_2D, 0); - - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColourAttachment, 0); - - - - // Create a depth buffer - glGenTextures(1, &DepthAttachment); - glBindTexture(GL_TEXTURE_2D, DepthAttachment); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, 800, 600, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); - - glBindTexture(GL_TEXTURE_2D, 0); - - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, DepthAttachment, 0); - - - /* - * // Render buffer - glGenRenderbuffers(1, &DepthAttachment); - glBindRenderbuffer(GL_RENDERBUFFER, DepthAttachment); - - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 800, 600); - - - glBindRenderbuffer(GL_RENDERBUFFER, 0); - - glFramebufferRenderbuffer(GL_RENDERBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, DepthAttachment); - - */ - - - - - - if (!glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) - { - std::cout << "Framebuffer is incomplete!" << std::endl; - } - else { - std::cout << "Framebuffer is complete!" << std::endl; - } - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - -} - -Framebuffer::~Framebuffer() -{ - glDeleteTextures(1, &ColourAttachment); - glDeleteRenderbuffers(1, &DepthAttachment); - glDeleteFramebuffers(1, &Id); -} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Memory/Framebuffer.h b/BarinkEngine/src/Graphics/Memory/Framebuffer.h deleted file mode 100644 index 56ac4d9..0000000 --- a/BarinkEngine/src/Graphics/Memory/Framebuffer.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -#include - -class Framebuffer { - -public: - Framebuffer(); - ~Framebuffer(); - - GLuint GetId() { return Id; } - GLuint GetColourAttachment() { return ColourAttachment; } - GLuint GetDepthAttachment() { return DepthAttachment; } - -private: - GLuint Id = 0; - GLuint ColourAttachment = 0; - GLuint DepthAttachment = 0; - - -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Memory/UniformBuffer.cpp b/BarinkEngine/src/Graphics/Memory/UniformBuffer.cpp deleted file mode 100644 index e969ba3..0000000 --- a/BarinkEngine/src/Graphics/Memory/UniformBuffer.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "UniformBuffer.h" -#include -UniformBuffer::UniformBuffer(unsigned int size) -{ - glGenBuffers(1, &Id ); - glBindBuffer(GL_ARRAY_BUFFER, Id); - glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); -} - -UniformBuffer::~UniformBuffer() -{ - glDeleteBuffers(1, &Id); -} - - -void UniformBuffer::setData( unsigned int offset , unsigned int size , void* data) -{ - glBindBuffer(GL_ARRAY_BUFFER, Id); - glBufferSubData(GL_ARRAY_BUFFER, offset , size, data); - glBindBuffer(GL_ARRAY_BUFFER, 0); -} - -void UniformBuffer::setDescriptor(unsigned int index, unsigned int size , unsigned int stride, void* pointer) -{ - glBindBuffer(GL_ARRAY_BUFFER, Id); - glVertexAttribPointer(index, size, GL_FLOAT, GL_FALSE, stride, pointer); - glBindBuffer(GL_ARRAY_BUFFER, 0); -} - - diff --git a/BarinkEngine/src/Graphics/Memory/UniformBuffer.h b/BarinkEngine/src/Graphics/Memory/UniformBuffer.h deleted file mode 100644 index b44e587..0000000 --- a/BarinkEngine/src/Graphics/Memory/UniformBuffer.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -class UniformBuffer { -public: - - UniformBuffer (unsigned int size); - ~UniformBuffer(); - void setData(unsigned int offset, unsigned int size, void* data); - void setDescriptor(unsigned int index, unsigned int size, unsigned int stride, void* pointer); - - -private: - unsigned int Id; - -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Memory/VertexArray.cpp b/BarinkEngine/src/Graphics/Memory/VertexArray.cpp deleted file mode 100644 index 1420c1f..0000000 --- a/BarinkEngine/src/Graphics/Memory/VertexArray.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "VertexArray.h" -#include - -void VertexArray::Create(){ - glGenVertexArrays(1, &id); -} - -void VertexArray::Bind(){ - glBindVertexArray(id); -} - -void VertexArray::Unbind(){ - glBindVertexArray(0); -} - -void VertexArray::Delete() { - glDeleteVertexArrays(1, &id); -} - - -void VertexArray::AttachAttribute(unsigned int index , int size, int stride ){ - glVertexAttribPointer(index, size, GL_FLOAT, GL_FALSE, stride, 0); - glEnableVertexAttribArray(0); -} - diff --git a/BarinkEngine/src/Graphics/Memory/VertexArray.h b/BarinkEngine/src/Graphics/Memory/VertexArray.h deleted file mode 100644 index 148c7d0..0000000 --- a/BarinkEngine/src/Graphics/Memory/VertexArray.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -class VertexArray{ -private: -unsigned int id; - - -public: -void Create(); -void Bind(); -void Unbind(); - -unsigned int getID() { return id; } - -void Delete(); - -void AttachAttribute(unsigned int index, int size, int stride); - - -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Primitives/Camera.cpp b/BarinkEngine/src/Graphics/Primitives/Camera.cpp deleted file mode 100644 index 972ee88..0000000 --- a/BarinkEngine/src/Graphics/Primitives/Camera.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "Camera.h" - -Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom) -: Position(position), Rotation(rotation), Zoom(zoom) { - - Front = glm::vec3(-1.0f, 0.0f, 0.0f); - Right = glm::vec3(0.0f, 0.0f, 1.0f); - Up = glm::vec3(0.0f, 1.0f, 0.0f); - -} - -Camera::~Camera() { - -} - -glm::mat4 Camera::GetViewMatrix() { - return glm::lookAt( - Position, - Position + Front, - Up - ); -} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Primitives/Camera.h b/BarinkEngine/src/Graphics/Primitives/Camera.h deleted file mode 100644 index db21689..0000000 --- a/BarinkEngine/src/Graphics/Primitives/Camera.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include - -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; - -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Primitives/Material.cpp b/BarinkEngine/src/Graphics/Primitives/Material.cpp deleted file mode 100644 index d34b9b4..0000000 --- a/BarinkEngine/src/Graphics/Primitives/Material.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Material.h" - -Material::Material(const Shader& shader) : -shader(shader) { -} - -void Material::Apply() const { - - shader.Use(); - shader.setUniformVec3("Color", Color); -} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Primitives/Material.h b/BarinkEngine/src/Graphics/Primitives/Material.h deleted file mode 100644 index c2066c9..0000000 --- a/BarinkEngine/src/Graphics/Primitives/Material.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include -#include "Shader.h" - -class Material { -public: - Material(const Shader& shader); - - void Apply()const; - glm::vec3 Color; - const Shader& shader; - -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Primitives/Shader.cpp b/BarinkEngine/src/Graphics/Primitives/Shader.cpp deleted file mode 100644 index a41819f..0000000 --- a/BarinkEngine/src/Graphics/Primitives/Shader.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "Shader.h" -#include "spdlog/spdlog.h" - -Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath) -{ - char infoLog[512]; - int succes; - - char* vertexCode = readFile(vertexShaderPath.c_str()); - //spdlog::info(vertexCode); - unsigned int vertId = glCreateShader(GL_VERTEX_SHADER); - - glShaderSource(vertId, 1, &vertexCode, NULL); - glCompileShader(vertId); - - glGetShaderiv(vertId, GL_COMPILE_STATUS, &succes); - if(!succes){ - glGetShaderInfoLog(vertId, 512, NULL, infoLog); - spdlog::error( "Vertex shader has compile error {}", infoLog); - return; - } - - - char* fragmentCode = readFile(fragmentShaderPath.c_str()); - //spdlog::info(fragmentCode); - unsigned int fragId = glCreateShader(GL_FRAGMENT_SHADER); - - - - glShaderSource(fragId, 1, &fragmentCode, NULL); - glCompileShader(fragId); - - - glGetShaderiv(fragId, GL_COMPILE_STATUS, &succes); - if(!succes){ - glGetShaderInfoLog(fragId, 512, NULL, infoLog); - spdlog::error("Fragment shader has compile error {}", infoLog); - return; - } - - id = glCreateProgram(); - - glAttachShader(id, vertId); - glAttachShader(id, fragId); - glLinkProgram(id); - - - int success; - glGetProgramiv(id, GL_LINK_STATUS, &success); - if(!success) { - glGetProgramInfoLog(id, 512, NULL, infoLog); - printf("ERROR::SHADER_PROGRAM::LINKING_FAILED\n %s", infoLog); - } - - - delete vertexCode; - delete fragmentCode; - - -} - -char* Shader::readFile (const char* filePath){ - - spdlog::info("Opening {} ", filePath); - - - std::ifstream file ; - file.open(filePath); - - if(file.is_open() == false){ - spdlog::info("File not found."); - return nullptr; - } - - - // Determine the file size! - file.seekg(0, std::ios::end); - size_t filesize = file.tellg(); - - // Undo previous seek. - file.seekg(0, std::ios::beg); - //spdlog::info("filesize: {}", filesize); - - - // Create a big enough buffer for the file - - size_t bufferSize = filesize + 3; - char* FileBuffer = new char[bufferSize]; - - memset(FileBuffer, '\0', bufferSize); - - // read the whole file - file.read(FileBuffer, filesize); - - return FileBuffer; -} - -void Shader::Use() const -{ - glUseProgram(id); -} - - -void Shader::setUniformMat4(std::string uniformName, glm::mat4 matrix4) const -{ - glUniformMatrix4fv(glGetUniformLocation(id, uniformName.c_str()), 1, GL_FALSE, glm::value_ptr(matrix4)); -} -void Shader::setUniformVec4(std::string uniformName, glm::vec4 vector4) const -{ - glUniform4fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector4)); -} -void Shader::setUniformVec3(std::string uniformName, glm::vec3 vector3) const -{ - glUniform3fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector3)); -} -void Shader::setUniformVec2(std::string uniformName, glm::vec2 vector2) const -{ - glUniform2fv(glGetUniformLocation(id, uniformName.c_str()),1, glm::value_ptr(vector2)); -} - -void Shader::setUniformFloat(std::string uniformName, float value) const -{ - glUniform1f(glGetUniformLocation(id, uniformName.c_str()), value); -} - -void Shader::setUniformInt(std::string uniformName, int value) const -{ - glUniform1i(glGetUniformLocation(id, uniformName.c_str()), value); -} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Primitives/Texture.cpp b/BarinkEngine/src/Graphics/Primitives/Texture.cpp deleted file mode 100644 index a0d30bc..0000000 --- a/BarinkEngine/src/Graphics/Primitives/Texture.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "Texture.h" -#include -#include -#define STB_IMAGE_IMPLEMENTATION -#include "../stb_image.h" -#include - -Texture::Texture(const std::string texturePath) { - - int width, height, channels; - unsigned char* data = stbi_load(texturePath.c_str(), &width, &height, &channels, 0); - std::cout << channels << std::endl; - - if (data) { - glGenTextures(1, &Id); - - glBindTexture(GL_TEXTURE_2D, Id); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); - glGenerateMipmap(GL_TEXTURE_2D); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - } - else { - spdlog::error("Failed to load image (%s)", texturePath ); - } - stbi_image_free(data); - -} - -void Texture::Bind() { - glBindTexture(GL_TEXTURE_2D, Id); -} - -void Texture::Unbind() { - glBindTexture(GL_TEXTURE_2D, 0); -} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Primitives/Texture.h b/BarinkEngine/src/Graphics/Primitives/Texture.h deleted file mode 100644 index 396d27a..0000000 --- a/BarinkEngine/src/Graphics/Primitives/Texture.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include -#include - - -class Texture { -public: - Texture(const std::string texturePath); - - void Bind(); - void Unbind(); - - -private: - - unsigned int Id; - -}; \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/RenderSurface.cpp b/BarinkEngine/src/Graphics/RenderSurface.cpp deleted file mode 100644 index 850eaa2..0000000 --- a/BarinkEngine/src/Graphics/RenderSurface.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "RenderSurface.h"; - -RenderSurface::RenderSurface(){ - shader = new Shader("build/SandboxAppliction/Debug/renderSuface.vs", "build/SandboxApplication/Debug/renderSurface.fs"); - - - - verts = std::vector{ - {-0.5f, 0.5f, 0.0f}, // 0 - {-0.5f, -0.5f, 0.0f}, // 1 - {0.5f, -0.5f, 0.0f}, // 2 - {0.5f, 0.5f, 0.0f}, // 3 - }; - - indices = std::vector{ - 0,2,1, - 0,3,2 - }; - - VAO.Create(); - VAO.Bind(); - - vertexBuffer.createBuffer(); - vertexBuffer.Bind(false); - vertexBuffer.setBufferData(&verts[0], verts.size() * sizeof(glm::vec3), false); - - elementBuffer.createBuffer(); - elementBuffer.Bind(true); - elementBuffer.setBufferData(&indices[0], indices.size() * sizeof(unsigned int), true); - - VAO.AttachAttribute(0, 3, 0); - - vertexBuffer.Unbind(false); - VAO.Unbind(); - - - -} - -RenderSurface::~RenderSurface() { - delete shader; -} - -void RenderSurface::Draw() { - -} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/RenderSurface.h b/BarinkEngine/src/Graphics/RenderSurface.h deleted file mode 100644 index 2805b8b..0000000 --- a/BarinkEngine/src/Graphics/RenderSurface.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "../BarinkEngine.h" -#include "../Graphics/Memory/Buffer.h" -#include "../Graphics/Memory/VertexArray.h" -#include -class RenderSurface -{ -public: - RenderSurface(); - ~RenderSurface(); - - void Draw(); - -private: - // would normally be a material - // however rendersurface is special and - // thus does not contain a material - Shader* shader; - - // Basically a mesh - std::vector verts; - std::vector indices; - - - Buffer vertexBuffer; - Buffer elementBuffer; - - VertexArray VAO; - - - -}; diff --git a/BarinkEngine/src/Input/InputManager.cpp b/BarinkEngine/src/Input/InputManager.cpp deleted file mode 100644 index 3133d51..0000000 --- a/BarinkEngine/src/Input/InputManager.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "InputManager.h" - -BarinkEngine::InputManager InputSystem; - -void BarinkEngine::InputManager::PollEvents() -{ - for (auto it = windows.begin(); it != windows.end(); ++it) { - auto window = *it; - window->Poll(); - - } -} - -void BarinkEngine::InputManager::KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - - Event KeyEvent{}; - KeyEvent.name = "KEY"; - - InputSystem.EmitEvent(KeyEvent); - - - if (key == GLFW_KEY_A && action == GLFW_PRESS) - { - - std::cout << "'a' key was pressed" << std::endl; - } - -} - -void BarinkEngine::InputManager::CursorPositionCallback(GLFWwindow* window, double x, double y) -{ - //std::cout << "Cursor Position x: " << x << ", y: " << y << std::endl; - Event CursorPosUpdate{}; - CursorPosUpdate.name = "UPDATE::CURSOR:POSITION"; - - InputSystem.EmitEvent(CursorPosUpdate); - - - -} - -void BarinkEngine::InputManager::CursorEnterCallback(GLFWwindow* window, int entered) -{ - if (entered) { - Event mouseEntered {}; - mouseEntered.name = "Mouse Entered Window's confines!"; - mouseEntered.argc = 0; - - InputSystem.EmitEvent(mouseEntered); - - - - } - else { - Event mouseLeft{}; - mouseLeft.name = "Mouse Left Window's confines!"; - mouseLeft.argc = 0; - - InputSystem.EmitEvent(mouseLeft); - - - } -} - - -void BarinkEngine::InputManager::MouseButtonCallback(GLFWwindow* window, int button, int action, int mods) -{ - - Event MouseButtonEvent{}; - MouseButtonEvent.name = "MOUSEBUTTON"; - - InputSystem.EmitEvent(MouseButtonEvent); - - - if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) { - std::cout << "Right mouse button was pressed!" << std::endl; - } - -} - -void BarinkEngine::InputManager::ScrollCallback(GLFWwindow* window, double xoffset, double yoffset) -{ - std::cout << "Scroll: x: " << xoffset << ", y: " << yoffset << std::endl; - - Event ScrollEvent{}; - ScrollEvent.name = "SCROLL"; - - InputSystem.EmitEvent(ScrollEvent); - - -} - - -void BarinkEngine::InputManager::attach(BarinkWindow* window) -{ - - windows.push_back(window); - - // Attach callbacks - glfwSetKeyCallback(window->windowptr(), KeyCallback); - glfwSetCursorPosCallback(window->windowptr(), CursorPositionCallback); - glfwSetCursorEnterCallback(window->windowptr(), CursorEnterCallback); - glfwSetMouseButtonCallback(window->windowptr(), MouseButtonCallback); - glfwSetScrollCallback(window->windowptr(), ScrollCallback); - - this->Subscribe( (EventListener&)(*window)); - - - -} - -BarinkEngine::InputManager::InputManager() : EventEmitter () -{ - windows = std::vector(); -} - - - diff --git a/BarinkEngine/src/PerfCounter.cpp b/BarinkEngine/src/PerfCounter.cpp deleted file mode 100644 index 55e2368..0000000 --- a/BarinkEngine/src/PerfCounter.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "PerfCounter.h" -#include -#include - -EngineStatistics ES; - -uint64_t EngineInstrumentation::GetPrecisionTime() { - using namespace std::chrono; // REMINDER: This is kinda ugly but safes line width - return duration_cast(high_resolution_clock::now().time_since_epoch()).count(); -} - -void EngineInstrumentation::PerfomanceSamplerInit() { - ES.frames = 0; - //EngineInstrumentation::lastSampleTime = GetPrecisionTime(); -} - - - -void EngineInstrumentation::Update() { -/* -uint64_t MilliSecondsPast = GetPrecisionTime() - EngineInstrumentation::lastSampleTime; - - if (MilliSecondsPast >= 1000) { - - ES.frameTime = (float)1000 / ES.frames; - ES.FPS = ES.frames; - ES.frames = 0; - //EngineInstrumentation::lastSampleTime = GetPrecisionTime(); - } -*/ - -} - -void EngineInstrumentation::ShowStats() { - ImGui::Begin("Statistics", false, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize); - - ImGui::Text("FPS: %i", ES.FPS); - ImGui::Text("Frame Time: %f", ES.frameTime); - ImGui::Text("Verts: %i", ES.verts); - ImGui::Text("Draw Calls: %i", ES.DC); - - ImGui::End(); -} - - -PerfSampler::PerfSampler(const std::string& name ) -: name(name) -{ - using namespace std::chrono; - startTime = high_resolution_clock::now(); - -} - -PerfSampler::~PerfSampler() -{ - Stop(); -} - -void PerfSampler::Stop() -{ - using namespace std::chrono; - auto end = high_resolution_clock::now(); - auto durationInuSeconds = - duration_cast(end.time_since_epoch()).count() - - duration_cast(startTime.time_since_epoch()).count(); - - auto ms = durationInuSeconds * 0.001f; - -// std::cout << "[" << name << "]" << "Took: " << durationInuSeconds << " us (" << ms << " ms)" << std::endl; -} \ No newline at end of file diff --git a/BarinkEngine/src/PerfCounter.h b/BarinkEngine/src/PerfCounter.h deleted file mode 100644 index bc202e3..0000000 --- a/BarinkEngine/src/PerfCounter.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include -#include -#include -struct EngineStatistics { - float frameTime; - uint32_t verts; - uint32_t DC; - - int64_t frames; - int64_t FPS; - -}; - -class EngineInstrumentation { -public: - - //static int64_t lastSampleTime; - - static uint64_t GetPrecisionTime(); - static void PerfomanceSamplerInit(); - - static void Update(); - static void ShowStats(); - -}; - -class PerfSampler { -public: - - PerfSampler(const std::string& name); - ~PerfSampler(); - void Stop(); -private: - const std::string& name; - std::chrono::time_point startTime; -}; \ No newline at end of file diff --git a/BarinkEngine/src/Platform/Window.cpp b/BarinkEngine/src/Platform/Window.cpp deleted file mode 100644 index 4fb8f59..0000000 --- a/BarinkEngine/src/Platform/Window.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "Window.h" - -bool BarinkWindow::InitGLFW(){ - if(!glfwInit()) - { - spdlog::error("Failed to initialise GLFW!"); - return false; - } - - return true; -} - -BarinkWindow::BarinkWindow(const int width, const int height) : -Width(width), Height(height), FullScreen(false) -{ - if (InitGLFW()==false) { - exit(-1); - } - - glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); - glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_TRUE); - // No window decorations such as a border, a close widget - // glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); - // glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); - // Disable resizing the window - //glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); - - - window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL); - - if( !window) - { - spdlog::error("GLFW failed to create window!"); - glfwTerminate(); - return; - } - - glfwMakeContextCurrent(window); - if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { - printf("Failed to initialize GLAD!\n"); - exit(-1); - } - - // Set vsync off !! - glfwSwapInterval(0); - - VulkanSupported = glfwVulkanSupported(); - - glfwGetFramebufferSize(window, &Width, &Height); - glViewport(0,0, Width, Height); - - - - glClearColor(0.2f, 0.2f, 0.2f, 1.0f); - -} - -BarinkWindow::~BarinkWindow(){ - - glfwTerminate(); -} - -GLFWwindow* BarinkWindow::windowptr() -{ - return window; -} - -bool BarinkWindow::WindowShouldClose(){ - return glfwWindowShouldClose(window); -} - -void BarinkWindow::Poll() -{ - glfwPollEvents(); -} - -void BarinkWindow::SwapBuffers() -{ - glfwSwapBuffers(window); -} - -void BarinkWindow::ReceiveEvent(Event& incident) -{ - //std::cout << "EVENT RECEIVED: " << incident.name << std::endl; -} - diff --git a/BarinkEngine/src/Scene/Entity.cpp b/BarinkEngine/src/Scene/Entity.cpp deleted file mode 100644 index d6e784d..0000000 --- a/BarinkEngine/src/Scene/Entity.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "Entity.h" - -Entity::Entity(entt::entity e, Scene* scene) - : m_entity(e), m_scene(scene) -{ -} - diff --git a/BarinkEngine/src/Scene/Entity.h b/BarinkEngine/src/Scene/Entity.h deleted file mode 100644 index 82e4ccc..0000000 --- a/BarinkEngine/src/Scene/Entity.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include -class Scene; - - -class Entity { -public: - Entity() = default; - Entity(entt::entity e, Scene* scene); - Entity(const Entity& other) = default; - - template - T& AddComponent() { - return m_scene->m_registry.emplace(m_entity); - } - - template - T& GetComponent() { - return m_scene->m_registry.get(m_entity); - } - - - template - bool HasComponent() { - return m_scene->getReg().all_of(m_entity); - } - - - - // NOTE: Not Scene context aware!! - bool operator== (Entity& other) { - return m_entity == other.m_entity; - } - -private: - entt::entity m_entity; - Scene* m_scene; - -}; - diff --git a/BarinkEngine/src/Scene/Scene.cpp b/BarinkEngine/src/Scene/Scene.cpp deleted file mode 100644 index 43f4e2e..0000000 --- a/BarinkEngine/src/Scene/Scene.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Scene.h" -#include "Entity.h" -#include "Components.h" -Scene::Scene() -{ - //m_registry = entt::basic_registry(); -} - -Scene::~Scene() -{} - -Entity Scene::AddEntity(std::string name) -{ - Entity entity = { m_registry.create(), this }; - - auto& ident = entity.AddComponent(); - ident.name = name; - entity.AddComponent(); - - - return entity; -} - - diff --git a/BarinkEngine/src/Scene/Scene.h b/BarinkEngine/src/Scene/Scene.h deleted file mode 100644 index dc085a3..0000000 --- a/BarinkEngine/src/Scene/Scene.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include -class Entity; - -class Scene -{ -public: - Scene(); - ~Scene(); - - Entity AddEntity(std::string name); - - entt::registry& getReg() { return m_registry; } - -private: - entt::registry m_registry; - - friend class Entity; -}; - - diff --git a/BarinkEngine/src/Scene/TransformTree/Node.cpp b/BarinkEngine/src/Scene/TransformTree/Node.cpp deleted file mode 100644 index e137d86..0000000 --- a/BarinkEngine/src/Scene/TransformTree/Node.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "Node.h" - -Node::Node(const std::string& name) - : name(name), parent(nullptr), children(std::vector()) {} - -Group::Group(const std::string& name ) - : Node(name) {} diff --git a/BarinkEngine/src/Scene/TransformTree/SceneNodeTypes.cpp b/BarinkEngine/src/Scene/TransformTree/SceneNodeTypes.cpp deleted file mode 100644 index 72f4b92..0000000 --- a/BarinkEngine/src/Scene/TransformTree/SceneNodeTypes.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "SceneNodeTypes.h" - -BarinkEngine::SceneCamera::SceneCamera() - : Group(std::string("Camera")), camera(Camera(glm::vec3(0.0f), glm::vec3(0.0f), 0)) -{} - -BarinkEngine::SceneObject::SceneObject(std::string name, Renderable* visual) - : Group(name), renderable(visual) -{} - -BarinkEngine::SceneObject::~SceneObject() -{} \ No newline at end of file diff --git a/BarinkEngine/src/Scripting/LuaScript.cpp b/BarinkEngine/src/Scripting/LuaScript.cpp deleted file mode 100644 index 738d206..0000000 --- a/BarinkEngine/src/Scripting/LuaScript.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "LuaScript.h" -/* -LuaScript::LuaScript(const std::string& path) -: filePath(path) { -} - -void LuaScript::execute(lua_State& l) -{ - luaL_dofile(&l, filePath.c_str()); -} -*/ \ No newline at end of file diff --git a/BarinkEngine/src/Scripting/LuaScript.h b/BarinkEngine/src/Scripting/LuaScript.h deleted file mode 100644 index 54806eb..0000000 --- a/BarinkEngine/src/Scripting/LuaScript.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include - -extern "C" -{ - #include "lauxlib.h" - #include "lua.h" - #include "lualib.h" -} - - -#include "LuaScriptingManager.h" - - -/* -class LuaScript { -public: - - LuaScript(const std::string&); - void execute(lua_State& l); - -private: - std::string filePath; - -}; - - -*/ \ No newline at end of file diff --git a/BarinkEngine/src/Scripting/LuaScriptingManager.cpp b/BarinkEngine/src/Scripting/LuaScriptingManager.cpp deleted file mode 100644 index 2c81198..0000000 --- a/BarinkEngine/src/Scripting/LuaScriptingManager.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "LuaScriptingManager.h" -/* -LuaScriptingManager::LuaScriptingManager() -{ - L = luaL_newstate(); - luaL_openlibs(L); -} - - -void LuaScriptingManager::ExecuteLuaString(const std::string& code) { - luaL_dostring(L, code.c_str()); -} - -lua_State& LuaScriptingManager::getState() -{ - return (*L); -} -*/ \ No newline at end of file diff --git a/BarinkEngine/src/Scripting/LuaScriptingManager.h b/BarinkEngine/src/Scripting/LuaScriptingManager.h deleted file mode 100644 index fdbab4e..0000000 --- a/BarinkEngine/src/Scripting/LuaScriptingManager.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include - -extern "C" -{ - #include "lauxlib.h" - #include "lua.h" - #include "lualib.h" -} - - -#include "LuaScript.h" - -/* -class LuaScriptingManager -{ -public: - std::vector scripts; - - LuaScriptingManager(); - - void ExecuteLuaString(const std::string&); - -private: - lua_State* L; - - lua_State& getState(); -};*/ \ No newline at end of file diff --git a/Editor/premake5.lua b/Editor/premake5.lua index e058529..a04e53c 100644 --- a/Editor/premake5.lua +++ b/Editor/premake5.lua @@ -4,7 +4,7 @@ kind "ConsoleApp" buildmessage "Building editor ..." links{ - "BarinkEngine", + "YoggieEngine", "ImGuizmo" } @@ -13,32 +13,27 @@ includedirs{ -- I'd prefer if didn't need these.. -- We'll figure that out some time later - "./../libs/lua/include", - "./../libs/spdlog/include", - "./../libs/glm", - "./../libs/GorillaAudio/include", + incfolder["lua"], + incfolder["spdlog"], + incfolder["glm"], + incfolder["assimp"], + incfolder["glad"], + incfolder["glfw"], - "./../libs/assimp/include", - "./../libs/glad/include", - "./../libs/glfw/include", - "./../libs/tinygltf", - "./../libs/glew/include", - "./../libs/glm", - "./../libs/ImGui", - "./../libs/guizmo", - - "./../libs/entt/src", + incfolder["imgui"], + incfolder["imguizmo"], + incfolder["entt"], "./include" } libdirs { - './../build/BarinkEngine/Debug' + staticlib["yoggie"] } files { - "./include/*.h", + "./src/*.h", "./src/*.cpp" } diff --git a/Editor/src/main.cpp b/Editor/src/main.cpp index 2893fe2..e3f2c6d 100644 --- a/Editor/src/main.cpp +++ b/Editor/src/main.cpp @@ -1,25 +1,23 @@ #include #include - #include -#include "stb_image.h" #include "../../libs/guizmo/ImGuizmo.h" -#include "../../BarinkEngine/src/BarinkEngine.h" -#include "../../BarinkEngine/src/AssetManager/ModelImporter.h" -#include "../../BarinkEngine/src/Graphics/Memory/Framebuffer.h" -#include "../../BarinkEngine/src/PerfCounter.cpp" -#include "../../BarinkEngine/src/Scene/Entity.h" +#include "../../YoggieEngine/src/BarinkEngine.h" +#include "../../YoggieEngine/src/AssetManager/ModelImporter.h" +#include "../../YoggieEngine/src/Graphics/Memory/Framebuffer.h" +#include "../../YoggieEngine/src/PerfCounter.cpp" +#include "../../YoggieEngine/src/Scene/Entity.h" #include "Widgets.h" - +using namespace YoggieEngine; /* * Define globals */ Framebuffer* framebuffer; Scene Level1; -BarinkEngine::SceneObject* Model; +SceneObject* Model; Entity cube; entt::entity Selected; @@ -35,25 +33,25 @@ void Start() { // Create a level and load it as the current level - auto importer = BarinkEngine::ModelImporter(); + auto importer = ModelImporter(); // Create a cube Model = importer.Import("build/Debug/Models/Cube.obj"); cube = Level1.AddEntity("cube"); - auto& render3DComponent = cube.AddComponent(); + auto& render3DComponent = cube.AddComponent(); render3DComponent.mesh = *(Model->renderable->mesh); - cube.GetComponent().Position = glm::vec3(1.0f, 0.0f, 5.0f); + cube.GetComponent().Position = glm::vec3(1.0f, 0.0f, 5.0f); auto cube2 = Level1.AddEntity("Cube1"); - auto& rendercube2 = cube2.AddComponent(); + auto& rendercube2 = cube2.AddComponent(); rendercube2.mesh = *(Model->renderable->mesh); // create an ambient light source auto AmbientLight = Level1.AddEntity("AmbientLight"); - auto light = AmbientLight.AddComponent(); + auto light = AmbientLight.AddComponent(); light.Color = glm::vec3(1.0f); light.Strength = 1.0f; diff --git a/Editor/src/widgets.cpp b/Editor/src/widgets.cpp index c517b2f..68df376 100644 --- a/Editor/src/widgets.cpp +++ b/Editor/src/widgets.cpp @@ -1,7 +1,8 @@ #include "widgets.h" +//#include "EditorConsole.h" #include -#include "../../BarinkEngine/src/Scene/Components.h" -#include "../../BarinkEngine/src/Scene/Entity.h" +#include "../../YoggieEngine/src/Scene/Components.h" +#include "../../YoggieEngine/src/Scene/Entity.h" class Editor; void ComponentView(const std::string& componentName, voidFunction func) @@ -18,33 +19,61 @@ void ComponentView(const std::string& componentName, voidFunction func) void Inspector(entt::entity ent , Scene& scene) { ImGui::Begin("Inspector"); + static char* names[] = { "Script Component", "Camera Component" }; + static float Zoom = 90; static glm::vec3 Position = glm::vec3(0.0f, 0.0f, 0.0f); static glm::vec3 Rotation = glm::vec3(0.0f, 0.0f, 0.0f); if (scene.getReg().valid(ent)) { Entity entity = Entity(ent, &scene); + + auto component = entity.GetComponent(); + ImGui::LabelText("## Name:", component.name.c_str()); + + + + if (ImGui::Button("Add Component")) + ImGui::OpenPopup("Component picker"); - auto component = entity.GetComponent(); - ImGui::LabelText("## Name:", component.name.c_str() ); + ImGui::SameLine(); + if (ImGui::BeginPopup("Component picker")) { + + for (int i = 0; i < IM_ARRAYSIZE(names); i++) + if (ImGui::MenuItem(names[i])) { + std::cout << "Add a " << names[i] << " to " + << entity.GetComponent().name << std::endl; + } + + ImGui::EndPopup(); + } + + ImGui::NewLine(); + - if (entity.HasComponent()) { - auto& transform = entity.GetComponent(); - ImGui::DragFloat3("Position", glm::value_ptr(transform.Position) , 0.01); + + + if (entity.HasComponent()) { + auto& transform = entity.GetComponent(); + if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_None )) { + ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.01); ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.01); ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.01, 0); - + + + } + } - if (entity.HasComponent()) { - auto& light = entity.GetComponent(); + if (entity.HasComponent()) { + auto& light = entity.GetComponent(); ImGui::DragFloat("Strength", &light.Strength, 0.001f); ImGui::ColorEdit3("Colour", glm::value_ptr(light.Color)); } - if (entity.HasComponent ()) { - auto& camera = entity.GetComponent(); + if (entity.HasComponent ()) { + auto& camera = entity.GetComponent(); ComponentView("Camera", [] { ImGui::SliderFloat("Zoom", &Zoom, 10, 190); ImGui::InputFloat3("Position:", &Position[0]); @@ -52,7 +81,7 @@ void Inspector(entt::entity ent , Scene& scene) { }); } - if (entity.HasComponent()) { + if (entity.HasComponent()) { ComponentView("Scripting", [] { ImGui::LabelText("##--", "Hello scripting"); }); @@ -71,7 +100,7 @@ void SceneExplorer(entt::entity& selected, Scene& scene ) scene.getReg().each([&](entt::entity enttNumber) { Entity entity = Entity(enttNumber, &scene); - auto id = entity.GetComponent(); + auto id = entity.GetComponent(); if (ImGui::Selectable(id.name.c_str(), enttNumber == selected )) { selected = enttNumber; @@ -122,9 +151,11 @@ void Settings() { ImGui::End(); } +//auto console = EditorConsole(); + void Console() { ImGui::Begin("Console", false); - ImGui::Dummy(ImVec2{ 128, 128 }); + // console.Draw(); ImGui::End(); } diff --git a/Editor/src/widgets.h b/Editor/src/widgets.h index a12b0bc..ec59cf6 100644 --- a/Editor/src/widgets.h +++ b/Editor/src/widgets.h @@ -2,11 +2,14 @@ #include #include #include -#include "../../libs/guizmo/ImGuizmo.h" -#include "../../BarinkEngine/src/BarinkEngine.h" + #include #include + +#include "../../libs/guizmo/ImGuizmo.h" +#include "../../YoggieEngine/src/BarinkEngine.h" typedef void ( *voidFunction ) (void); +using namespace YoggieEngine; void ComponentView(const std::string& componentName, voidFunction func); diff --git a/Runtime/premake5.lua b/Runtime/premake5.lua index 0b6fc49..9c81316 100644 --- a/Runtime/premake5.lua +++ b/Runtime/premake5.lua @@ -4,11 +4,11 @@ kind "ConsoleApp" buildmessage "Building the runtime ..." links{ - "BarinkEngine" + "YoggieEngine" } includedirs{ - "./../BarinkEngine/src", + "./../YoggieEngine/src", -- I'd prefer if didn't need these.. -- We'll figure that out some time later "./../libs/lua/include", @@ -30,7 +30,7 @@ includedirs{ } libdirs { - './../build/BarinkEngine/Debug' + './../YoggieEngine/build/Debug' } files { diff --git a/SandboxApp/premake5.lua b/SandboxApp/premake5.lua index cbf2b45..02c87eb 100644 --- a/SandboxApp/premake5.lua +++ b/SandboxApp/premake5.lua @@ -4,11 +4,11 @@ kind "ConsoleApp" buildmessage "Building SandboxApp ..." links{ - "BarinkEngine" + "YoggieEngine" } includedirs{ - "./../BarinkEngine/Include", + "./../YoggieEngine/Include", -- I'd prefer if didn't need these.. -- We'll figure that out some time later @@ -31,7 +31,7 @@ includedirs{ } libdirs { - './../build/BarinkEngine/Debug' + './../YoggieEngine/build/Debug' } files { diff --git a/SandboxApp/src/GUI.h b/SandboxApp/src/GUI.h index e711383..a2c0896 100644 --- a/SandboxApp/src/GUI.h +++ b/SandboxApp/src/GUI.h @@ -1,7 +1,7 @@ #pragma once #include "imgui.h" -#include "../../BarinkEngine/src/BarinkEngine.h" -#include "../../BarinkEngine/src/Graphics/Memory/Framebuffer.h" +#include "../../YoggieEngine/src/BarinkEngine.h" +#include "../../YoggieEngine/src/Graphics/Memory/Framebuffer.h" void CameraTool(); void ScriptingTool(char* code); diff --git a/SandboxApp/src/Sandbox.cpp b/SandboxApp/src/Sandbox.cpp index 5b7bba2..f0509ed 100644 --- a/SandboxApp/src/Sandbox.cpp +++ b/SandboxApp/src/Sandbox.cpp @@ -1,13 +1,15 @@ -#include "../../BarinkEngine/src/BarinkEngine.h" -#include "../../BarinkEngine/src/Scene/Components.h" -#include "../../BarinkEngine/src/Scene/Scene.h" -#include "../../BarinkEngine/src/Scene/Entity.h" -#include "../../BarinkEngine/src/AssetManager/ModelImporter.h" #include #include "GUI.h" #include "Util.h" #include -#include "../../BarinkEngine/src/PerfCounter.h" + +#include "../../YoggieEngine/src/BarinkEngine.h" +#include "../../YoggieEngine/src/Scene/Components.h" +#include "../../YoggieEngine/src/Scene/Scene.h" +#include "../../YoggieEngine/src/Scene/Entity.h" +#include "../../YoggieEngine/src/AssetManager/ModelImporter.h" +#include "../../YoggieEngine/src/PerfCounter.h" + /* * Define globals diff --git a/SandboxApp/src/Util.h b/SandboxApp/src/Util.h index de2df52..22726f4 100644 --- a/SandboxApp/src/Util.h +++ b/SandboxApp/src/Util.h @@ -1,5 +1,5 @@ #pragma once -#include "../../BarinkEngine/src/BarinkEngine.h" +#include "../../YoggieEngine/src/BarinkEngine.h" //void PrintSceneTree(Node& node, int depth); diff --git a/BarinkEngine/premake5.lua b/YoggieEngine/premake5.lua similarity index 86% rename from BarinkEngine/premake5.lua rename to YoggieEngine/premake5.lua index 166e39a..0fb435d 100644 --- a/BarinkEngine/premake5.lua +++ b/YoggieEngine/premake5.lua @@ -1,63 +1,62 @@ -project "BarinkEngine" - kind "StaticLib" - - buildmessage "Building BarinkEngine" - - includedirs { - "../libs/spdlog/include", - "../libs/glm", - - "../libs/glfw/include", - "../libs/glew/include", - "../libs/glad/include", - - - "../libs/assimp/include", - "../libs/entt/src", - - "../libs/physx/physx/include", - - "../libs/lua/include", - - "../libs/GorillaAudio/include", - "../libs/steam-audio/include", - - - "../libs/ImGui", - } - - links { - -- This needs to fall under the filter as the names can differ on different platforms - "phonon", - "lua54", - "spdlog", - "assimp-vc143-mtd", - "glfw3", - "ImGui", - } - - - libdirs { - "../libs/steam-audio/lib/windows-x64", - "../libs/lua", - "../libs/spdlog/build/Release", - "../libs/assimp/lib/Debug", - "../libs/glfw/build/src/Debug", - } - - files { - "../libs/glad/src/glad.c", - - "./src/*.cpp", - "./src/*.h", - "./src/**/*.cpp", - "./src/**/*.h" - } - - prebuildcommands - { - ok,err = os.copyfile("BarinkEngine/src/Graphics/shaders/*" ,"SandboxApp/build/Debug/") - } - -include('../ImGui') -include("../ImGuizmo") \ No newline at end of file +project "YoggieEngine" + kind "StaticLib" + + buildmessage "Building Yoggie Engine" + + includedirs { + "../libs/spdlog/include", + "../libs/glm", + + "../libs/glfw/include", + "../libs/glew/include", + "../libs/glad/include", + + + "../libs/assimp/include", + "../libs/entt/src", + + "../libs/physx/physx/include", + + "../libs/lua/include", + + "../libs/GorillaAudio/include", + "../libs/steam-audio/include", + + + "../libs/ImGui", + } + + links { + -- This needs to fall under the filter as the names can differ on different platforms + "phonon", + "lua54", + "spdlog", + "assimp-vc143-mtd", + "glfw3", + "ImGui", + } + + + libdirs { + "../libs/steam-audio/lib/windows-x64", + "../libs/lua", + "../libs/spdlog/build/Release", + "../libs/assimp/lib/Debug", + "../libs/glfw/build/src/Debug", + } + + files { + "../libs/glad/src/glad.c", + + "./src/*.cpp", + "./src/*.h", + "./src/**/*.cpp", + "./src/**/*.h" + } + + prebuildcommands + { + ok,err = os.copyfile("BarinkEngine/src/Graphics/shaders/*" ,"SandboxApp/build/Debug/") + } + + diff --git a/YoggieEngine/src/AssetManager/ModelImporter.cpp b/YoggieEngine/src/AssetManager/ModelImporter.cpp new file mode 100644 index 0000000..3273a9a --- /dev/null +++ b/YoggieEngine/src/AssetManager/ModelImporter.cpp @@ -0,0 +1,101 @@ +#include "ModelImporter.h" +#include "spdlog/spdlog.h" +namespace YoggieEngine { + + SceneObject* ModelImporter::Import(const std::string path) + { + SceneObject* root = new SceneObject(std::string(path), nullptr); + + Assimp::Importer importer; + const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs); + + aiNode* currentNode = scene->mRootNode; + + std::vector meshes = processNode(currentNode, scene); + + std::cout << "[DEBUG]: Loaded " << meshes.size() << " meshes!" << std::endl; + + // create a renderable (per mesh ?? ) + root->renderable = new Renderable(); + root->renderable->mesh = new Mesh(meshes[0]); + + return root; + + } + + std::vector ModelImporter::processNode(aiNode* node, const aiScene* scene) + { + + std::vector meshes; + + for (unsigned int i = 0; i < node->mNumMeshes; i++) { + aiMesh* mesh = scene->mMeshes[node->mMeshes[i]]; + meshes.push_back(processMesh(mesh, scene)); + } + + for (unsigned int i = 0; i < node->mNumChildren; i++) { + auto m2 = processNode(node->mChildren[i], scene); + + for (auto m : m2) { + meshes.push_back(m); + } + } + + return meshes; + } + + Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene) { + std::vector indices; + std::vector vertices; + + ProcessVertices(mesh, vertices); + + ProcessIndices(mesh, indices); + + Mesh result; + result.vertices = vertices; + result.elements = indices; + + + return result; + + } + + void ProcessVertices(aiMesh* mesh, std::vector& out_vertices) { + // Process vertices + for (unsigned int i = 0; i < mesh->mNumVertices; i++) { + Vertex v{}; + glm::vec3 vector; + vector.x = mesh->mVertices[i].x; + vector.y = mesh->mVertices[i].y; + vector.z = mesh->mVertices[i].z; + + v.vertices = vector; + + if (mesh->mTextureCoords[0]) { + + glm::vec2 texCoord; + + texCoord.x = mesh->mTextureCoords[0][i].x; + texCoord.y = mesh->mTextureCoords[0][i].y; + + v.uv = texCoord; + + } + + out_vertices.push_back(v); + } + } + + void ProcessIndices(aiMesh* mesh, std::vector& out_indices) { + // Process Indices + for (unsigned int i = 0; i < mesh->mNumFaces; i++) { + aiFace face = mesh->mFaces[i]; + if (face.mNumIndices < 3) + continue; + for (unsigned int j = 0; j < face.mNumIndices; j++) { + out_indices.push_back(face.mIndices[j]); + } + } + } +} \ No newline at end of file diff --git a/YoggieEngine/src/AssetManager/ModelImporter.h b/YoggieEngine/src/AssetManager/ModelImporter.h new file mode 100644 index 0000000..79f7629 --- /dev/null +++ b/YoggieEngine/src/AssetManager/ModelImporter.h @@ -0,0 +1,31 @@ +#pragma once +#define STB_IMAGE_IMPLEMENTATION +#define STB_IMAGE_WRITE_IMPLEMENTATION + +#include "../Graphics/Primitives/Mesh.h" +#include +#include +#include +#include +#include "../Scene/TransformTree/SceneNodeTypes.h" + +namespace YoggieEngine { + void ProcessVertices(aiMesh* mesh, std::vector& out_vertices); + void ProcessIndices(aiMesh* mesh, std::vector& out_indices); + + class ModelImporter { + + public: + + SceneObject* Import(const std::string path); + + + private: + + static Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene); + static std::vector ModelImporter::processNode(aiNode* node, const aiScene* scene); + + + + }; +} diff --git a/BarinkEngine/src/BarinkEngine.cpp b/YoggieEngine/src/BarinkEngine.cpp similarity index 68% rename from BarinkEngine/src/BarinkEngine.cpp rename to YoggieEngine/src/BarinkEngine.cpp index 1ece7d0..b3116a7 100644 --- a/BarinkEngine/src/BarinkEngine.cpp +++ b/YoggieEngine/src/BarinkEngine.cpp @@ -1,19 +1,20 @@ #include "BarinkEngine.h" +using namespace YoggieEngine; + +Renderer renderer; -extern EngineStatistics ES; -BarinkEngine::Renderer renderer; const unsigned int MS_PER_UPDATE = 2; + int main(int argc, char* argv[]) { // Setup performance sampler EngineInstrumentation::PerfomanceSamplerInit(); // Startup services - BarinkWindow MainWindow = BarinkWindow(1200, 700); + BarinkWindow MainWindow = BarinkWindow(1200, 700); - renderer = BarinkEngine::Renderer(); - InputSystem = BarinkEngine::InputManager(); + renderer = Renderer(); + InputSystem = InputManager(); - ES = EngineStatistics{}; InputSystem.attach(&MainWindow); GUIManager GUISystem = GUIManager(&MainWindow); @@ -22,7 +23,6 @@ int main(int argc, char* argv[]) { // First call to setup game { - PerfSampler("Start"); Start(); } @@ -31,9 +31,9 @@ int main(int argc, char* argv[]) { double lag = 0.0; // Runtime loop - while (!MainWindow.WindowShouldClose()) + while (!MainWindow.WindowShouldClose()) { - + double current = glfwGetTime(); double elapsed = current - previous; previous = current; @@ -43,13 +43,11 @@ int main(int argc, char* argv[]) { // Execute main logic { - PerfSampler("PollEvents"); InputSystem.PollEvents(); } - + { - PerfSampler("Update"); while (lag >= MS_PER_UPDATE) { Update(); lag -= MS_PER_UPDATE; @@ -57,32 +55,30 @@ int main(int argc, char* argv[]) { } { - PerfSampler("Render"); Render(); } - - { - PerfSampler("GUI-Render"); - GUISystem.Render(); - } - { - PerfSampler("BufferSwap"); + GUISystem.Render(); + } + + + { MainWindow.SwapBuffers(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } - + } // Shutdown game { - PerfSampler("Stop"); Stop(); } - + // Shutdown Services return 0; } + + diff --git a/BarinkEngine/src/BarinkEngine.h b/YoggieEngine/src/BarinkEngine.h similarity index 89% rename from BarinkEngine/src/BarinkEngine.h rename to YoggieEngine/src/BarinkEngine.h index 913bb8a..e1b5488 100644 --- a/BarinkEngine/src/BarinkEngine.h +++ b/YoggieEngine/src/BarinkEngine.h @@ -14,10 +14,9 @@ #include "Graphics/Renderer.h" #include "GUI/GUIManager.h" #include "Scene/Scene.h" -#include "PerfCounter.h" +using namespace YoggieEngine; +extern Renderer renderer; - -extern BarinkEngine::Renderer renderer; extern void Start(); extern void Update(); extern void Render(); diff --git a/YoggieEngine/src/EventSystem/Event.h b/YoggieEngine/src/EventSystem/Event.h new file mode 100644 index 0000000..3e8d5fc --- /dev/null +++ b/YoggieEngine/src/EventSystem/Event.h @@ -0,0 +1,14 @@ +#pragma once +#include + +namespace YoggieEngine { + + struct Event + { + public: + std::string name; + int argc; + void** argv; + + }; +} \ No newline at end of file diff --git a/YoggieEngine/src/EventSystem/EventEmitter.cpp b/YoggieEngine/src/EventSystem/EventEmitter.cpp new file mode 100644 index 0000000..4a5095e --- /dev/null +++ b/YoggieEngine/src/EventSystem/EventEmitter.cpp @@ -0,0 +1,27 @@ +#include "EventEmitter.h" + +namespace YoggieEngine { + + void EventEmitter::Subscribe(EventListener& subscriber) + { + subscribers.push_back(&subscriber); + } + + void EventEmitter::Unsubscribe(EventListener& subscriber) + { + subscribers.remove(&subscriber); + } + + void EventEmitter::EmitEvent(Event& incident) + { + // Notify all subscribers an event has taken place + for (auto it = subscribers.begin(); it != subscribers.end(); ++it) + { + (*it)->ReceiveEvent(incident); + } + } + + EventEmitter::EventEmitter() { + subscribers = std::list{}; + } +} \ No newline at end of file diff --git a/YoggieEngine/src/EventSystem/EventEmitter.h b/YoggieEngine/src/EventSystem/EventEmitter.h new file mode 100644 index 0000000..19a004b --- /dev/null +++ b/YoggieEngine/src/EventSystem/EventEmitter.h @@ -0,0 +1,17 @@ +#pragma once +#include "Event.h" +#include "EventListener.h" +namespace YoggieEngine{ + class EventEmitter { + public: + void Subscribe(EventListener& subscriber); + void Unsubscribe(EventListener& subscriber); + + protected: + std::list subscribers; + void EmitEvent(Event& incident); + + EventEmitter(); + + }; +} diff --git a/YoggieEngine/src/EventSystem/EventListener.h b/YoggieEngine/src/EventSystem/EventListener.h new file mode 100644 index 0000000..5f0153e --- /dev/null +++ b/YoggieEngine/src/EventSystem/EventListener.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include + +#include "spdlog/spdlog.h" +#include "Event.h" +namespace YoggieEngine { + class EventListener { + public: + virtual void ReceiveEvent(Event& incident) = 0; + + }; +} diff --git a/YoggieEngine/src/GUI/GUIManager.cpp b/YoggieEngine/src/GUI/GUIManager.cpp new file mode 100644 index 0000000..444436b --- /dev/null +++ b/YoggieEngine/src/GUI/GUIManager.cpp @@ -0,0 +1,65 @@ +#include "GUIManager.h" +#include "imgui.h" +#include "backends/imgui_impl_opengl3.h" +#include +#include "../../libs/guizmo/ImGuizmo.h" +#include "../BarinkEngine.h" + +namespace YoggieEngine { + + GUIManager::GUIManager(BarinkWindow* window) + : currentwindow(window) + { + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable; + io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable; + + ImGui::StyleColorsDark(); + + ImGui_ImplGlfw_InitForOpenGL(currentwindow->windowptr(), true); + ImGui_ImplOpenGL3_Init("#version 440"); + + + } + + GUIManager::~GUIManager() + { + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplGlfw_Shutdown(); + ImGui::DestroyContext(); + } + + void GUIManager::Render() + { + ImGui_ImplGlfw_NewFrame(); + ImGui_ImplOpenGL3_NewFrame(); + + ImGui::NewFrame(); + + ImGuizmo::SetOrthographic(true); + ImGuizmo::BeginFrame(); + + + + ImmediateGraphicsDraw(); + + + + ImGui::EndFrame(); + + + ImGui::Render(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + + if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) + { + GLFWwindow* last_context = glfwGetCurrentContext(); + ImGui::UpdatePlatformWindows(); + ImGui::RenderPlatformWindowsDefault(); + glfwMakeContextCurrent(last_context); + } + } + +} diff --git a/YoggieEngine/src/GUI/GUIManager.h b/YoggieEngine/src/GUI/GUIManager.h new file mode 100644 index 0000000..ace922b --- /dev/null +++ b/YoggieEngine/src/GUI/GUIManager.h @@ -0,0 +1,14 @@ +#pragma once +#include "../Platform/Window.h" + +namespace YoggieEngine { + class GUIManager { + public: + GUIManager(BarinkWindow* window); + ~GUIManager(); + void Render(); + + private: + BarinkWindow* currentwindow; + }; +} diff --git a/YoggieEngine/src/Graphics/Memory/Buffer.cpp b/YoggieEngine/src/Graphics/Memory/Buffer.cpp new file mode 100644 index 0000000..9a45c26 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/Buffer.cpp @@ -0,0 +1,49 @@ +#include "Buffer.h" + +namespace YoggieEngine { + + int Buffer::getBufferID() { + return id; + } + + void Buffer::createBuffer() { + glGenBuffers(1, (GLuint*)&id); + } + + void Buffer::setBufferData(void* data, size_t dataSize, bool elementBuffer = false) { + + if (elementBuffer) { + glBufferData(GL_ELEMENT_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW); + + } + else { + glBufferData(GL_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW); + } + + } + + void Buffer::Bind(bool elementBuffer = false) { + if (elementBuffer) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id); + + } + else { + glBindBuffer(GL_ARRAY_BUFFER, id); + + } + } + + void Buffer::Unbind(bool elementBuffer = false) { + if (elementBuffer) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } + else { + glBindBuffer(GL_ARRAY_BUFFER, 0); + + } + } + + void Buffer::Delete() { + glDeleteBuffers(1, (GLuint*)&id); + } +} diff --git a/YoggieEngine/src/Graphics/Memory/Buffer.h b/YoggieEngine/src/Graphics/Memory/Buffer.h new file mode 100644 index 0000000..1a7f489 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/Buffer.h @@ -0,0 +1,24 @@ +#pragma once +#include + +namespace YoggieEngine { + class Buffer { + + public: + + int getBufferID(); + + void createBuffer(); + + void setBufferData(void* data, size_t dataSize, bool elementBuffer); + + void Bind(bool elementBuffer); + void Unbind(bool elementBuffer); + + void Delete(); + + private: + unsigned int id; + + }; +} diff --git a/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp b/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp new file mode 100644 index 0000000..b819d61 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp @@ -0,0 +1,72 @@ +#include "Framebuffer.h" +#include +namespace YoggieEngine { + Framebuffer::Framebuffer() + { + glGenFramebuffers(1, &Id); + glBindFramebuffer(GL_FRAMEBUFFER, Id); + + // Create a colour texture! + glGenTextures(1, &ColourAttachment); + glBindTexture(GL_TEXTURE_2D, ColourAttachment); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 800, 600, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glBindTexture(GL_TEXTURE_2D, 0); + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColourAttachment, 0); + + + + // Create a depth buffer + glGenTextures(1, &DepthAttachment); + glBindTexture(GL_TEXTURE_2D, DepthAttachment); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, 800, 600, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); + + glBindTexture(GL_TEXTURE_2D, 0); + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, DepthAttachment, 0); + + + /* + * // Render buffer + glGenRenderbuffers(1, &DepthAttachment); + glBindRenderbuffer(GL_RENDERBUFFER, DepthAttachment); + + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 800, 600); + + + glBindRenderbuffer(GL_RENDERBUFFER, 0); + + glFramebufferRenderbuffer(GL_RENDERBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, DepthAttachment); + + */ + + + + + + if (!glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) + { + std::cout << "Framebuffer is incomplete!" << std::endl; + } + else { + std::cout << "Framebuffer is complete!" << std::endl; + } + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + + } + + Framebuffer::~Framebuffer() + { + glDeleteTextures(1, &ColourAttachment); + glDeleteRenderbuffers(1, &DepthAttachment); + glDeleteFramebuffers(1, &Id); + } +} diff --git a/YoggieEngine/src/Graphics/Memory/Framebuffer.h b/YoggieEngine/src/Graphics/Memory/Framebuffer.h new file mode 100644 index 0000000..99a7d73 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/Framebuffer.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include + +namespace YoggieEngine { + class Framebuffer { + + public: + Framebuffer(); + ~Framebuffer(); + + GLuint GetId() { return Id; } + GLuint GetColourAttachment() { return ColourAttachment; } + GLuint GetDepthAttachment() { return DepthAttachment; } + + private: + GLuint Id = 0; + GLuint ColourAttachment = 0; + GLuint DepthAttachment = 0; + + + }; +} diff --git a/YoggieEngine/src/Graphics/Memory/UniformBuffer.cpp b/YoggieEngine/src/Graphics/Memory/UniformBuffer.cpp new file mode 100644 index 0000000..7da7728 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/UniformBuffer.cpp @@ -0,0 +1,33 @@ +#include "UniformBuffer.h" +#include + +namespace YoggieEngine { + UniformBuffer::UniformBuffer(unsigned int size) + { + glGenBuffers(1, &Id); + glBindBuffer(GL_ARRAY_BUFFER, Id); + glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + + UniformBuffer::~UniformBuffer() + { + glDeleteBuffers(1, &Id); + } + + + void UniformBuffer::setData(unsigned int offset, unsigned int size, void* data) + { + glBindBuffer(GL_ARRAY_BUFFER, Id); + glBufferSubData(GL_ARRAY_BUFFER, offset, size, data); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + + void UniformBuffer::setDescriptor(unsigned int index, unsigned int size, unsigned int stride, void* pointer) + { + glBindBuffer(GL_ARRAY_BUFFER, Id); + glVertexAttribPointer(index, size, GL_FLOAT, GL_FALSE, stride, pointer); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + +} diff --git a/YoggieEngine/src/Graphics/Memory/UniformBuffer.h b/YoggieEngine/src/Graphics/Memory/UniformBuffer.h new file mode 100644 index 0000000..b7bf0c3 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/UniformBuffer.h @@ -0,0 +1,17 @@ +#pragma once + +namespace YoggieEngine { + class UniformBuffer { + public: + + UniformBuffer(unsigned int size); + ~UniformBuffer(); + void setData(unsigned int offset, unsigned int size, void* data); + void setDescriptor(unsigned int index, unsigned int size, unsigned int stride, void* pointer); + + + private: + unsigned int Id; + + }; +} diff --git a/YoggieEngine/src/Graphics/Memory/VertexArray.cpp b/YoggieEngine/src/Graphics/Memory/VertexArray.cpp new file mode 100644 index 0000000..bd6e000 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/VertexArray.cpp @@ -0,0 +1,25 @@ +#include "VertexArray.h" +#include +namespace YoggieEngine { + void VertexArray::Create() { + glGenVertexArrays(1, &id); + } + + void VertexArray::Bind() { + glBindVertexArray(id); + } + + void VertexArray::Unbind() { + glBindVertexArray(0); + } + + void VertexArray::Delete() { + glDeleteVertexArrays(1, &id); + } + + + void VertexArray::AttachAttribute(unsigned int index, int size, int stride) { + glVertexAttribPointer(index, size, GL_FLOAT, GL_FALSE, stride, 0); + glEnableVertexAttribArray(0); + } +} diff --git a/YoggieEngine/src/Graphics/Memory/VertexArray.h b/YoggieEngine/src/Graphics/Memory/VertexArray.h new file mode 100644 index 0000000..96d70c0 --- /dev/null +++ b/YoggieEngine/src/Graphics/Memory/VertexArray.h @@ -0,0 +1,22 @@ +#pragma once + +namespace YoggieEngine { + class VertexArray { + private: + unsigned int id; + + + public: + void Create(); + void Bind(); + void Unbind(); + + unsigned int getID() { return id; } + + void Delete(); + + void AttachAttribute(unsigned int index, int size, int stride); + + + }; +} diff --git a/YoggieEngine/src/Graphics/Primitives/Camera.cpp b/YoggieEngine/src/Graphics/Primitives/Camera.cpp new file mode 100644 index 0000000..82d4498 --- /dev/null +++ b/YoggieEngine/src/Graphics/Primitives/Camera.cpp @@ -0,0 +1,23 @@ +#include "Camera.h" +namespace YoggieEngine { + Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom) + : Position(position), Rotation(rotation), Zoom(zoom) { + + Front = glm::vec3(-1.0f, 0.0f, 0.0f); + Right = glm::vec3(0.0f, 0.0f, 1.0f); + Up = glm::vec3(0.0f, 1.0f, 0.0f); + + } + + Camera::~Camera() { + + } + + glm::mat4 Camera::GetViewMatrix() { + return glm::lookAt( + Position, + Position + Front, + Up + ); + } +} diff --git a/YoggieEngine/src/Graphics/Primitives/Camera.h b/YoggieEngine/src/Graphics/Primitives/Camera.h new file mode 100644 index 0000000..b990b2b --- /dev/null +++ b/YoggieEngine/src/Graphics/Primitives/Camera.h @@ -0,0 +1,24 @@ +#pragma once +#include +#include + +namespace YoggieEngine { + 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; + + }; +} diff --git a/YoggieEngine/src/Graphics/Primitives/Material.cpp b/YoggieEngine/src/Graphics/Primitives/Material.cpp new file mode 100644 index 0000000..a976921 --- /dev/null +++ b/YoggieEngine/src/Graphics/Primitives/Material.cpp @@ -0,0 +1,14 @@ +#include "Material.h" + +namespace YoggieEngine { + + Material::Material(const Shader& shader) : + shader(shader) { + } + + void Material::Apply() const { + + shader.Use(); + shader.setUniformVec3("Color", Color); + } +} diff --git a/YoggieEngine/src/Graphics/Primitives/Material.h b/YoggieEngine/src/Graphics/Primitives/Material.h new file mode 100644 index 0000000..d689408 --- /dev/null +++ b/YoggieEngine/src/Graphics/Primitives/Material.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include +#include "Shader.h" + +namespace YoggieEngine { + class Material { + public: + Material(const Shader& shader); + + void Apply()const; + glm::vec3 Color; + const Shader& shader; + + }; +} diff --git a/BarinkEngine/src/Graphics/Primitives/Mesh.h b/YoggieEngine/src/Graphics/Primitives/Mesh.h similarity index 86% rename from BarinkEngine/src/Graphics/Primitives/Mesh.h rename to YoggieEngine/src/Graphics/Primitives/Mesh.h index 2a21e5f..e3420ea 100644 --- a/BarinkEngine/src/Graphics/Primitives/Mesh.h +++ b/YoggieEngine/src/Graphics/Primitives/Mesh.h @@ -3,7 +3,7 @@ #include #include "Vertex.h" -namespace BarinkEngine { +namespace YoggieEngine { struct Mesh { std::vector vertices; std::vector elements; diff --git a/YoggieEngine/src/Graphics/Primitives/Shader.cpp b/YoggieEngine/src/Graphics/Primitives/Shader.cpp new file mode 100644 index 0000000..ba7eb83 --- /dev/null +++ b/YoggieEngine/src/Graphics/Primitives/Shader.cpp @@ -0,0 +1,130 @@ +#include "Shader.h" +#include "spdlog/spdlog.h" +namespace YoggieEngine { + Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath) + { + char infoLog[512]; + int succes; + + char* vertexCode = readFile(vertexShaderPath.c_str()); + //spdlog::info(vertexCode); + unsigned int vertId = glCreateShader(GL_VERTEX_SHADER); + + glShaderSource(vertId, 1, &vertexCode, NULL); + glCompileShader(vertId); + + glGetShaderiv(vertId, GL_COMPILE_STATUS, &succes); + if (!succes) { + glGetShaderInfoLog(vertId, 512, NULL, infoLog); + spdlog::error("Vertex shader has compile error {}", infoLog); + return; + } + + + char* fragmentCode = readFile(fragmentShaderPath.c_str()); + //spdlog::info(fragmentCode); + unsigned int fragId = glCreateShader(GL_FRAGMENT_SHADER); + + + + glShaderSource(fragId, 1, &fragmentCode, NULL); + glCompileShader(fragId); + + + glGetShaderiv(fragId, GL_COMPILE_STATUS, &succes); + if (!succes) { + glGetShaderInfoLog(fragId, 512, NULL, infoLog); + spdlog::error("Fragment shader has compile error {}", infoLog); + return; + } + + id = glCreateProgram(); + + glAttachShader(id, vertId); + glAttachShader(id, fragId); + glLinkProgram(id); + + + int success; + glGetProgramiv(id, GL_LINK_STATUS, &success); + if (!success) { + glGetProgramInfoLog(id, 512, NULL, infoLog); + printf("ERROR::SHADER_PROGRAM::LINKING_FAILED\n %s", infoLog); + } + + + delete vertexCode; + delete fragmentCode; + + + } + + char* Shader::readFile(const char* filePath) { + + spdlog::info("Opening {} ", filePath); + + + std::ifstream file; + file.open(filePath); + + if (file.is_open() == false) { + spdlog::info("File not found."); + return nullptr; + } + + + // Determine the file size! + file.seekg(0, std::ios::end); + size_t filesize = file.tellg(); + + // Undo previous seek. + file.seekg(0, std::ios::beg); + //spdlog::info("filesize: {}", filesize); + + + // Create a big enough buffer for the file + + size_t bufferSize = filesize + 3; + char* FileBuffer = new char[bufferSize]; + + memset(FileBuffer, '\0', bufferSize); + + // read the whole file + file.read(FileBuffer, filesize); + + return FileBuffer; + } + + void Shader::Use() const + { + glUseProgram(id); + } + + + void Shader::setUniformMat4(std::string uniformName, glm::mat4 matrix4) const + { + glUniformMatrix4fv(glGetUniformLocation(id, uniformName.c_str()), 1, GL_FALSE, glm::value_ptr(matrix4)); + } + void Shader::setUniformVec4(std::string uniformName, glm::vec4 vector4) const + { + glUniform4fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector4)); + } + void Shader::setUniformVec3(std::string uniformName, glm::vec3 vector3) const + { + glUniform3fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector3)); + } + void Shader::setUniformVec2(std::string uniformName, glm::vec2 vector2) const + { + glUniform2fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector2)); + } + + void Shader::setUniformFloat(std::string uniformName, float value) const + { + glUniform1f(glGetUniformLocation(id, uniformName.c_str()), value); + } + + void Shader::setUniformInt(std::string uniformName, int value) const + { + glUniform1i(glGetUniformLocation(id, uniformName.c_str()), value); + } +} diff --git a/BarinkEngine/src/Graphics/Primitives/Shader.h b/YoggieEngine/src/Graphics/Primitives/Shader.h similarity index 87% rename from BarinkEngine/src/Graphics/Primitives/Shader.h rename to YoggieEngine/src/Graphics/Primitives/Shader.h index 1f0733d..44099c4 100644 --- a/BarinkEngine/src/Graphics/Primitives/Shader.h +++ b/YoggieEngine/src/Graphics/Primitives/Shader.h @@ -7,11 +7,11 @@ #include #include - -class Shader { +namespace YoggieEngine { + class Shader { private: - - char* readFile (const char* filePath); + + char* readFile(const char* filePath); public: Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath); void Use() const; @@ -20,8 +20,9 @@ class Shader { void setUniformVec3(std::string uniformName, glm::vec3 vector3)const; void setUniformVec2(std::string uniformName, glm::vec2 vector2)const; void setUniformFloat(std::string uniformName, float value)const; - void setUniformInt(std::string uniformName, int value) const ; + void setUniformInt(std::string uniformName, int value) const; int id; -}; \ No newline at end of file + }; +} diff --git a/YoggieEngine/src/Graphics/Primitives/Texture.cpp b/YoggieEngine/src/Graphics/Primitives/Texture.cpp new file mode 100644 index 0000000..7dbf5c9 --- /dev/null +++ b/YoggieEngine/src/Graphics/Primitives/Texture.cpp @@ -0,0 +1,42 @@ +#include "Texture.h" +#include +#include +#define STB_IMAGE_IMPLEMENTATION +#include "../stb_image.h" +#include + +namespace YoggieEngine { + Texture::Texture(const std::string texturePath) { + + int width, height, channels; + unsigned char* data = stbi_load(texturePath.c_str(), &width, &height, &channels, 0); + std::cout << channels << std::endl; + + if (data) { + glGenTextures(1, &Id); + + glBindTexture(GL_TEXTURE_2D, Id); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); + glGenerateMipmap(GL_TEXTURE_2D); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + } + else { + spdlog::error("Failed to load image (%s)", texturePath); + } + stbi_image_free(data); + + } + + void Texture::Bind() { + glBindTexture(GL_TEXTURE_2D, Id); + } + + void Texture::Unbind() { + glBindTexture(GL_TEXTURE_2D, 0); + } +} diff --git a/YoggieEngine/src/Graphics/Primitives/Texture.h b/YoggieEngine/src/Graphics/Primitives/Texture.h new file mode 100644 index 0000000..d1e6cec --- /dev/null +++ b/YoggieEngine/src/Graphics/Primitives/Texture.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include + +namespace YoggieEngine { + class Texture { + public: + Texture(const std::string texturePath); + + void Bind(); + void Unbind(); + + private: + unsigned int Id; + }; +} diff --git a/BarinkEngine/src/Graphics/Primitives/Vertex.h b/YoggieEngine/src/Graphics/Primitives/Vertex.h similarity index 78% rename from BarinkEngine/src/Graphics/Primitives/Vertex.h rename to YoggieEngine/src/Graphics/Primitives/Vertex.h index d7b04a6..9cb2ae4 100644 --- a/BarinkEngine/src/Graphics/Primitives/Vertex.h +++ b/YoggieEngine/src/Graphics/Primitives/Vertex.h @@ -1,7 +1,7 @@ #pragma once #include -namespace BarinkEngine { +namespace YoggieEngine { struct Vertex { glm::vec3 vertices; glm::vec2 uv; diff --git a/YoggieEngine/src/Graphics/RenderSurface.cpp b/YoggieEngine/src/Graphics/RenderSurface.cpp new file mode 100644 index 0000000..805c65b --- /dev/null +++ b/YoggieEngine/src/Graphics/RenderSurface.cpp @@ -0,0 +1,47 @@ +#include "RenderSurface.h"; +namespace YoggieEngine { + RenderSurface::RenderSurface() { + shader = new Shader("build/SandboxAppliction/Debug/renderSuface.vs", "build/SandboxApplication/Debug/renderSurface.fs"); + + + + verts = std::vector{ + {-0.5f, 0.5f, 0.0f}, // 0 + {-0.5f, -0.5f, 0.0f}, // 1 + {0.5f, -0.5f, 0.0f}, // 2 + {0.5f, 0.5f, 0.0f}, // 3 + }; + + indices = std::vector{ + 0,2,1, + 0,3,2 + }; + + VAO.Create(); + VAO.Bind(); + + vertexBuffer.createBuffer(); + vertexBuffer.Bind(false); + vertexBuffer.setBufferData(&verts[0], verts.size() * sizeof(glm::vec3), false); + + elementBuffer.createBuffer(); + elementBuffer.Bind(true); + elementBuffer.setBufferData(&indices[0], indices.size() * sizeof(unsigned int), true); + + VAO.AttachAttribute(0, 3, 0); + + vertexBuffer.Unbind(false); + VAO.Unbind(); + + + + } + + RenderSurface::~RenderSurface() { + delete shader; + } + + void RenderSurface::Draw() { + + } +} diff --git a/YoggieEngine/src/Graphics/RenderSurface.h b/YoggieEngine/src/Graphics/RenderSurface.h new file mode 100644 index 0000000..01f3110 --- /dev/null +++ b/YoggieEngine/src/Graphics/RenderSurface.h @@ -0,0 +1,33 @@ +#pragma once +#include "../BarinkEngine.h" +#include "../Graphics/Memory/Buffer.h" +#include "../Graphics/Memory/VertexArray.h" +#include + +namespace YoggieEngine { + + class RenderSurface + { + public: + RenderSurface(); + ~RenderSurface(); + + void Draw(); + + private: + // would normally be a material + // however rendersurface is special and + // thus does not contain a material + Shader* shader; + + // Basically a mesh + std::vector verts; + std::vector indices; + + Buffer vertexBuffer; + Buffer elementBuffer; + + VertexArray VAO; + }; + +} diff --git a/BarinkEngine/src/Graphics/Renderable.h b/YoggieEngine/src/Graphics/Renderable.h similarity index 79% rename from BarinkEngine/src/Graphics/Renderable.h rename to YoggieEngine/src/Graphics/Renderable.h index fdfce68..609e1f3 100644 --- a/BarinkEngine/src/Graphics/Renderable.h +++ b/YoggieEngine/src/Graphics/Renderable.h @@ -4,10 +4,10 @@ #include "Primitives/Texture.h" #include "../Scene/Scene.h" -namespace BarinkEngine { +namespace YoggieEngine { struct Renderable { - BarinkEngine::Mesh* mesh; + Mesh* mesh; Material* material; Texture* texture; }; diff --git a/BarinkEngine/src/Graphics/Renderer.cpp b/YoggieEngine/src/Graphics/Renderer.cpp similarity index 81% rename from BarinkEngine/src/Graphics/Renderer.cpp rename to YoggieEngine/src/Graphics/Renderer.cpp index 89d7bb6..1edc392 100644 --- a/BarinkEngine/src/Graphics/Renderer.cpp +++ b/YoggieEngine/src/Graphics/Renderer.cpp @@ -4,17 +4,19 @@ #include "../Graphics/Memory/Buffer.h" #include #include + +namespace YoggieEngine { float Angle = 0.0; Camera cam = Camera(glm::vec3(12.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f); glm::mat4 projection = glm::perspective(glm::radians(cam.Zoom), (800.0f / 600.0f), 0.001f, 100.0f); -BarinkEngine::Renderer::Renderer(){} +Renderer::Renderer(){} -BarinkEngine::Renderer::~Renderer(){} +Renderer::~Renderer(){} -void BarinkEngine::Renderer::Prepare(Scene& scene ) { - auto group = scene.getReg().view(); - group.each([](auto enity, BarinkEngine::Render3DComponent& renderComponent) { +void Renderer::Prepare(Scene& scene ) { + auto group = scene.getReg().view(); + group.each([](auto enity, Render3DComponent& renderComponent) { VertexArray va = VertexArray(); Buffer vertexBuffer = Buffer(); Buffer elementBuffer = Buffer(); @@ -24,15 +26,15 @@ void BarinkEngine::Renderer::Prepare(Scene& scene ) { vertexBuffer.createBuffer(); vertexBuffer.Bind(false); - vertexBuffer.setBufferData((void*)&renderComponent.mesh.vertices[0], renderComponent.mesh.vertices.size() * sizeof(BarinkEngine::Vertex), false); + vertexBuffer.setBufferData((void*)&renderComponent.mesh.vertices[0], renderComponent.mesh.vertices.size() * sizeof(Vertex), false); elementBuffer.createBuffer(); elementBuffer.Bind(true); elementBuffer.setBufferData((void*)&renderComponent.mesh.elements[0], renderComponent.mesh.elements.size() * sizeof(unsigned int), true); - va.AttachAttribute(0, 3, sizeof(BarinkEngine::Vertex)); + va.AttachAttribute(0, 3, sizeof(Vertex)); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(BarinkEngine::Vertex), (void*)0); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); @@ -47,7 +49,7 @@ void BarinkEngine::Renderer::Prepare(Scene& scene ) { -void BarinkEngine::Renderer::Render(Scene& scene) +void Renderer::Render(Scene& scene) { auto group = scene.getReg().view(); group.each([&](auto entity , TransformComponent& trans, Render3DComponent& renderComponent) @@ -86,7 +88,7 @@ void BarinkEngine::Renderer::Render(Scene& scene) } -void BarinkEngine::Renderer::Render(Framebuffer& framebuffer, Scene& scene) +void Renderer::Render(Framebuffer& framebuffer, Scene& scene) { glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.GetId()); @@ -100,3 +102,4 @@ void BarinkEngine::Renderer::Render(Framebuffer& framebuffer, Scene& scene) +} \ No newline at end of file diff --git a/BarinkEngine/src/Graphics/Renderer.h b/YoggieEngine/src/Graphics/Renderer.h similarity index 94% rename from BarinkEngine/src/Graphics/Renderer.h rename to YoggieEngine/src/Graphics/Renderer.h index 046f9ab..024073f 100644 --- a/BarinkEngine/src/Graphics/Renderer.h +++ b/YoggieEngine/src/Graphics/Renderer.h @@ -12,7 +12,7 @@ #include "Memory/Framebuffer.h" #include "../Scene/Components.h" -namespace BarinkEngine { +namespace YoggieEngine { class Renderer { public: diff --git a/BarinkEngine/src/Graphics/stb_image.h b/YoggieEngine/src/Graphics/stb_image.h similarity index 100% rename from BarinkEngine/src/Graphics/stb_image.h rename to YoggieEngine/src/Graphics/stb_image.h diff --git a/YoggieEngine/src/Input/InputManager.cpp b/YoggieEngine/src/Input/InputManager.cpp new file mode 100644 index 0000000..54d775a --- /dev/null +++ b/YoggieEngine/src/Input/InputManager.cpp @@ -0,0 +1,119 @@ +#include "InputManager.h" +namespace YoggieEngine { + InputManager InputSystem; + + void InputManager::PollEvents() + { + for (auto it = windows.begin(); it != windows.end(); ++it) { + auto window = *it; + window->Poll(); + + } + } + + void InputManager::KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) + { + + Event KeyEvent{}; + KeyEvent.name = "KEY"; + + InputSystem.EmitEvent(KeyEvent); + + + if (key == GLFW_KEY_A && action == GLFW_PRESS) + { + + std::cout << "'a' key was pressed" << std::endl; + } + + } + + void InputManager::CursorPositionCallback(GLFWwindow* window, double x, double y) + { + //std::cout << "Cursor Position x: " << x << ", y: " << y << std::endl; + Event CursorPosUpdate{}; + CursorPosUpdate.name = "UPDATE::CURSOR:POSITION"; + + InputSystem.EmitEvent(CursorPosUpdate); + + + + } + + void InputManager::CursorEnterCallback(GLFWwindow* window, int entered) + { + if (entered) { + Event mouseEntered {}; + mouseEntered.name = "Mouse Entered Window's confines!"; + mouseEntered.argc = 0; + + InputSystem.EmitEvent(mouseEntered); + + + + } + else { + Event mouseLeft{}; + mouseLeft.name = "Mouse Left Window's confines!"; + mouseLeft.argc = 0; + + InputSystem.EmitEvent(mouseLeft); + + + } + } + + + void InputManager::MouseButtonCallback(GLFWwindow* window, int button, int action, int mods) + { + + Event MouseButtonEvent{}; + MouseButtonEvent.name = "MOUSEBUTTON"; + + InputSystem.EmitEvent(MouseButtonEvent); + + + if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) { + std::cout << "Right mouse button was pressed!" << std::endl; + } + + } + + void InputManager::ScrollCallback(GLFWwindow* window, double xoffset, double yoffset) + { + std::cout << "Scroll: x: " << xoffset << ", y: " << yoffset << std::endl; + + Event ScrollEvent{}; + ScrollEvent.name = "SCROLL"; + + InputSystem.EmitEvent(ScrollEvent); + + + } + + + void InputManager::attach(BarinkWindow* window) + { + + windows.push_back(window); + + // Attach callbacks + glfwSetKeyCallback(window->windowptr(), KeyCallback); + glfwSetCursorPosCallback(window->windowptr(), CursorPositionCallback); + glfwSetCursorEnterCallback(window->windowptr(), CursorEnterCallback); + glfwSetMouseButtonCallback(window->windowptr(), MouseButtonCallback); + glfwSetScrollCallback(window->windowptr(), ScrollCallback); + + this->Subscribe( (EventListener&)(*window)); + + + + } + + InputManager::InputManager() : EventEmitter () + { + windows = std::vector(); + } +} + + diff --git a/BarinkEngine/src/Input/InputManager.h b/YoggieEngine/src/Input/InputManager.h similarity index 91% rename from BarinkEngine/src/Input/InputManager.h rename to YoggieEngine/src/Input/InputManager.h index 1069b94..2c1e0c0 100644 --- a/BarinkEngine/src/Input/InputManager.h +++ b/YoggieEngine/src/Input/InputManager.h @@ -7,7 +7,7 @@ #include "../EventSystem/EventListener.h" #include "../Platform/Window.h" -namespace BarinkEngine { +namespace YoggieEngine { class InputManager : EventEmitter { public: @@ -26,6 +26,5 @@ namespace BarinkEngine { std::vector windows; }; + extern InputManager InputSystem; } - -extern BarinkEngine::InputManager InputSystem; \ No newline at end of file diff --git a/YoggieEngine/src/PerfCounter.cpp b/YoggieEngine/src/PerfCounter.cpp new file mode 100644 index 0000000..72eccbe --- /dev/null +++ b/YoggieEngine/src/PerfCounter.cpp @@ -0,0 +1,70 @@ +#include "PerfCounter.h" +#include +#include +namespace YoggieEngine { + uint64_t EngineInstrumentation::GetPrecisionTime() { + using namespace std::chrono; // REMINDER: This is kinda ugly but safes line width + return duration_cast(high_resolution_clock::now().time_since_epoch()).count(); + } + + void EngineInstrumentation::PerfomanceSamplerInit() { + //ES.frames = 0; + //EngineInstrumentation::lastSampleTime = GetPrecisionTime(); + } + + + + void EngineInstrumentation::Update() { + /* + uint64_t MilliSecondsPast = GetPrecisionTime() - EngineInstrumentation::lastSampleTime; + + if (MilliSecondsPast >= 1000) { + + ES.frameTime = (float)1000 / ES.frames; + ES.FPS = ES.frames; + ES.frames = 0; + //EngineInstrumentation::lastSampleTime = GetPrecisionTime(); + } + */ + + } + + void EngineInstrumentation::ShowStats() { + ImGui::Begin("Statistics", false, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize); + + ImGui::Text("Currently not available"); +/* ImGui::Text("FPS: %i", ES.FPS); + ImGui::Text("Frame Time: %f", ES.frameTime); + ImGui::Text("Verts: %i", ES.verts); + ImGui::Text("Draw Calls: %i", ES.DC); + */ + ImGui::End(); + } + + + PerfSampler::PerfSampler(const std::string& name) + : name(name) + { + using namespace std::chrono; + startTime = high_resolution_clock::now(); + + } + + PerfSampler::~PerfSampler() + { + Stop(); + } + + void PerfSampler::Stop() + { + using namespace std::chrono; + auto end = high_resolution_clock::now(); + auto durationInuSeconds = + duration_cast(end.time_since_epoch()).count() - + duration_cast(startTime.time_since_epoch()).count(); + + auto ms = durationInuSeconds * 0.001f; + + // std::cout << "[" << name << "]" << "Took: " << durationInuSeconds << " us (" << ms << " ms)" << std::endl; + } +} diff --git a/YoggieEngine/src/PerfCounter.h b/YoggieEngine/src/PerfCounter.h new file mode 100644 index 0000000..3aa87ab --- /dev/null +++ b/YoggieEngine/src/PerfCounter.h @@ -0,0 +1,41 @@ +#pragma once +#include +#include +#include + +namespace YoggieEngine { + struct EngineStatistics { + float frameTime; + uint32_t verts; + uint32_t DC; + + int64_t frames; + int64_t FPS; + + }; + + class EngineInstrumentation { + public: + + //static int64_t lastSampleTime; + + static uint64_t GetPrecisionTime(); + static void PerfomanceSamplerInit(); + + static void Update(); + static void ShowStats(); + + }; + + class PerfSampler { + public: + + PerfSampler(const std::string& name); + ~PerfSampler(); + void Stop(); + private: + const std::string& name; + std::chrono::time_point startTime; + }; + +} diff --git a/YoggieEngine/src/Platform/Window.cpp b/YoggieEngine/src/Platform/Window.cpp new file mode 100644 index 0000000..f48673e --- /dev/null +++ b/YoggieEngine/src/Platform/Window.cpp @@ -0,0 +1,88 @@ +#include "Window.h" +namespace YoggieEngine { + bool BarinkWindow::InitGLFW() { + if (!glfwInit()) + { + spdlog::error("Failed to initialise GLFW!"); + return false; + } + + return true; + } + + BarinkWindow::BarinkWindow(const int width, const int height) : + Width(width), Height(height), FullScreen(false) + { + if (InitGLFW() == false) { + exit(-1); + } + + glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); + glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_TRUE); + // No window decorations such as a border, a close widget + // glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); + // glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); + // Disable resizing the window + //glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); + + + window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL); + + if (!window) + { + spdlog::error("GLFW failed to create window!"); + glfwTerminate(); + return; + } + + glfwMakeContextCurrent(window); + if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { + printf("Failed to initialize GLAD!\n"); + exit(-1); + } + + // Set vsync off !! + glfwSwapInterval(0); + + VulkanSupported = glfwVulkanSupported(); + + glfwGetFramebufferSize(window, &Width, &Height); + glViewport(0, 0, Width, Height); + + + + glClearColor(0.2f, 0.2f, 0.2f, 1.0f); + + } + + BarinkWindow::~BarinkWindow() { + + glfwTerminate(); + } + + GLFWwindow* BarinkWindow::windowptr() + { + return window; + } + + bool BarinkWindow::WindowShouldClose() { + return glfwWindowShouldClose(window); + } + + void BarinkWindow::Poll() + { + glfwPollEvents(); + } + + void BarinkWindow::SwapBuffers() + { + glfwSwapBuffers(window); + } + + void BarinkWindow::ReceiveEvent(Event& incident) + { + //std::cout << "EVENT RECEIVED: " << incident.name << std::endl; + } + + +} diff --git a/BarinkEngine/src/Platform/Window.h b/YoggieEngine/src/Platform/Window.h similarity index 82% rename from BarinkEngine/src/Platform/Window.h rename to YoggieEngine/src/Platform/Window.h index 072f847..792f6fd 100644 --- a/BarinkEngine/src/Platform/Window.h +++ b/YoggieEngine/src/Platform/Window.h @@ -11,8 +11,8 @@ #include "../EventSystem/Event.h" #include "../EventSystem/EventListener.h" - -class BarinkWindow : EventListener { +namespace YoggieEngine { + class BarinkWindow : EventListener { private: GLFWwindow* window; bool FullScreen; @@ -27,11 +27,12 @@ class BarinkWindow : EventListener { GLFWwindow* windowptr(); - void ReceiveEvent(Event& incident) override ; + void ReceiveEvent(Event& incident) override; bool WindowShouldClose(); void Poll(); void SwapBuffers(); -}; \ No newline at end of file + }; +} diff --git a/BarinkEngine/src/Scene/Components.h b/YoggieEngine/src/Scene/Components.h similarity index 97% rename from BarinkEngine/src/Scene/Components.h rename to YoggieEngine/src/Scene/Components.h index 6f8da69..106703c 100644 --- a/BarinkEngine/src/Scene/Components.h +++ b/YoggieEngine/src/Scene/Components.h @@ -2,7 +2,7 @@ #include #include "../Graphics/Primitives/Shader.h" #include "../Graphics/Primitives/Mesh.h" -namespace BarinkEngine { +namespace YoggieEngine { struct IdentifierComponent { std::string name; }; diff --git a/YoggieEngine/src/Scene/Entity.cpp b/YoggieEngine/src/Scene/Entity.cpp new file mode 100644 index 0000000..f33f537 --- /dev/null +++ b/YoggieEngine/src/Scene/Entity.cpp @@ -0,0 +1,10 @@ +#include "Entity.h" + +namespace YoggieEngine { + Entity::Entity(entt::entity e, Scene* scene) + : m_entity(e), m_scene(scene) + { + } + +} + diff --git a/YoggieEngine/src/Scene/Entity.h b/YoggieEngine/src/Scene/Entity.h new file mode 100644 index 0000000..26842c7 --- /dev/null +++ b/YoggieEngine/src/Scene/Entity.h @@ -0,0 +1,40 @@ +#pragma once +#include +namespace YoggieEngine { + class Scene; + class Entity { + public: + Entity() = default; + Entity(entt::entity e, Scene* scene); + Entity(const Entity& other) = default; + + template + T& AddComponent() { + return m_scene->m_registry.emplace(m_entity); + } + + template + T& GetComponent() { + return m_scene->m_registry.get(m_entity); + } + + + template + bool HasComponent() { + return m_scene->getReg().all_of(m_entity); + } + + + + // NOTE: Not Scene context aware!! + bool operator== (Entity& other) { + return m_entity == other.m_entity; + } + + private: + entt::entity m_entity; + Scene* m_scene; + + }; + +} diff --git a/YoggieEngine/src/Scene/Scene.cpp b/YoggieEngine/src/Scene/Scene.cpp new file mode 100644 index 0000000..2e58126 --- /dev/null +++ b/YoggieEngine/src/Scene/Scene.cpp @@ -0,0 +1,25 @@ +#include "Scene.h" +#include "Entity.h" +#include "Components.h" + +namespace YoggieEngine{ + Scene::Scene() + { + } + + Scene::~Scene() + {} + + Entity Scene::AddEntity(std::string name) + { + Entity entity = { m_registry.create(), this }; + + auto& ident = entity.AddComponent(); + ident.name = name; + entity.AddComponent(); + + + return entity; + } + +} diff --git a/YoggieEngine/src/Scene/Scene.h b/YoggieEngine/src/Scene/Scene.h new file mode 100644 index 0000000..82ca5b8 --- /dev/null +++ b/YoggieEngine/src/Scene/Scene.h @@ -0,0 +1,22 @@ +#pragma once +#include +#include +namespace YoggieEngine { + class Entity; + class Scene + { + public: + Scene(); + ~Scene(); + + Entity AddEntity(std::string name); + + entt::registry& getReg() { return m_registry; } + + private: + entt::registry m_registry; + + friend class Entity; + }; + +} diff --git a/YoggieEngine/src/Scene/TransformTree/Node.cpp b/YoggieEngine/src/Scene/TransformTree/Node.cpp new file mode 100644 index 0000000..ae6e5ed --- /dev/null +++ b/YoggieEngine/src/Scene/TransformTree/Node.cpp @@ -0,0 +1,9 @@ +#include "Node.h" + +namespace YoggieEngine { + Node::Node(const std::string& name) + : name(name), parent(nullptr), children(std::vector()) {} + + Group::Group(const std::string& name) + : Node(name) {} +} \ No newline at end of file diff --git a/BarinkEngine/src/Scene/TransformTree/Node.h b/YoggieEngine/src/Scene/TransformTree/Node.h similarity index 61% rename from BarinkEngine/src/Scene/TransformTree/Node.h rename to YoggieEngine/src/Scene/TransformTree/Node.h index 4f73f0c..0b33f7d 100644 --- a/BarinkEngine/src/Scene/TransformTree/Node.h +++ b/YoggieEngine/src/Scene/TransformTree/Node.h @@ -1,8 +1,8 @@ #pragma once #include #include - -class Node { +namespace YoggieEngine { + class Node { public: Node(const std::string& name); std::string name; @@ -11,12 +11,14 @@ class Node { void addChild(Node& node); -}; + }; -class Group : public Node { -public: - Group(const std::string& name); + class Group : public Node { + public: + Group(const std::string& name); -}; + }; + +} diff --git a/YoggieEngine/src/Scene/TransformTree/SceneNodeTypes.cpp b/YoggieEngine/src/Scene/TransformTree/SceneNodeTypes.cpp new file mode 100644 index 0000000..a2393d4 --- /dev/null +++ b/YoggieEngine/src/Scene/TransformTree/SceneNodeTypes.cpp @@ -0,0 +1,13 @@ +#include "SceneNodeTypes.h" +namespace YoggieEngine { + SceneCamera::SceneCamera() + : Group(std::string("Camera")), camera(Camera(glm::vec3(0.0f), glm::vec3(0.0f), 0)) + {} + + SceneObject::SceneObject(std::string name, Renderable* visual) + : Group(name), renderable(visual) + {} + + SceneObject::~SceneObject() + {} +} diff --git a/BarinkEngine/src/Scene/TransformTree/SceneNodeTypes.h b/YoggieEngine/src/Scene/TransformTree/SceneNodeTypes.h similarity index 93% rename from BarinkEngine/src/Scene/TransformTree/SceneNodeTypes.h rename to YoggieEngine/src/Scene/TransformTree/SceneNodeTypes.h index a6c5d1e..3e35349 100644 --- a/BarinkEngine/src/Scene/TransformTree/SceneNodeTypes.h +++ b/YoggieEngine/src/Scene/TransformTree/SceneNodeTypes.h @@ -3,7 +3,7 @@ #include "../../Graphics/Renderable.h" #include "Node.h" -namespace BarinkEngine { +namespace YoggieEngine { class SceneCamera : public Group { public: diff --git a/YoggieEngine/src/Scripting/LuaScript.cpp b/YoggieEngine/src/Scripting/LuaScript.cpp new file mode 100644 index 0000000..32b2420 --- /dev/null +++ b/YoggieEngine/src/Scripting/LuaScript.cpp @@ -0,0 +1,13 @@ +#include "LuaScript.h" +/* +namespace YoggieEngine { + LuaScript::LuaScript(const std::string& path) + : filePath(path) { + } + + void LuaScript::execute(lua_State& l) + { + luaL_dofile(&l, filePath.c_str()); + } +} +*/ \ No newline at end of file diff --git a/YoggieEngine/src/Scripting/LuaScript.h b/YoggieEngine/src/Scripting/LuaScript.h new file mode 100644 index 0000000..cd094cf --- /dev/null +++ b/YoggieEngine/src/Scripting/LuaScript.h @@ -0,0 +1,29 @@ +#pragma once +#include + +extern "C" +{ + #include "lauxlib.h" + #include "lua.h" + #include "lualib.h" +} + + +#include "LuaScriptingManager.h" + + +/* +namespace YoggieEngine { + class LuaScript { + public: + + LuaScript(const std::string&); + void execute(lua_State& l); + + private: + std::string filePath; + + }; + +} +*/ \ No newline at end of file diff --git a/YoggieEngine/src/Scripting/LuaScriptingManager.cpp b/YoggieEngine/src/Scripting/LuaScriptingManager.cpp new file mode 100644 index 0000000..8a2b476 --- /dev/null +++ b/YoggieEngine/src/Scripting/LuaScriptingManager.cpp @@ -0,0 +1,21 @@ +#include "LuaScriptingManager.h" +/* +namespace YoggieEngine { + LuaScriptingManager::LuaScriptingManager() + { + L = luaL_newstate(); + luaL_openlibs(L); + } + + + void LuaScriptingManager::ExecuteLuaString(const std::string& code) { + luaL_dostring(L, code.c_str()); + } + + lua_State& LuaScriptingManager::getState() + { + return (*L); + } + +} +*/ \ No newline at end of file diff --git a/YoggieEngine/src/Scripting/LuaScriptingManager.h b/YoggieEngine/src/Scripting/LuaScriptingManager.h new file mode 100644 index 0000000..4c19915 --- /dev/null +++ b/YoggieEngine/src/Scripting/LuaScriptingManager.h @@ -0,0 +1,31 @@ +#pragma once +#include + +extern "C" +{ + #include "lauxlib.h" + #include "lua.h" + #include "lualib.h" +} + + +#include "LuaScript.h" + +/* +namespace YoggieEngine { + class LuaScriptingManager + { + public: + std::vector scripts; + + LuaScriptingManager(); + + void ExecuteLuaString(const std::string&); + + private: + lua_State* L; + + lua_State& getState(); + }; +} +*/ \ No newline at end of file diff --git a/BarinkEngine/src/Shaders/RenderSurfaceFrag.shader b/YoggieEngine/src/Shaders/RenderSurfaceFrag.shader similarity index 100% rename from BarinkEngine/src/Shaders/RenderSurfaceFrag.shader rename to YoggieEngine/src/Shaders/RenderSurfaceFrag.shader diff --git a/BarinkEngine/src/Shaders/RenderSurfaceVert.shader b/YoggieEngine/src/Shaders/RenderSurfaceVert.shader similarity index 100% rename from BarinkEngine/src/Shaders/RenderSurfaceVert.shader rename to YoggieEngine/src/Shaders/RenderSurfaceVert.shader diff --git a/BarinkEngine/src/Shaders/fragment.shader b/YoggieEngine/src/Shaders/fragment.shader similarity index 100% rename from BarinkEngine/src/Shaders/fragment.shader rename to YoggieEngine/src/Shaders/fragment.shader diff --git a/BarinkEngine/src/Shaders/vertex.shader b/YoggieEngine/src/Shaders/vertex.shader similarity index 100% rename from BarinkEngine/src/Shaders/vertex.shader rename to YoggieEngine/src/Shaders/vertex.shader diff --git a/buildSolution.bat b/buildSolution.bat new file mode 100644 index 0000000..eb95ee9 --- /dev/null +++ b/buildSolution.bat @@ -0,0 +1,11 @@ +@echo off +echo Clean up .. +REM Does nothing for now +REM In the future we might want to remove certain files, if they exist, when re-generating the solution +echo Creating Solution for Yoggie engine... + +.\tools\premake5.exe vs2022 + + + +pause \ No newline at end of file diff --git a/libraries.lua b/libraries.lua new file mode 100644 index 0000000..aa86f74 --- /dev/null +++ b/libraries.lua @@ -0,0 +1,31 @@ +incfolder = {} + +--Utils +incfolder["spdlog"] = "%{wks.location}/libs/spdlog/include" +incfolder["assimp"] = "%{wks.location}/libs/assimp/include" +incfolder["glm"] = "%{wks.location}/libs/glm" +incfolder["entt"] = "%{wks.location}/libs/entt/src" + +-- Graphics +incfolder["glad"] = "%{wks.location}/libs/glad/include" +incfolder["glfw"] = "%{wks.location}/libs/glfw/include" +incfolder["glew"] = "%{wks.location}/libs/glew/include" +-- Physics + +-- Scripting +incfolder["lua"] = "%{wks.location}/libs/lua/include" + + +-- Audio +incfolder["gorillaaudio"] = "%{wks.location}/libs/GorillaAudio/include" + +-- Immediate Mode GUI +incfolder["imgui"] = "%{wks.location}/libs/ImGui" +incfolder["imguizmo"] = "%{wks.location}/libs/guizmo" + +staticlib = {} + +staticlib["yoggie"] = "Yoggie/build/Debug" + + + diff --git a/libs/tinygltf b/libs/tinygltf deleted file mode 160000 index a159945..0000000 --- a/libs/tinygltf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a159945db9d97e79a30cb34e2aaa45fd28dea576 diff --git a/premake5.lua b/premake5.lua index 4661855..8d835f2 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,4 +1,7 @@ -workspace "BarinkEngine" +include("libraries") +print("Using Premake version ", _PREMAKE_VERSION) + +workspace "Yoggie GameEngine" configurations { "Debug", "Test", "Release" } language "C++" @@ -8,7 +11,7 @@ workspace "BarinkEngine" targetdir "./%{prj.name}/build/%{cfg.buildcfg}" objdir "./%{prj.name}/build/%{cfg.buildcfg}/intermediates/" - startproject("SandboxApp") + startproject("Editor") filter "configurations:Debug" defines {"DEBUG"} @@ -19,7 +22,16 @@ workspace "BarinkEngine" optimize "On" -include("./BarinkEngine") -include("./Runtime") +include("./YoggieEngine") include ("./Editor") -include("./SandboxApp") + + +group("Other") + includeexternal("./SandboxApp") + includeexternal("./Runtime") + + + +group("Libraries") + include('../ImGui') + include("../ImGuizmo")