![]() | TextureUploadT Method (glPixelFormat, Int32, Int32, T, Int32, glPixelDataType, Int32) |
Namespace: Ooogles
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()
Exception | Condition |
---|---|
GLException | InvalidValue if this is a cube map texture and the width and height parameters are not equal. |
GLException | InvalidValue if level is less than 0 or greater than the maximum level. |
GLException | InvalidValue if width or height is less than 0 or greater than the maximum texture size. |
GLException | InvalidOperation if type is UnsignedShort565 and format is not Rgb. |
GLException | InvalidOperation if type is UnsignedShort4444 or UnsignedShort5551 and format is not Rgba. |
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