|
|
@@ -265,4 +265,53 @@ namespace graphics { namespace shaders {
|
|
|
}
|
|
|
return id;
|
|
|
}
|
|
|
+
|
|
|
+ void activate(unsigned int id) {
|
|
|
+ // 100. Use the shader program ID to "turn it on" for all subsequent drawing
|
|
|
+ glUseProgram(id);
|
|
|
+
|
|
|
+ /*
|
|
|
+ // 101. Enable texturing and Bind texture(s) to GPU texture units
|
|
|
+ glActiveTexture(GL_TEXTURE3);
|
|
|
+ glEnable(GL_TEXTURE_2D);
|
|
|
+ glBindTexture(GL_TEXTURE_2D, emissiveTextureID);
|
|
|
+
|
|
|
+ glActiveTexture(GL_TEXTURE2);
|
|
|
+ glEnable(GL_TEXTURE_2D);
|
|
|
+ glBindTexture(GL_TEXTURE_2D, specularTextureID);
|
|
|
+
|
|
|
+ glActiveTexture(GL_TEXTURE1);
|
|
|
+ glEnable(GL_TEXTURE_2D);
|
|
|
+ glBindTexture(GL_TEXTURE_2D, normalTextureID);
|
|
|
+
|
|
|
+ glActiveTexture(GL_TEXTURE0);
|
|
|
+ glEnable(GL_TEXTURE_2D);
|
|
|
+ glBindTexture(GL_TEXTURE_2D, diffuseTextureID);
|
|
|
+ */
|
|
|
+
|
|
|
+ // 102. Get the location # of each named uniform you wish to pass in to the
|
|
|
+ // shader
|
|
|
+ int timeUniformLocation = glGetUniformLocation(id, "u_time");
|
|
|
+ int scale = glGetUniformLocation(id, "Scale");
|
|
|
+ int diffuseMapUniformLocation = glGetUniformLocation(id, "u_diffuseMap");
|
|
|
+ int normalMapUniformLocation = glGetUniformLocation(id, "u_normalMap");
|
|
|
+ int specularMapUniformLocation = glGetUniformLocation(id, "u_specularMap");
|
|
|
+ int emissiveMapUniformLocation = glGetUniformLocation(id, "u_emissiveMap");
|
|
|
+ int debugWave = glGetUniformLocation(id, "g_debugWave");
|
|
|
+
|
|
|
+ // 103. Set the uniform values, including the texture unit numbers for
|
|
|
+ // texture (sampler) uniforms
|
|
|
+ // Env::GetCurrentTimeSeconds()
|
|
|
+ glUniform1f(timeUniformLocation, (float)time(NULL));
|
|
|
+ glUniform1f(scale, 2.f);
|
|
|
+ glUniform1i(debugWave, 1); // TODO: m_waveEffectOn in ShaderProgram??
|
|
|
+ // for GL_TEXTURE0, texture unit 0
|
|
|
+ glUniform1i(diffuseMapUniformLocation, 0);
|
|
|
+ // for GL_TEXTURE1, texture unit 1
|
|
|
+ glUniform1i(normalMapUniformLocation, 1);
|
|
|
+ // for GL_TEXTURE2, texture unit 2
|
|
|
+ glUniform1i(specularMapUniformLocation, 2);
|
|
|
+ // for GL_TEXTURE3, texture unit 3
|
|
|
+ glUniform1i(emissiveMapUniformLocation, 3);
|
|
|
+ }
|
|
|
}}
|