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",
|
"glfw3",
|
||||||
|
|
||||||
"ImGUI_Opengl3",
|
"ImGUI_Opengl3",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,9 +50,9 @@ project "BarinkEngine"
|
|||||||
"../libs/glad/src/glad.c",
|
"../libs/glad/src/glad.c",
|
||||||
|
|
||||||
"./src/*.cpp",
|
"./src/*.cpp",
|
||||||
"./Include/*.h",
|
"./src/*.h",
|
||||||
"./src/**/*.cpp",
|
"./src/**/*.cpp",
|
||||||
"./Include/**/*.h"
|
"./src/**/*.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "AssetManager/ModelImporter.h"
|
#include "ModelImporter.h"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
BarinkEngine::SceneObject* BarinkEngine::ModelImporter::Import(const std::string path)
|
BarinkEngine::SceneObject* BarinkEngine::ModelImporter::Import(const std::string path)
|
@ -5,12 +5,12 @@
|
|||||||
#define TINYGLTF_IMPLEMENTATION
|
#define TINYGLTF_IMPLEMENTATION
|
||||||
#define TINYGLTF_NO_EXTERNAL_IMAGE
|
#define TINYGLTF_NO_EXTERNAL_IMAGE
|
||||||
|
|
||||||
#include "Graphics/Mesh.h"
|
#include "../Graphics/Mesh.h"
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Scene/SceneNodeTypes.h"
|
#include "../Scene/SceneNodeTypes.h"
|
||||||
|
|
||||||
|
|
||||||
void ProcessVertices(aiMesh* mesh, std::vector<BarinkEngine::Vertex>& out_vertices);
|
void ProcessVertices(aiMesh* mesh, std::vector<BarinkEngine::Vertex>& out_vertices);
|
@ -40,10 +40,6 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
renderer.Render();
|
|
||||||
|
|
||||||
ImmediateGraphicsDraw();
|
|
||||||
|
|
||||||
GUISystem.Render();
|
GUISystem.Render();
|
||||||
|
|
||||||
MainWindow.SwapBuffers();
|
MainWindow.SwapBuffers();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "../Include/EventSystem/EventEmitter.h"
|
#include "EventEmitter.h"
|
||||||
|
|
||||||
|
|
||||||
void EventEmitter::Subscribe(EventListener& subscriber)
|
void EventEmitter::Subscribe(EventListener& subscriber)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "Graphics/Buffer.h"
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
|
||||||
int GpuBuffer::getBufferID() {
|
int GpuBuffer::getBufferID() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "Graphics/Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom)
|
Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom)
|
||||||
: Position(position), Rotation(rotation), Zoom(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() {
|
||||||
}
|
}
|
||||||
BarinkEngine::GPU_Bucket::~GPU_Bucket() {
|
BarinkEngine::GPU_Bucket::~GPU_Bucket() {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include "Graphics/GUI/GUIManager.h"
|
#include "GUIManager.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "backends/imgui_impl_opengl3.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)
|
GUIManager::GUIManager(BarinkWindow* window)
|
||||||
: currentwindow(window)
|
: currentwindow(window)
|
||||||
@ -9,16 +10,15 @@ GUIManager::GUIManager(BarinkWindow* window)
|
|||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
(void)io;
|
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
|
||||||
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
|
||||||
ImGui_ImplGlfw_InitForOpenGL(currentwindow->windowptr(), true);
|
ImGui_ImplGlfw_InitForOpenGL(currentwindow->windowptr(), true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 440");
|
ImGui_ImplOpenGL3_Init("#version 440");
|
||||||
|
|
||||||
|
|
||||||
ImGui_ImplGlfw_NewFrame();
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIManager::~GUIManager()
|
GUIManager::~GUIManager()
|
||||||
@ -28,11 +28,47 @@ GUIManager::~GUIManager()
|
|||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GUIManager::Render()
|
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::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
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
|
#pragma once
|
||||||
#include "Graphics/Window.h"
|
#include "../Window.h"
|
||||||
|
|
||||||
|
|
||||||
class GUIManager {
|
class GUIManager {
|
@ -1,4 +1,4 @@
|
|||||||
#include "../Include/Graphics/Material.h"
|
#include "Material.h"
|
||||||
|
|
||||||
Material::Material(const Shader& shader) :
|
Material::Material(const Shader& shader) :
|
||||||
shader(shader) {
|
shader(shader) {
|
||||||
|
@ -8,12 +8,7 @@ public:
|
|||||||
Material(const Shader& shader);
|
Material(const Shader& shader);
|
||||||
|
|
||||||
void Apply()const;
|
void Apply()const;
|
||||||
|
|
||||||
glm::vec3 Color;
|
glm::vec3 Color;
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Shader& shader;
|
const Shader& shader;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
@ -1,4 +1,4 @@
|
|||||||
#include "Graphics/RenderSurface.h";
|
#include "RenderSurface.h";
|
||||||
|
|
||||||
RenderSurface::RenderSurface(){
|
RenderSurface::RenderSurface(){
|
||||||
shader = new Shader("build/SandboxAppliction/Debug/renderSuface.vs", "build/SandboxApplication/Debug/renderSurface.fs");
|
shader = new Shader("build/SandboxAppliction/Debug/renderSuface.vs", "build/SandboxApplication/Debug/renderSurface.fs");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "BarinkEngine.h"
|
#include "../BarinkEngine.h"
|
||||||
#include <vector>;
|
#include <vector>
|
||||||
class RenderSurface
|
class RenderSurface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
@ -2,7 +2,7 @@
|
|||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
#include "Material.h"
|
#include "Material.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Scene.h"
|
#include "../Scene.h"
|
||||||
|
|
||||||
namespace BarinkEngine {
|
namespace BarinkEngine {
|
||||||
|
|
@ -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()
|
BarinkEngine::Renderer::Renderer()
|
||||||
{
|
{
|
||||||
@ -18,13 +22,12 @@ BarinkEngine::Renderer::~Renderer()
|
|||||||
// glDeleteBuffers(1, &UV_id);
|
// glDeleteBuffers(1, &UV_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Angle = 0.0;
|
void BarinkEngine::Renderer::Render(Framebuffer& framebuffer)
|
||||||
|
|
||||||
void BarinkEngine::Renderer::Render()
|
|
||||||
{
|
{
|
||||||
// This creation of the projection and camera is somewhat wastefull
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.GetId());
|
||||||
Camera cam = Camera(glm::vec3(16.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f);
|
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
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);
|
||||||
|
|
||||||
Angle += 0.0001f;
|
Angle += 0.0001f;
|
||||||
|
|
||||||
for (auto model : models) {
|
for (auto model : models) {
|
||||||
@ -33,9 +36,9 @@ void BarinkEngine::Renderer::Render()
|
|||||||
|
|
||||||
model->elementBuffer.Bind(true);
|
model->elementBuffer.Bind(true);
|
||||||
|
|
||||||
|
|
||||||
if (model->material == nullptr) {
|
if (model->material == nullptr) {
|
||||||
std::cout << "No material attached!" << std::endl;
|
std::cout << "No material attached!" << std::endl;
|
||||||
|
// continue; //NOTE: Or use some default Material
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
model->material->shader.Use();
|
model->material->shader.Use();
|
||||||
@ -47,9 +50,6 @@ 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("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("V", cam.GetViewMatrix());
|
||||||
model->material->shader.setUniformMat4("P", projection);
|
model->material->shader.setUniformMat4("P", projection);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update perf counters
|
// Update perf counters
|
||||||
ES.verts = model->mesh->vertices.size();
|
ES.verts = model->mesh->vertices.size();
|
||||||
ES.DC++;
|
ES.DC++;
|
||||||
@ -59,13 +59,15 @@ void BarinkEngine::Renderer::Render()
|
|||||||
GL_UNSIGNED_INT,
|
GL_UNSIGNED_INT,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
model->vertexarray.Unbind();
|
model->vertexarray.Unbind();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
#include "glad/glad.h"
|
#include "glad/glad.h"
|
||||||
#include "GLFW/glfw3.h"
|
#include "GLFW/glfw3.h"
|
||||||
|
|
||||||
#include "PerfCounter.h"
|
#include "../PerfCounter.h"
|
||||||
|
|
||||||
#include "Graphics/Camera.h"
|
#include "Camera.h"
|
||||||
#include "Graphics/Renderable.h"
|
#include "Renderable.h"
|
||||||
#include "Graphics/GPUBucket.h"
|
#include "GPUBucket.h"
|
||||||
|
#include "Framebuffer.h"
|
||||||
|
|
||||||
namespace BarinkEngine {
|
namespace BarinkEngine {
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ namespace BarinkEngine {
|
|||||||
Renderer();
|
Renderer();
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
|
||||||
void Render();
|
void Render(Framebuffer& framebuffer);
|
||||||
|
|
||||||
void Submit(Renderable* model);
|
void Submit(Renderable* model);
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "Graphics/Shader.h"
|
#include "Shader.h"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath)
|
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 <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "Graphics/stb_image.h"
|
#include "stb_image.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
Texture::Texture(const std::string texturePath) {
|
Texture::Texture(const std::string texturePath) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "Graphics/VertexArray.h"
|
#include "VertexArray.h"
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
void VertexArray::Create(){
|
void VertexArray::Create(){
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
#include "EventSystem/Event.h"
|
#include "../EventSystem/Event.h"
|
||||||
#include "EventSystem/EventListener.h"
|
#include "../EventSystem/EventListener.h"
|
||||||
|
|
||||||
class BarinkWindow : EventListener {
|
class BarinkWindow : EventListener {
|
||||||
private:
|
private:
|
@ -1,4 +1,4 @@
|
|||||||
#include "Graphics/Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
bool BarinkWindow::InitGLFW(){
|
bool BarinkWindow::InitGLFW(){
|
||||||
if(!glfwInit())
|
if(!glfwInit())
|
||||||
@ -54,7 +54,6 @@ Width(width), Height(height), FullScreen(false){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BarinkWindow::~BarinkWindow(){
|
BarinkWindow::~BarinkWindow(){
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
@ -81,6 +80,6 @@ void BarinkWindow::SwapBuffers()
|
|||||||
|
|
||||||
void BarinkWindow::ReceiveEvent(Event& incident)
|
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;
|
BarinkEngine::InputManager InputSystem;
|
||||||
|
|
||||||
void BarinkEngine::InputManager::PollEvents()
|
void BarinkEngine::InputManager::PollEvents()
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
#include "EventSystem/EventEmitter.h"
|
#include "../EventSystem/EventEmitter.h"
|
||||||
#include "EventSystem/EventListener.h"
|
#include "../EventSystem/EventListener.h"
|
||||||
#include "Graphics/Window.h"
|
#include "../Graphics/Window.h"
|
||||||
|
|
||||||
namespace BarinkEngine {
|
namespace BarinkEngine {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "Scene/Node.h"
|
#include "Node.h"
|
||||||
|
|
||||||
Node::Node(const std::string& name)
|
Node::Node(const std::string& name)
|
||||||
: name(name), parent(nullptr), children(std::vector<Node*>()) {}
|
: name(name), parent(nullptr), children(std::vector<Node*>()) {}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Graphics/Transform.h"
|
#include "../Graphics/Transform.h"
|
||||||
|
|
||||||
class Node {
|
class Node {
|
||||||
public:
|
public:
|
@ -1,4 +1,4 @@
|
|||||||
#include "Scene/SceneManager.h"
|
#include "SceneManager.h"
|
||||||
|
|
||||||
Scene* SceneManager::CreateScene(const std::string& name)
|
Scene* SceneManager::CreateScene(const std::string& name)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "Scene.h"
|
#include "../Scene.h"
|
||||||
class SceneManager {
|
class SceneManager {
|
||||||
|
|
||||||
public:
|
public:
|
@ -1,4 +1,4 @@
|
|||||||
#include "Scene/SceneNodeTypes.h"
|
#include "SceneNodeTypes.h"
|
||||||
|
|
||||||
BarinkEngine::SceneCamera::SceneCamera()
|
BarinkEngine::SceneCamera::SceneCamera()
|
||||||
: Group(std::string("Camera")), camera(Camera(glm::vec3(0.0f), glm::vec3(0.0f), 0))
|
: Group(std::string("Camera")), camera(Camera(glm::vec3(0.0f), glm::vec3(0.0f), 0))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Graphics/Camera.h"
|
#include "../Graphics/Camera.h"
|
||||||
#include "Graphics/Renderable.h"
|
#include "../Graphics/Renderable.h"
|
||||||
#include "Scene/Node.h"
|
#include "Node.h"
|
||||||
|
|
||||||
namespace BarinkEngine {
|
namespace BarinkEngine {
|
||||||
class SceneCamera : public Group
|
class SceneCamera : public Group
|
@ -1,4 +1,4 @@
|
|||||||
#include "Scripting/LuaScript.h"
|
#include "LuaScript.h"
|
||||||
/*
|
/*
|
||||||
LuaScript::LuaScript(const std::string& path)
|
LuaScript::LuaScript(const std::string& path)
|
||||||
: filePath(path) {
|
: filePath(path) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "Scripting/LuaScriptingManager.h"
|
#include "LuaScriptingManager.h"
|
||||||
/*
|
/*
|
||||||
LuaScriptingManager::LuaScriptingManager()
|
LuaScriptingManager::LuaScriptingManager()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "imgui.h"
|
#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 ScriptingTool(char* code);
|
||||||
void transformWindow(Transform& transform, std::string PanelName);
|
void transformWindow(Transform& transform, std::string PanelName);
|
||||||
void materialWindow(Material& material, 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
|
#pragma once
|
||||||
#include "BarinkEngine.h"
|
#include "../../BarinkEngine/src/BarinkEngine.h"
|
||||||
|
|
||||||
void PrintSceneTree(Node& node, int depth);
|
void PrintSceneTree(Node& node, int depth);
|
||||||
|
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
#include "GUI.h"
|
#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
|
// Show first node
|
||||||
ImGui::Selectable(next->name.c_str(), true);
|
//ImGui::Selectable(next->name.c_str(), true);
|
||||||
|
// ImGui::Selectable("Scene Node", true);
|
||||||
|
// ImGui::Indent();
|
||||||
|
|
||||||
ImGui::Indent();
|
/*
|
||||||
|
|
||||||
if (next->children.size() != 0) {
|
if (next->children.size() != 0) {
|
||||||
for (auto child : next->children)
|
for (auto child : next->children)
|
||||||
@ -21,24 +23,29 @@ void SceneExplorer(Scene& scene, std::string PanelName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::ListBoxFooter();
|
*/
|
||||||
|
|
||||||
|
// ImGui::ListBoxFooter();
|
||||||
}
|
// }
|
||||||
ImGui::End();
|
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::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();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
@ -46,7 +53,8 @@ void CameraTool(Camera* cam) {
|
|||||||
void ScriptingTool(char* code) {
|
void ScriptingTool(char* code) {
|
||||||
ImGui::Begin("Scripting");
|
ImGui::Begin("Scripting");
|
||||||
|
|
||||||
ImGui::InputTextMultiline("Lua Script", code, 255);
|
ImGui::Text("Lua Code");
|
||||||
|
ImGui::InputTextMultiline("##", code, 255);
|
||||||
bool runCode = ImGui::Button("Run");
|
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) {
|
void transformWindow(Transform& transform, std::string PanelName) {
|
||||||
ImGui::Begin(PanelName.c_str());
|
ImGui::Begin(PanelName.c_str());
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "BarinkEngine.h"
|
#include "../../BarinkEngine/src/BarinkEngine.h"
|
||||||
#include "Scene\SceneManager.h"
|
#include "../../BarinkEngine/src/Scene/SceneManager.h"
|
||||||
#include "Scene\SceneNodeTypes.h"
|
#include "../../BarinkEngine/src/Scene/SceneNodeTypes.h"
|
||||||
#include "AssetManager/ModelImporter.h"
|
#include "../../BarinkEngine/src/AssetManager/ModelImporter.h"
|
||||||
|
#include "../../BarinkEngine/src/Graphics/Framebuffer.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
#include "Util.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";
|
const std::string fragmentShaderSource = "../build/SandboxApplication/Debug/test.fs";
|
||||||
|
|
||||||
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
|
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
|
||||||
|
Framebuffer* framebuffer;
|
||||||
Scene* Level1;
|
Scene* Level1;
|
||||||
BarinkEngine::SceneObject* cube;
|
BarinkEngine::SceneObject* cube;
|
||||||
/*
|
/*
|
||||||
@ -49,11 +49,13 @@ void Start() {
|
|||||||
Level1->GetRoot().addChild(*cube);
|
Level1->GetRoot().addChild(*cube);
|
||||||
|
|
||||||
memset(code, '\0', 254);
|
memset(code, '\0', 254);
|
||||||
|
framebuffer = new Framebuffer();
|
||||||
|
|
||||||
|
std::cout << "Colour attachment id; "<< framebuffer->GetColourAttachment() << std::endl;
|
||||||
// TODO: Move to runtime/ Engine
|
// TODO: Move to runtime/ Engine
|
||||||
// NOTE: Submits should later be done through walking the sceneTree
|
// NOTE: Submits should later be done through walking the sceneTree
|
||||||
renderer.Submit(cube->renderable);
|
|
||||||
|
|
||||||
|
renderer.Submit(cube->renderable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,21 +63,17 @@ void Start() {
|
|||||||
* Runs every frame
|
* Runs every frame
|
||||||
* - Use to draw Immediate mode graphics (Not meant for HUD's )
|
* - Use to draw Immediate mode graphics (Not meant for HUD's )
|
||||||
*/
|
*/
|
||||||
void ImmediateGraphicsDraw() {
|
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
|
// Show internal BarinkEngine stats
|
||||||
ShowStats();
|
ShowStats();
|
||||||
|
SceneView(*framebuffer);
|
||||||
|
|
||||||
// Show different tooling for this specific sandbox
|
// Show different tooling for this specific sandbox
|
||||||
// CameraTool(cam);
|
CameraTool();
|
||||||
//ScriptingTool(code);
|
ScriptingTool(code);
|
||||||
|
|
||||||
//SceneExplorer(*Level1, "Scene Explorer");
|
SceneExplorer( "Scene Explorer");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,14 +83,20 @@ void ImmediateGraphicsDraw() {
|
|||||||
*/
|
*/
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
// glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->GetId());
|
||||||
|
|
||||||
|
renderer.Render(*framebuffer);
|
||||||
|
|
||||||
|
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Runs at the end of the program
|
* Runs at the end of the program
|
||||||
* - Meant for cleanup
|
* - Meant for cleanup
|
||||||
*/
|
*/
|
||||||
void Stop() {
|
void Stop()
|
||||||
|
{
|
||||||
|
delete framebuffer;
|
||||||
delete MI;
|
delete MI;
|
||||||
delete shader;
|
delete shader;
|
||||||
}
|
}
|
@ -1 +1 @@
|
|||||||
Subproject commit 6d27fecce1ea2cb10ca956cd67b8179cb76b35c3
|
Subproject commit d666a1d4737739274449dbe0e8558454bba82ec4
|
@ -9,7 +9,6 @@ workspace "BarinkEngine"
|
|||||||
|
|
||||||
architecture "x86_64"
|
architecture "x86_64"
|
||||||
|
|
||||||
|
|
||||||
filter "configurations:Debug"
|
filter "configurations:Debug"
|
||||||
defines {"DEBUG"}
|
defines {"DEBUG"}
|
||||||
symbols "On"
|
symbols "On"
|
||||||
|
Loading…
Reference in New Issue
Block a user