Skip to content

Commit

Permalink
refactor(webgl): switch to non-const enums
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Apr 4, 2020
1 parent be42b21 commit c491b00
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
10 changes: 5 additions & 5 deletions packages/webgl/src/api/blend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Tuple } from "@thi.ng/api";

export const enum Blend {
export enum Blend {
ZERO = 0,
ONE = 1,
SRC_COLOR = 768,
Expand All @@ -15,15 +15,15 @@ export const enum Blend {
ONE_MINUS_CONSTANT_COLOR = 32770,
CONSTANT_ALPHA = 32771,
ONE_MINUS_CONSTANT_ALPHA = 32772,
SRC_ALPHA_SATURATE = 776
SRC_ALPHA_SATURATE = 776,
}

export const enum BlendEquation {
export enum BlendEquation {
FUNC_ADD = 32774,
FUNC_REVERSE_SUBTRACT = 32779,
FUNC_SUBTRACT = 32778,
MAX = 32776,
MIN = 32775
MIN = 32775,
}

export type BlendFunc = Tuple<Blend, 2>;
Expand All @@ -33,7 +33,7 @@ export type BlendFunc = Tuple<Blend, 2>;

export const BLEND_NORMAL: BlendFunc = [
Blend.SRC_ALPHA,
Blend.ONE_MINUS_SRC_ALPHA
Blend.ONE_MINUS_SRC_ALPHA,
];

export const BLEND_ADD: BlendFunc = [Blend.SRC_ALPHA, Blend.DST_ALPHA];
4 changes: 2 additions & 2 deletions packages/webgl/src/api/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import type { IndexBufferSpec, IWebGLBuffer } from "./buffers";
import type { AttribBufferData, IShader, UniformValues } from "./shader";
import type { ITexture } from "./texture";

export const enum DrawMode {
export enum DrawMode {
POINTS = 0,
LINES = 1,
LINE_LOOP = 2,
LINE_STRIP = 3,
TRIANGLES = 4,
TRIANGLE_STRIP = 5,
TRIANGLE_FAN = 6
TRIANGLE_FAN = 6,
}

export type ModelAttributeSpecs = IObjectOf<ModelAttributeSpec>;
Expand Down
8 changes: 4 additions & 4 deletions packages/webgl/src/api/stencil.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import type { Tuple } from "@thi.ng/api";

export const enum StencilOp {
export enum StencilOp {
KEEP = 7680,
ZERO = 0,
REPLACE = 7681,
INCR = 7682,
INCR_WRAP = 34055,
DECR = 7683,
DECR_WRAP = 34056,
INVERT = 5386
INVERT = 5386,
}

export const enum StencilFn {
export enum StencilFn {
NEVER = 512,
LESS = 513,
EQUAL = 514,
LEQUAL = 515,
GREATER = 516,
NOTEQUAL = 517,
GEQUAL = 518,
ALWAYS = 519
ALWAYS = 519,
}

export type StencilOpParams = Tuple<StencilOp, 3>;
Expand Down
40 changes: 20 additions & 20 deletions packages/webgl/src/api/texture.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IBind, IObjectOf, IRelease } from "@thi.ng/api";
import type { IConfigure } from "./buffers";

export const enum TextureFormat {
export enum TextureFormat {
ALPHA = 0x1906,
DEPTH_COMPONENT = 0x1902,
DEPTH_COMPONENT16 = 0x81a5,
Expand Down Expand Up @@ -68,10 +68,10 @@ export const enum TextureFormat {
RGBA8I = 0x8d8e,
RGBA8UI = 0x8d7c,
SRGB8 = 0x8c41,
SRGB8_ALPHA8 = 0x8c43
SRGB8_ALPHA8 = 0x8c43,
}

export const enum TextureType {
export enum TextureType {
BYTE = 0x1400,
UNSIGNED_BYTE,
SHORT,
Expand All @@ -88,29 +88,29 @@ export const enum TextureType {
UNSIGNED_INT_10F_11F_11F_REV = 0x8c3b,
UNSIGNED_INT_5_9_9_9_REV = 0x8c3e,
HALF_FLOAT_OES = 0x8d61,
FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8dad
FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8dad,
}

export const enum TextureTarget {
export enum TextureTarget {
TEXTURE_2D = 3553,
TEXTURE_3D = 32879,
TEXTURE_CUBE_MAP = 34067,
TEXTURE_2D_ARRAY = 35866
TEXTURE_2D_ARRAY = 35866,
}

export const enum TextureFilter {
export enum TextureFilter {
LINEAR = 9729,
NEAREST = 9728,
NEAREST_MIPMAP_NEAREST = 9984,
LINEAR_MIPMAP_NEAREST = 9985,
NEAREST_MIPMAP_LINEAR = 9986,
LINEAR_MIPMAP_LINEAR = 9987
LINEAR_MIPMAP_LINEAR = 9987,
}

export const enum TextureRepeat {
export enum TextureRepeat {
REPEAT = 10497,
CLAMP = 33071,
REPEAT_MIRROR = 33648
REPEAT_MIRROR = 33648,
}

export interface TextureFormatDecl {
Expand Down Expand Up @@ -158,7 +158,7 @@ const $ = (
render,
renderExt,
filter,
num
num,
});

export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
Expand All @@ -172,7 +172,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.HALF_FLOAT_OES,
2,
TextureType.FLOAT,
4
4,
],
1,
true,
Expand Down Expand Up @@ -230,7 +230,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.HALF_FLOAT_OES,
4,
TextureType.FLOAT,
8
8,
],
2,
true,
Expand All @@ -246,7 +246,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.HALF_FLOAT_OES,
2,
TextureType.FLOAT,
4
4,
],
1,
true,
Expand All @@ -260,7 +260,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.HALF_FLOAT,
6,
TextureType.UNSIGNED_INT_10F_11F_11F_REV,
4
4,
],
3,
false,
Expand Down Expand Up @@ -411,7 +411,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.FLOAT,
12,
TextureType.UNSIGNED_SHORT_5_6_5,
2
2,
],
3,
true,
Expand Down Expand Up @@ -466,7 +466,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.UNSIGNED_SHORT_5_5_5_1,
2,
TextureType.UNSIGNED_INT_2_10_10_10_REV,
4
4,
],
4,
true,
Expand Down Expand Up @@ -511,7 +511,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.HALF_FLOAT,
6,
TextureType.UNSIGNED_INT_5_9_9_9_REV,
4
4,
],
3,
false,
Expand All @@ -531,7 +531,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
TextureType.UNSIGNED_SHORT_4_4_4_4,
2,
TextureType.UNSIGNED_SHORT_5_5_5_1,
2
2,
],
4,
true,
Expand Down Expand Up @@ -623,7 +623,7 @@ export const TEX_FORMATS: IObjectOf<TextureFormatDecl> = {
3,
false,
true
)
),
};

export type ReadableTextureFormat =
Expand Down

0 comments on commit c491b00

Please sign in to comment.