Working on basic rendering #4

* Added a basic material abstraction
* Started implementation of RenderTarget (such as render textures)
This commit is contained in:
Nigel Barink 2022-06-04 18:26:58 +02:00
parent d9f0f40ad9
commit d019155d10
20 changed files with 633 additions and 452 deletions

6
.gitmodules vendored
View File

@ -19,3 +19,9 @@
[submodule "assimp"] [submodule "assimp"]
path = libs/assimp path = libs/assimp
url = https://github.com/assimp/assimp.git 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

View File

@ -1,57 +1,59 @@
#include "BarinkEngine.h" #include "BarinkEngine.h"
#include <phonon.h>
EngineStatistics* ES;
EngineStatistics* ES;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// Setup performance sampler // Setup performance sampler
PerfomanceSamplerInit(); PerfomanceSamplerInit();
// Startup services // Startup services
BarinkWindow MainWindow = BarinkWindow(800, 600); BarinkWindow MainWindow = BarinkWindow(800, 600);
BarinkEngine::Renderer renderer = BarinkEngine::Renderer(); BarinkEngine::Renderer renderer = BarinkEngine::Renderer();
BarinkEngine::InputManager InputSystem = BarinkEngine::InputManager(); BarinkEngine::InputManager InputSystem = BarinkEngine::InputManager();
InputSystem.attach(&MainWindow); InputSystem.attach(&MainWindow);
GUIManager GUISystem = GUIManager(&MainWindow); GUIManager GUISystem = GUIManager(&MainWindow);
// First call to setup game
Start();
// First call to setup game
Start();
// Runtime loop
while (!MainWindow.WindowShouldClose()) {
// Runtime loop
SamplePerformance(); while (!MainWindow.WindowShouldClose()) {
SamplePerformance();
// Execute main logic
InputSystem.PollEvents();
// Execute main logic
Update(); InputSystem.PollEvents();
renderer.Render(); Update();
ImmediateGraphicsDraw(); renderer.Render();
GUISystem.Render(); ImmediateGraphicsDraw();
GUISystem.Render();
MainWindow.SwapBuffers();
}
MainWindow.SwapBuffers();
}
// Shutdown game
Stop();
// Shutdown game
Stop();
// Shutdown Services
delete ES;
// Shutdown Services
return 0; delete ES;
}
return 0;
}

View File

@ -1,18 +1,20 @@
#pragma once #pragma once
#include "glm/glm.hpp" #include "glm/glm.hpp"
#include "graphics/Shader.h" #include "graphics/Shader.h"
#include "graphics/Window.h" #include "graphics/Window.h"
#include "graphics/Camera.h" #include "graphics/Camera.h"
#include "graphics/Renderable.h" #include "graphics/Renderable.h"
#include "spdlog/spdlog.h" #include "Graphics/Material.h"
#include "spdlog/spdlog.h"
#include "Input/InputManager.h"
#include "Graphics/Renderer.h" #include "Input/InputManager.h"
#include "Graphics/GUI/GUIManager.h" #include "Graphics/Renderer.h"
#include "Scene.h" #include "Graphics/GUI/GUIManager.h"
#include "PerfCounter.h" #include "Scene.h"
#include "PerfCounter.h"
extern void Start();
extern void Update();
extern void ImmediateGraphicsDraw(); extern void Start();
extern void Stop(); extern void Update();
extern void ImmediateGraphicsDraw();
extern void Stop();

View File

@ -0,0 +1,19 @@
#pragma once
#include <glm/glm.hpp>
#include <string>
#include "Shader.h"
class Material {
public:
Material(const Shader& shader);
void Apply();
glm::vec3 Color;
private:
const Shader& shader;
};

View File

@ -0,0 +1,30 @@
#pragma once
#include "BarinkEngine.h"
#include <vector>;
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<glm::vec3> verts;
std::vector<unsigned int > indices;
Buffer vertexBuffer;
Buffer elementBuffer;
VertexArray VAO;
};

View File

