diff options
author | hnOsmium0001 <[email protected]> | 2022-04-30 13:55:20 -0700 |
---|---|---|
committer | hnOsmium0001 <[email protected]> | 2022-04-30 13:55:20 -0700 |
commit | 242317c1f7f2a6abdfbdbc99d5297539bbdc842f (patch) | |
tree | 4ccaae8f20b9b2534022419eb9eb7744b913cac7 /source/main.cpp | |
parent | 5f467c899d1024b01c0d7ba86d9ac2f28878eb55 (diff) |
Add ImGuizmo for GameObjects, start to make things actually render
Diffstat (limited to 'source/main.cpp')
-rw-r--r-- | source/main.cpp | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/source/main.cpp b/source/main.cpp index fe50b94..f96a6a3 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,10 +1,10 @@ #include "App.hpp" #include "AppConfig.hpp" +#include "CommonVertexIndex.hpp" #include "Ires.hpp" #include "Material.hpp" #include "Shader.hpp" -#include "VertexIndex.hpp" #define GLFW_INCLUDE_NONE #include <GLFW/glfw3.h> @@ -187,16 +187,16 @@ int main(int argc, char* argv[]) { glfwSetErrorCallback(&GlfwErrorCallback); - // Decide GL+GLSL versions + glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); + #if defined(__APPLE__) - // GL 3.2 + GLSL 150 const char* imguiGlslVersion = "#version 150"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac #else - // GL 3.3 + GLSL 130 const char* imguiGlslVersion = "#version 130"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); @@ -232,7 +232,9 @@ int main(int argc, char* argv[]) { } IMGUI_CHECKVERSION(); - ImGui::CreateContext(); + auto ctx = ImGui::CreateContext(); + auto& io = ImGui::GetIO(); + ImGuizmo::SetImGuiContext(ctx); ImGui_ImplGlfw_InitForOpenGL(window, true); if (imguiUseOpenGL3) { @@ -241,9 +243,6 @@ int main(int argc, char* argv[]) { ImGui_ImplOpenGL2_Init(); } - auto& io = ImGui::GetIO(); - auto& ctx = *ImGui::GetCurrentContext(); - IresManager::instance = new IresManager(); IresManager::instance->DiscoverFilesDesignatedLocation(); @@ -254,41 +253,40 @@ int main(int argc, char* argv[]) { .semantic = VES_Position, }); gVformatStandard->AddElement(VertexElementFormat{ - .bindingIndex = 1, + .bindingIndex = 0, .type = VET_Float2, .semantic = VES_TexCoords1, }); gVformatStandard->AddElement(VertexElementFormat{ - .bindingIndex = 1, + .bindingIndex = 0, .type = VET_Ubyte4Norm, .semantic = VES_Color1, }); - gVformatStandardPacked.Attach(new VertexFormat()); - gVformatStandardPacked->AddElement(VertexElementFormat{ + gVformatStandardSplit.Attach(new VertexFormat()); + gVformatStandardSplit->AddElement(VertexElementFormat{ .bindingIndex = 0, .type = VET_Float3, .semantic = VES_Position, }); - gVformatStandardPacked->AddElement(VertexElementFormat{ - .bindingIndex = 0, + gVformatStandardSplit->AddElement(VertexElementFormat{ + .bindingIndex = 1, .type = VET_Float2, .semantic = VES_TexCoords1, }); - gVformatStandardPacked->AddElement(VertexElementFormat{ - .bindingIndex = 0, + gVformatStandardSplit->AddElement(VertexElementFormat{ + .bindingIndex = 1, .type = VET_Ubyte4Norm, .semantic = VES_Color1, }); - // Matches gVformatStandardPacked + // Matches gVformatStandard gDefaultShader.Attach(new Shader()); gDefaultShader->InitFromSources(Shader::ShaderSources{ .vertex = R"""( #version 330 core layout(location = 0) in vec3 pos; -layout(location = 1) in vec2 texcoord; -layout(location = 2) in vec4 color; +layout(location = 1) in vec4 color; out vec4 v2fColor; uniform mat4 transformation; void main() { @@ -321,22 +319,6 @@ void main() { .index = (int)gDefaultShader->GetInfo().inputs.size() - 1, }); } - { // in vec2 texcoord; - ShaderMathVariable var; - var.scalarType = GL_FLOAT; - var.width = 1; - var.height = 2; - var.arrayLength = 1; - var.semantic = VES_TexCoords1; - var.location = 1; - gDefaultShader->GetInfo().inputs.push_back(std::move(var)); - gDefaultShader->GetInfo().things.try_emplace( - "texcoord"s, - ShaderThingId{ - .kind = ShaderThingId::KD_Input, - .index = (int)gDefaultShader->GetInfo().inputs.size() - 1, - }); - } { // in vec4 color; ShaderMathVariable var; var.scalarType = GL_FLOAT; @@ -344,7 +326,7 @@ void main() { var.height = 4; var.arrayLength = 1; var.semantic = VES_Color1; - var.location = 2; + var.location = 1; gDefaultShader->GetInfo().inputs.push_back(std::move(var)); gDefaultShader->GetInfo().things.try_emplace( "color"s, |