glTexImage2D¶
specify a two-dimensional texture image
function glTexImage2D(int $target, int $level, int $internalformat, int $width, int $height, int $border, int $format, int $type, ?\GL\Buffer\BufferInterface $data) : void
PHP-GLFW Note
for This function has been modified to accept a BufferInterface
object instead of a pointer.
Also in this PHP OpenGL extension, the arguments are validated against the
passed buffer object. If the buffer object is too small for the given width,
height, and format an exception is thrown. This is done to prevent segfaults,
this will unfortunately, make the function quite a bit slower. But as
uploading textures is anyway a heavy operation the impact should not be
noticeable in normal applications.
Example:
glGenTextures(1, $texture);
glBindTexture(GL_TEXTURE_2D, $texture);
// we just create a simple 2x2 texture with 4 channels
$buffer = new GL\Buffer\UByteBuffer([
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255,
255, 255, 255, 255,
]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
$buffer);
- arguments
-
int
$target
Specifies the target texture. Must beGL_TEXTURE_2D ,GL_PROXY_TEXTURE_2D ,GL_TEXTURE_1D_ARRAY ,GL_PROXY_TEXTURE_1D_ARRAY ,GL_TEXTURE_RECTANGLE ,GL_PROXY_TEXTURE_RECTANGLE ,GL_TEXTURE_CUBE_MAP_POSITIVE_X ,GL_TEXTURE_CUBE_MAP_NEGATIVE_X ,GL_TEXTURE_CUBE_MAP_POSITIVE_Y ,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y ,GL_TEXTURE_CUBE_MAP_POSITIVE_Z ,GL_TEXTURE_CUBE_MAP_NEGATIVE_Z , orGL_PROXY_TEXTURE_CUBE_MAP .int
$level
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. If target isGL_TEXTURE_RECTANGLE orGL_PROXY_TEXTURE_RECTANGLE , level must be 0.int
$internalformat
Specifies the number of color components in the texture. Must be one of base internal formats given in Table 1, one of the sized internal formats given in Table 2, or one of the compressed internal formats given in Table 3, below.int
$width
Specifies the width of the texture image. All implementations support texture images that are at least 1024 texels wide.int
$height
Specifies the height of the texture image, or the number of layers in a texture array, in the case of theGL_TEXTURE_1D_ARRAY andGL_PROXY_TEXTURE_1D_ARRAY targets. All implementations support 2D texture images that are at least 1024 texels high, and texture arrays that are at least 256 layers deep.int
$border
This value must be 0.int
$format
Specifies the format of the pixel data. The following symbolic values are accepted:GL_RED ,GL_RG ,GL_RGB ,GL_BGR ,GL_RGBA ,GL_BGRA ,GL_RED_INTEGER ,GL_RG_INTEGER ,GL_RGB_INTEGER ,GL_BGR_INTEGER ,GL_RGBA_INTEGER ,GL_BGRA_INTEGER ,GL_STENCIL_INDEX ,GL_DEPTH_COMPONENT ,GL_DEPTH_STENCIL .int
$type
Specifies the data type of the pixel data. The following symbolic values are accepted:GL_UNSIGNED_BYTE ,GL_BYTE ,GL_UNSIGNED_SHORT ,GL_SHORT ,GL_UNSIGNED_INT ,GL_INT ,GL_HALF_FLOAT ,GL_FLOAT ,GL_UNSIGNED_BYTE_3_3_2 ,GL_UNSIGNED_BYTE_2_3_3_REV ,GL_UNSIGNED_SHORT_5_6_5 ,GL_UNSIGNED_SHORT_5_6_5_REV ,GL_UNSIGNED_SHORT_4_4_4_4 ,GL_UNSIGNED_SHORT_4_4_4_4_REV ,GL_UNSIGNED_SHORT_5_5_5_1 ,GL_UNSIGNED_SHORT_1_5_5_5_REV ,GL_UNSIGNED_INT_8_8_8_8 ,GL_UNSIGNED_INT_8_8_8_8_REV ,GL_UNSIGNED_INT_10_10_10_2 , andGL_UNSIGNED_INT_2_10_10_10_REV .?\GL\Buffer\BufferInterface
$data
- returns
-
void
Copyright © 2010-2014 Khronos Group
This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. https://opencontent.org/openpub/.