Adding docking support through ImGui , Adding multiviewport support through ImGui, Moving header file back into the src directory , started building the editor, Added framebuffer to renderer.

BUG:
The framebuffer will not be displayed in the editor for some reason
This commit is contained in:
2022-10-22 13:27:23 +02:00
parent 463a9ff307
commit 29e715b92a
64 changed files with 8338 additions and 8223 deletions

View File

@ -1,4 +1,4 @@
#include "AssetManager/ModelImporter.h"
#include "ModelImporter.h"
#include "spdlog/spdlog.h"
BarinkEngine::SceneObject* BarinkEngine::ModelImporter::Import(const std::string path)

View File

@ -0,0 +1,35 @@
#pragma once
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define TINYGLTF_IMPLEMENTATION
#define TINYGLTF_NO_EXTERNAL_IMAGE
#include "../Graphics/Mesh.h"
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <string>
#include "../Scene/SceneNodeTypes.h"
void ProcessVertices(aiMesh* mesh, std::vector<BarinkEngine::Vertex>& out_vertices);
void ProcessIndices(aiMesh* mesh, std::vector<unsigned int>& 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<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene);
};
}

View File

@ -40,10 +40,6 @@ int main(int argc, char* argv[]) {
Update();
renderer.Render();
ImmediateGraphicsDraw();
GUISystem.Render();
MainWindow.SwapBuffers();

View File

@ -0,0 +1,24 @@
#pragma once
#include "glm/glm.hpp"
#include "graphics/Shader.h"
#include "graphics/Window.h"
#include "graphics/Texture.h"
#include "graphics/Camera.h"
#include "graphics/Renderable.h"
#include "Graphics/Renderer.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 BarinkEngine::Renderer renderer;
extern void Start();
extern void Update();
extern void ImmediateGraphicsDraw();
extern void Stop();

View File

@ -0,0 +1,7 @@
#pragma once
namespace BECS {
struct Component {
};
}

View File

@ -0,0 +1,13 @@
#pragma once
#include <vector>
#include "Component.h"
namespace BECS {
typedef unsigned long int Entity;
}

View File

@ -0,0 +1,7 @@
#pragma once
namespace BECS {
struct System {
};
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "System.h"
#include <vector>
#include "Component.h"
#include "Entity.h"
namespace BECS {
struct World {
private:
std::vector<System> systems;
std::vector<Component> components;
std::vector<Entity> entities;
};
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <string>
class EditorWindow {
protected:
std::string WindowTitle;
public:
virtual void Show() = 0;
};

View File

@ -0,0 +1,11 @@
#pragma once
#include <string>
struct Event
{
public:
std::string name;
int argc;
void** argv;
};

View File

@ -1,4 +1,4 @@
#include "../Include/EventSystem/EventEmitter.h"
#include "EventEmitter.h"
void EventEmitter::Subscribe(EventListener& subscriber)

View File

@ -0,0 +1,16 @@
#pragma once
#include "Event.h"
#include "EventListener.h"
class EventEmitter {
public:
void Subscribe (EventListener& subscriber);
void Unsubscribe(EventListener& subscriber);
protected:
std::list<EventListener*> subscribers;
void EmitEvent(Event& incident);
EventEmitter();
};

View File

@ -0,0 +1,12 @@
#pragma once
#include <list>
#include <iostream>
#include "spdlog/spdlog.h"
#include "Event.h"
class EventListener{
public:
virtual void ReceiveEvent(Event& incident) = 0 ;
};

View File

@ -1,4 +1,4 @@
#include "Graphics/Buffer.h"
#include "Buffer.h"
int GpuBuffer::getBufferID() {

View File

@ -0,0 +1,19 @@
#pragma once
#include <glad/glad.h>
class GpuBuffer {
private:
unsigned int id;
public:
int getBufferID();
void createBuffer();
void setBufferData(void* data, size_t dataSize, bool elementBuffer );
void Bind(bool elementBuffer);
void Unbind(bool elementBuffer);
void Delete();
};

View File

@ -1,4 +1,4 @@
#include "Graphics/Camera.h"
#include "Camera.h"
Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom)
: Position(position), Rotation(rotation), Zoom(zoom) {

View File

@ -0,0 +1,22 @@
#pragma once
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
class Camera {
public:
glm::vec3 Position;
glm::vec3 Rotation;
float Zoom;
Camera(glm::vec3 position, glm::vec3 rotation, float zoom );
~Camera();
glm::mat4 GetViewMatrix();
private:
glm::vec3 Front;
glm::vec3 Right;
glm::vec3 Up;
};

View File

@ -0,0 +1,49 @@
#include "Framebuffer.h"
#include <iostream>
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, 1, 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);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColourAttachment, 0);
glBindTexture(GL_TEXTURE_2D, 0);
// Create a depth buffer
glGenRenderbuffers(1, &DepthAttachment);
glBindRenderbuffer(GL_RENDERBUFFER, DepthAttachment);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 800, 600);
glFramebufferRenderbuffer(GL_RENDERBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, DepthAttachment);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
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);
}

