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/Shader.cpp | |
parent | 5f467c899d1024b01c0d7ba86d9ac2f28878eb55 (diff) |
Add ImGuizmo for GameObjects, start to make things actually render
Diffstat (limited to 'source/Shader.cpp')
-rw-r--r-- | source/Shader.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/Shader.cpp b/source/Shader.cpp index fd68a0c..2ab77af 100644 --- a/source/Shader.cpp +++ b/source/Shader.cpp @@ -45,6 +45,26 @@ GLuint FindLocation(const std::vector<ShaderMathVariable>& vars, Tags::VertexEle } return Tags::kInvalidLocation; } + +constexpr auto kAfnTransform = "transform"; +constexpr auto kAfnTime = "time"; +constexpr auto kAfnDeltaTime = "deltaTime"; +constexpr auto kAfnTextureAtlas = "textureAtlas"; + +void InitAutoFill(const char* name, GLuint program, GLuint& location) { + GLint result = glGetUniformLocation(program, name); + if (result != -1) { + location = result; + } +} + +void InitAutoFills(Shader& shader) { + GLuint pg = shader.GetProgram(); + InitAutoFill(kAfnTransform, pg, shader.autofill_Transform); + InitAutoFill(kAfnTime, pg, shader.autofill_Time); + InitAutoFill(kAfnDeltaTime, pg, shader.autofill_DeltaTime); + InitAutoFill(kAfnTextureAtlas, pg, shader.autofill_TextureAtlas); +} } // namespace ProjectBrussel_UNITY_ID GLuint ShaderInfo::FindInputLocation(Tags::VertexElementSemantic semantic) { @@ -178,6 +198,8 @@ Shader::ErrorCode Shader::InitFromSources(const ShaderSources& sources) { sg.Dismiss(); mProgram = program; + InitAutoFills(*this); + return EC_Success; } @@ -295,6 +317,8 @@ Shader::ErrorCode Shader::InitFromSource(std::string_view source) { sg.Dismiss(); mProgram = program; + InitAutoFills(*this); + return EC_Success; } @@ -573,6 +597,7 @@ void IresShader::InvalidateInstance() { void IresShader::ShowEditor(EditorInstance& editor) { using namespace Tags; + using namespace ProjectBrussel_UNITY_ID; IresObject::ShowEditor(editor); @@ -607,6 +632,18 @@ void IresShader::ShowEditor(EditorInstance& editor) { for (auto& uniform : info.uniforms) { uniform->ShowInfo(); } + if (auto loc = mInstance->autofill_Transform; loc != kInvalidLocation) { + ImGui::BulletText("(Autofill)\nLocation: %d\nName: %s", loc, kAfnTransform); + } + if (auto loc = mInstance->autofill_Time; loc != kInvalidLocation) { + ImGui::BulletText("(Autofill)\nLocation: %d\nName: %s", loc, kAfnTime); + } + if (auto loc = mInstance->autofill_DeltaTime; loc != kInvalidLocation) { + ImGui::BulletText("(Autofill)\nLocation: %d\nName: %s", loc, kAfnDeltaTime); + } + if (auto loc = mInstance->autofill_TextureAtlas; loc != kInvalidLocation) { + ImGui::BulletText("(Autofill)\nLocation: %d\nName: %s", loc, kAfnTextureAtlas); + } } } |