Compare commits

...

28 Commits

Author SHA1 Message Date
Jack Christensen 3f6f19aaf0 Update .gitlab-ci.yml file 2024-08-29 15:32:12 +00:00
Jack Christensen fa298669ef Update .gitlab-ci.yml file 2024-08-29 05:16:01 +00:00
Jack Christensen a4070255f5 Update .gitlab-ci.yml file 2024-08-29 05:14:02 +00:00
Jack 353ba0ef63 Add release to .gitlab-ci.yml 2024-08-29 01:12:10 -04:00
Jack 0ffef286eb Updated to v0.0.4 2024-08-28 23:14:36 -04:00
Jack f8e1c14fa7 Merge branch 'main' of https://git.jackmchristensen.com/jack/terravisor 2024-08-28 23:12:22 -04:00
Jack 9a3b928c8f Merge branches 2024-08-28 23:12:18 -04:00
Jack Christensen 8f6b1de6fc Merge branch 'feature/3-mesh-tessellation' into 'main'
Bind attribute location

See merge request jack/terravisor!4
2024-08-29 03:10:24 +00:00
Jack b3aac984a7 Correctly calculate normals with dynamic tessellation 2024-08-28 23:07:40 -04:00
Jack 85533814e1 Dynamic tessellation based on slope
TODO normals do not reflect slope tessellation
2024-08-28 22:24:23 -04:00
Jack 9fa18ac69e Merge branch 'main' into feature/3-mesh-tessellation 2024-08-28 21:20:02 -04:00
Jack Christensen 9e6d0d4c02 Merge branch 'feature/interface-scaling' into 'main'
Resize font and add JetBrainsMono

See merge request jack/terravisor!3
2024-08-29 01:13:43 +00:00
Jack af7fa08016 Add check for OS to get font
For some reason in Windows, the root directory is /terravisor, but in Linux it's /terravisor/build. Idk why it is that way in Windows.
2024-08-28 21:12:19 -04:00
Jack fa24633a9e Check root directory for font 2024-08-28 21:09:26 -04:00
Jack 9c00945ea1 Resize font and add JetBrainsMono 2024-08-28 21:07:15 -04:00
Jack 93048ed1b6 Merge branch 'main' into feature/3-mesh-tessellation 2024-08-28 13:59:01 -04:00
Jack da8487d7dd Update to v0.0.3 2024-08-28 13:50:54 -04:00
Jack 5b38f5548e Updated imgui.ini 2024-08-28 10:06:02 -04:00
Jack a66f4e275a Merge branch 'feature/1-camera-controls' into feature/3-mesh-tessellation 2024-08-28 10:05:24 -04:00
Jack 97e13c088e Camera updates correctly on window resize 2024-08-28 09:45:08 -04:00
Jack 1b54280c52 Create Interface struct and functions to control ImGui windows
Should now be able to get and manipulate data pertaining to the ImGui windows so I can properly update the camera's aspect.
2024-08-26 16:53:49 -04:00
Jack eff5bb09e9 Add check for viewport size change to update camera 2024-08-26 10:58:22 -04:00
Jack eb1e2a0ba8 Resize viewport keeps propper aspect
TODO keep correct aspect when resizing main window
2024-08-26 10:55:54 -04:00
Jack a92b85ab35 Add GeoData to TEC 2024-08-25 23:04:34 -04:00
Jack c4f539c5b8 Fix namechange
Revert back to regular uniforms file name
2024-08-25 22:53:24 -04:00
Jack 1b4e3990e8 Tmp commit
Because I'm just renaming a file by making it lower case (technically snake_case) I need to do a tmp commit so the rename sticks.
2024-08-25 22:52:15 -04:00
Jack 7cf2ec7b55 Refactor uniforms
Add GeoData to control uniforms for geo pass. TODO refactor post pass uniforms
2024-08-25 22:49:45 -04:00
Jack f638a2f1f8 Bind attribute location
Realized that attribute locations were not bound for the geometry pass. Fixed that and renamed variables to be camelCase
2024-08-25 22:16:14 -04:00
46 changed files with 288 additions and 105 deletions

View File

@ -7,6 +7,7 @@ stages:
variables:
VCPKG_ROOT: "/vcpkg"
CMAKE_BUILD_TYPE: "Release"
build:
stage: build
@ -32,4 +33,4 @@ run_tests:
- export DISPLAY=:99
- export TEST_MODE=1
- cd build
- ./TerraVisor
- ./TerraVisor

View File