View File

@ -0,0 +1,20 @@
#pragma once
#include <glad/glad.h>
#include <glm/glm.hpp>
class Framebuffer {
public:
Framebuffer();
~Framebuffer();
unsigned int GetId() { return Id; }
unsigned int GetColourAttachment() { return ColourAttachment; }
private:
unsigned int Id = 0;
unsigned int ColourAttachment = 0;
unsigned int DepthAttachment = 0;
};

View File

@ -1,4 +1,4 @@
#include "Graphics/GPUBucket.h"
#include "GPUBucket.h"
BarinkEngine::GPU_Bucket::GPU_Bucket() {
}
BarinkEngine::GPU_Bucket::~GPU_Bucket() {

View File

@ -0,0 +1,32 @@
#pragma once
#include "VertexArray.h"
#include "Buffer.h"
#include "Mesh.h"
#include "Material.h"
#include <glm/glm.hpp>
namespace BarinkEngine {
class GPU_Bucket {
public:
GPU_Bucket();
~GPU_Bucket();
void Upload(const Mesh& renderable);
GpuBuffer vertexBuffer;
GpuBuffer elementBuffer;
VertexArray vertexarray;
const Mesh* mesh;
const Material* material;
private :
unsigned int uv_id;
};
};

View File

@ -1,24 +1,24 @@
#include "Graphics/GUI/GUIManager.h"
#include "GUIManager.h"
#include "imgui.h"
#include "backends/imgui_impl_opengl3.h"
#include <backends/imgui_impl_glfw.cpp>
#include <backends/imgui_impl_glfw.h>
#include "../../BarinkEngine.h"
GUIManager::GUIManager(BarinkWindow* window)
: currentwindow(window)
GUIManager::GUIManager(BarinkWindow* window)
: currentwindow(window)
{
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
(void)io;
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
ImGui::StyleColorsDark();
ImGui_ImplGlfw_InitForOpenGL(currentwindow->windowptr(), true);
ImGui_ImplOpenGL3_Init("#version 440");
ImGui_ImplGlfw_NewFrame();
ImGui_ImplOpenGL3_NewFrame();
}
GUIManager::~GUIManager()
@ -28,11 +28,47 @@ GUIManager::~GUIManager()
ImGui::DestroyContext();
}
void GUIManager::Render()
{
ImGui_ImplGlfw_NewFrame();
ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame();
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
ImGui::Begin("##App");
// Show a menu bar
ImGui::BeginMainMenuBar();
if (ImGui::BeginMenu("Application")) {
if (ImGui::MenuItem("Exit")) {
// TODO: Exit application
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
ImmediateGraphicsDraw();
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* last_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(last_context);
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include "../Window.h"
class GUIManager {
public:
GUIManager(BarinkWindow* window);
~GUIManager();
void Render();
private:
BarinkWindow* currentwindow;
};

View File

@ -1,4 +1,4 @@
#include "../Include/Graphics/Material.h"
#include "Material.h"
Material::Material(const Shader& shader) :
shader(shader) {

View File

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

View File

@ -0,0 +1,12 @@
#pragma once
#include <vector>
#include <glm/glm.hpp>
#include "Vertex.h"
namespace BarinkEngine {
struct Mesh {
std::vector<Vertex> vertices;
std::vector<unsigned int> elements;
};
}

View File

@ -1,4 +1,4 @@
#include "Graphics/RenderSurface.h";
#include "RenderSurface.h";
RenderSurface::RenderSurface(){
shader = new Shader("build/SandboxAppliction/Debug/renderSuface.vs", "build/SandboxApplication/Debug/renderSurface.fs");

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;
GpuBuffer vertexBuffer;
GpuBuffer elementBuffer;
VertexArray VAO;
};

View File

@ -0,0 +1,14 @@
#pragma once
#include "Mesh.h"
#include "Material.h"
#include "Texture.h"
#include "../Scene.h"
namespace BarinkEngine {
struct Renderable {
BarinkEngine::Mesh* mesh;
Material* material;
Texture* texture;
};
}

View File

@ -1,4 +1,8 @@
#include "Graphics/Renderer.h"
#include "Renderer.h"
float Angle = 0.0;
Camera cam = Camera(glm::vec3(16.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()
{
@ -18,13 +22,12 @@ BarinkEngine::Renderer::~Renderer()
// glDeleteBuffers(1, &UV_id);
}
float Angle = 0.0;
void BarinkEngine::Renderer::Render()
void BarinkEngine::Renderer::Render(Framebuffer& framebuffer)
{
// This creation of the projection and camera is somewhat wastefull
Camera cam = Camera(glm::vec3(16.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);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.GetId());
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Angle += 0.0001f;
for (auto model : models) {
@ -33,9 +36,9 @@ void BarinkEngine::Renderer::Render()
model->elementBuffer.Bind(true);
if (model->material == nullptr) {
std::cout << "No material attached!" << std::endl;
// continue; //NOTE: Or use some default Material
}
else {
model->material->shader.Use();
@ -47,25 +50,24 @@ void BarinkEngine::Renderer::Render()
model->material->shader.setUniformMat4("M", glm::rotate(glm::mat4(), Angle, glm::vec3(0.5f, 0.5f, 0.0f)));
model->material->shader.setUniformMat4("V", cam.GetViewMatrix());
model->material->shader.setUniformMat4("P", projection);
// Update perf counters
ES.verts = model->mesh->vertices.size();
ES.DC++;
glDrawElements(GL_TRIANGLES,
static_cast<unsigned int>(model->mesh->elements.size()),
GL_UNSIGNED_INT,
NULL
);
}
// Update perf counters
ES.verts = model->mesh->vertices.size();
ES.DC++;
glDrawElements(GL_TRIANGLES,
static_cast<unsigned int>(model->mesh->elements.size()),
GL_UNSIGNED_INT,
NULL
);
model->vertexarray.Unbind();
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

View File

@ -0,0 +1,30 @@
#pragma once
#include <vector>
#include <glm/gtc/matrix_transform.hpp>
#include "glad/glad.h"
#include "GLFW/glfw3.h"
#include "../PerfCounter.h"
#include "Camera.h"
#include "Renderable.h"
#include "GPUBucket.h"
#include "Framebuffer.h"
namespace BarinkEngine {
class Renderer {
public:
Renderer();
~Renderer();
void Render(Framebuffer& framebuffer);
void Submit(Renderable* model);
private:
std::vector<GPU_Bucket*> models;
};
}

View File

@ -1,4 +1,4 @@
#include "Graphics/Shader.h"
#include "Shader.h"
#include "spdlog/spdlog.h"
Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath)

View File

@ -0,0 +1,27 @@
#pragma once
#include <glad/glad.h>
#include <string>
#include <iostream>
#include <fstream>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
class Shader {
private:
char* readFile (const char* filePath);
public:
Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath);
void Use() const;
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 ;
int id;
};

View File

@ -1,8 +1,8 @@
#include "../Include/Graphics/Texture.h"
#include "Texture.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#define STB_IMAGE_IMPLEMENTATION
#include "Graphics/stb_image.h"
#include "stb_image.h"
#include <iostream>
Texture::Texture(const std::string texturePath) {

View File

@ -0,0 +1,18 @@
#pragma once
#include <spdlog/spdlog.h>
#include <string>
class Texture {
public:
Texture(const std::string texturePath);
void Bind();
void Unbind();
private:
unsigned int Id;
};

View File

@ -0,0 +1,11 @@
#pragma once
#include <glm/glm.hpp>
struct Transform {
glm::vec3 Position;
glm::vec3 Rotation;
glm::vec3 Scale;
glm::mat4 ModelMatrix;
};

View File

@ -0,0 +1,9 @@
#pragma once
#include <glm/glm.hpp>
namespace BarinkEngine {
struct Vertex {
glm::vec3 vertices;
glm::vec2 uv;
};
}

View File

@ -1,4 +1,4 @@
#include "Graphics/VertexArray.h"
#include "VertexArray.h"
#include <glad/glad.h>
void VertexArray::Create(){

View File

@ -0,0 +1,18 @@
#pragma once
class VertexArray{
private:
unsigned int id;
public:
void Create();
void Bind();
void Unbind();
void Delete();
void AttachAttribute(unsigned int index, int size, int stride);
};

View File

@ -0,0 +1,37 @@
#pragma once
#define GLFW_STATIC
#include <glad/glad.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <GLFW/glfw3.h>
#include <spdlog/spdlog.h>
#include "../EventSystem/Event.h"
#include "../EventSystem/EventListener.h"
class BarinkWindow : EventListener {
private:
GLFWwindow* window;
bool FullScreen;
bool VulkanSupported;
int Width, Height;
static bool InitGLFW();
public:
BarinkWindow(const int width, const int height);
~BarinkWindow();
GLFWwindow* windowptr();
void ReceiveEvent(Event& incident) override ;
bool WindowShouldClose();
void Poll();
void SwapBuffers();
};

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#include "Graphics/Window.h"
#include "Window.h"
bool BarinkWindow::InitGLFW(){
if(!glfwInit())
@ -19,8 +19,8 @@ Width(width), Height(height), FullScreen(false){
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);
// glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
// glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
// Disable resizing the window
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
@ -54,7 +54,6 @@ Width(width), Height(height), FullScreen(false){
}
BarinkWindow::~BarinkWindow(){
glfwTerminate();
@ -81,6 +80,6 @@ void BarinkWindow::SwapBuffers()
void BarinkWindow::ReceiveEvent(Event& incident)
{
std::cout << "EVENT RECEIVED: " << incident.name << std::endl;
//std::cout << "EVENT RECEIVED: " << incident.name << std::endl;
}

View File

@ -1,4 +1,5 @@
#include "Input/InputManager.h"
#include "InputManager.h"
BarinkEngine::InputManager InputSystem;
void BarinkEngine::InputManager::PollEvents()

View File

@ -0,0 +1,31 @@
#pragma once
#include <vector>
#include <iostream>
#include "spdlog/spdlog.h"
#include "../EventSystem/EventEmitter.h"
#include "../EventSystem/EventListener.h"
#include "../Graphics/Window.h"
namespace BarinkEngine {
class InputManager : EventEmitter {
public:
InputManager();
void PollEvents();
void attach(BarinkWindow* window);
// GLFW Handlers
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
static void CursorPositionCallback(GLFWwindow* window, double x, double y);
static void CursorEnterCallback(GLFWwindow* window, int entered);
static void MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
static void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
private:
std::vector<BarinkWindow*> windows;
};
}
extern BarinkEngine::InputManager InputSystem;

View File

@ -0,0 +1,52 @@
#pragma once
#include <chrono>
#include <imgui.h>
struct EngineStatistics {
float frameTime;
uint32_t verts;
uint32_t DC;
long long lastSampleTime;
long long frames;
long long FPS;
};
extern EngineStatistics ES;
inline void PerfomanceSamplerInit(){
ES.frames = 0;
ES.lastSampleTime = 0;
ES.lastSampleTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
}
inline void SamplePerformance(void) {
ES.frames++;
ES.DC = 0;
ES.verts = 0;
unsigned long long now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
unsigned long long MilliSecondsPast = now - ES.lastSampleTime;
if (MilliSecondsPast >= 1000) {
ES.frameTime = (float)1000 / ES.frames;
ES.FPS = ES.frames;
ES.frames = 0;
ES.lastSampleTime = now;
}
}
inline void ShowStats() {
ImGui::Begin("Statistics", false, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
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();
}

23
BarinkEngine/src/Scene.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <string>
#include <vector>
#include "Graphics/Transform.h"
#include "Scene/Node.h"
/*
* Scene should be a description of a game world
*/
class Scene {
public:
Node& GetSceneNode(std::string);
Node& GetRoot();
Scene(const std::string& sceneName = "Default Scene");
~Scene();
private:
Node* root;
};

View File

@ -1,4 +1,4 @@
#include "Scene/Node.h"
#include "Node.h"
Node::Node(const std::string& name)
: name(name), parent(nullptr), children(std::vector<Node*>()) {}

View File

@ -0,0 +1,24 @@
#pragma once
#include <string>
#include <vector>
#include "../Graphics/Transform.h"
class Node {
public:
Node(const std::string& name);
std::string name;
Node* parent;
std::vector<Node*> children;
void addChild(Node& node);
};
class Group : public Node {
public:
Group(const std::string& name);
Transform& transform;
};

View File

@ -0,0 +1,15 @@
#pragma once
#include "Graphics/Renderable.h"
#include "Scene/SceneNodeTypes.h"
#include <glm/glm.hpp>
#include "../../src/Scene/SceneNodeTypes.cpp"
/*
* Define a helper class to more easily build a proper scene
*/
static class SceneBuilder {
static Group* AddGroup(std::string name);
static BarinkEngine::SceneObject* AddVisual(std::string name, BarinkEngine::Renderable& object, glm::vec3 position );
};

View File

@ -1,4 +1,4 @@
#include "Scene/SceneManager.h"
#include "SceneManager.h"
Scene* SceneManager::CreateScene(const std::string& name)
{

View File

@ -0,0 +1,17 @@
#pragma once
#include <string>
#include <map>
#include "../Scene.h"
class SceneManager {
public:
static Scene* CreateScene(const std::string& name );
static Scene& GetScene(const std::string& name);
static void LoadScene(Scene& scene);
private:
static Scene* CurrentScene;
static std::map<std::string, Scene*> Scenes;
};

View File

@ -1,4 +1,4 @@
#include "Scene/SceneNodeTypes.h"
#include "SceneNodeTypes.h"
BarinkEngine::SceneCamera::SceneCamera()
: Group(std::string("Camera")), camera(Camera(glm::vec3(0.0f), glm::vec3(0.0f), 0))

View File

@ -0,0 +1,22 @@
#pragma once
#include "../Graphics/Camera.h"
#include "../Graphics/Renderable.h"
#include "Node.h"
namespace BarinkEngine {
class SceneCamera : public Group
{
public:
Camera& camera;
SceneCamera();
};
class SceneObject : public Group
{
public:
SceneObject(std::string name, Renderable* visual);
~SceneObject();
Renderable* renderable;
};
}

View File

@ -1,4 +1,4 @@
#include "Scripting/LuaScript.h"
#include "LuaScript.h"
/*
LuaScript::LuaScript(const std::string& path)
: filePath(path) {

View File

@ -0,0 +1,28 @@
#pragma once
#include <string>
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;
};
*/

View File

@ -1,4 +1,4 @@
#include "Scripting/LuaScriptingManager.h"
#include "LuaScriptingManager.h"
/*
LuaScriptingManager::LuaScriptingManager()
{

View File

@ -0,0 +1,28 @@
#pragma once
#include <vector>
extern "C"
{
#include "lauxlib.h"
#include "lua.h"
#include "lualib.h"
}
#include "LuaScript.h"
/*
class LuaScriptingManager
{
public:
std::vector<LuaScript*> scripts;
LuaScriptingManager();
void ExecuteLuaString(const std::string&);
private:
lua_State* L;
lua_State& getState();
};*/