1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| function initBuffers(gl) {
var carreBuffers = {};
carreBuffers.positionBuffer = gl.createArrayBuffer([
-1, -1,0,
-1, 1, 0,
1, 1, 0,
1, 1, 0,
-1, -1,0,
1, -1,0
]);
//gl.translate(matrice_projection);
var colors = [
[0, 0, 1, 1], // Front face - Pink
[0, 0, 1, 1], // Back face - Green
[0, 0, 1, 1], // Top face - Blue
[1, 0, 0, 1], // Bottom face - Turquoise
[1, 0, 0, 1], // Right face - Yellow
[1, 0, 0, 1], // Left face - Red
];
var colorVertices = [];
for (var n in colors) {
var color = colors[n];
colorVertices = colorVertices.concat(color);
}
carreBuffers.colorBuffer = gl.createArrayBuffer(colorVertices);
carreBuffers.indexBuffer = gl.createElementArrayBuffer([
0, 1, 2, 0, 2, 5
]);
return carreBuffers;
} |