@ -1,21 +1,33 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include "Mesh.h" #include "Mesh.h"
#include "Buffer.h" #include "Buffer.h"
#include "VertexArray.h" #include "Material.h"
#include "Scene.h" #include "VertexArray.h"
#include "Scene.h"
class Renderable : public SceneNode {
public:
Buffer vertexBuffer; class Renderable : public SceneNode {
Buffer elementBuffer; public:
VertexArray VAO; /*
~Renderable(); * NOTE: Should combine into a Mesh!!
*/
static Renderable* Load(); Buffer vertexBuffer;
void Draw(); Buffer elementBuffer;
VertexArray VAO;
private:
std::vector<BarinkEngine::Mesh> meshes;
Renderable(); Material* material;
Shader* shader;
~Renderable();
static Renderable* Load();
void Draw();
private:
std::vector<BarinkEngine::Mesh> meshes;
Renderable();
}; };

View File

@ -15,12 +15,12 @@ class Shader {
public: public:
Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath); Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath);
void Use(); void Use();
void setUniformMat4(std::string uniformName, glm::mat4 matrix4); void setUniformMat4(std::string uniformName, glm::mat4 matrix4)const;
void setUniformVec4(std::string uniformName, glm::vec4 vector4); void setUniformVec4(std::string uniformName, glm::vec4 vector4)const;
void setUniformVec3(std::string uniformName, glm::vec3 vector3); void setUniformVec3(std::string uniformName, glm::vec3 vector3)const;
void setUniformVec2(std::string uniformName, glm::vec2 vector2); void setUniformVec2(std::string uniformName, glm::vec2 vector2)const;
void setUniformFloat(std::string uniformName, float value); void setUniformFloat(std::string uniformName, float value)const;
void setUniformInt(std::string uniformName, int value); void setUniformInt(std::string uniformName, int value) const ;
}; };

View File

@ -1,19 +1,18 @@
#include "Input/InputManager.h" #include "Input/InputManager.h"
void BarinkEngine::InputManager::PollEvents() void BarinkEngine::InputManager::PollEvents()
{ {
for (std::vector<BarinkWindow*>::iterator it = windows.begin(); it != windows.end(); ++it) {
for (std::vector<BarinkWindow*>::iterator it = windows.begin(); it != windows.end(); ++it) { (*it)->Poll();
(*it)->Poll(); }
} }
}
void BarinkEngine::InputManager::attach(BarinkWindow* window)
void BarinkEngine::InputManager::attach(BarinkWindow* window) {
{ windows.push_back(window);
windows.push_back(window); }
}
BarinkEngine::InputManager::InputManager()
BarinkEngine::InputManager::InputManager() {
{ windows = std::vector<BarinkWindow*>();
windows = std::vector<BarinkWindow*>(); }
}

View File

@ -0,0 +1,10 @@
#include "../Include/Graphics/Material.h"
Material::Material(const Shader& shader) :
shader(shader) {
}
void Material::Apply() {
shader.setUniformVec3("Color", Color);
}

View File

@ -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<glm::vec3>{
{-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<unsigned int>{
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() {
}

View File

@ -1,24 +1,25 @@
#include "Graphics/Renderer.h" #include "Graphics/Renderer.h"
BarinkEngine::Renderer::Renderer() BarinkEngine::Renderer::Renderer()
{ {
models = std::vector<Renderable*>(); models = std::vector<Renderable*>();
} }
BarinkEngine::Renderer::~Renderer() BarinkEngine::Renderer::~Renderer()
{ {
// CleanUp! // CleanUp!
} }
void BarinkEngine::Renderer::Render() void BarinkEngine::Renderer::Render()
{ {
for (auto model : models) {
model->Draw(); for (auto model : models) {
} model->Draw();
}
}
}
void BarinkEngine::Renderer::Submit(Renderable* model)
{ void BarinkEngine::Renderer::Submit(Renderable* model)
models.push_back(model); {
} models.push_back(model);
}

View File

@ -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)); 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)); 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)); 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)); 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); 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); glUniform1i(glGetUniformLocation(id, uniformName.c_str()), value);
} }

