Skip to content

Commit b9f98d3

Browse files
committed
Merge pull request tparisi#1 from greggman/remove-viewportwidth
Remove gl.viewportWidth and gl.viewportHeight
2 parents ed9ee28 + 797c817 commit b9f98d3

File tree

22 files changed

+39
-83
lines changed

22 files changed

+39
-83
lines changed

example01/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@
8888
function initGL(canvas) {
8989
try {
9090
gl = canvas.getContext("experimental-webgl");
91-
gl.viewportWidth = canvas.width;
92-
gl.viewportHeight = canvas.height;
9391
} catch(e) {
9492
}
9593
if (!gl) {
@@ -191,7 +189,7 @@
191189
[-2.2, -1.2],
192190
];
193191
function drawScene() {
194-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
192+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
195193
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
196194

197195
gl.bindBuffer(gl.ARRAY_BUFFER, vertexPositionBuffer.id);

example02/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@
126126
function initGL(canvas) {
127127
try {
128128
gl = canvas.getContext("experimental-webgl");
129-
gl.viewportWidth = canvas.width;
130-
gl.viewportHeight = canvas.height;
131129
} catch(e) {
132130
}
133131
if (!gl) {
@@ -487,10 +485,10 @@
487485

488486

489487
function drawScene() {
490-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
488+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
491489
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
492490

493-
mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix);
491+
mat4.perspective(45, gl.canvas.clientWidth / gl.canvas.clientHeight, 0.1, 100.0, pMatrix);
494492

495493
for (var i in cubes) {
496494
cubes[i].draw();

example03/particles-01-noenable.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
function initGL(canvas) {
5757
try {
5858
gl = canvas.getContext("experimental-webgl");
59-
gl.viewportWidth = canvas.width;
60-
gl.viewportHeight = canvas.height;
6159
} catch(e) {
6260
}
6361
if (!gl) {
@@ -204,7 +202,7 @@
204202
var centerPos;
205203
var color;
206204
function drawScene() {
207-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
205+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
208206

209207
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
210208

example03/particles-01.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
function initGL(canvas) {
5757
try {
5858
gl = canvas.getContext("experimental-webgl");
59-
gl.viewportWidth = canvas.width;
60-
gl.viewportHeight = canvas.height;
6159
} catch(e) {
6260
}
6361
if (!gl) {
@@ -204,7 +202,7 @@
204202
var centerPos;
205203
var color;
206204
function drawScene() {
207-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
205+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
208206

209207
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
210208

example03/particles-02.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
function initGL(canvas) {
6363
try {
6464
gl = canvas.getContext("experimental-webgl");
65-
gl.viewportWidth = canvas.width;
66-
gl.viewportHeight = canvas.height;
6765
} catch(e) {
6866
}
6967
if (!gl) {
@@ -261,7 +259,7 @@
261259
var centerPos;
262260
var color;
263261
function drawScene() {
264-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
262+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
265263

266264
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
267265

example03/particles-03.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
function initGL(canvas) {
6363
try {
6464
gl = canvas.getContext("experimental-webgl");
65-
gl.viewportWidth = canvas.width;
66-
gl.viewportHeight = canvas.height;
6765
} catch(e) {
6866
}
6967
if (!gl) {
@@ -272,7 +270,7 @@
272270
var centerPos;
273271
var color;
274272
function drawScene() {
275-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
273+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
276274

277275
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
278276

lesson01/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
function initGL(canvas) {
3333
try {
3434
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
35-
gl.viewportWidth = canvas.width;
36-
gl.viewportHeight = canvas.height;
3735
} catch (e) {
3836
}
3937
if (!gl) {
@@ -143,10 +141,10 @@
143141

144142

145143
function drawScene() {
146-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
144+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
147145
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
148146

149-
mat4.perspective(pMatrix, 45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0);
147+
mat4.perspective(pMatrix, 45, gl.canvas.clientWidth / gl.canvas.clientHeight, 0.1, 100.0);
150148

151149
mat4.identity(mvMatrix);
152150

lesson02/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
function initGL(canvas) {
4040
try {
4141
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
42-
gl.viewportWidth = canvas.width;
43-
gl.viewportHeight = canvas.height;
4442
} catch (e) {
4543
}
4644
if (!gl) {
@@ -177,10 +175,10 @@
177175

178176

179177
function drawScene() {
180-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
178+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
181179
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
182180

183-
mat4.perspective(pMatrix, 45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0);
181+
mat4.perspective(pMatrix, 45, gl.canvas.clientWidth / gl.canvas.clientHeight, 0.1, 100.0);
184182

185183
mat4.identity(mvMatrix);
186184

lesson03/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
function initGL(canvas) {
4141
try {
4242
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
43-
gl.viewportWidth = canvas.width;
44-
gl.viewportHeight = canvas.height;
4543
} catch (e) {
4644
}
4745
if (!gl) {
@@ -201,10 +199,10 @@
201199
var rSquare = 0;
202200

203201
function drawScene() {
204-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
202+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
205203
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
206204

207-
mat4.perspective(pMatrix, 45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0);
205+
mat4.perspective(pMatrix, 45, gl.canvas.clientWidth / gl.canvas.clientHeight, 0.1, 100.0);
208206

209207
mat4.identity(mvMatrix);
210208

lesson04/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
function initGL(canvas) {
4141
try {
4242
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
43-
gl.viewportWidth = canvas.width;
44-
gl.viewportHeight = canvas.height;
4543
} catch (e) {
4644
}
4745
if (!gl) {
@@ -289,10 +287,10 @@
289287
var rCube = 0;
290288

291289
function drawScene() {
292-
gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
290+
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
293291
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
294292

295-
mat4.perspective(pMatrix, 45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0);
293+
mat4.perspective(pMatrix, 45, gl.canvas.clientWidth / gl.canvas.clientHeight, 0.1, 100.0);
296294

297295
mat4.identity(mvMatrix);
298296

0 commit comments

Comments
 (0)