
Explore tens of thousands of sets crafted by our community.
WebGL Essentials
25
Flashcards
0/25
gl.getAttribLocation(program, name)
Returns the location of an attribute variable in a given WebGLProgram. `program` is the program object, and `name` is the name of the attribute variable in the GLSL shader code.
gl.disableVertexAttribArray(index)
Disables a generic vertex attribute array. `index` is the position of the attribute array to disable.
gl.texParameteri(target, pname, param)
Sets texture parameters. `target` specifies the texture target, `pname` is the parameter to set, and `param` is the value to set for that parameter.
gl.createShader(type)
Creates a shader object of a specified type, either `gl.VERTEX_SHADER` or `gl.FRAGMENT_SHADER`, to be used in a WebGL program.
gl.compileShader(shader)
Compiles the shader source code into a form that can be executed by the WebGL system. `shader` is the shader object to compile.
gl.clear(mask)
Clears buffers to preset values specified by the mask. The mask can be `gl.COLOR_BUFFER_BIT`, `gl.DEPTH_BUFFER_BIT`, or `gl.STENCIL_BUFFER_BIT`.
gl.useProgram(program)
Sets the specified compiled and linked WebGLProgram as the active program for rendering.
gl.linkProgram(program)
Links all attached shaders in a WebGLProgram into a final program that can be used for rendering.
gl.vertexAttribPointer(index, size, type, normalized, stride, offset)
Defines an array of generic vertex attribute data. Parameters configure the data format and the location and the memory layout of the vertex attributes in the buffer.
gl.activeTexture(texture)
Activates a texture unit. `texture` must be one of `gl.TEXTURE0` to `gl.TEXTURE31`. Subsequent texture operations will affect the active texture unit.
gl.shaderSource(shader, source)
Sets the source code in a shader object. `shader` is the shader object to update, and `source` is a string containing the GLSL source code.
gl.attachShader(program, shader)
Attaches a compiled shader object to a WebGLProgram. `program` is the program to attach to, and `shader` is the shader object.
gl.texImage2D(target, level, internalformat, width, height, border, format, type, pixels)
Defines a two-dimensional texture image. Parameters allow specification of the texture's target, mipmap level, internal format, size, border, format, data type, and the image data itself.
gl.bindBuffer(target, buffer)
Binds a given WebGLBuffer to a buffer target. The `target` can be either `gl.ARRAY_BUFFER` for vertex attributes or `gl.ELEMENT_ARRAY_BUFFER` for element indices.
gl.bufferData(target, sizeOrData, usage)
Creates and initializes the buffer object's data store. `target` is the buffer bind point, `sizeOrData` is the data store size or data in ArrayBuffer, and `usage` specifies the intended usage pattern of the data store.
gl.bindTexture(target, texture)
Binds a given WebGLTexture to a texture target. The `target` is often `gl.TEXTURE_2D`. The `texture` is the WebGLTexture to bind.
gl.clearColor(r, g, b, a)
Sets the color values used when clearing color buffers, where r, g, b, and a represent the red, green, blue and alpha values used for the clear operation.
gl.drawArrays(mode, first, count)
Renders primitives from array data. The mode specifies the type of primitive to render, `first` is the starting index, and `count` is the number of indices to render.
gl.createProgram()
Creates and initializes a WebGLProgram object that shaders can be attached to.
gl.uniformMatrix4fv(location, transpose, value)
Specifies matrix values for uniform variables. `location` indicates the uniform variable location, `transpose` indicates if the matrix should be transposed, and `value` is an array or typed array of `16` float values.
gl.deleteBuffer(buffer)
Deletes a buffer object, freeing the memory. `buffer` is a WebGLBuffer to be deleted.
gl.getUniformLocation(program, name)
Returns the location of a uniform variable within a WebGLProgram. `program` is the program object containing the shader with the uniform variable, and `name` is the name of the uniform variable in the GLSL shader code.
gl.enableVertexAttribArray(index)
Enables a generic vertex attribute array. `index` is the position of the attribute array to enable, as obtained from `gl.getAttribLocation()`.
gl.createBuffer()
Creates a new instance of `WebGLBuffer`. This buffer can store vertex data, such as vertex coordinates, texture coordinate data, or vertex color data.
gl.viewport(x, y, width, height)
Sets the viewport, specifying the affine transformation of x and y from normalized device coordinates to window coordinates. This affects how the rendered image is scaled and translated into the canvas.
© Hypatia.Tech. 2024 All rights reserved.