Skip to content

Commit

Permalink
refactor(examples): update to use webgl enums
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 11, 2020
1 parent 5adaa23 commit d73a29d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
3 changes: 2 additions & 1 deletion examples/soa-ecs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
BLEND_ADD,
compileModel,
draw,
DrawMode,
GLMat4,
GLVec4,
ModelSpec,
Expand Down Expand Up @@ -185,7 +186,7 @@ const app = () => {
color2: COLOR2
},
num: NUM,
mode: gl.POINTS
mode: DrawMode.POINTS
});
},
update: (el, gl, __, time) => {
Expand Down
7 changes: 4 additions & 3 deletions examples/webgl-cubemap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
GLMat4,
ModelSpec,
shader,
ShaderSpec
ShaderSpec,
TextureFilter
} from "@thi.ng/webgl";

const CUBEMAP_SHADER: ShaderSpec = {
Expand Down Expand Up @@ -85,8 +86,8 @@ const app = () => {
textures: [
cubeMap(gl, faces, {
filter: [
gl.LINEAR_MIPMAP_LINEAR,
gl.LINEAR
TextureFilter.LINEAR_MIPMAP_LINEAR,
TextureFilter.LINEAR
],
mipmap: true
})
Expand Down
8 changes: 5 additions & 3 deletions examples/webgl-grid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
LAMBERT,
ModelSpec,
shader,
texture
texture,
TextureFilter,
TextureRepeat
} from "@thi.ng/webgl";

const app = () => {
Expand Down Expand Up @@ -69,8 +71,8 @@ const app = () => {
col2: 0xffffffff,
corners: true
}),
filter: gl.NEAREST,
wrap: gl.CLAMP_TO_EDGE
filter: TextureFilter.NEAREST,
wrap: TextureRepeat.CLAMP
})
]
});
Expand Down
11 changes: 7 additions & 4 deletions examples/webgl-msdf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ import {
BLEND_NORMAL,
compileModel,
draw,
DrawMode,
GLMat4,
ModelSpec,
shader,
texture
texture,
TextureFilter,
TextureRepeat
} from "@thi.ng/webgl";
import {
alignCenter,
Expand Down Expand Up @@ -103,8 +106,8 @@ const createText = (
textures: [
texture(gl, {
image: img,
filter: gl.LINEAR,
wrap: gl.CLAMP_TO_EDGE
filter: TextureFilter.LINEAR,
wrap: TextureRepeat.CLAMP
})
],
uniforms: {
Expand Down Expand Up @@ -213,7 +216,7 @@ const createStarField = (gl: WebGLRenderingContext, num = 1000) => {
blendFn: BLEND_NORMAL
}
}),
mode: gl.POINTS,
mode: DrawMode.POINTS,
num
});
};
Expand Down
19 changes: 11 additions & 8 deletions examples/webgl-ssao/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import {
rbo,
shader,
texture,
TextureOpts
TextureFilter,
TextureFormat,
TextureOpts,
TextureRepeat
} from "@thi.ng/webgl";
import { CONTROLS, PARAM_DEFS, PARAMS } from "./params";
import { FINAL_SHADER, LIGHT_SHADER, SSAO_SHADER } from "./shaders";
Expand Down Expand Up @@ -72,20 +75,20 @@ const app = () => {
}
const [colorTex, posTex, normTex, noiseTex, ssaoTex] = [
{},
{ format: gl.RGBA16F },
{ format: gl.RGBA16F },
{ format: TextureFormat.RGBA16F },
{ format: TextureFormat.RGBA16F },
{
image: NOISE,
format: gl.RG16F
format: TextureFormat.RG16F
},
{}
].map((opts: Partial<TextureOpts>) =>
texture(gl, {
width: W,
height: H,
image: null,
filter: gl.NEAREST,
wrap: gl.CLAMP_TO_EDGE,
filter: TextureFilter.NEAREST,
wrap: TextureRepeat.CLAMP,
...opts
})
);
Expand Down Expand Up @@ -140,8 +143,8 @@ const app = () => {
col2: 0xffe0e0e0,
corners: true
}),
filter: gl.NEAREST,
wrap: gl.CLAMP_TO_EDGE
filter: TextureFilter.NEAREST,
wrap: TextureRepeat.CLAMP
})
]
});
Expand Down

0 comments on commit d73a29d

Please sign in to comment.