Adding textures capabilities
* Added Texures to the two sample cubes * Modified mesh structure - mesh now contains indices and vertices - Vertices contain vertices and uv's (later on they will also contain normals) Solution definitely not perfect and needs improvement.
This commit is contained in:
		@ -1,9 +1,14 @@
 | 
			
		||||
#version 440 core
 | 
			
		||||
 | 
			
		||||
out vec4 FragColor;
 | 
			
		||||
 | 
			
		||||
uniform vec3 MatColour;
 | 
			
		||||
 | 
			
		||||
void main(){
 | 
			
		||||
	FragColor = vec4(MatColour, 1.0f);
 | 
			
		||||
#version 440 core
 | 
			
		||||
 | 
			
		||||
out vec4 FragColor;
 | 
			
		||||
 | 
			
		||||
uniform vec3 Color;
 | 
			
		||||
 | 
			
		||||
in vec2 TexCoord;
 | 
			
		||||
 | 
			
		||||
uniform sampler2D Texture;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void main(){
 | 
			
		||||
	FragColor = mix ( texture(Texture, TexCoord), vec4(Color, 1.0f));
 | 
			
		||||
}
 | 
			
		||||
@ -1,10 +1,15 @@
 | 
			
		||||
#version 440 core
 | 
			
		||||
in layout(location=0) vec3 aPos;
 | 
			
		||||
in layout(location=1) vec2 uv;
 | 
			
		||||
 | 
			
		||||
uniform mat4 M;
 | 
			
		||||
uniform mat4 V;
 | 
			
		||||
uniform mat4 P;
 | 
			
		||||
 | 
			
		||||
out vec2 TexCoord;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void main() {
 | 
			
		||||
    TexCoord = uv;
 | 
			
		||||
    gl_Position = P * V * M * vec4(aPos.x, aPos.y, aPos.z, 1.0);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user