aboutsummaryrefslogtreecommitdiff
path: root/source/Shader.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-04-30 13:55:20 -0700
committerrtk0c <[email protected]>2022-04-30 13:55:20 -0700
commit453e1df6fb7a5847c8a5b26bd8479451091fb69d (patch)
treee0753be4c78535a3d2697c8b7be4123b76d2ad0d /source/Shader.cpp
parentac153a0a9463e3877fb0066e3603b6bf15fe6706 (diff)
Changeset: 20 Add ImGuizmo for GameObjects, start to make things actually render
Diffstat (limited to 'source/Shader.cpp')
-rw-r--r--source/Shader.cpp37
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);
+ }
}
}