EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

bindTexture method

Binds a named texture object to a target.

IE11

 

Syntax

WebGLRenderingContext.bindTexture(target, texture object);

Parameters

target [in]

Type: Number

gl.TEXTURE_2D
gl.TEXTURE_CUBE_MAP
texture object [in]

Type: WebGLTexture

Either a reference to a texture object or null.

Return value

This method does not return a value.

Remarks

WebGL errorDescription
gl.INVALID_ENUMIf target isn't one of the listed values..
gl.INVALID_OPERATIONIf texture was created with different target than target.

 

Examples

This example binds a texture to a WebGL context. For more info on this example, see Get started with WebGL.


// Create a texture object that will contain the image.
var texture = gl.createTexture();

// Bind the texture the target (TEXTURE_2D) of the active texture unit.
gl.bindTexture(gl.TEXTURE_2D, texture);

// Flip the image's Y axis to match the WebGL texture coordinate space.
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
    
// Set the parameters so we can render any size image.        
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); 
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);

  // Upload the resized canvas image into the texture.
//    Note: a canvas is used here but can be replaced by an image object. 
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);


See also

WebGLRenderingContext

 

 

표시:
© 2014 Microsoft