Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. // Clear the colorbuffer
  2. glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
  3. glClear(GL_COLOR_BUFFER_BIT);
  4.  
  5. //ourShader.Use(); <----this is using the shader
  6. glActiveTexture(GL_TEXTURE0);
  7. glBindTexture(GL_TEXTURE_2D, texture);
  8. glUniform1i(glGetUniformLocation(ourShader.Program, "ourTexture"), 0);
  9.  
  10. // Draw container
  11. glBindVertexArray(VAO);
  12. glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
  13. glBindVertexArray(0);
  14.  
  15. #version 330 core
  16. in vec3 ourColor;
  17. in vec2 TexCoord;
  18.  
  19. out vec4 color;
  20.  
  21. // Texture samplers
  22. uniform sampler2D ourTexture1;
  23.  
  24. void main()
  25. {
  26. // Linearly interpolate between both textures (second texture is only slightly combined)
  27. color = texture(ourTexture1, TexCoord);
  28. }
  29.  
  30. #version 330 core
  31. layout (location = 0) in vec3 position;
  32. layout (location = 1) in vec3 color;
  33. layout (location = 2) in vec2 texCoord;
  34.  
  35. out vec3 ourColor;
  36. out vec2 TexCoord;
  37.  
  38. void main()
  39. {
  40. gl_Position = vec4(position, 1.0f);
  41. ourColor = color;
  42. // 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.
  43. // TexCoord = texCoord;
  44. TexCoord = vec2(texCoord.x, 1.0 - texCoord.y);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement