Question

I'm currently developing an OpenGL-ES application for Android using the NDK. The application would greatly benefit from the following Open-GL extension:

GL_EXT_texture_array

(details here: GL_EXT_texture_arary)
The extension is supported by my Tegra-3 device (Asus EeePad Transformer Prime Tf-201)

The issue I'm now facing is, that I have no clue how to make the extension available for my application as it is not included by the Open-GL ES API registry.
(see "Extension Specifications": http://www.khronos.org/registry/gles/)
However I noticed an extension called "GL_NV_texture_array" which seems to be of the same use, but is not supported by my Tegra-3 device.

I'm aware of the possibility to include extensions using function pointers. But I thought there might be a more comfortable way. I have also found a header file (gl2ext_nv.h), which contains the necessary extension. But when you search for it through google, the file is always part of particular projects, not something official. I have also downloaded the Tegra Android Development Pack (2.0) in which neither this header file nor the desired extension is included.

Can anyone explain this to me, please?
How can I use Open-GL ES extension supported by my Tegra-3 device, which are seemingly not supported by any official Open-GL ES specific headers (in the NDK)?

Thanks in advance!

Was it helpful?

Solution

When you say that your Tegra 3 device supports GL_EXT_texture_array but not GL_NV_texture_array, I'm assuming that you determined that through a call to glGetString(GL_EXTENSIONS).

GL_NV_texture_array is very similar to GL_EXT_texture_array, just limited to 2d texture arrays. Not surprisingly, it uses many of the same constants as GL_EXT_texture_array, just with different names.

GL_NV_texture_array:

TEXTURE_2D_ARRAY_NV                             0x8C1A
TEXTURE_BINDING_2D_ARRAY_NV                     0x8C1D
MAX_ARRAY_TEXTURE_LAYERS_NV                     0x88FF
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_NV         0x8CD4
SAMPLER_2D_ARRAY_NV                             0x8DC1

GL_EXT_texture_array:

TEXTURE_2D_ARRAY_EXT                            0x8C1A
TEXTURE_BINDING_2D_ARRAY_EXT                    0x8C1D
MAX_ARRAY_TEXTURE_LAYERS_EXT                    0x88FF
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT        0x8CD4
SAMPLER_2D_ARRAY_EXT                            0x8DC1

This version of gl2ext_nv.h defines the constants for GL_EXT_texture_array but not for GL_NV_texture_array, so perhaps nVidia is using the the old name now. If you can't find a more recent version of the header, just include this one.

To gain access to functions offered by GL extensions, use eglGetProcAddress to assign the function to a function pointer.

// The function pointer, declared in a header.
// You can put this in a class instance or at global scope.
// If the latter, declare it with "extern", and define the actual function
// pointer without "extern" in a single source file.
PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC glFramebufferTextureLayerEXT; 

In your function that checks for the presence of the GL_EXT_texture_array extension, if it's found, get the address of the function and store it in your function pointer. With OpenGL-ES, that means asking EGL:

glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) eglGetProcAddress("glFramebufferTextureLayerEXT");

Now you can use the function just like it was part of regular OpenGL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top