I have two specific questions about WebGL 2's overloads added to texImage2D().

What is the purpose of WebGL 2 adding new overloads for texImage2D() that specify width, height and border for image/canvas/video sources? For example:

// WebGL 1:
void gl.texImage2D(target, level, internalformat, format, type, HTMLImageElement? source );

// added in WebGL 2:
void gl.texImage2D(target, level, internalformat, width, height, border, format, type, HTMLImageElement source);

I can't find anything detailed about this. Through simple usage it seems to only trim the top and right edges when the width and height are less than the image native width and height; if either value is larger than the image dimension, it throws; if they're the same, it does nothing noticeably different. The overload retains the border argument, but again it must be 0. I'm struggling to see an edge case this solves except maybe symmetry with the older array-buffer overload, but I'm new to WebGL so I lack a lot of history and perspective.

Also, for the new WebGL overload for PIXEL_UNPACK_BUFFER the Khronos OpenGL Wiki says:

PBOs are not connected to textures. They are only used to perform pixel transfers; the buffer objects used in this process do not become connected to the texture in any way. The storage for the image data remains with the texture.

Yet a buffer must be found to this target for this specific overload:

void gl.texImage2D(target, level, internalformat, width, height, border, format, type, GLintptr offset);

Maybe I'm reading too much into the wiki text, but can anyone shed light on what the use case is for texImage2D() and PIXEL_UNPACK_BUFFER? It seems pretty useful, so I want to make sure I understand this caution from Khronos.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.