Hello Cube: Textures
This example shows how texture map a cube using an image fetched from a URL.
Image URL:
// World View Projection matrix that will transform the input vertices // to screen space. uniform mat4 worldViewProjection; // input parameters for our vertex shader attribute vec4 position; attribute vec2 texcoords0; varying vec2 uvs; /** * The vertex shader simply transforms the input vertices to screen space. */ void main() { // Multiply the vertex positions by the worldViewProjection matrix to // transform them to screen space. gl_Position = worldViewProjection * position; uvs = texcoords0; } // This hack his here for now since O3D only allows one string // to be passed to Effect::loadFromFXString // #o3d SplitMarker // #o3d MatrixLoadOrder RowMajor // Color to draw with. uniform sampler2D texSampler0; varying vec2 uvs; /** * This pixel shader just returns the color red. */ void main() { gl_FragColor = texture2D(texSampler0, uvs); }