Working on basic rendering #4
* Added a basic material abstraction * Started implementation of RenderTarget (such as render textures)
This commit is contained in:
parent
d9f0f40ad9
commit
d019155d10
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -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
|
||||
|
@ -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 <phonon.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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
19
BarinkEngine/Include/Graphics/Material.h
Normal file
19
BarinkEngine/Include/Graphics/Material.h
Normal 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;
|
||||
|
||||
|
||||
};
|
30
BarinkEngine/Include/Graphics/RenderSurface.h
Normal file
30
BarinkEngine/Include/Graphics/RenderSurface.h
Normal 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;
|
||||
|
||||
|
||||
|
||||
};
|
@ -1,21 +1,33 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#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<BarinkEngine::Mesh> meshes;
|
||||
Renderable();
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#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<BarinkEngine::Mesh> meshes;
|
||||
Renderable();
|
||||
};
|
@ -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 ;
|
||||
|
||||
|
||||
};
|
@ -1,19 +1,18 @@
|
||||
#include "Input/InputManager.h"
|
||||
|
||||
void BarinkEngine::InputManager::PollEvents()
|
||||
{
|
||||
|
||||
for (std::vector<BarinkWindow*>::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<BarinkWindow*>();
|
||||
}
|
||||
#include "Input/InputManager.h"
|
||||
|
||||
void BarinkEngine::InputManager::PollEvents()
|
||||
{
|
||||
for (std::vector<BarinkWindow*>::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<BarinkWindow*>();
|
||||
}
|
||||
|
10
BarinkEngine/graphics/Material.cpp
Normal file
10
BarinkEngine/graphics/Material.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "../Include/Graphics/Material.h"
|
||||
|
||||
Material::Material(const Shader& shader) :
|
||||
shader(shader) {
|
||||
}
|
||||
|
||||
|
||||
void Material::Apply() {
|
||||
shader.setUniformVec3("Color", Color);
|
||||
}
|
46
BarinkEngine/graphics/RenderSurface.cpp
Normal file
46
BarinkEngine/graphics/RenderSurface.cpp
Normal 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() {
|
||||
|
||||
}
|
@ -1,24 +1,25 @@
|
||||
#include "Graphics/Renderer.h"
|
||||
|
||||
BarinkEngine::Renderer::Renderer()
|
||||
{
|
||||
models = std::vector<Renderable*>();
|
||||
}
|
||||
|
||||
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<Renderable*>();
|
||||
}
|
||||
|
||||
BarinkEngine::Renderer::~Renderer()
|
||||
{
|
||||
// CleanUp!
|
||||
}
|
||||
|
||||
void BarinkEngine::Renderer::Render()
|
||||
{
|
||||
|
||||
for (auto model : models) {
|
||||
model->Draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BarinkEngine::Renderer::Submit(Renderable* model)
|
||||
{
|
||||
models.push_back(model);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
11
BarinkEngine/graphics/shaders/RenderSurfaceFrag.shader
Normal file
11
BarinkEngine/graphics/shaders/RenderSurfaceFrag.shader
Normal 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;
|
||||
}
|
11
BarinkEngine/graphics/shaders/RenderSurfaceVert.shader
Normal file
11
BarinkEngine/graphics/shaders/RenderSurfaceVert.shader
Normal file
@ -0,0 +1,11 @@
|
||||
#version 440 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoords;
|
||||
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
|
||||
void main(){
|
||||
FragColor = texture(screenTexture, aTexCoords);
|
||||
}
|
@ -1,73 +1,76 @@
|
||||
#include "Graphics/Window.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <spdlog/spdlog.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);
|
||||
}
|
||||
|
||||
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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <spdlog/spdlog.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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
1
libs/physx
Submodule
1
libs/physx
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit c3d5537bdebd6f5cd82fcaf87474b838fe6fd5fa
|
1
libs/steam-audio
Submodule
1
libs/steam-audio
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit de6414694deccde57396c95dc44f8cc5f7d790f5
|
Loading…
Reference in New Issue
Block a user