View File

@ -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;
}

View File

@ -0,0 +1,11 @@
#version 440 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D screenTexture;
void main(){
FragColor = texture(screenTexture, aTexCoords);
}

View File

@ -1,73 +1,76 @@
#include "Graphics/Window.h" #include "Graphics/Window.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
bool BarinkWindow::InitGLFW(){ bool BarinkWindow::InitGLFW(){
if(!glfwInit()) if(!glfwInit())
{ {
spdlog::error("Failed to initialise GLFW!"); spdlog::error("Failed to initialise GLFW!");
return false; return false;
} }
return true; return true;
} }
BarinkWindow::BarinkWindow(const int width, const int height) : BarinkWindow::BarinkWindow(const int width, const int height) :
Width(width), Height(height), FullScreen(false){ Width(width), Height(height), FullScreen(false){
if (InitGLFW()==false) { if (InitGLFW()==false) {
exit(-1); exit(-1);
} }
window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL); window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL);
if( !window) if( !window)
{ {
spdlog::error("GLFW failed to create window!"); spdlog::error("GLFW failed to create window!");
glfwTerminate(); glfwTerminate();
return; return;
} }
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
printf("Failed to initialize GLAD!\n"); printf("Failed to initialize GLAD!\n");
exit(-1); exit(-1);
} }
VulkanSupported = glfwVulkanSupported(); // Set vsync off !!
glfwSwapInterval(0);
glfwGetFramebufferSize(window, &Width, &Height);
glViewport(0,0, Width, Height); VulkanSupported = glfwVulkanSupported();
glfwGetFramebufferSize(window, &Width, &Height);
glViewport(0,0, Width, Height);
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
}
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
BarinkWindow::~BarinkWindow(){ }
glfwTerminate();
} BarinkWindow::~BarinkWindow(){
GLFWwindow* BarinkWindow::windowptr() glfwTerminate();
{ }
return window;
} GLFWwindow* BarinkWindow::windowptr()
{
bool BarinkWindow::WindowShouldClose(){ return window;
return glfwWindowShouldClose(window); }
}
bool BarinkWindow::WindowShouldClose(){
void BarinkWindow::Poll() return glfwWindowShouldClose(window);
{ }
glfwPollEvents();
} void BarinkWindow::Poll()
{
void BarinkWindow::SwapBuffers() glfwPollEvents();
{ }
glfwSwapBuffers(window);
void BarinkWindow::SwapBuffers()
{
glfwSwapBuffers(window);
} }

View File

@ -1,58 +1,69 @@
project "BarinkEngine" project "BarinkEngine"
kind "StaticLib" kind "StaticLib"
buildmessage "Building BarinkEngine" buildmessage "Building BarinkEngine"
includedirs { includedirs {
"Include/", "Include/",
"../libs/lua/include", "../libs/lua/include",
"../libs/spdlog/include", "../libs/spdlog/include",
"../libs/glm", "../libs/glm",
"../libs/GorillaAudio/include", "../libs/GorillaAudio/include",
"../libs/assimp/include", "../libs/physx/physx/include",
"../libs/glad/include", "../libs/steam-audio/include",
"../libs/glfw/include", "../libs/assimp/include",
"../libs/tinygltf", "../libs/glad/include",
"../libs/glew/include", "../libs/glfw/include",
"../libs/glm", "../libs/tinygltf",
"../libs/ImGui", "../libs/glew/include",
"../libs/glm",
} "../libs/ImGui",
libdirs { }
"../libs/lua",
"../libs/spdlog/build/Release", libdirs {
"../libs/assimp/lib/Debug", "../libs/steam-audio/lib/windows-x64",
"../libs/glfw/build/src/Debug", "../libs/lua",
"../libs/ImGui" "../libs/spdlog/build/Release",
} "../libs/assimp/lib/Debug",
"../libs/glfw/build/src/Debug",
links { "../libs/ImGui"
"lua54", }
"spdlog",
"assimp-vc143-mtd", links {
"glfw3" "phonon",
} "lua54",
"spdlog",
files { "assimp-vc143-mtd",
"../libs/ImGui/*.cpp", "glfw3"
"../libs/ImGui/backends/imgui_impl_glfw.cpp", }
"../libs/ImGui/backends/imgui_impl_Opengl3.cpp",
"../libs/glad/src/glad.c", files {
"../libs/ImGui/*.cpp",
"./*.cpp", "../libs/ImGui/backends/imgui_impl_glfw.cpp",
"./*.h", "../libs/ImGui/backends/imgui_impl_Opengl3.cpp",
"./**/*.cpp", "../libs/glad/src/glad.c",
"./**/*.h"
} "./*.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") -- NOTE: make these copy instructions more flexible
if err then error("Copy vertex shader source failed!") end 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

