Framebuffer now takes a size parameter

Scene now fills entire scene/Game view widget
This commit is contained in:
2022-11-11 19:30:54 +01:00
parent 628225af45
commit 3d3596a3b6
6 changed files with 38 additions and 24 deletions

View File

@ -4,6 +4,8 @@
#include "../../YoggieEngine/src/PerfCounter.h"
#include "../../YoggieEngine/src/Scene/Entity.h"
#include "Project/Project.h"
#include "AssetManagement/AssetManager.h"
class EditorRuntime : public ApplicationRuntime {
@ -12,8 +14,15 @@ public:
void Start() override
{
CurrentProject = std::make_shared<Project>("Random");
std::string path = (std::filesystem::current_path()).string();
CurrentProject.get()->setProjectDirectory(path);
framebuffer = new Framebuffer();
AssetManager::Init();
AssetManager::setAssetPath(CurrentProject.get()->GetProjectDirectory());
AssetManager::BuildAssetView();
framebuffer = new Framebuffer(800, 600);
// Create a level and load it as the current level
auto importer = ModelImporter();
@ -43,6 +52,7 @@ public:
void Update() override
{
}
void FixedUpdate() override

View File

@ -117,27 +117,18 @@ void SceneExplorer(entt::entity& selected, Scene& scene )
void Viewport(Framebuffer& framebuffer) {
unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar ;
ImGui::Begin("Viewport", false, viewportWindowFlags);
ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)800,(float)600 });
ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()});
ImGuizmo::SetDrawlist();
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
ImGuizmo::Enable(true);
auto cam = glm::mat4(1.0f);
auto eye = glm::vec3(0.0f);
auto center = glm::vec3(0.0f);
auto up = glm::vec3(0.0f, 1.0f, 0.0f);
auto view = glm::lookAt(eye, center, up);
glm::mat4 projection = glm::perspective(glm::radians(90.0f), (800.0f / 600.0f), 0.001f, 100.0f);
auto transformMatrix = glm::mat4(1.0f);
ImGuizmo::Manipulate(glm::value_ptr(view), glm::value_ptr(projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(transformMatrix));
//ImGuizmo::SetDrawlist();
//ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
//ImGuizmo::Enable(true);
//ImGuizmo::Manipulate(glm::value_ptr(view), glm::value_ptr(projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(trans));
//ImGuizmo::Manipulate(glm::value_ptr(static_cam), glm::value_ptr(static_projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(trans));
ImGuizmo::ViewManipulate(glm::value_ptr(cam), 8.0f, ImVec2{ 0.0f,0.0f }, ImVec2{ 128.0f,128.0f }, 0x10101010);
ImGui::End();
}
@ -147,7 +138,7 @@ void GamePort(Framebuffer& framebuffer)
unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
ImGui::Begin("Game", false, viewportWindowFlags);
ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)800, (float)600 });
ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), { ImGui::GetWindowWidth(), ImGui::GetWindowHeight() });
ImGui::End();

View File

@ -36,7 +36,6 @@ public:
double previous = glfwGetTime();
double lag = 0.0;
AssetManager::Init();
renderer->Prepare(activeRuntime.MainScene);
while (!mainWindow.WindowShouldClose())