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,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);

View File

@ -1,5 +1,5 @@
#pragma once
#include "BarinkEngine.h"
#include "../../BarinkEngine/src/BarinkEngine.h"
void PrintSceneTree(Node& node, int depth);

View File

@ -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 = &current;
//Node* next = &current;
// 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());

View File

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