Game Development Reference
In-Depth Information
Let's see what each parameter of this function does:
target : This parameter specifies the texture target, either gl.TEXTURE_2D
or one of the cubemap face targets (for example, gl.TEXTURE_CUBE_MAP_
POSITIVE_X , or gl.TEXTURE_CUBE_MAP_NEGATIVE_X , among others).
level : This parameter specifies which mip level to load. The base level is
specified by 0 followed by an increasing level for each successive mipmap.
internalFormat : This parameter specifies the internal format for the texture
storage; this can be gl.RGBA , gl.RGB , gl.LUMINANCE_ALPHA , gl.LUMINANCE ,
or gl.ALPHA .
format : This parameter specifies the format of the pixel data. The following
symbolic values are accepted: GL_RED , GL_RG , GL_RGB , GL_BGR , GL_RGBA , and
GL_BGRA .
type : This parameter specifies the type of the incoming pixel data and can
be gl.UNSIGNED_BYTE , gl.UNSIGNED_SHORT_4_4_4_4 , gl.UNSIGNED_
SHORT_5_5_5_1 , or gl.UNSIGNED_SHORT_5_6_5 .
pixels : This parameter contains the actual pixel data for the image.
The data must contain (width multiplied by height) the number of pixels
with the appropriate number of bytes per pixel based on the format and
type specification.
We are only using the simplest overloaded function as it is also capable of loading
the texture data from the HTML video element. The second parameter, level ,
is the parameter used for loading mipmap levels which we will use in the next
code packet.
To set texture parameters for the current texture unit, the gl.texParameteri
function is used, which is declared as follows:
Void gl.texParameteri(GLenum target, GLenum pname, GLint param)
Let's see what each parameter of this function does:
target : This parameter specifies the target texture, which must be one
of the following: GL_TEXTURE_1D , GL_TEXTURE_2D , GL_TEXTURE_3D , GL_
TEXTURE_1D_ARRAY , GL_TEXTURE_2D_ARRAY , GL_TEXTURE_RECTANGLE , or
GL_TEXTURE_CUBE_MAP
 
Search WWH ::




Custom Search