fixing WebGL warnings
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import AbstractAuthenticatedView from "./abstracts/AbstractAuthenticatedView.js";
|
||||
import "../3D/maths/gl-matrix-min.js"
|
||||
import { initShaderProgram, shaderInfos } from "../3D/shaders.js"
|
||||
import { initShaderProgram } from "../3D/shaders.js"
|
||||
import { initBuffers } from "../3D/buffers.js"
|
||||
import { renderCube } from "../3D/cube.js"
|
||||
|
||||
@ -481,18 +481,18 @@ class Game {
|
||||
this.setPositionAttribute();
|
||||
this.setNormalAttribute();
|
||||
|
||||
this.context.useProgram(shaderInfos.program);
|
||||
this.context.useProgram(this.shader_prog.program);
|
||||
|
||||
this.context.uniformMatrix4fv(shaderInfos.uniformLocations.projectionMatrix, false, projectionMatrix);
|
||||
this.context.uniformMatrix4fv(shaderInfos.uniformLocations.viewMatrix, false, viewMatrix);
|
||||
this.context.uniformMatrix4fv(this.shader_prog.uniformLocations.projectionMatrix, false, projectionMatrix);
|
||||
this.context.uniformMatrix4fv(this.shader_prog.uniformLocations.viewMatrix, false, viewMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
alert('Unknown rendering context type');
|
||||
}
|
||||
this.players[0].paddle.update(this.context);
|
||||
this.players[1].paddle.update(this.context);
|
||||
this.ball.update(this.context);
|
||||
this.players[0].paddle.update(this.context, this.shader_prog);
|
||||
this.players[1].paddle.update(this.context, this.shader_prog);
|
||||
this.ball.update(this.context, this.shader_prog);
|
||||
}
|
||||
|
||||
updateScore(p1Score, p2Score) {
|
||||
@ -559,14 +559,14 @@ class Game {
|
||||
const offset = 0;
|
||||
this.context.bindBuffer(this.context.ARRAY_BUFFER, this.buffers.normal);
|
||||
this.context.vertexAttribPointer(
|
||||
shaderInfos.attribLocations.vertexNormal,
|
||||
this.shader_prog.attribLocations.vertexNormal,
|
||||
numComponents,
|
||||
type,
|
||||
normalize,
|
||||
stride,
|
||||
offset,
|
||||
);
|
||||
this.context.enableVertexAttribArray(shaderInfos.attribLocations.vertexNormal);
|
||||
this.context.enableVertexAttribArray(this.shader_prog.attribLocations.vertexNormal);
|
||||
}
|
||||
|
||||
setPositionAttribute()
|
||||
@ -579,14 +579,14 @@ class Game {
|
||||
this.context.bindBuffer(this.context.ARRAY_BUFFER, this.buffers.vertex);
|
||||
this.context.bindBuffer(this.context.ELEMENT_ARRAY_BUFFER, this.buffers.index);
|
||||
this.context.vertexAttribPointer(
|
||||
shaderInfos.attribLocations.vertexPosition,
|
||||
this.shader_prog.attribLocations.vertexPosition,
|
||||
numComponents,
|
||||
type,
|
||||
normalize,
|
||||
stride,
|
||||
offset
|
||||
);
|
||||
this.context.enableVertexAttribArray(shaderInfos.attribLocations.vertexPosition);
|
||||
this.context.enableVertexAttribArray(this.shader_prog.attribLocations.vertexPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@ -600,7 +600,7 @@ class Paddle {
|
||||
this.update();
|
||||
}
|
||||
|
||||
update(ctx) {
|
||||
update(ctx, shader_infos) {
|
||||
if(ctx instanceof CanvasRenderingContext2D)
|
||||
{
|
||||
ctx.fillStyle = 'black';
|
||||
@ -610,7 +610,8 @@ class Paddle {
|
||||
{
|
||||
const posx = (this.x - this.def.CANVASWIDTH / 2);
|
||||
const posy = (this.y - this.def.CANVASHEIGHT / 3);
|
||||
renderCube(ctx, posx, 0, posy, 0, this.width, this.width, this.height / 2);
|
||||
if(shader_infos !== undefined)
|
||||
renderCube(ctx, shader_infos, posx, 0, posy, 0, this.width, this.width, this.height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -637,7 +638,7 @@ class Ball {
|
||||
this.update(ctx);
|
||||
}
|
||||
|
||||
update(ctx) {
|
||||
update(ctx, shader_infos) {
|
||||
if(ctx instanceof CanvasRenderingContext2D)
|
||||
{
|
||||
ctx.fillStyle = 'black';
|
||||
@ -650,7 +651,8 @@ class Ball {
|
||||
const size = this.radius;
|
||||
const posx = (this.x - this.radius / 2) - this.def.CANVASWIDTH / 2;
|
||||
const posy = (this.y - this.radius / 2) - this.def.CANVASHEIGHT / 2;
|
||||
renderCube(ctx, posx, 0, posy, 0, size, size, size);
|
||||
if(shader_infos !== undefined)
|
||||
renderCube(ctx, shader_infos, posx, 0, posy, 0, size, size, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user