Added some more WebGL functions to gl_functions.js. Made the test_app render something more interesting. Added a bool return from App_UpdateAndRender which allows it to request that the application loop ends.
This commit is contained in:
@@ -69,6 +69,40 @@ function verifyParameter(verifyResult, functionName, parameterName, parameterVal
|
||||
// +--------------------------------------------------------------+
|
||||
// | WebGL API |
|
||||
// +--------------------------------------------------------------+
|
||||
export function jsGlEnable(capability)
|
||||
{
|
||||
appGlobals.glContext.enable(capability);
|
||||
}
|
||||
export function jsGlDisable(capability)
|
||||
{
|
||||
appGlobals.glContext.disable(capability);
|
||||
}
|
||||
|
||||
export function jsGlBlendFunc(srcFactor, dstFactor)
|
||||
{
|
||||
appGlobals.glContext.blendFunc(srcFactor, dstFactor);
|
||||
}
|
||||
export function jsGlBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha)
|
||||
{
|
||||
appGlobals.glContext.blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
export function jsGlDepthFunc(depthFunc)
|
||||
{
|
||||
appGlobals.glContext.depthFunc(depthFunc);
|
||||
}
|
||||
|
||||
export function jsGlFrontFace(cullMode)
|
||||
{
|
||||
appGlobals.glContext.frontFace(cullMode);
|
||||
}
|
||||
|
||||
export function jsGlDeleteBuffer(bufferId)
|
||||
{
|
||||
if (!verifyParameter(verifyGlBufferId(bufferId, false), "gl.deleteBuffer", "bufferId", bufferId)) { return; }
|
||||
appGlobals.glContext.deleteBuffer(glObjects.buffers[bufferId]);
|
||||
glObjects.buffers[bufferId] = null;
|
||||
}
|
||||
export function jsGlCreateBuffer()
|
||||
{
|
||||
let newBuffer = appGlobals.glContext.createBuffer();
|
||||
@@ -98,6 +132,7 @@ export function jsGlCreateVertexArray()
|
||||
return newVaoId;
|
||||
}
|
||||
|
||||
//TODO: jsGlDeleteVertexArray?
|
||||
export function jsGlBindVertexArray(vaoId)
|
||||
{
|
||||
if (!verifyParameter(verifyGlVaoId(vaoId, true), "gl.bindVertexArray", "vaoId", vaoId)) { return; }
|
||||
@@ -115,6 +150,12 @@ export function jsGlVertexAttribPointer(attribLocation, componentCount, componen
|
||||
appGlobals.glContext.vertexAttribPointer(attribLocation, componentCount, componentType, normalized, stride, offset);
|
||||
}
|
||||
|
||||
export function jsGlDeleteShader(shaderId)
|
||||
{
|
||||
if (!verifyParameter(verifyGlShaderId(shaderId, false), "gl.deleteShader", "shaderId", shaderId)) { return; }
|
||||
appGlobals.glContext.deleteShader(glObjects.shaders[shaderId]);
|
||||
glObjects.shaders[shaderId] = null;
|
||||
}
|
||||
export function jsGlCreateShader(shaderType)
|
||||
{
|
||||
let newShader = appGlobals.glContext.createShader(shaderType);
|
||||
@@ -155,6 +196,12 @@ export function jsGlGetShaderParameterInt(shaderId, parameter)
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
export function jsGlDeleteProgram(programId)
|
||||
{
|
||||
if (!verifyParameter(verifyGlProgramId(programId, false), "gl.deleteProgram", "programId", programId)) { return; }
|
||||
appGlobals.glContext.deleteShader(glObjects.programs[programId]);
|
||||
glObjects.programs[programId] = null;
|
||||
}
|
||||
export function jsGlCreateProgram()
|
||||
{
|
||||
let newProgram = appGlobals.glContext.createProgram();
|
||||
@@ -207,6 +254,14 @@ export function jsGlClearColor(rValue, gValue, bValue, aValue)
|
||||
{
|
||||
appGlobals.glContext.clearColor(rValue, gValue, bValue, aValue);
|
||||
}
|
||||
export function jsGlClearDepth(depth)
|
||||
{
|
||||
appGlobals.glContext.clearDepth(depth);
|
||||
}
|
||||
export function jsGlClearStencil(stencilValue)
|
||||
{
|
||||
appGlobals.glContext.clearStencil(stencilValue);
|
||||
}
|
||||
|
||||
export function jsGlClear(bufferBits)
|
||||
{
|
||||
@@ -360,6 +415,13 @@ export function jsGlUniformMatrix4fv(locationId, valuesPntr)
|
||||
}
|
||||
|
||||
export let jsGlFunctions = {
|
||||
jsGlEnable: jsGlEnable,
|
||||
jsGlDisable: jsGlDisable,
|
||||
jsGlBlendFunc: jsGlBlendFunc,
|
||||
jsGlBlendFuncSeparate: jsGlBlendFuncSeparate,
|
||||
jsGlDepthFunc: jsGlDepthFunc,
|
||||
jsGlFrontFace: jsGlFrontFace,
|
||||
jsGlDeleteBuffer: jsGlDeleteBuffer,
|
||||
jsGlCreateBuffer: jsGlCreateBuffer,
|
||||
jsGlBindBuffer: jsGlBindBuffer,
|
||||
jsGlBufferData: jsGlBufferData,
|
||||
@@ -367,11 +429,13 @@ export let jsGlFunctions = {
|
||||
jsGlBindVertexArray: jsGlBindVertexArray,
|
||||
jsGlEnableVertexAttribArray: jsGlEnableVertexAttribArray,
|
||||
jsGlVertexAttribPointer: jsGlVertexAttribPointer,
|
||||
jsGlDeleteShader: jsGlDeleteShader,
|
||||
jsGlCreateShader: jsGlCreateShader,
|
||||
jsGlShaderSource: jsGlShaderSource,
|
||||
jsGlCompileShader: jsGlCompileShader,
|
||||
jsGlGetShaderParameterBool: jsGlGetShaderParameterBool,
|
||||
jsGlGetShaderParameterInt: jsGlGetShaderParameterInt,
|
||||
jsGlDeleteProgram: jsGlDeleteProgram,
|
||||
jsGlCreateProgram: jsGlCreateProgram,
|
||||
jsGlAttachShader: jsGlAttachShader,
|
||||
jsGlLinkProgram: jsGlLinkProgram,
|
||||
@@ -379,6 +443,8 @@ export let jsGlFunctions = {
|
||||
jsGlGetProgramParameterBool: jsGlGetProgramParameterBool,
|
||||
jsGlGetProgramParameterInt: jsGlGetProgramParameterInt,
|
||||
jsGlClearColor: jsGlClearColor,
|
||||
jsGlClearDepth: jsGlClearDepth,
|
||||
jsGlClearStencil: jsGlClearStencil,
|
||||
jsGlClear: jsGlClear,
|
||||
jsGlDrawArrays: jsGlDrawArrays,
|
||||
jsGlGetUniformLocation: jsGlGetUniformLocation,
|
||||
@@ -403,5 +469,9 @@ export let jsGlFunctions = {
|
||||
jsGlUniformMatrix4fv: jsGlUniformMatrix4fv,
|
||||
};
|
||||
|
||||
//TODO: deleteTexture(webglObjects.textures[textureId])
|
||||
//TODO: texImage2D(target, level, internalformat, width, height, border, format, type, dataBuffer)
|
||||
//TODO: generateMipmap(target)
|
||||
|
||||
//TODO: string getShaderInfoLog(shaderId)
|
||||
//TODO: string getProgramInfoLog(programId)
|
||||
|
||||
Reference in New Issue
Block a user