Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Clear the colorbuffer
- glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- //ourShader.Use(); <----this is using the shader
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texture);
- glUniform1i(glGetUniformLocation(ourShader.Program, "ourTexture"), 0);
- // Draw container
- glBindVertexArray(VAO);
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
- glBindVertexArray(0);
- #version 330 core
- in vec3 ourColor;
- in vec2 TexCoord;
- out vec4 color;
- // Texture samplers
- uniform sampler2D ourTexture1;
- void main()
- {
- // Linearly interpolate between both textures (second texture is only slightly combined)
- color = texture(ourTexture1, TexCoord);
- }
- #version 330 core
- layout (location = 0) in vec3 position;
- layout (location = 1) in vec3 color;
- layout (location = 2) in vec2 texCoord;
- out vec3 ourColor;
- out vec2 TexCoord;
- void main()
- {
- gl_Position = vec4(position, 1.0f);
- ourColor = color;
- // We swap the y-axis by substracing our coordinates from 1. This is done because most images have the top y-axis inversed with OpenGL's top y-axis.
- // TexCoord = texCoord;
- TexCoord = vec2(texCoord.x, 1.0 - texCoord.y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement