Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Function texture2DArray always requires to enable GL_EXT_texture_array

  1. #1
    Newbie Newbie
    Join Date
    Nov 2013
    Posts
    3

    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:
    Code :
    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?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,220
    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.

  3. #3
    Newbie Newbie
    Join Date
    Nov 2013
    Posts
    3
    Quote Originally Posted by Dark Photon View Post
    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.
    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!

  4. #4
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    783
    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()".

  5. #5
    Newbie Newbie
    Join Date
    Nov 2013
    Posts
    3
    Quote Originally Posted by arekkusu View Post
    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()".
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •