aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-06-11 11:39:51 -0700
committerrtk0c <[email protected]>2022-06-11 11:39:51 -0700
commitf2011f48feb7a7ed4139ec6aa1ee874d520f1d86 (patch)
tree689af72d2d90c55851e84fb7fb8647b60dcba291 /source
parentf29a141ab4c4308aed66f930a6f3a42cd20a482d (diff)
Changeset: 71 Initial work on rendering grid in editor mode, move ImGuizmo out of game project (no more codegen)
Diffstat (limited to 'source')
-rw-r--r--source/10-editor-common/ImGuiGuizmo.cpp (renamed from source/30-game/EditorGuizmo.cpp)2
-rw-r--r--source/10-editor-common/ImGuiGuizmo.hpp (renamed from source/30-game/EditorGuizmo.hpp)0
-rw-r--r--source/30-game/CommonVertexIndex.hpp1
-rw-r--r--source/30-game/EditorCorePrivate.cpp4
-rw-r--r--source/30-game/EditorCorePrivate.hpp2
-rw-r--r--source/30-game/EditorUtils.hpp2
-rw-r--r--source/30-game/EditorWorldGuides.cpp26
-rw-r--r--source/30-game/EditorWorldGuides.hpp16
-rw-r--r--source/30-game/main.cpp6
9 files changed, 53 insertions, 6 deletions
diff --git a/source/30-game/EditorGuizmo.cpp b/source/10-editor-common/ImGuiGuizmo.cpp
index 3e4f890..3786076 100644
--- a/source/30-game/EditorGuizmo.cpp
+++ b/source/10-editor-common/ImGuiGuizmo.cpp
@@ -27,7 +27,7 @@
#ifndef IMGUI_DEFINE_MATH_OPERATORS
# define IMGUI_DEFINE_MATH_OPERATORS
#endif
-#include "EditorGuizmo.hpp"
+#include "ImGuiGuizmo.hpp"
#include "imgui_internal.h"
#if defined(_MSC_VER) || defined(__MINGW32__)
diff --git a/source/30-game/EditorGuizmo.hpp b/source/10-editor-common/ImGuiGuizmo.hpp
index 0560050..0560050 100644
--- a/source/30-game/EditorGuizmo.hpp
+++ b/source/10-editor-common/ImGuiGuizmo.hpp
diff --git a/source/30-game/CommonVertexIndex.hpp b/source/30-game/CommonVertexIndex.hpp
index adb81b6..7e6aa66 100644
--- a/source/30-game/CommonVertexIndex.hpp
+++ b/source/30-game/CommonVertexIndex.hpp
@@ -11,6 +11,7 @@
// Initialized in main()
inline RcPtr<VertexFormat> gVformatStandard{};
inline RcPtr<VertexFormat> gVformatStandardSplit{};
+inline RcPtr<VertexFormat> gVformatLines{};
// Suffixes:
// - _P_osition
diff --git a/source/30-game/EditorCorePrivate.cpp b/source/30-game/EditorCorePrivate.cpp
index 1e7b010..358a95a 100644
--- a/source/30-game/EditorCorePrivate.cpp
+++ b/source/30-game/EditorCorePrivate.cpp
@@ -426,7 +426,9 @@ std::unique_ptr<IEditor> IEditor::CreateInstance(App* app) {
EditorInstance::EditorInstance(App* app)
: mApp{ app }
- , mEdContentBrowser(&mEdInspector) {
+ , mEdContentBrowser(&mEdInspector)
+ , mEdGuides(app, this) //
+{
mEditorCamera.name = "Editor Camera"s;
mEditorCamera.SetEyePos(glm::vec3(0, 0, 1));
mEditorCamera.SetTargetDirection(glm::vec3(0, 0, -1));
diff --git a/source/30-game/EditorCorePrivate.hpp b/source/30-game/EditorCorePrivate.hpp
index 42be050..e70f5ec 100644
--- a/source/30-game/EditorCorePrivate.hpp
+++ b/source/30-game/EditorCorePrivate.hpp
@@ -6,6 +6,7 @@
#include "EditorAttachment.hpp"
#include "EditorCommandPalette.hpp"
#include "EditorUtils.hpp"
+#include "EditorWorldGuides.hpp"
#include "GameObject.hpp"
#include "Ires.hpp"
#include "Level.hpp"
@@ -85,6 +86,7 @@ private:
EditorCommandPalette mEdCommandPalette;
EditorInspector mEdInspector;
EditorContentBrowser mEdContentBrowser;
+ EditorWorldGuides mEdGuides;
GuizmoState mGuizmo;
glm::vec3 mDragCam_CamInitial;
ImVec2 mDragCam_CursorInitial;
diff --git a/source/30-game/EditorUtils.hpp b/source/30-game/EditorUtils.hpp
index 8a9ab95..9d15f61 100644
--- a/source/30-game/EditorUtils.hpp
+++ b/source/30-game/EditorUtils.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "EditorCore.hpp"
-#include "EditorGuizmo.hpp"
+#include "ImGuiGuizmo.hpp"
#include "Ires.hpp"
#include <Color.hpp>
diff --git a/source/30-game/EditorWorldGuides.cpp b/source/30-game/EditorWorldGuides.cpp
new file mode 100644
index 0000000..f0d66b8
--- /dev/null
+++ b/source/30-game/EditorWorldGuides.cpp
@@ -0,0 +1,26 @@
+#include "EditorWorldGuides.hpp"
+
+#include "App.hpp"
+#include "CommonVertexIndex.hpp"
+#include "GraphicsTags.hpp"
+#include "VertexIndex.hpp"
+
+EditorWorldGuides::EditorWorldGuides(App* app, IEditor* editor)
+ : mApp{ app }
+ , mEditor{ editor } //
+{
+ using namespace Tags;
+
+ mRoGrid.SetFormat(gVformatLines.Get(), IT_16Bit);
+ mRoGrid.SetMaterial(gDefaultMaterial.Get());
+ mRoGrid.RebuildIfNecessary();
+
+ mRoDebugSkybox.SetFormat(gVformatStandard.Get(), IT_16Bit);
+ mRoDebugSkybox.SetMaterial(gDefaultMaterial.Get());
+ mRoDebugSkybox.RebuildIfNecessary();
+}
+
+void EditorWorldGuides::Update() {
+ auto& camera = *mApp->GetActiveCamera();
+ // TODO
+}
diff --git a/source/30-game/EditorWorldGuides.hpp b/source/30-game/EditorWorldGuides.hpp
new file mode 100644
index 0000000..0dfdea2
--- /dev/null
+++ b/source/30-game/EditorWorldGuides.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "Renderer.hpp"
+
+class EditorWorldGuides {
+private:
+ App* mApp;
+ IEditor* mEditor;
+ RenderObject mRoGrid;
+ RenderObject mRoDebugSkybox;
+
+public:
+ EditorWorldGuides(App* app, IEditor* editor);
+
+ void Update();
+};
diff --git a/source/30-game/main.cpp b/source/30-game/main.cpp
index 89f0e97..d98f225 100644
--- a/source/30-game/main.cpp
+++ b/source/30-game/main.cpp
@@ -2,7 +2,7 @@
#include "AppConfig.hpp"
#include "CommonVertexIndex.hpp"
-#include "EditorGuizmo.hpp"
+#include "ImGuiGuizmo.hpp"
#include "Ires.hpp"
#include "Level.hpp"
#include "Material.hpp"
@@ -36,7 +36,7 @@ void GlfwErrorCallback(int error, const char* description) {
fprintf(stderr, "[GLFW] Error %d: %s\n", error, description);
}
-void OpenGLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam​) {
+void OpenGLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) {
fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n", (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), type, severity, message);
}
@@ -259,7 +259,7 @@ int main(int argc, char* argv[]) {
// TODO check extension KHR_debug availability
// TODO conan glad is not including any extensions
// NOTE: KHR_debug is a core extension, which means it may be available in lower version even though the feature is added in 4.3
-
+
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(&OpenGLDebugCallback, 0);
}