Click or drag to resize

TextureUploadT Method (glPixelFormat, Int32, Int32, T, Int32, glPixelDataType, Int32)

Uploads an image to the texture.

Namespace:  Ooogles
Assembly:  Ooogles (in Ooogles.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public void Upload<T>(
	glPixelFormat format,
	int width,
	int height,
	T[] data,
	int level = 0,
	glPixelDataType type = glPixelDataType.UnsignedByte,
	int cubeTarget = 0
)
where T : struct, new()

Parameters

format
Type: OooglesglPixelFormat
the format of the texel data.
width
Type: SystemInt32
the width of the texture image. All implementations support 2D texture images that are at least 64 texels wide and cube-mapped texture images that are at least 16 texels wide.
height
Type: SystemInt32
the height of the texture image. All implementations support 2D texture images that are at least 64 texels high and cube-mapped texture images that are at least 16 texels high.
data
Type: T
one-dimensional array with the image data in memory.
level (Optional)
Type: SystemInt32
(optional) level-of-detail number if updating separate mipmap levels. Level 0 (default) is the base image level. Level N is the Nth mipmap reduction image.
type (Optional)
Type: OooglesglPixelDataType
(optional) data type the texel data. Defaults to UnsignedByte.
cubeTarget (Optional)
Type: SystemInt32
(optional) if this texture is a cube texture, then this parameter specifies which of the 6 cube faces to update. This parameter is ignored for 2D textures.

Type Parameters

T
the type of data in the data array
Exceptions
ExceptionCondition
GLExceptionInvalidValue if this is a cube map texture and the width and height parameters are not equal.
GLExceptionInvalidValue if level is less than 0 or greater than the maximum level.
GLExceptionInvalidValue if width or height is less than 0 or greater than the maximum texture size.
GLExceptionInvalidOperation if type is UnsignedShort565 and format is not Rgb.
GLExceptionInvalidOperation if type is UnsignedShort4444 or UnsignedShort5551 and format is not Rgba.
Remarks
This creates the texture in memory.

Texturing maps a portion of a specified texture image onto each graphical primitive for which texturing is active. Texturing is active when the current fragment shader or vertex shader makes use of built-in texture lookup functions.

To define texture images, call Upload. The arguments describe the parameters of the texture image, such as height, width, level-of-detail number (see MinificationFilter), and format. The other arguments describe how the image is represented in memory.

Data is read from data as a sequence of unsigned bytes or shorts, depending on type. Color components are converted to floating point based on the type.

width × height texels are read from memory, starting at location data. By default, these texels are taken from adjacent memory locations, except that after all width texels are read, the read pointer is advanced to the next four-byte boundary. The four-byte row alignment is specified by PixelStore(glPixelStoreMode, glPixelStoreValue) with argument UnpackAlignment, and it can be set to one, two, four, or eight bytes.

The first element corresponds to the lower left corner of the texture image. Subsequent elements progress left-to-right through the remaining texels in the lowest row of the texture image, and then in successively higher rows of the texture image. The final element corresponds to the upper right corner of the texture image.

Note: to reserve memory for the texture without specifying texture data, use Reserve(glPixelFormat, Int32, Int32, Int32, glPixelDataType, Int32) instead. You can then upload subtextures to initialize this texture memory. The image is undefined if the user tries to apply an uninitialized portion of the texture image to a primitive.

Note: This method specifies a two-dimensional or cube-map texture for the current texture unit, specified with BindToTextureUnit(Int32).

Note: in DEBUG mode with assertions enabled, an error will be logged to the debug console if this texture is not bound.

OpenGL API: glTexImage2D

See Also

Reference