Skip navigation

The page 05 Texture requires JavaScript to function.

Harald Markus Wirth


Page Content:

05 Texture

The canvas needs a black background, or there will be artifacts in Firefox! You can try for yourself using the Inspector tools: Just disable the background on canvas.viewport

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
// VERTEX SHADER
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
attribute vec4 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;

varying highp vec2 vTextureCoord;

void main () {
	gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;
	vTextureCoord = aTextureCoord;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
// FRAGMENT SHADER
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////119:/
varying highp vec2 vTextureCoord;

uniform sampler2D uSampler;

void main () {
	gl_FragColor = texture2D( uSampler, vTextureCoord );
}


https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL



Content Management:

μCMS α1.6