diff --git a/.gitmodules b/.gitmodules index c3b7a0a..0ddec11 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,9 @@ [submodule "assimp"] path = libs/assimp url = https://github.com/assimp/assimp.git +[submodule "libs/steam-audio"] + path = libs/steam-audio + url = https://github.com/ValveSoftware/steam-audio.git +[submodule "libs/physx"] + path = libs/physx + url = https://git.barink.dev/Nigel/PhysX.git diff --git a/BarinkEngine/BarinkEngine.cpp b/BarinkEngine/BarinkEngine.cpp index 5f1b339..9c67a48 100644 --- a/BarinkEngine/BarinkEngine.cpp +++ b/BarinkEngine/BarinkEngine.cpp @@ -1,57 +1,59 @@ -#include "BarinkEngine.h" - -EngineStatistics* ES; - - -int main(int argc, char* argv[]) { - // Setup performance sampler - PerfomanceSamplerInit(); - - - // Startup services - BarinkWindow MainWindow = BarinkWindow(800, 600); - - BarinkEngine::Renderer renderer = BarinkEngine::Renderer(); - BarinkEngine::InputManager InputSystem = BarinkEngine::InputManager(); - - InputSystem.attach(&MainWindow); - - GUIManager GUISystem = GUIManager(&MainWindow); - - // First call to setup game - Start(); - - - // Runtime loop - while (!MainWindow.WindowShouldClose()) { - - SamplePerformance(); - - - // Execute main logic - InputSystem.PollEvents(); - - Update(); - - renderer.Render(); - - ImmediateGraphicsDraw(); - - GUISystem.Render(); - - - - MainWindow.SwapBuffers(); - } - - - // Shutdown game - Stop(); - - - // Shutdown Services - delete ES; - - return 0; -} - +#include "BarinkEngine.h" +#include + +EngineStatistics* ES; + +int main(int argc, char* argv[]) { + // Setup performance sampler + PerfomanceSamplerInit(); + + + // Startup services + BarinkWindow MainWindow = BarinkWindow(800, 600); + + BarinkEngine::Renderer renderer = BarinkEngine::Renderer(); + BarinkEngine::InputManager InputSystem = BarinkEngine::InputManager(); + + InputSystem.attach(&MainWindow); + + GUIManager GUISystem = GUIManager(&MainWindow); + + + + // First call to setup game + Start(); + + + // Runtime loop + while (!MainWindow.WindowShouldClose()) { + + SamplePerformance(); + + + // Execute main logic + InputSystem.PollEvents(); + + Update(); + + renderer.Render(); + + ImmediateGraphicsDraw(); + + GUISystem.Render(); + + + + MainWindow.SwapBuffers(); + } + + + // Shutdown game + Stop(); + + + // Shutdown Services + delete ES; + + return 0; +} + diff --git a/BarinkEngine/Include/BarinkEngine.h b/BarinkEngine/Include/BarinkEngine.h index 8ea66b0..7e1ddbd 100644 --- a/BarinkEngine/Include/BarinkEngine.h +++ b/BarinkEngine/Include/BarinkEngine.h @@ -1,18 +1,20 @@ -#pragma once -#include "glm/glm.hpp" -#include "graphics/Shader.h" -#include "graphics/Window.h" -#include "graphics/Camera.h" -#include "graphics/Renderable.h" -#include "spdlog/spdlog.h" - -#include "Input/InputManager.h" -#include "Graphics/Renderer.h" -#include "Graphics/GUI/GUIManager.h" -#include "Scene.h" -#include "PerfCounter.h" - -extern void Start(); -extern void Update(); -extern void ImmediateGraphicsDraw(); -extern void Stop(); +#pragma once +#include "glm/glm.hpp" +#include "graphics/Shader.h" +#include "graphics/Window.h" +#include "graphics/Camera.h" +#include "graphics/Renderable.h" +#include "Graphics/Material.h" +#include "spdlog/spdlog.h" + +#include "Input/InputManager.h" +#include "Graphics/Renderer.h" +#include "Graphics/GUI/GUIManager.h" +#include "Scene.h" +#include "PerfCounter.h" + + +extern void Start(); +extern void Update(); +extern void ImmediateGraphicsDraw(); +extern void Stop(); diff --git a/BarinkEngine/Include/Graphics/Material.h b/BarinkEngine/Include/Graphics/Material.h new file mode 100644 index 0000000..58e92ce --- /dev/null +++ b/BarinkEngine/Include/Graphics/Material.h @@ -0,0 +1,19 @@ +#pragma once +#include +#include +#include "Shader.h" + +class Material { +public: + Material(const Shader& shader); + + void Apply(); + + glm::vec3 Color; + + +private: + const Shader& shader; + + +}; \ No newline at end of file diff --git a/BarinkEngine/Include/Graphics/RenderSurface.h b/BarinkEngine/Include/Graphics/RenderSurface.h new file mode 100644 index 0000000..23cfbf9 --- /dev/null +++ b/BarinkEngine/Include/Graphics/RenderSurface.h @@ -0,0 +1,30 @@ +#pragma once +#include "BarinkEngine.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/Include/Graphics/Renderable.h b/BarinkEngine/Include/Graphics/Renderable.h index 06e9695..ae6ada3 100644 --- a/BarinkEngine/Include/Graphics/Renderable.h +++ b/BarinkEngine/Include/Graphics/Renderable.h @@ -1,21 +1,33 @@ -#pragma once -#include -#include "Mesh.h" -#include "Buffer.h" -#include "VertexArray.h" -#include "Scene.h" - -class Renderable : public SceneNode { -public: - Buffer vertexBuffer; - Buffer elementBuffer; - VertexArray VAO; - ~Renderable(); - - static Renderable* Load(); - void Draw(); - -private: - std::vector meshes; - Renderable(); +#pragma once +#include +#include "Mesh.h" +#include "Buffer.h" +#include "Material.h" +#include "VertexArray.h" +#include "Scene.h" + + +class Renderable : public SceneNode { +public: + /* + * NOTE: Should combine into a Mesh!! + */ + Buffer vertexBuffer; + Buffer elementBuffer; + VertexArray VAO; + + + Material* material; + + + Shader* shader; + + ~Renderable(); + + static Renderable* Load(); + void Draw(); + +private: + std::vector meshes; + Renderable(); }; \ No newline at end of file diff --git a/BarinkEngine/Include/Graphics/Shader.h b/BarinkEngine/Include/Graphics/Shader.h index f2985f1..e6dcad0 100644 --- a/BarinkEngine/Include/Graphics/Shader.h +++ b/BarinkEngine/Include/Graphics/Shader.h @@ -15,12 +15,12 @@ class Shader { public: Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath); void Use(); - void setUniformMat4(std::string uniformName, glm::mat4 matrix4); - void setUniformVec4(std::string uniformName, glm::vec4 vector4); - void setUniformVec3(std::string uniformName, glm::vec3 vector3); - void setUniformVec2(std::string uniformName, glm::vec2 vector2); - void setUniformFloat(std::string uniformName, float value); - void setUniformInt(std::string uniformName, int value); + void setUniformMat4(std::string uniformName, glm::mat4 matrix4)const; + void setUniformVec4(std::string uniformName, glm::vec4 vector4)const; + 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 ; }; \ No newline at end of file diff --git a/BarinkEngine/Input/InputManager.cpp b/BarinkEngine/Input/InputManager.cpp index 66b5336..c823c65 100644 --- a/BarinkEngine/Input/InputManager.cpp +++ b/BarinkEngine/Input/InputManager.cpp @@ -1,19 +1,18 @@ -#include "Input/InputManager.h" - -void BarinkEngine::InputManager::PollEvents() -{ - - for (std::vector::iterator it = windows.begin(); it != windows.end(); ++it) { - (*it)->Poll(); - } -} - -void BarinkEngine::InputManager::attach(BarinkWindow* window) -{ - windows.push_back(window); -} - -BarinkEngine::InputManager::InputManager() -{ - windows = std::vector(); -} +#include "Input/InputManager.h" + +void BarinkEngine::InputManager::PollEvents() +{ + for (std::vector::iterator it = windows.begin(); it != windows.end(); ++it) { + (*it)->Poll(); + } +} + +void BarinkEngine::InputManager::attach(BarinkWindow* window) +{ + windows.push_back(window); +} + +BarinkEngine::InputManager::InputManager() +{ + windows = std::vector(); +} diff --git a/BarinkEngine/graphics/Material.cpp b/BarinkEngine/graphics/Material.cpp new file mode 100644 index 0000000..8951ad6 --- /dev/null +++ b/BarinkEngine/graphics/Material.cpp @@ -0,0 +1,10 @@ +#include "../Include/Graphics/Material.h" + +Material::Material(const Shader& shader) : +shader(shader) { +} + + +void Material::Apply() { + shader.setUniformVec3("Color", Color); +} \ No newline at end of file diff --git a/BarinkEngine/graphics/RenderSurface.cpp b/BarinkEngine/graphics/RenderSurface.cpp new file mode 100644 index 0000000..bda3c2e --- /dev/null +++ b/BarinkEngine/graphics/RenderSurface.cpp @@ -0,0 +1,46 @@ +#include "Graphics/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/graphics/Renderer.cpp b/BarinkEngine/graphics/Renderer.cpp index 38f3b30..c3b4d30 100644 --- a/BarinkEngine/graphics/Renderer.cpp +++ b/BarinkEngine/graphics/Renderer.cpp @@ -1,24 +1,25 @@ -#include "Graphics/Renderer.h" - -BarinkEngine::Renderer::Renderer() -{ - models = std::vector(); -} - -BarinkEngine::Renderer::~Renderer() -{ - // CleanUp! -} - -void BarinkEngine::Renderer::Render() -{ - for (auto model : models) { - model->Draw(); - } - -} - -void BarinkEngine::Renderer::Submit(Renderable* model) -{ - models.push_back(model); -} +#include "Graphics/Renderer.h" + +BarinkEngine::Renderer::Renderer() +{ + models = std::vector(); +} + +BarinkEngine::Renderer::~Renderer() +{ + // CleanUp! +} + +void BarinkEngine::Renderer::Render() +{ + + for (auto model : models) { + model->Draw(); + } + +} + +void BarinkEngine::Renderer::Submit(Renderable* model) +{ + models.push_back(model); +} diff --git a/BarinkEngine/graphics/Shader.cpp b/BarinkEngine/graphics/Shader.cpp index 22f8720..4af6cff 100644 --- a/BarinkEngine/graphics/Shader.cpp +++ b/BarinkEngine/graphics/Shader.cpp @@ -96,29 +96,29 @@ void Shader::Use() } -void Shader::setUniformMat4(std::string uniformName, glm::mat4 matrix4) +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) +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) +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) +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) +void Shader::setUniformFloat(std::string uniformName, float value) const { glUniform1f(glGetUniformLocation(id, uniformName.c_str()), value); } -void Shader::setUniformInt(std::string uniformName, int 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/graphics/shaders/RenderSurfaceFrag.shader b/BarinkEngine/graphics/shaders/RenderSurfaceFrag.shader new file mode 100644 index 0000000..c543573 --- /dev/null +++ b/BarinkEngine/graphics/shaders/RenderSurfaceFrag.shader @@ -0,0 +1,11 @@ +#version 440 core +layout (location = 0) in vec2 aPos; +layout (location = 1) in vec2 aTexCoords; + + +out vec2 aTexCoords; + +void main(){ + gl_Position = vec4(aPos.xy , 0.0 ,1.0); + aTexCoords = aTexCoords; +} \ No newline at end of file diff --git a/BarinkEngine/graphics/shaders/RenderSurfaceVert.shader b/BarinkEngine/graphics/shaders/RenderSurfaceVert.shader new file mode 100644 index 0000000..be5b98c --- /dev/null +++ b/BarinkEngine/graphics/shaders/RenderSurfaceVert.shader @@ -0,0 +1,11 @@ +#version 440 core +out vec4 FragColor; + +in vec2 TexCoords; + +uniform sampler2D screenTexture; + + +void main(){ + FragColor = texture(screenTexture, aTexCoords); +} \ No newline at end of file diff --git a/BarinkEngine/graphics/window.cpp b/BarinkEngine/graphics/window.cpp index f4990cf..6306d85 100644 --- a/BarinkEngine/graphics/window.cpp +++ b/BarinkEngine/graphics/window.cpp @@ -1,73 +1,76 @@ -#include "Graphics/Window.h" -#include -#include -#include -#include - - -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); - } - - 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); - } - - 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); +#include "Graphics/Window.h" +#include +#include +#include +#include + + +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); + } + + 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); } \ No newline at end of file diff --git a/BarinkEngine/premake5.lua b/BarinkEngine/premake5.lua index 3702f58..905219d 100644 --- a/BarinkEngine/premake5.lua +++ b/BarinkEngine/premake5.lua @@ -1,58 +1,69 @@ -project "BarinkEngine" - kind "StaticLib" - - buildmessage "Building BarinkEngine" - - includedirs { - "Include/", - - "../libs/lua/include", - "../libs/spdlog/include", - "../libs/glm", - "../libs/GorillaAudio/include", - - "../libs/assimp/include", - "../libs/glad/include", - "../libs/glfw/include", - "../libs/tinygltf", - "../libs/glew/include", - "../libs/glm", - "../libs/ImGui", - - } - - libdirs { - "../libs/lua", - "../libs/spdlog/build/Release", - "../libs/assimp/lib/Debug", - "../libs/glfw/build/src/Debug", - "../libs/ImGui" - } - - links { - "lua54", - "spdlog", - "assimp-vc143-mtd", - "glfw3" - } - - files { - "../libs/ImGui/*.cpp", - "../libs/ImGui/backends/imgui_impl_glfw.cpp", - "../libs/ImGui/backends/imgui_impl_Opengl3.cpp", - "../libs/glad/src/glad.c", - - "./*.cpp", - "./*.h", - "./**/*.cpp", - "./**/*.h" - } - - - - -- NOTE: make these copy instructions more flexible - ok, err = os.copyfile("graphics/shaders/fragment.shader", "../build/SandboxApplication/Debug/test.fs") - if err then error("Copy fragment shader source failed!") end - - ok, err = os.copyfile("graphics/shaders/vertex.shader", "../build/SandboxApplication/Debug/test.vs") - if err then error("Copy vertex shader source failed!") end +project "BarinkEngine" + kind "StaticLib" + + buildmessage "Building BarinkEngine" + + includedirs { + "Include/", + + "../libs/lua/include", + "../libs/spdlog/include", + "../libs/glm", + "../libs/GorillaAudio/include", + + "../libs/physx/physx/include", + "../libs/steam-audio/include", + "../libs/assimp/include", + "../libs/glad/include", + "../libs/glfw/include", + "../libs/tinygltf", + "../libs/glew/include", + "../libs/glm", + "../libs/ImGui", + + } + + libdirs { + "../libs/steam-audio/lib/windows-x64", + "../libs/lua", + "../libs/spdlog/build/Release", + "../libs/assimp/lib/Debug", + "../libs/glfw/build/src/Debug", + "../libs/ImGui" + } + + links { + "phonon", + "lua54", + "spdlog", + "assimp-vc143-mtd", + "glfw3" + } + + files { + "../libs/ImGui/*.cpp", + "../libs/ImGui/backends/imgui_impl_glfw.cpp", + "../libs/ImGui/backends/imgui_impl_Opengl3.cpp", + "../libs/glad/src/glad.c", + + "./*.cpp", + "./*.h", + "./**/*.cpp", + "./**/*.h" + } + + + + -- NOTE: make these copy instructions more flexible + ok, err = os.copyfile("graphics/shaders/fragment.shader", "../build/SandboxApplication/Debug/test.fs") + if err then error("Copy fragment shader source failed!") end + + ok, err = os.copyfile("graphics/shaders/vertex.shader", "../build/SandboxApplication/Debug/test.vs") + if err then error("Copy vertex shader source failed!") end + + ok, err = os.copyfile("graphics/shaders/RenderSurfaceFrag.shader", "../build/SandboxApplication/Debug/RenderSurface.fs") + if err then error("Copy fragment shader source failed!") end + + ok, err = os.copyfile("graphics/shaders/RenderSurfaceVert.shader", "../build/SandboxApplication/Debug/RenderSurface.vs") + if err then error("Copy vertex shader source failed!") end + diff --git a/SandboxApplication/GUI.cpp b/SandboxApplication/GUI.cpp index e10bfea..b9873ef 100644 --- a/SandboxApplication/GUI.cpp +++ b/SandboxApplication/GUI.cpp @@ -1,31 +1,35 @@ -#include "GUI.h" - -void CameraTool(Camera* cam) { - - ImGui::Begin("Camera"); - - ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190); - - ImGui::End(); -} - -void ScriptingTool(char* code) { - ImGui::Begin("Scripting"); - - ImGui::InputTextMultiline("Lua Script", code, 255); - bool runCode = ImGui::Button("Run"); - - - ImGui::End(); - -} - - -void transformWindow(Transform& transform, std::string PanelName) { - ImGui::Begin(PanelName.c_str()); - ImGui::InputFloat3("Position:", (float*)&transform.Position[0]); - ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]); - ImGui::InputFloat3("Scale:", (float*)&transform.Scale[0]); - ImGui::End(); - +#include "GUI.h" + +void CameraTool(Camera* cam) { + + ImGui::Begin("Camera"); + + ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190); + + ImGui::InputFloat3("Position:", &cam->Position[0]); + + ImGui::InputFloat3("Rotation:", &cam->Rotation[0]); + + ImGui::End(); +} + +void ScriptingTool(char* code) { + ImGui::Begin("Scripting"); + + ImGui::InputTextMultiline("Lua Script", code, 255); + bool runCode = ImGui::Button("Run"); + + + ImGui::End(); + +} + + +void transformWindow(Transform& transform, std::string PanelName) { + ImGui::Begin(PanelName.c_str()); + ImGui::InputFloat3("Position:", (float*)&transform.Position[0]); + ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]); + ImGui::InputFloat3("Scale:", (float*)&transform.Scale[0]); + ImGui::End(); + } \ No newline at end of file diff --git a/SandboxApplication/Sandbox.cpp b/SandboxApplication/Sandbox.cpp index 47a5b5f..e0a7cbc 100644 --- a/SandboxApplication/Sandbox.cpp +++ b/SandboxApplication/Sandbox.cpp @@ -1,143 +1,155 @@ -#include "BarinkEngine.h" -#include "imgui.h" -#include "GUI.h" -#include "Util.h" - -/* -* Define globals -*/ -Camera* cam; -Renderable* Cube; -Renderable* Cube2; - -Shader* shader; - -char* code = new char[254]; - -const std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs"; -const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs"; - -/* -* Runs once at startup -* - USe to initialize the game/sandbox/demo -*/ -void Start() { - - /* - Building a very basic scene graph - */ - SceneNode MyCube = SceneNode(); - MyCube.name = "MyCube"; - - SceneNode MyBaby = SceneNode(); - MyBaby.name = "Baby"; - - SceneNode MySecondCube = SceneNode(); - MySecondCube.name = "MySecondCube"; - - - MyCube.addChild(MyBaby); - - - Scene scene = Scene("My awesome Game Scene"); - scene.GetRoot().addChild(MyCube); - scene.GetRoot().addChild(MySecondCube); - - - // Walk scene graph - PrintSceneTree(scene.GetRoot(),0); - - - shader = new Shader(vertexShaderSource, fragmentShaderSource); - - - /* - * load meshes - */ - Cube = Renderable::Load(); - Cube2 = Renderable::Load(); - Cube->addChild(*Cube2); - - cam = new Camera(glm::vec3(0.0f, 1.5f, -10.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f); - - memset(code, '\0', 254); - -} - - -/* -* Runs every frame -* - Use to draw Immediate mode graphics (Not meant for HUD's ) -*/ -void ImmediateGraphicsDraw() { - ImGui::NewFrame(); - - // Show ImGui demo such that I can easily look - // at possible GUI elements to use - ImGui::ShowDemoWindow(); - - - // Show internal BarinkEngine stats - ShowStats(); - - - // Show different tooling for this specific sandbox - CameraTool(cam); - ScriptingTool(code); - - transformWindow(Cube->transform, "Transform (Cube)"); - - transformWindow(Cube2->transform, "Transform (Cube2)"); - - - -} - -/* -* Runs every frame -* - Meant for game logic ( non-physics related) -*/ -void Update() -{ - - - /* - * NOTE: this needs to move to the renderer - * Render code should not appear in the sandbox file - */ - glm::mat4 projection = glm::perspective(glm::radians(cam->Zoom), (800.0f / 600.0f), 0.001f, 100.0f); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - - shader->Use(); - shader->setUniformMat4("P", projection); - shader->setUniformMat4("M", CalculateModelMat(Cube->transform)); - shader->setUniformMat4("V", cam->GetViewMatrix()); - shader->setUniformVec3("MatColour", glm::vec3(1.0f, 0.0f, 0.0f)); - - Cube->Draw(); - - shader->setUniformMat4("M", CalculateModelMat(Cube2->transform)); - shader->setUniformVec3("MatColour", glm::vec3(0.0f, 1.0f, 0.0f)); - - Cube2->Draw(); - -} - -/* -* Runs at the end of the program -* - Meant for cleanup -*/ -void Stop() { - // Cleanup - Cube->VAO.Delete(); - Cube->elementBuffer.Delete(); - - Cube2->VAO.Delete(); - Cube2->elementBuffer.Delete(); - - delete Cube2; - delete Cube; - - delete shader; +#include "BarinkEngine.h" +#include "imgui.h" +#include "GUI.h" +#include "Util.h" + +/* +* Define globals +*/ +Camera* cam; +Renderable* Cube; +Renderable* Cube2; + +Shader* shader; +Material* matCube; +Material* matCube2; + +char* code = new char[254]; + + +const std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs"; +const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs"; + + + +/* +* Runs once at startup +* - USe to initialize the game/sandbox/demo +*/ +void Start() { + + /* + Building a very basic scene graph + */ + SceneNode MyCube = SceneNode(); + MyCube.name = "MyCube"; + + SceneNode MyBaby = SceneNode(); + MyBaby.name = "Baby"; + + SceneNode MySecondCube = SceneNode(); + MySecondCube.name = "MySecondCube"; + + + MyCube.addChild(MyBaby); + + + Scene scene = Scene("My awesome Game Scene"); + scene.GetRoot().addChild(MyCube); + scene.GetRoot().addChild(MySecondCube); + + + // Walk scene graph + PrintSceneTree(scene.GetRoot(),0); + + shader = new Shader(vertexShaderSource, fragmentShaderSource); + + matCube = new Material(*shader); + matCube->Color = glm::vec3(1.0, 0.0, 0.0); + + matCube2 = new Material(*shader); + matCube2->Color = glm::vec3(0.0, 1.0f, 0.0); + + /* + * load meshes + */ + Cube = Renderable::Load(); + Cube2 = Renderable::Load(); + Cube->addChild(*Cube2); + + cam = new Camera(glm::vec3(0.0f, 1.5f, -10.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f); + + memset(code, '\0', 254); + +} + + +/* +* Runs every frame +* - Use to draw Immediate mode graphics (Not meant for HUD's ) +*/ +void ImmediateGraphicsDraw() { + ImGui::NewFrame(); + + // Show ImGui demo such that I can easily look + // at possible GUI elements to use + ImGui::ShowDemoWindow(); + + + // Show internal BarinkEngine stats + ShowStats(); + + + // Show different tooling for this specific sandbox + CameraTool(cam); + ScriptingTool(code); + + transformWindow(Cube->transform, "Transform (Cube)"); + + transformWindow(Cube2->transform, "Transform (Cube2)"); + + + +} + +/* +* Runs every frame +* - Meant for game logic ( non-physics related) +*/ +void Update() +{ + + + /* + * NOTE: this needs to move to the renderer + * Render code should not appear in the sandbox file + */ + glm::mat4 projection = glm::perspective(glm::radians(cam->Zoom), (800.0f / 600.0f), 0.001f, 100.0f); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + shader->Use(); + shader->setUniformMat4("P", projection); + shader->setUniformMat4("M", CalculateModelMat(Cube->transform)); + shader->setUniformMat4("V", cam->GetViewMatrix()); + matCube->Apply(); + + Cube->Draw(); + + shader->setUniformMat4("M", CalculateModelMat(Cube2->transform)); + matCube2->Apply(); + + Cube2->Draw(); + +} + +/* +* Runs at the end of the program +* - Meant for cleanup +*/ +void Stop() { + // Cleanup + Cube->VAO.Delete(); + Cube->elementBuffer.Delete(); + + Cube2->VAO.Delete(); + Cube2->elementBuffer.Delete(); + + delete Cube2; + delete Cube; + + delete matCube; + delete matCube2; + + delete shader; } \ No newline at end of file diff --git a/libs/physx b/libs/physx new file mode 160000 index 0000000..c3d5537 --- /dev/null +++ b/libs/physx @@ -0,0 +1 @@ +Subproject commit c3d5537bdebd6f5cd82fcaf87474b838fe6fd5fa diff --git a/libs/steam-audio b/libs/steam-audio new file mode 160000 index 0000000..de64146 --- /dev/null +++ b/libs/steam-audio @@ -0,0 +1 @@ +Subproject commit de6414694deccde57396c95dc44f8cc5f7d790f5