Added support for PNG

This commit is contained in:
Robert 2021-01-21 16:11:41 +01:00
parent 7571b3943d
commit 8174ebaee4
5 changed files with 27 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -76,7 +76,8 @@ int main(int argc, char** argv)
}
// Create a texture
oglu::Texture texture = oglu::MakeTexture("assets/crate.jpg");
oglu::Texture crate = oglu::MakeTexture("assets/crate.jpg");
oglu::Texture opengl = oglu::MakeTexture("assets/opengl.png");
// Window loop
while (!glfwWindowShouldClose(window))
@ -85,8 +86,15 @@ int main(int argc, char** argv)
oglu::ClearScreen(GL_COLOR_BUFFER_BIT, oglu::Color(0.29f, 0.13f, 0.23f));
oglu::ActiveTexture(0);
crate->Bind();
oglu::ActiveTexture(1);
opengl->Bind();
shader->Use();
texture->Bind();
shader->SetUniform("texture1", 0);
shader->SetUniform("texture2", 1);
square->BindAndDraw();
glfwSwapBuffers(window);

View file

@ -4,9 +4,10 @@ in vec2 oUV;
out vec4 FragColor;
uniform sampler2D ourTexture;
uniform sampler2D texture1;
uniform sampler2D texture2;
void main()
{
FragColor = texture(ourTexture, oUV) * vec4(oCol, 1.0);
FragColor = mix(texture(texture1, oUV), texture(texture2, oUV), 0.2);
}