View File

@ -1,31 +1,35 @@
#include "GUI.h" #include "GUI.h"
void CameraTool(Camera* cam) { void CameraTool(Camera* cam) {
ImGui::Begin("Camera"); ImGui::Begin("Camera");
ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190); ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190);
ImGui::End(); ImGui::InputFloat3("Position:", &cam->Position[0]);
}
ImGui::InputFloat3("Rotation:", &cam->Rotation[0]);
void ScriptingTool(char* code) {
ImGui::Begin("Scripting"); ImGui::End();
}
ImGui::InputTextMultiline("Lua Script", code, 255);
bool runCode = ImGui::Button("Run"); void ScriptingTool(char* code) {
ImGui::Begin("Scripting");
ImGui::End(); 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]); void transformWindow(Transform& transform, std::string PanelName) {
ImGui::End(); 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();
} }

View File

@ -1,143 +1,155 @@
#include "BarinkEngine.h" #include "BarinkEngine.h"
#include "imgui.h" #include "imgui.h"
#include "GUI.h" #include "GUI.h"
#include "Util.h" #include "Util.h"
/* /*
* Define globals * Define globals
*/ */
Camera* cam; Camera* cam;
Renderable* Cube; Renderable* Cube;
Renderable* Cube2; Renderable* Cube2;
Shader* shader; Shader* shader;
Material* matCube;
char* code = new char[254]; Material* matCube2;
const std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs"; char* code = new char[254];
const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs";
/* const std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs";
* Runs once at startup const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs";
* - USe to initialize the game/sandbox/demo
*/
void Start() {
/*
/* * Runs once at startup
Building a very basic scene graph * - USe to initialize the game/sandbox/demo
*/ */
SceneNode MyCube = SceneNode(); void Start() {
MyCube.name = "MyCube";
/*
SceneNode MyBaby = SceneNode(); Building a very basic scene graph
MyBaby.name = "Baby"; */
SceneNode MyCube = SceneNode();
SceneNode MySecondCube = SceneNode(); MyCube.name = "MyCube";
MySecondCube.name = "MySecondCube";
SceneNode MyBaby = SceneNode();
MyBaby.name = "Baby";
MyCube.addChild(MyBaby);
SceneNode MySecondCube = SceneNode();
MySecondCube.name = "MySecondCube";
Scene scene = Scene("My awesome Game Scene");
scene.GetRoot().addChild(MyCube);
scene.GetRoot().addChild(MySecondCube); MyCube.addChild(MyBaby);
// Walk scene graph Scene scene = Scene("My awesome Game Scene");
PrintSceneTree(scene.GetRoot(),0); scene.GetRoot().addChild(MyCube);
scene.GetRoot().addChild(MySecondCube);
shader = new Shader(vertexShaderSource, fragmentShaderSource);
// Walk scene graph
PrintSceneTree(scene.GetRoot(),0);
/*
* load meshes shader = new Shader(vertexShaderSource, fragmentShaderSource);
*/
Cube = Renderable::Load(); matCube = new Material(*shader);
Cube2 = Renderable::Load(); matCube->Color = glm::vec3(1.0, 0.0, 0.0);
Cube->addChild(*Cube2);
matCube2 = new Material(*shader);
cam = new Camera(glm::vec3(0.0f, 1.5f, -10.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f); matCube2->Color = glm::vec3(0.0, 1.0f, 0.0);
memset(code, '\0', 254); /*
* load meshes
} */
Cube = Renderable::Load();
Cube2 = Renderable::Load();
/* Cube->addChild(*Cube2);
* Runs every frame
* - Use to draw Immediate mode graphics (Not meant for HUD's ) cam = new Camera(glm::vec3(0.0f, 1.5f, -10.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f);
*/
void ImmediateGraphicsDraw() { memset(code, '\0', 254);
ImGui::NewFrame();
}
// Show ImGui demo such that I can easily look
// at possible GUI elements to use
ImGui::ShowDemoWindow(); /*
* Runs every frame
* - Use to draw Immediate mode graphics (Not meant for HUD's )
// Show internal BarinkEngine stats */
ShowStats(); void ImmediateGraphicsDraw() {
ImGui::NewFrame();
// Show different tooling for this specific sandbox // Show ImGui demo such that I can easily look
CameraTool(cam); // at possible GUI elements to use
ScriptingTool(code); ImGui::ShowDemoWindow();
transformWindow(Cube->transform, "Transform (Cube)");
// Show internal BarinkEngine stats
transformWindow(Cube2->transform, "Transform (Cube2)"); ShowStats();
// Show different tooling for this specific sandbox
} CameraTool(cam);
ScriptingTool(code);
/*
* Runs every frame transformWindow(Cube->transform, "Transform (Cube)");
* - Meant for game logic ( non-physics related)
*/ transformWindow(Cube2->transform, "Transform (Cube2)");
void Update()
{
}
/*
* NOTE: this needs to move to the renderer /*
* Render code should not appear in the sandbox file * Runs every frame
*/ * - Meant for game logic ( non-physics related)
glm::mat4 projection = glm::perspective(glm::radians(cam->Zoom), (800.0f / 600.0f), 0.001f, 100.0f); */
void Update()
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)); * NOTE: this needs to move to the renderer
shader->setUniformMat4("V", cam->GetViewMatrix()); * Render code should not appear in the sandbox file
shader->setUniformVec3("MatColour", glm::vec3(1.0f, 0.0f, 0.0f)); */
glm::mat4 projection = glm::perspective(glm::radians(cam->Zoom), (800.0f / 600.0f), 0.001f, 100.0f);
Cube->Draw();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
shader->setUniformMat4("M", CalculateModelMat(Cube2->transform));
shader->setUniformVec3("MatColour", glm::vec3(0.0f, 1.0f, 0.0f)); shader->Use();
shader->setUniformMat4("P", projection);
Cube2->Draw(); shader->setUniformMat4("M", CalculateModelMat(Cube->transform));
shader->setUniformMat4("V", cam->GetViewMatrix());
} matCube->Apply();
/* Cube->Draw();
* Runs at the end of the program
* - Meant for cleanup shader->setUniformMat4("M", CalculateModelMat(Cube2->transform));
*/ matCube2->Apply();
void Stop() {
// Cleanup Cube2->Draw();
Cube->VAO.Delete();
Cube->elementBuffer.Delete(); }
Cube2->VAO.Delete(); /*
Cube2->elementBuffer.Delete(); * Runs at the end of the program
* - Meant for cleanup
delete Cube2; */
delete Cube; void Stop() {
// Cleanup
delete shader; Cube->VAO.Delete();
Cube->elementBuffer.Delete();
Cube2->VAO.Delete();
Cube2->elementBuffer.Delete();
delete Cube2;
delete Cube;
delete matCube;
delete matCube2;
delete shader;
} }

1
libs/physx Submodule

@ -0,0 +1 @@
Subproject commit c3d5537bdebd6f5cd82fcaf87474b838fe6fd5fa

1
libs/steam-audio Submodule

@ -0,0 +1 @@
Subproject commit de6414694deccde57396c95dc44f8cc5f7d790f5