We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesComputer Graphics KitC/C++GPU ExtensionsSmart CacheOpenGLglTexImage2D

glTexImage2D

Definition

Collapse
Word wrap
Dark theme
Copy code
  1. void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid const *pixels)

Function

Maps part of the specified texture image to each primitive that is textured into activity. The texture is active when the current fragment shader or vertex shader uses the built-in texture lookup function. Call glTexImage2D to define a texture image. Before that, call glBindTexture to specify the texture ID to be operated. This API allows you to redefine the texture object.

Parameters

Expand

Parameter

Type

Description

target

unsigned integer

Target texture. Must be GL_TEXTURE_2D.

level

integer

Execution detail level. 0 indicates the basic image level, and n indicates level n.

internalformat

integer

Color component of the texture. The options are as follows:

  • GL_ALPHA
  • GL_RGB
  • GL_RGBA
  • GL_LUMINANCE
  • GL_LUMINANCE_ALPHA

width

integer

Width of the texture image. Must be a power of 2 (2n). The texture image must support the width of at least 64 material elements.

height

integer

Height of the texture image. Must be a power of 2 (2m). The texture image must support the height of at least 64 material elements.

border

integer

Width of the border. Must be set to 0.

format

unsigned integer

Color format of the pixel data. Its value does not need to be the same as internalformat. For details about the options, please refer to internalformat.

type

unsigned integer

Data type of the specified pixel data. The options are as follows:

  • GL_UNSIGNED_BYTE
  • GL_UNSIGNED_SHORT_5_6_5
  • GL_UNSIGNED_SHORT_4_4_4_4
  • GL_UNSIGNED_SHORT_5_5_5_1

pixels

pointer

Pointer to image data in the specified memory.

Call Example

Collapse
Word wrap
Dark theme
Copy code
  1. glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, fbo_width, fbo_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
Search in References
Enter a keyword.