add supporting of various uniform type
This commit is contained in:
parent
400ade6f22
commit
2058e610cc
@ -14,6 +14,7 @@
|
||||
"@emotion/styled": "^11.3.0",
|
||||
"@mui/material": "^5.0.1",
|
||||
"@types/react": "^17.0.24",
|
||||
"gl-matrix": "^3.3.0",
|
||||
"parcel-bundler": "^1.12.5",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { mat4, vec2, vec3, vec4 } from "gl-matrix";
|
||||
import * as util from "./gl_util";
|
||||
|
||||
export class VertexBuffer{
|
||||
@ -88,10 +89,32 @@ export class GLProgram{
|
||||
use(gl:WebGL2RenderingContext):void{
|
||||
gl.useProgram(this.program);
|
||||
}
|
||||
setUniform4fv(gl:WebGL2RenderingContext,name:string,v:number[]){
|
||||
|
||||
setUniform1i(gl:WebGL2RenderingContext,name:string,v:number){
|
||||
const loc = this.getUniformLocation(gl,name);
|
||||
gl.uniform1i(loc,v);
|
||||
}
|
||||
setUniform1f(gl:WebGL2RenderingContext,name:string,v:number){
|
||||
const loc = this.getUniformLocation(gl,name);
|
||||
gl.uniform1f(loc,v);
|
||||
}
|
||||
setUniform2fv(gl:WebGL2RenderingContext,name:string,v:vec2){
|
||||
const loc = this.getUniformLocation(gl,name);
|
||||
gl.uniform2fv(loc,v);
|
||||
}
|
||||
setUniform3fv(gl:WebGL2RenderingContext,name:string,v:vec3){
|
||||
const loc = this.getUniformLocation(gl,name);
|
||||
gl.uniform3fv(loc,v);
|
||||
}
|
||||
setUniform4fv(gl:WebGL2RenderingContext,name:string,v:vec4){
|
||||
const loc = this.getUniformLocation(gl,name);
|
||||
gl.uniform4fv(loc,v);
|
||||
}
|
||||
setUniformMat4f(gl:WebGL2RenderingContext,name:string,v:mat4){
|
||||
const loc = this.getUniformLocation(gl,name);
|
||||
gl.uniformMatrix4fv(loc,false,v);
|
||||
}
|
||||
|
||||
unuse(gl:WebGL2RenderingContext):void{
|
||||
gl.useProgram(null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user