Skip to content

Commit 0827c76

Browse files
committed
This adds the setopacity function
1 parent 46f964e commit 0827c76

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

phong_shader.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ void PhongShader::SetGlobalTime(float global_time)
6969
glUniform1f(uniforms.global_time , global_time);
7070
}
7171

72+
void PhongShader::SetOpacity(float opacity)
73+
{
74+
assert(this->is_used == true);
75+
glUniform1f(uniforms.opacity , opacity);
76+
}
7277
void PhongShader::CustomSetup()
7378
{
7479
Shader::Use();
@@ -79,6 +84,7 @@ void PhongShader::CustomSetup()
7984
uniforms.specular_albedo = glGetUniformLocation(this->program_id, "specular_albedo");
8085
uniforms.specular_power = glGetUniformLocation(this->program_id, "specular_power");
8186
uniforms.ambient = glGetUniformLocation(this->program_id, "ambient");
87+
uniforms.opacity = glGetUniformLocation(this->program_id , "opacity");
8288
uniforms.modelview_matrix = glGetUniformLocation(this->program_id , "mv_matrix");
8389
uniforms.view_matrix = glGetUniformLocation(this->program_id , "view_matrix");
8490
uniforms.normal_matrix = glGetUniformLocation(this->program_id , "normal_matrix");
@@ -89,7 +95,6 @@ void PhongShader::CustomSetup()
8995
this->subroutine_indices.push_back(glGetSubroutineIndex(this->program_id , GL_FRAGMENT_SHADER, "PerPixelLighting"));
9096
this->subroutine_indices.push_back(glGetSubroutineIndex(this->program_id , GL_FRAGMENT_SHADER , "PPLWithTexture"));
9197
this->subroutine_indices.push_back(glGetSubroutineIndex(this->program_id , GL_FRAGMENT_SHADER , "ShaderToy1"));
92-
this->subroutine_indices.push_back(glGetSubroutineIndex(this->program_id , GL_FRAGMENT_SHADER , "PPLWithTextureAndVignette"));
9398
Shader::UnUse();
9499
}
95100

phong_shader.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class PhongShader : public Shader
1515
void CustomSetup();
1616
void SetGlobalTime(float global_time);
1717
void EnableTexture(ILContainer & ilcontainer , GLuint texture_unit);
18+
void SetOpacity(float opacity);
1819

1920
enum SubroutineIndices
2021
{
2122
CONSTANT,
2223
BASIC_PHONG,
2324
PHONG_WITH_TEXTURE,
2425
SHADER_TOY_1,
25-
VIGNETTE,
2626
NUMBER_OF_SUBROUTINES
2727
};
2828

@@ -42,6 +42,7 @@ class PhongShader : public Shader
4242
GLuint light_position;
4343
GLuint base_texture_location;
4444
GLuint global_time;
45+
GLuint opacity;
4546
GLuint param1;
4647
GLuint param2;
4748
} uniforms;

0 commit comments

Comments
 (0)