change drawable interface
This commit is contained in:
parent
af1a1319a5
commit
1517b1ef2c
@ -35,8 +35,8 @@ export class CanvasApp{
|
|||||||
|
|
||||||
this.gl.clearColor(0,0,0,0);
|
this.gl.clearColor(0,0,0,0);
|
||||||
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
||||||
this.renderer.draw(this.gl);
|
this.renderer.draw(this.gl,{});
|
||||||
this.trenderer.draw(this.gl);
|
this.trenderer.draw(this.gl,{});
|
||||||
requestAnimationFrame(this.drawScene.bind(this));
|
requestAnimationFrame(this.drawScene.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1,4 +1,6 @@
|
|||||||
|
export interface RenderState{
|
||||||
|
}
|
||||||
|
|
||||||
export interface Drawable{
|
export interface Drawable{
|
||||||
draw(gl:WebGL2RenderingContext):void;
|
draw(gl:WebGL2RenderingContext, state : RenderState):void;
|
||||||
};
|
};
|
@ -17,7 +17,7 @@ uniform vec4 u_color;
|
|||||||
void main() {
|
void main() {
|
||||||
outColor = u_color;
|
outColor = u_color;
|
||||||
}`;
|
}`;
|
||||||
import { Drawable } from "./drawable";
|
import { Drawable, RenderState } from "./drawable";
|
||||||
import * as G from "./glWrapper";
|
import * as G from "./glWrapper";
|
||||||
import { getUniformDefaultValue, UniformSet } from "./uniform";
|
import { getUniformDefaultValue, UniformSet } from "./uniform";
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ export class Drawer2D implements Drawable{
|
|||||||
setUniform(u:UniformSet){
|
setUniform(u:UniformSet){
|
||||||
this.uniforms = u;
|
this.uniforms = u;
|
||||||
}
|
}
|
||||||
draw(gl:WebGL2RenderingContext){
|
draw(gl:WebGL2RenderingContext, state : RenderState){
|
||||||
this.useProgram();
|
this.useProgram();
|
||||||
|
|
||||||
this.program.setUniform4fv(gl,"u_color",[this.uniforms.redcolor,0.3,0.8,1.0]);
|
this.program.setUniform4fv(gl,"u_color",[this.uniforms.redcolor,0.3,0.8,1.0]);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Drawable } from "./drawable";
|
import { Drawable, RenderState } from "./drawable";
|
||||||
import {createProgramFromSource, ProgramError, ShaderError} from "./gl_util";
|
import {createProgramFromSource, ProgramError, ShaderError} from "./gl_util";
|
||||||
import { createIndexBuffer, createVertexArray, createVertexBuffer, GLProgram, IndexBuffer, VertexArray, VertexBuffer } from "./glWrapper";
|
import { createIndexBuffer, createVertexArray, createVertexBuffer, GLProgram, IndexBuffer, VertexArray, VertexBuffer } from "./glWrapper";
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ export class TriangleDrawer implements Drawable{
|
|||||||
this.indexBuffer.bind(gl);
|
this.indexBuffer.bind(gl);
|
||||||
this.vao.unbind(gl);
|
this.vao.unbind(gl);
|
||||||
}
|
}
|
||||||
draw(gl: WebGL2RenderingContext): void {
|
draw(gl: WebGL2RenderingContext, state :RenderState): void {
|
||||||
this.program.use(gl);
|
this.program.use(gl);
|
||||||
this.vao.bind(gl);
|
this.vao.bind(gl);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user