@ -1,3 +1,11 @@
## [v0.0.2] - 2024-08-25
### Changed
- Refactored uniform handling in the initial geometry pass to improve maintainability.
- Refactored uniform handling in the initial geometry pass to improve maintainability.
## [v0.0.3] - 2024-08-28
### Changed
- Correctly manage window resizing for camera aspect ratio
## [v0.0.4] - 2024-08-28
### Changed
- Added dynamic tessellation determined by the slope of the terrain

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(TerraVisor VERSION 0.0.2)
project(TerraVisor VERSION 0.0.4)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

View File

@ -4,8 +4,8 @@ Size=400,400
Collapsed=0
[Window][Terrain Controls]
Pos=877,19
Size=403,701
Pos=861,19
Size=419,701
Collapsed=0
DockId=0x00000002,0
@ -19,17 +19,31 @@ Collapsed=0
[Window][TerraVisor]
Pos=0,0
Size=1280,720
Size=2880,1676
Collapsed=0
[Window][Scene Window]
Pos=0,19
Size=875,701
Size=859,701
Collapsed=0
DockId=0x00000001,0
DockId=0x00000003,0
[Window][Viewport]
Pos=0,34
Size=2178,1641
Collapsed=0
DockId=0x00000003,0
[Window][Scene Settings]
Pos=2181,34
Size=699,1641
Collapsed=0
DockId=0x00000004,0
[Docking][Data]
DockSpace ID=0x6F42A598 Window=0xE80F322C Pos=0,19 Size=1280,701 Split=X Selected=0x9F2D9299
DockNode ID=0x00000001 Parent=0x6F42A598 SizeRef=875,701 CentralNode=1 Selected=0x9F2D9299
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=403,701 Selected=0xF69494A7
DockSpace ID=0x6F42A598 Window=0xE80F322C Pos=0,34 Size=2880,1641 Split=X Selected=0x9F2D9299
DockNode ID=0x00000001 Parent=0x6F42A598 SizeRef=0,0 Split=X Selected=0x13926F0B
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=578,701 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=699,701 Selected=0x413E6147
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=419,701 Selected=0xF69494A7

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,6 +13,7 @@ struct Framebuffer {
namespace FBO {
Framebuffer GenerateFramebuffer(int width, int height);
void UpdateFrameBuffer(Framebuffer& fbo, int width, int height);
void Bind(const Framebuffer& fbo);
void Unbind();
void Cleanup(const Framebuffer& fbo);

29
include/interface.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef INTERFACE_H_
#define INTERFACE_H_
#include <GLFW/glfw3.h>
#include <imgui.h>
#include <string>
#include <vector>
#include <functional>
struct Window {
std::string name;
ImVec2 size;
ImVec2 position;
bool isOpen = true;
std::function<void()> renderContent;
Window(const std::string& name, std::function<void()> renderFunc)
: name(name), size(ImVec2(512, 512)), position(ImVec2(0, 0)), renderContent(renderFunc) {}
};
namespace Interface {
void ApplyUIScaling(GLFWwindow* window);
void AddWindow(std::vector<Window>& windows, const std::string& name, std::function<void()> renderFunc);
Window* GetWindowByName(std::vector<Window>& windows, const std::string& name);
void RenderWindows(std::vector<Window>& windows);
}
#endif // INTERFACE_H_

View File

@ -8,6 +8,7 @@
#include "fbo.h"
#include "camera.h"
#include "interface.h"
struct Vertex {
glm::vec3 position;
@ -25,15 +26,21 @@ class Scene {
void DrawGui(GLFWwindow* window);
void Idle();
void ReloadShader();
void UpdateCamera();
void OnScreenResize(Window* viewport);
void UpdateViewport();
std::vector<int16_t> LoadHGT(const std::string& filename, int width, int height);
int window_width;
int window_height;
std::vector<Window> windows_;
private:
void InitBuffers();
void InitQuadBuffers();
void InitShaders();
void InitUI();
Camera activeCamera_;
Framebuffer geo_fbo_;
@ -52,7 +59,6 @@ class Scene {
glm::mat4 view_matrix_;
glm::mat4 projection_matrix_;
void UpdateCamera();
int16_t SwapEndian(int16_t val);
GLuint CreateHeightmapTexture(std::vector<int16_t> data, int width, int height);
};

View File

@ -24,21 +24,48 @@ in VS_OUT {
out TC_OUT {
vec3 position;
vec2 texCoord;
float tessLevel;
} tc_out[];
float getHeight(vec2 uv) {
return texture(heightTexture, uv).r * displacementScale;
}
float calculateSlope() {
float step = 1.0f / (float(gridDensity) * maxTessellation + 1.0f);
// Find surrounding heights
float hLeft = getHeight(tc_in[gl_InvocationID].texCoord + vec2(-step, 0.0f));
float hRight = getHeight(tc_in[gl_InvocationID].texCoord + vec2(step, 0.0f));
float hUp = getHeight(tc_in[gl_InvocationID].texCoord + vec2(0.0f, step));
float hDown = getHeight(tc_in[gl_InvocationID].texCoord + vec2(0.0f, -step));
float slopeX = abs(hLeft - hRight) * displacementScale;
float slopeY = abs(hUp - hDown) * displacementScale;
float maxSlope = max(slopeX, slopeY);
return maxSlope;
}
void main() {
// Pass through position and texture coordinates to the tessellation evaluation shader
tc_out[gl_InvocationID].position = tc_in[gl_InvocationID].position;
tc_out[gl_InvocationID].texCoord = tc_in[gl_InvocationID].texCoord;
float slope = calculateSlope();
float tessLevel = tessellationFactor * (1.0f + slope * 10.0f);
tessLevel = max(tessLevel, maxTessellation);
tc_out[gl_InvocationID].tessLevel = tessLevel;
// Set tessellation levels
if (gl_InvocationID == 0) {
gl_TessLevelOuter[0] = maxTessellation;
gl_TessLevelOuter[1] = maxTessellation;
gl_TessLevelOuter[2] = maxTessellation;
gl_TessLevelOuter[3] = maxTessellation;
gl_TessLevelOuter[0] = tessLevel;
gl_TessLevelOuter[1] = tessLevel;
gl_TessLevelOuter[2] = tessLevel;
gl_TessLevelOuter[3] = tessLevel;
gl_TessLevelInner[0] = maxTessellation;
gl_TessLevelInner[1] = maxTessellation;
gl_TessLevelInner[0] = tessLevel;
gl_TessLevelInner[1] = tessLevel;
}
}

View File

@ -18,6 +18,7 @@ layout(std140, binding = 4) uniform GeoUniforms
in TC_OUT {
vec3 position;
vec2 texCoord;
float tessLevel;
} te_in[];
out TE_OUT {
@ -30,19 +31,25 @@ float getHeight(vec2 uv) {
return texture(heightTexture, uv).r * displacementScale;
}
float getNeighbor(float tessFactor) {
return (float(gridDensity) * tessFactor + 1.0f);
}
vec3 calculateSmoothNormal(vec3 pos, vec2 coord) {
// Currently hardcoded to match patch density
float step = 1.0f / (float(gridDensity) * maxTessellation + 1.0f);
//float step = 1.0f / (float(gridDensity) * tessLevel + 1.0f);
float stepU = 1.0f / (float(gridDensity) * gl_TessLevelInner[0]);
float stepV = 1.0f / (float(gridDensity) * gl_TessLevelInner[1]);
// Find surrounding heights
float hLeft = getHeight(coord + vec2(-step, 0.0f));
float hRight = getHeight(coord + vec2(step, 0.0f));
float hUp = getHeight(coord + vec2(0.0f, step));
float hDown = getHeight(coord + vec2(0.0f, -step));
float hLeft = getHeight(coord + vec2(-stepU, 0.0f));
float hRight = getHeight(coord + vec2(stepU, 0.0f));
float hUp = getHeight(coord + vec2(0.0f, stepV));
float hDown = getHeight(coord + vec2(0.0f, -stepV));
// Calculate tangents
vec3 tangentX = normalize(vec3(step, hRight - hLeft, 0.0));
vec3 tangentY = normalize(vec3(0.0, hUp - hDown, step));
vec3 tangentX = normalize(vec3(stepU, hRight - hLeft, 0.0));
vec3 tangentY = normalize(vec3(0.0, hUp - hDown, stepV));
return normalize(cross(tangentY, tangentX));
}

View File

@ -1,6 +1,7 @@
#include <glm/glm.hpp>
#include "callbacks.h"
#include "interface.h"
namespace Callbacks {
Scene* scene_ = nullptr;
@ -52,11 +53,17 @@ void Callbacks::MouseButton(GLFWwindow* window, int button, int action, int mods
void Callbacks::Resize(GLFWwindow* window, int width, int height)
{
width = glm::max(1, width);
height = glm::max(1, height);
//Set viewport to cover entire framebuffer
glViewport(0, 0, width, height);
Window* viewport = Interface::GetWindowByName(scene_->windows_, "Viewport");
scene_->window_width = static_cast<int>(viewport->size.x);
scene_->window_height = static_cast<int>(viewport->size.y);
scene_->OnScreenResize(viewport);
//Set aspect ratio used in view matrix calculation
// scene_->window_width = width;
// scene_->window_height = height;
// scene_->Scene::UpdateCamera();
//Scene::Camera::Aspect = float(width) / float(height);
//Scene::Camera::UpdateP();
}

View File

@ -54,6 +54,13 @@ namespace FBO {
Framebuffer GenerateFramebuffer(int width, int height) {
Framebuffer fbo;
fbo.id = CreateFramebuffer();
UpdateFrameBuffer(fbo, width, height);
return fbo;
}
void UpdateFrameBuffer(Framebuffer& fbo, int width, int height) {
glBindFramebuffer(GL_FRAMEBUFFER, fbo.id);
fbo.albedoTexture = CreateTexture(width, height, GL_RGBA);
@ -73,8 +80,6 @@ namespace FBO {
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
return fbo;
}
void Bind(const Framebuffer& fbo) {

107
source/interface.cpp Normal file
View File

@ -0,0 +1,107 @@
#include "interface.h"
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <algorithm>
#include <iostream>
#include <filesystem>
namespace Interface {
void ApplyUIScaling(GLFWwindow* window) {
float xScale, yScale;
glfwGetWindowContentScale(window, &xScale, &yScale);
float scale = (xScale + yScale) * 0.5f;
ImGui::GetIO().FontGlobalScale = scale;
ImGuiStyle& style = ImGui::GetStyle();
style.ScaleAllSizes(scale);
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
#ifdef _WIN32
io.Fonts->AddFontFromFileTTF("imgui/misc/fonts/JetBrainsMono/JetBrainsMono-Medium.ttf", 8.0f * scale);
#else
io.Fonts->AddFontFromFileTTF("../imgui/misc/fonts/JetBrainsMono/JetBrainsMono-Medium.ttf", 8.0f * scale);
#endif
io.Fonts->Build();
}
void AddWindow(std::vector<Window>& windows, const std::string& name, std::function<void()> renderFunc) {
windows.emplace_back(name, renderFunc);
}
Window* GetWindowByName(std::vector<Window>& windows, const std::string& name) {
auto it = std::find_if(windows.begin(), windows.end(), [&name](const Window& window) {
return window.name == name;
});
if (it != windows.end()) {
return &(*it); // Return pointer to the found window
} else {
return nullptr; // Return nullptr if the window was not found
}
}
void RenderWindows(std::vector<Window>& windows) {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
ImGui::NewFrame();
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
// Style windows
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);
ImGui::SetNextWindowSize(viewport->WorkSize);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
window_flags |= ImGuiWindowFlags_NoBackground;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("TerraVisor", nullptr, window_flags);
ImGui::PopStyleVar(3);
// Submit the DockSpace
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) {
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
}
if (ImGui::BeginMenuBar()) {
if (ImGui::BeginMenu("Options")) {
ImGui::Text("Nothing Here Yet, Check Back Later!");
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}
ImGui::End();
for (auto& window : windows) {
if (window.isOpen && ImGui::Begin(window.name.c_str(), &window.isOpen)) {
window.size = ImGui::GetWindowSize();
window.position = ImGui::GetWindowPos();
if (window.renderContent) {
window.renderContent();
}
}
ImGui::End();
}
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
}

View File

@ -42,6 +42,7 @@
#include "config.h"
#include "callbacks.h"
#include "scene.h"
#include "interface.h"
namespace {
@ -156,6 +157,7 @@ int main() {
scene.Init();
InitializeImGui(window);
FreeImage_Initialise();
Interface::ApplyUIScaling(window);
// Check if we're in test mode
const char* testEnv = std::getenv("TEST_MODE");

View File

@ -9,10 +9,6 @@
#include <glm/gtx/transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <imgui.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <iostream>
#include <fstream>
#include <sstream>
@ -29,6 +25,7 @@
#include "InitShader.h"
#include "DebugCallback.h"
#include "load_texture.h"
#include "interface.h"
namespace {
@ -91,6 +88,7 @@ void Scene::Init() {
InitBuffers();
ReloadShader();
InitQuadBuffers();
InitUI();
CameraControls::SetPosition(activeCamera_, glm::vec3(1.4f, 1.4f, 0.0f));
CameraControls::SetRotation(activeCamera_, -glm::normalize(CameraControls::GetPosition(activeCamera_)));
@ -197,6 +195,25 @@ void Scene::InitQuadBuffers() {
glBindVertexArray(0);
}
void Scene::InitUI() {
Interface::AddWindow(windows_, "Viewport", [this]() {
ImGui::Image((void*)(intptr_t)lht_fbo_.albedoTexture, ImVec2(window_width, window_height), ImVec2(0, 1), ImVec2(1, 0));
});
Interface::AddWindow(windows_, "Scene Settings", [this]() {
// if (ImGui::Button("Quit")) {
// glfwSetWindowShouldClose(window, GLFW_TRUE);
// }
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::SliderFloat("Tessellation Level", &Uniforms::GeoData.maxTessellation, 1.0f, 64.0f);
ImGui::SliderInt("Patch Grid Density", &Uniforms::GeoData.gridDensity, 1, 24);
ImGui::SliderFloat("Max Height", &Uniforms::GeoData.displacementScale, 0.0f, 1.0f);
Window* viewport = Interface::GetWindowByName(windows_, "Viewport");
ImGui::Text("Viewport size: (%.3f, %.3f)", viewport->size.x, viewport->size.y);
});
}
// Allows for runtime shader updates
void Scene::ReloadShader() {
@ -223,7 +240,12 @@ void Scene::Display(GLFWwindow* window) {
glUseProgram(shader_program_);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
Window* viewport = Interface::GetWindowByName(windows_, "Viewport");
if (viewport && viewport->size.x > 0 && viewport->size.y > 0) {
OnScreenResize(viewport);
}
Uniforms::GeoData.PV = projection_matrix_ * CameraControls::GetViewMatrix(activeCamera_); // Projection-View matrix
Uniforms::BufferSceneData();
@ -247,7 +269,9 @@ void Scene::Display(GLFWwindow* window) {
glPatchParameteri(GL_PATCH_VERTICES, 4);
glDrawElements(GL_PATCHES, indices.size(), GL_UNSIGNED_INT, 0);
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
FBO::Unbind();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
FBO::Bind(lht_fbo_);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -274,79 +298,24 @@ void Scene::Display(GLFWwindow* window) {
FBO::Unbind();
DrawGui(window);
//DrawGui(window);
Interface::RenderWindows(windows_);
glfwSwapBuffers(window);
}
void Scene::DrawGui(GLFWwindow* window) {
// Begin ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
void Scene::OnScreenResize(Window* viewport) {
if (window_width != static_cast<int>(viewport->size.x) || window_height != static_cast<int>(viewport->size.y)) {
window_width = static_cast<int>(viewport->size.x);
window_height = static_cast<int>(viewport->size.y);
// Enable docking
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
ImGui::NewFrame();
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode;
// Add menu bar
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
// Style windows
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);
ImGui::SetNextWindowSize(viewport->WorkSize);
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
window_flags |= ImGuiWindowFlags_NoBackground;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("TerraVisor", nullptr, window_flags);
ImGui::PopStyleVar(3);
// Submit the DockSpace
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) {
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
UpdateCamera();
}
}
if (ImGui::BeginMenuBar()) {
if (ImGui::BeginMenu("Options")) {
ImGui::Text("Nothing Here Yet, Check Back Later!");
ImGui::EndMenu();
}
ImGui::EndMenuBar();
}
ImGui::End();
// Draw Gui
ImGui::Begin("Terrain Controls");
if (ImGui::Button("Quit")) {
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::SliderFloat("Tessellation Level", &Uniforms::GeoData.maxTessellation, 1.0f, 64.0f);
ImGui::SliderInt("Patch Grid Density", &Uniforms::GeoData.gridDensity, 1, 24);
ImGui::End();
// Draw FBO to ImGui window
ImGui::Begin("Scene Window");
ImVec2 windowSize = ImGui::GetContentRegionAvail();
ImGui::Image((void*)(intptr_t)lht_fbo_.albedoTexture, windowSize, ImVec2(0, 1), ImVec2(1, 0));
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
void Scene::UpdateViewport() {
window_width = ImGui::GetWindowSize().x;
window_height = ImGui::GetWindowSize().y;
UpdateCamera();
}
void Scene::Idle() {
@ -383,7 +352,7 @@ std::vector<int16_t> Scene::LoadHGT(const std::string& filename, int width, int
}
void Scene::UpdateCamera() {
projection_matrix_ = glm::perspective(CameraControls::GetFOV(activeCamera_), aspect_, activeCamera_.nearPlane, activeCamera_.farPlane);
projection_matrix_ = glm::perspective(CameraControls::GetFOV(activeCamera_), static_cast<float>(window_width) / window_height, activeCamera_.nearPlane, activeCamera_.farPlane);
}
GLuint Scene::CreateHeightmapTexture(std::vector<int16_t> data, int width, int height) {