Function texture2DArray always requires to enable GL_EXT_texture_array

I am simply trying to render one layer of a 2D array texture. Obviously I would sample the texture using a sampler2DArray and the function texture2DArray. However compiling the shader produces the errors:


0(33) : error C7531: global function texture2DArray requires "#extension GL_EXT_texture_array : enable" before use
0(33) : error C0000: ... or #extension GL_NV_texture_array : enable

.

I went to check the OpenGL version that I have access to in my program by requesting the string GL_VERSION and it returns: 4.3.0

I have also tried compiling the shader with all the #versions that are available to me, yet it always requires me to enable the extension.

My Question is: Should I not be able to use the function texture2DArray from the core functionality, or is there a reason why the extension is still required up to #versions of 430?

Do you have a #version directive in your shader to specify which version you’re targetting? If you don’t, you get GLSL 1.1 by default (equivalent to #version 110).

Support for 2D array textures (e.g. sampler2Darray) wasn’t added until GLSL 1.3. So you need at least a #version 130 to get it. Or you can patch it into your current version with a #extension directive, as the warning implies.

[QUOTE=Dark Photon;1256096]Do you have a #version directive in your shader to specify which version you’re targetting? If you don’t, you get GLSL 1.1 by default (equivalent to #version 110).

Support for 2D array textures (e.g. sampler2Darray) wasn’t added until GLSL 1.3. So you need at least a #version 130 to get it. Or you can patch it into your current version with a #extension directive, as the warning implies.[/QUOTE]

I have. As I said, I tried compiling with all the #version directives that seemed to work. I failed to specify those versions explicitly, though.
So that’s:
#version 120
#version 130
#version 150
#version 400
#version 430

Beyond 4.3 it no longer compiles (my OpenGL is 4.3, so quite obvious).

Thank you anyways!

If you look at the GLSL specifications, you’ll see that “texture2DArray()” is not present in any version. It really is only available in the EXT_texture_array extension.

Around the time EXT_texture_array was promoted to core functionality, all of the texture sampling functions in GLSL were also renamed. If you look at the spec you’ll see that the function “texture()” is overloaded to accept a sampler2DArray argument.

…if you’re using a forward compatible context (where all the legacy compatibility GLSL functions have been removed) then this is the same as all the other 1D/2D/3D/Cube sampling functions; they’re all removed. So declare #version 130 or later, and use “texture()”.

[QUOTE=arekkusu;1256110]If you look at the GLSL specifications, you’ll see that “texture2DArray()” is not present in any version. It really is only available in the EXT_texture_array extension.

Around the time EXT_texture_array was promoted to core functionality, all of the texture sampling functions in GLSL were also renamed. If you look at the spec you’ll see that the function “texture()” is overloaded to accept a sampler2DArray argument.

…if you’re using a forward compatible context (where all the legacy compatibility GLSL functions have been removed) then this is the same as all the other 1D/2D/3D/Cube sampling functions; they’re all removed. So declare #version 130 or later, and use “texture()”.[/QUOTE]

I admit, that I did not bother to read through the GLSL specifications. Yet…

Thank you! This explained alot to me!

Because sampler2DArray exists in GLSL, I expected texture2DArray to be core functionality, too. I simply didn’t know about the overloaded texture() function.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.