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:
parent
463a9ff307
commit
29e715b92a
@ -35,9 +35,6 @@ project "BarinkEngine"
|
||||
"glfw3",
|
||||
|
||||
"ImGUI_Opengl3",
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -53,9 +50,9 @@ project "BarinkEngine"
|
||||
"../libs/glad/src/glad.c",
|
||||
|
||||
"./src/*.cpp",
|
||||
"./Include/*.h",
|
||||
"./src/*.h",
|
||||
"./src/**/*.cpp",
|
||||
"./Include/**/*.h"
|
||||
"./src/**/*.h"
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "AssetManager/ModelImporter.h"
|
||||
#include "ModelImporter.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
BarinkEngine::SceneObject* BarinkEngine::ModelImporter::Import(const std::string path)
|
@ -5,12 +5,12 @@
|
||||
#define TINYGLTF_IMPLEMENTATION
|
||||
#define TINYGLTF_NO_EXTERNAL_IMAGE
|
||||
|
||||
#include "Graphics/Mesh.h"
|
||||
#include "../Graphics/Mesh.h"
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <string>
|
||||
#include "Scene/SceneNodeTypes.h"
|
||||
#include "../Scene/SceneNodeTypes.h"
|
||||
|
||||
|
||||
void ProcessVertices(aiMesh* mesh, std::vector<BarinkEngine::Vertex>& out_vertices);
|
@ -40,10 +40,6 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
Update();
|
||||
|
||||
renderer.Render();
|
||||
|
||||
ImmediateGraphicsDraw();
|
||||
|
||||
GUISystem.Render();
|
||||
|
||||
MainWindow.SwapBuffers();
|
||||
|
@ -1,24 +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();
|
||||
#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();
|
@ -1,4 +1,4 @@
|
||||
#include "../Include/EventSystem/EventEmitter.h"
|
||||
#include "EventEmitter.h"
|
||||
|
||||
|
||||
void EventEmitter::Subscribe(EventListener& subscriber)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "Graphics/Buffer.h"
|
||||
#include "Buffer.h"
|
||||
|
||||
|
||||
int GpuBuffer::getBufferID() {
|
||||
|
@ -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) {
|
||||
|
49
BarinkEngine/src/Graphics/FrameBuffer.cpp
Normal file
49
BarinkEngine/src/Graphics/FrameBuffer.cpp
Normal 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);
|
||||
}
|
20
BarinkEngine/src/Graphics/Framebuffer.h
Normal file
20
BarinkEngine/src/Graphics/Framebuffer.h
Normal 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;
|
||||
|
||||
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
#include "Graphics/GPUBucket.h"
|
||||
#include "GPUBucket.h"
|
||||
BarinkEngine::GPU_Bucket::GPU_Bucket() {
|
||||
}
|
||||
BarinkEngine::GPU_Bucket::~GPU_Bucket() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "Graphics/Window.h"
|
||||
#include "../Window.h"
|
||||
|
||||
|
||||
class GUIManager {
|
@ -1,4 +1,4 @@
|
||||
#include "../Include/Graphics/Material.h"
|
||||
#include "Material.h"
|
||||
|
||||
Material::Material(const Shader& shader) :
|
||||
shader(shader) {
|
||||
|
@ -1,19 +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;
|
||||
|
||||
|
||||
private:
|
||||
const Shader& shader;
|
||||
|
||||
|
||||
#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;
|
||||
|
||||
};
|
@ -1,12 +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;
|
||||
};
|
||||
|
||||
}
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
#include "Vertex.h"
|
||||
|
||||
namespace BarinkEngine {
|
||||
struct Mesh {
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<unsigned int> elements;
|
||||
};
|
||||
|
||||
}
|
@ -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");
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "BarinkEngine.h"
|
||||
#include <vector>;
|
||||
#include "../BarinkEngine.h"
|
||||
#include <vector>
|
||||
class RenderSurface
|
||||
{
|
||||
public:
|
@ -1,14 +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;
|
||||
};
|
||||
#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;
|
||||
};
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,11 +5,12 @@
|
||||
#include "glad/glad.h"
|
||||
#include "GLFW/glfw3.h"
|
||||
|
||||
#include "PerfCounter.h"
|
||||
#include "../PerfCounter.h"
|
||||
|
||||
#include "Graphics/Camera.h"
|
||||
#include "Graphics/Renderable.h"
|
||||
#include "Graphics/GPUBucket.h"
|
||||
#include "Camera.h"
|
||||
#include "Renderable.h"
|
||||
#include "GPUBucket.h"
|
||||
#include "Framebuffer.h"
|
||||
|
||||
namespace BarinkEngine {
|
||||
|
||||
@ -18,7 +19,7 @@ namespace BarinkEngine {
|
||||
Renderer();
|
||||
~Renderer();
|
||||
|
||||
void Render();
|
||||
void Render(Framebuffer& framebuffer);
|
||||
|
||||
void Submit(Renderable* model);
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -1,18 +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;
|
||||
|
||||
#pragma once
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
class Texture {
|
||||
public:
|
||||
Texture(const std::string texturePath);
|
||||
|
||||
void Bind();
|
||||
void Unbind();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
unsigned int Id;
|
||||
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
#include "Graphics/VertexArray.h"
|
||||
#include "VertexArray.h"
|
||||
#include <glad/glad.h>
|
||||
|
||||
void VertexArray::Create(){
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "EventSystem/Event.h"
|
||||
#include "EventSystem/EventListener.h"
|
||||
#include "../EventSystem/Event.h"
|
||||
#include "../EventSystem/EventListener.h"
|
||||
|
||||
class BarinkWindow : EventListener {
|
||||
private:
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "Input/InputManager.h"
|
||||
#include "InputManager.h"
|
||||
|
||||
BarinkEngine::InputManager InputSystem;
|
||||
|
||||
void BarinkEngine::InputManager::PollEvents()
|
||||
|
@ -3,9 +3,9 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "EventSystem/EventEmitter.h"
|
||||
#include "EventSystem/EventListener.h"
|
||||
#include "Graphics/Window.h"
|
||||
#include "../EventSystem/EventEmitter.h"
|
||||
#include "../EventSystem/EventListener.h"
|
||||
#include "../Graphics/Window.h"
|
||||
|
||||
namespace BarinkEngine {
|
||||
|
@ -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*>()) {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Graphics/Transform.h"
|
||||
#include "../Graphics/Transform.h"
|
||||
|
||||
class Node {
|
||||
public:
|
@ -1,4 +1,4 @@
|
||||
#include "Scene/SceneManager.h"
|
||||
#include "SceneManager.h"
|
||||
|
||||
Scene* SceneManager::CreateScene(const std::string& name)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "Scene.h"
|
||||
#include "../Scene.h"
|
||||
class SceneManager {
|
||||
|
||||
public:
|
@ -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))
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Graphics/Camera.h"
|
||||
#include "Graphics/Renderable.h"
|
||||
#include "Scene/Node.h"
|
||||
#include "../Graphics/Camera.h"
|
||||
#include "../Graphics/Renderable.h"
|
||||
#include "Node.h"
|
||||
|
||||
namespace BarinkEngine {
|
||||
class SceneCamera : public Group
|
@ -1,4 +1,4 @@
|
||||
#include "Scripting/LuaScript.h"
|
||||
#include "LuaScript.h"
|
||||
/*
|
||||
LuaScript::LuaScript(const std::string& path)
|
||||
: filePath(path) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "Scripting/LuaScriptingManager.h"
|
||||
#include "LuaScriptingManager.h"
|
||||
/*
|
||||
LuaScriptingManager::LuaScriptingManager()
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include "imgui.h"
|
||||
#include <BarinkEngine.h>
|
||||
#include "../../BarinkEngine/src/BarinkEngine.h"
|
||||
#include "../../BarinkEngine/src/Graphics/Framebuffer.h"
|
||||
|
||||
void CameraTool(Camera* camera);
|
||||
void CameraTool();
|
||||
void ScriptingTool(char* code);
|
||||
void transformWindow(Transform& transform, std::string PanelName);
|
||||
void materialWindow(Material& material, std::string PanelName);
|
||||
void SceneExplorer(Scene& scene, std::string PanelName);
|
||||
void SceneExplorer(const std::string& PanelName);
|
||||
void SceneView(Framebuffer& framebuffer);
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "BarinkEngine.h"
|
||||
#include "../../BarinkEngine/src/BarinkEngine.h"
|
||||
|
||||
void PrintSceneTree(Node& node, int depth);
|
||||
|
||||
|
@ -1,44 +1,51 @@
|
||||
#include "GUI.h"
|
||||
|
||||
void SceneExplorer(Scene& scene, std::string PanelName) {
|
||||
if (ImGui::Begin(PanelName.c_str())) {
|
||||
ImGui::ListBoxHeader("##ObjectList");
|
||||
|
||||
Node& current = scene.GetRoot();
|
||||
void SceneExplorer(const std::string& PanelName) {
|
||||
ImGui::Begin(PanelName.c_str());
|
||||
//if (ImGui::ListBoxHeader("##ObjectList")) {
|
||||
//Node& current = scene.GetRoot();
|
||||
|
||||
Node* next = ¤t;
|
||||
//Node* next = ¤t;
|
||||
|
||||
// Show first node
|
||||
ImGui::Selectable(next->name.c_str(), true);
|
||||
// Show first node
|
||||
//ImGui::Selectable(next->name.c_str(), true);
|
||||
// ImGui::Selectable("Scene Node", true);
|
||||
// ImGui::Indent();
|
||||
|
||||
ImGui::Indent();
|
||||
/*
|
||||
|
||||
if (next->children.size() != 0) {
|
||||
for (auto child : next->children)
|
||||
{
|
||||
std::string& name = child->name;
|
||||
ImGui::Selectable(name.c_str(), false);
|
||||
}
|
||||
}
|
||||
if (next->children.size() != 0) {
|
||||
for (auto child : next->children)
|
||||
{
|
||||
std::string& name = child->name;
|
||||
ImGui::Selectable(name.c_str(), false);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::ListBoxFooter();
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
// ImGui::ListBoxFooter();
|
||||
// }
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CameraTool(Camera* cam) {
|
||||
void CameraTool() {
|
||||
static float Zoom = 0;
|
||||
static glm::vec3 Position = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
static glm::vec3 Rotation = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
||||
ImGui::Begin("Camera");
|
||||
|
||||
ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190);
|
||||
|
||||
ImGui::InputFloat3("Position:", &cam->Position[0]);
|
||||
ImGui::SliderFloat("Zoom:", &Zoom, 10, 190);
|
||||
|
||||
ImGui::InputFloat3("Rotation:", &cam->Rotation[0]);
|
||||
ImGui::InputFloat3("Position:", &Position[0]);
|
||||
|
||||
ImGui::InputFloat3("Rotation:", &Rotation[0]);
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
@ -46,7 +53,8 @@ void CameraTool(Camera* cam) {
|
||||
void ScriptingTool(char* code) {
|
||||
ImGui::Begin("Scripting");
|
||||
|
||||
ImGui::InputTextMultiline("Lua Script", code, 255);
|
||||
ImGui::Text("Lua Code");
|
||||
ImGui::InputTextMultiline("##", code, 255);
|
||||
bool runCode = ImGui::Button("Run");
|
||||
|
||||
|
||||
@ -54,6 +62,12 @@ void ScriptingTool(char* code) {
|
||||
|
||||
}
|
||||
|
||||
void SceneView(Framebuffer& framebuffer ) {
|
||||
ImGui::Begin("Viewport");
|
||||
ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{800, 600});
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
void transformWindow(Transform& transform, std::string PanelName) {
|
||||
ImGui::Begin(PanelName.c_str());
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "BarinkEngine.h"
|
||||
#include "Scene\SceneManager.h"
|
||||
#include "Scene\SceneNodeTypes.h"
|
||||
#include "AssetManager/ModelImporter.h"
|
||||
|
||||
#include "../../BarinkEngine/src/BarinkEngine.h"
|
||||
#include "../../BarinkEngine/src/Scene/SceneManager.h"
|
||||
#include "../../BarinkEngine/src/Scene/SceneNodeTypes.h"
|
||||
#include "../../BarinkEngine/src/AssetManager/ModelImporter.h"
|
||||
#include "../../BarinkEngine/src/Graphics/Framebuffer.h"
|
||||
#include "imgui.h"
|
||||
#include "GUI.h"
|
||||
#include "Util.h"
|
||||
@ -18,7 +18,7 @@ const std::string vertexShaderSource = "../build/SandboxApplication/Debug/test.v
|
||||
const std::string fragmentShaderSource = "../build/SandboxApplication/Debug/test.fs";
|
||||
|
||||
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
|
||||
|
||||
Framebuffer* framebuffer;
|
||||
Scene* Level1;
|
||||
BarinkEngine::SceneObject* cube;
|
||||
/*
|
||||
@ -49,34 +49,32 @@ void Start() {
|
||||
Level1->GetRoot().addChild(*cube);
|
||||
|
||||
memset(code, '\0', 254);
|
||||
framebuffer = new Framebuffer();
|
||||
|
||||
std::cout << "Colour attachment id; "<< framebuffer->GetColourAttachment() << std::endl;
|
||||
// TODO: Move to runtime/ Engine
|
||||
// NOTE: Submits should later be done through walking the sceneTree
|
||||
|
||||
renderer.Submit(cube->renderable);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 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();
|
||||
|
||||
void ImmediateGraphicsDraw()
|
||||
{
|
||||
// Show internal BarinkEngine stats
|
||||
ShowStats();
|
||||
|
||||
SceneView(*framebuffer);
|
||||
|
||||
// Show different tooling for this specific sandbox
|
||||
// CameraTool(cam);
|
||||
//ScriptingTool(code);
|
||||
|
||||
//SceneExplorer(*Level1, "Scene Explorer");
|
||||
CameraTool();
|
||||
ScriptingTool(code);
|
||||
|
||||
SceneExplorer( "Scene Explorer");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -85,14 +83,20 @@ void ImmediateGraphicsDraw() {
|
||||
*/
|
||||
void Update()
|
||||
{
|
||||
|
||||
// glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->GetId());
|
||||
|
||||
renderer.Render(*framebuffer);
|
||||
|
||||
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Runs at the end of the program
|
||||
* - Meant for cleanup
|
||||
*/
|
||||
void Stop() {
|
||||
void Stop()
|
||||
{
|
||||
delete framebuffer;
|
||||
delete MI;
|
||||
delete shader;
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit 6d27fecce1ea2cb10ca956cd67b8179cb76b35c3
|
||||
Subproject commit d666a1d4737739274449dbe0e8558454bba82ec4
|
@ -9,7 +9,6 @@ workspace "BarinkEngine"
|
||||
|
||||
architecture "x86_64"
|
||||
|
||||
|
||||
filter "configurations:Debug"
|
||||
defines {"DEBUG"}
|
||||
symbols "On"
|
||||
|
Loading…
Reference in New Issue
Block a user