Following webglacademy 5th tutorial at creating textures (http://www.webglacademy.com/#5), the point is to load the texture on the cube object which works, kinda.
Look at the result -
Can anyone tell me why the texture looks like this while it should be fit perfectly on cube side?
Demo here - http://kgpk.esy.es/WebGL/ (Hold mouse button and drag to move the cube; mousewheel to zoom in/out)
Texture used - http://kgpk.esy.es/WebGL/texture.png
Code - http://kgpk.esy.es/WebGL/WEBGL.js (Texture gets loaded in f_IniatializeTextures function [line 209] which uses f_GetTexture function [line 255] to load the texture and the texture is thrown into stream at f_Animate function [line 427]
Vertex and fragment can be found in function f_InitializeShaders [line 215]
base.m_ShaderVertex = [
"attribute vec3 position;", // The position of the point.
"uniform mat4 Pmatrix;", // Projection matrix.
"uniform mat4 Vmatrix;", // Movement matrix from object reference to view reference.
"uniform mat4 Mmatrix;", // Movement matrix.
"attribute vec2 uv;",
"varying vec2 vUV;",
"void main(void) {",
"gl_Position = Pmatrix * Vmatrix * Mmatrix * vec4(position, 1.0);",
"vUV = uv;", // Set color.
"}"
].join("\n");
base.m_ShaderFragment = [
"precision mediump float;",
"uniform sampler2D sampler;",
"varying vec2 vUV;",
"void main(void) {",
"gl_FragColor = texture2D(sampler, vUV);", // Assign the color to pixel with total opaque.
"}"
].join("\n");
Thanks.