Skip to content

Commit be0ce66

Browse files
.
1 parent 8f8ce1e commit be0ce66

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

Book example codes/Chapter 3/2.0/3_First WebGL program_js.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var WebGL = function () {
44
gl = initializeWebGL(gl);
55

66
//Step 1 (Set background color): First specify the color with the help of Quadlet(R,G,B,Alpha) and the clear the buffer related to background.
7-
gl.clearColor(0, 0, 0, 1.0);
7+
gl.clearColor(0.5, 0, 0, 1.0);
88
gl.clear(gl.COLOR_BUFFER_BIT);
99
//Note: The default background color in WebGl is white.
1010

@@ -71,7 +71,7 @@ var WebGL = function () {
7171
//gl.drawElements(gl.LINES, IndicesArrayJS.length, gl.UNSIGNED_SHORT, 0);
7272
//gl.drawElements(gl.LINE_STRIP, IndicesArrayJS.length, gl.UNSIGNED_SHORT, 0);
7373
//gl.drawElements(gl.LINE_LOOP, IndicesArrayJS.length, gl.UNSIGNED_SHORT, 0);
74-
gl.drawElements(gl.TRIANGLES, IndicesArrayJS.length, gl.UNSIGNED_SHORT, 0);
74+
gl.drawElements(gl.LINES, IndicesArrayJS.length, gl.UNSIGNED_SHORT, 0);
7575
};
7676

7777
function initializeWebGL(gl)
@@ -97,6 +97,7 @@ function getShaderProgram(gl)
9797
void main()
9898
{
9999
gl_Position = vec4(geometryCoordinatesGPU, 1.0);
100+
gl_PointSize = 5.0;
100101
}`;
101102

102103
//Step 8 (Create actual vertex shader): Create the actual vertex shader with the text defined in Step 1.

Book example codes/Chapter 6/2.0/6_Tri_color_triangle_js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ var WebGL = function () {
1111
//Step 2 (Speficy vertices data): Speficy the coordinates (X,Y,Z) of the geometry and the color information related to each coordinates.
1212
var verticesDataArrayJS =
1313
[ //X Y Z R G B
14-
0.0, 0.8, 0, 1, 0, 0, //Vertex A
14+
0.0, 0.8, 0, 0, 1, 0, //Vertex A
1515
0.8, -0.8, 0, 0, 1, 0, //Vertex B
16-
-0.8, -0.8, 0, 0, 0, 1 //Vertex C
16+
-0.8, -0.8, 0, 0, 1, //Vertex C
1717
];
1818

1919
//Step 3 (Specify how to connect the points): Specify the order with which the coordinates defined in Step2 will be joined.

Book example codes/Chapter 8/2.0/8_3D_cuboid.HTML

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,6 @@
103103
gl_Position = projMatGPU * viewMatGPU * vec4(verticesGPU, 1.0);
104104
}`;
105105

106-
// var vertexShaderText =
107-
// ' precision mediump float; ' +
108-
// ' attribute vec3 verticesGPU; ' +
109-
// ' uniform mat4 projMatGPU; '+
110-
// ' uniform mat4 viewMatGPU; '+
111-
// ' void main() ' +
112-
// ' { ' +
113-
// ' gl_Position = projMatGPU * viewMatGPU * vec4(verticesGPU, 1.0); ' +
114-
// ' } ';
115-
116106
var fragmentShaderText = `#version 300 es
117107
#pragma vscode_glsllint_stage: frag
118108
precision mediump float;

0 commit comments

Comments
 (0)