feat: put awesome face over container

This commit is contained in:
Krzysztof Rudnicki 2023-03-12 14:46:56 +01:00
parent 8b1b1bd28c
commit 7dbd77117e
4 changed files with 18 additions and 12 deletions

View File

@ -1,9 +1,16 @@
#version 330 core
out vec4 FragColor;
in vec3 ourColor;
in vec2 TexCoord;
uniform sampler2D ourTexture;
// texture samplers
uniform sampler2D texture1;
uniform sampler2D texture2;
void main()
{
FragColor = texture(ourTexture, TexCoord);
}
// linearly interpolate between both textures (80% container, 20% awesomeface)
FragColor = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), 0.2);
}

View File

@ -10,5 +10,5 @@ void main()
{
gl_Position = vec4(aPos, 1.0);
ourColor = aColor;
TexCoord = aTexCoord;
TexCoord = vec2(aTexCoord.x, aTexCoord.y);
}

View File

@ -179,20 +179,19 @@ drawFigureReturn drawDebilMode(const char* vertexPath, const char* fragmentPath,
configureVertexAttribute(true, true);
unsigned int texture1 = loadAndCreateTexture("assets/Preview.png", GL_RGBA, true);
// unsigned int texture2 = loadAndCreateTexture("assets/awesomeface.png", GL_RGBA, false);
activateAndBindTextures(texture1, GL_TEXTURE0);
// activateAndBindTextures(texture2, GL_TEXTURE1);
unsigned int texture1 = loadAndCreateTexture("assets/container.png", GL_RGB, true);
unsigned int texture2 = loadAndCreateTexture("assets/awesomeface.png", GL_RGBA, false);
ourShader.use(); // don't forget to activate/use the shader before setting uniforms!
// either set it manually like so:
glUniform1i(glGetUniformLocation(ourShader.ID, "texture1"), 0);
ourShader.setInt("texture1", 0);
// or set it via the texture class
ourShader.setInt("texture2", 1);
activateAndBindTextures(texture1, GL_TEXTURE0);
activateAndBindTextures(texture2, GL_TEXTURE1);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
drawFigureReturn newReturn;

Binary file not shown.