Skip to content
Snippets Groups Projects
Commit c440ba2d authored by Alexander Rose's avatar Alexander Rose
Browse files

gl tweaks

- add more docs
- clean schema types
parent a3267daf
No related branches found
No related tags found
No related merge requests found
......@@ -76,13 +76,15 @@ export function AttributeSpec<K extends AttributeKind>(kind: K, itemSize: Attrib
return { type: 'attribute', kind, itemSize, divisor };
}
export type UniformSpec<K extends UniformKind> = { type: 'uniform', kind: K, variant?: 'material' | 'buffered' }
export function UniformSpec<K extends UniformKind>(kind: K, variant?: 'material' | 'buffered'): UniformSpec<K> {
type UniformVariant = 'material' | 'buffered'
export type UniformSpec<K extends UniformKind> = { type: 'uniform', kind: K, variant?: UniformVariant }
export function UniformSpec<K extends UniformKind>(kind: K, variant?: UniformVariant): UniformSpec<K> {
return { type: 'uniform', kind, variant };
}
export type TextureSpec<K extends TextureKind> = { type: 'texture', kind: K, format: TextureFormat, dataType: TextureType, filter: TextureFilter, variant?: 'material' }
export function TextureSpec<K extends TextureKind>(kind: K, format: TextureFormat, dataType: TextureType, filter: TextureFilter, variant?: 'material'): TextureSpec<K> {
type TextureVariant = 'material'
export type TextureSpec<K extends TextureKind> = { type: 'texture', kind: K, format: TextureFormat, dataType: TextureType, filter: TextureFilter, variant?: TextureVariant }
export function TextureSpec<K extends TextureKind>(kind: K, format: TextureFormat, dataType: TextureType, filter: TextureFilter, variant?: TextureVariant): TextureSpec<K> {
return { type: 'texture', kind, format, dataType, filter, variant };
}
......
......@@ -23,8 +23,28 @@ export function isWebGL2(gl: any): gl is WebGL2RenderingContext {
* See https://registry.khronos.org/webgl/extensions/ANGLE_instanced_arrays/
*/
export interface COMPAT_instanced_arrays {
/**
* Renders primitives from array data like the `drawArrays` method. In addition, it can execute multiple instances of the range of elements.
* @param mode the type primitive to render.
* @param first the starting index in the array of vector points.
* @param count the number of indices to be rendered.
* @param primcount the number of instances of the range of elements to execute.
*/
drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
/**
* Renders primitives from array data like the `drawElements` method. In addition, it can execute multiple instances of a set of elements.
* @param mode the type primitive to render.
* @param count the number of elements to be rendered.
* @param type the type of the values in the element array buffer.
* @param offset an offset in the element array buffer. Must be a valid multiple of the size of the given `type`.
* @param primcount the number of instances of the set of elements to execute.
*/
drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
/**
* Modifies the rate at which generic vertex attributes advance when rendering multiple instances of primitives with `drawArraysInstanced` and `drawElementsInstanced`
* @param index the index of the generic vertex attributes.
* @param divisor the number of instances that will pass between updates of the generic attribute.
*/
vertexAttribDivisor(index: number, divisor: number): void;
readonly VERTEX_ATTRIB_ARRAY_DIVISOR: number;
}
......@@ -109,6 +129,9 @@ export function getVertexArrayObject(gl: GLRenderingContext): COMPAT_vertex_arra
}
}
/**
* See https://registry.khronos.org/webgl/extensions/OES_texture_float/
*/
export interface COMPAT_texture_float {
}
......@@ -116,6 +139,9 @@ export function getTextureFloat(gl: GLRenderingContext): COMPAT_texture_float |
return isWebGL2(gl) ? {} : gl.getExtension('OES_texture_float');
}
/**
* See https://registry.khronos.org/webgl/extensions/OES_texture_float_linear/
*/
export interface COMPAT_texture_float_linear {
}
......@@ -123,6 +149,9 @@ export function getTextureFloatLinear(gl: GLRenderingContext): COMPAT_texture_fl
return gl.getExtension('OES_texture_float_linear');
}
/**
* See https://registry.khronos.org/webgl/extensions/OES_texture_half_float/
*/
export interface COMPAT_texture_half_float {
readonly HALF_FLOAT: number
}
......@@ -137,6 +166,9 @@ export function getTextureHalfFloat(gl: GLRenderingContext): COMPAT_texture_half
}
}
/**
* See https://registry.khronos.org/webgl/extensions/OES_texture_half_float_linear/
*/
export interface COMPAT_texture_half_float_linear {
}
......@@ -172,6 +204,9 @@ export function getFragDepth(gl: GLRenderingContext): COMPAT_frag_depth | null {
return isWebGL2(gl) ? {} : gl.getExtension('EXT_frag_depth');
}
/**
* See https://registry.khronos.org/webgl/extensions/EXT_color_buffer_float/
*/
export interface COMPAT_color_buffer_float {
readonly RGBA32F: number;
}
......@@ -193,6 +228,9 @@ export function getColorBufferFloat(gl: GLRenderingContext): COMPAT_color_buffer
}
}
/**
* See https://registry.khronos.org/webgl/extensions/EXT_color_buffer_half_float/
*/
export interface COMPAT_color_buffer_half_float {
readonly RGBA16F: number;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment