As mentioned previously, the image
loader will typically load the image into RAM on the host computer
(client). However, to use the texture we
must pass it to the GPU (server). There
are several ways to do this.
glTexImage2D(target,
level, internalFormat, width, height, border, format, type,
*texels);
- target:
usually GL_TEXTURE_2D
- level: 0 unless using mipmapping
- internalFormat
:
specifies the colour components used internally by OpenGL on the GPU side
(GL_RGB, GL_RGBA, etc.)
- width, height:
size of the image – often a power of 2
- border:
width of border, typically 0
- format specifies
the colour components on the CPU side (GL_RGB, GL_RGBA, etc.)
- type defines the data type of the pixel data
(e.g., GL_UNSIGNED_BYTE)
- texels: pointer
to the client side image data.
Note
that after calling glTexImage2D, the CPU side memory can be freed since the
texture will be loaded into VRAM.