From 1517b1ef2c74226286cb35c708373ec4b7d5f9c5 Mon Sep 17 00:00:00 2001 From: monoid Date: Sun, 10 Oct 2021 00:20:31 +0900 Subject: [PATCH] change drawable interface --- src/app.ts | 4 ++-- src/drawable.ts | 4 +++- src/drawer2D.ts | 4 ++-- src/triangle_drawer.ts | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app.ts b/src/app.ts index 3e4e7d5..3a8a10f 100644 --- a/src/app.ts +++ b/src/app.ts @@ -35,8 +35,8 @@ export class CanvasApp{ this.gl.clearColor(0,0,0,0); this.gl.clear(this.gl.COLOR_BUFFER_BIT); - this.renderer.draw(this.gl); - this.trenderer.draw(this.gl); + this.renderer.draw(this.gl,{}); + this.trenderer.draw(this.gl,{}); requestAnimationFrame(this.drawScene.bind(this)); } }; \ No newline at end of file diff --git a/src/drawable.ts b/src/drawable.ts index 58b86b0..1e1b7a6 100644 --- a/src/drawable.ts +++ b/src/drawable.ts @@ -1,4 +1,6 @@ +export interface RenderState{ +} export interface Drawable{ - draw(gl:WebGL2RenderingContext):void; + draw(gl:WebGL2RenderingContext, state : RenderState):void; }; \ No newline at end of file diff --git a/src/drawer2D.ts b/src/drawer2D.ts index ab46d8f..b09b3c3 100644 --- a/src/drawer2D.ts +++ b/src/drawer2D.ts @@ -17,7 +17,7 @@ uniform vec4 u_color; void main() { outColor = u_color; }`; -import { Drawable } from "./drawable"; +import { Drawable, RenderState } from "./drawable"; import * as G from "./glWrapper"; import { getUniformDefaultValue, UniformSet } from "./uniform"; @@ -82,7 +82,7 @@ export class Drawer2D implements Drawable{ setUniform(u:UniformSet){ this.uniforms = u; } - draw(gl:WebGL2RenderingContext){ + draw(gl:WebGL2RenderingContext, state : RenderState){ this.useProgram(); this.program.setUniform4fv(gl,"u_color",[this.uniforms.redcolor,0.3,0.8,1.0]); diff --git a/src/triangle_drawer.ts b/src/triangle_drawer.ts index 038264e..5cf47b1 100644 --- a/src/triangle_drawer.ts +++ b/src/triangle_drawer.ts @@ -1,4 +1,4 @@ -import { Drawable } from "./drawable"; +import { Drawable, RenderState } from "./drawable"; import {createProgramFromSource, ProgramError, ShaderError} from "./gl_util"; import { createIndexBuffer, createVertexArray, createVertexBuffer, GLProgram, IndexBuffer, VertexArray, VertexBuffer } from "./glWrapper"; @@ -55,7 +55,7 @@ export class TriangleDrawer implements Drawable{ this.indexBuffer.bind(gl); this.vao.unbind(gl); } - draw(gl: WebGL2RenderingContext): void { + draw(gl: WebGL2RenderingContext, state :RenderState): void { this.program.use(gl); this.vao.bind(gl);