I want to set the initial data of a texture in an OpenGL 4.5 program (using OpenTK.Next and .NET), utilizing the new Direct State Access methods.

However, I cannot find a DSA version of glTexImage2D. There are methods like glTextureSubImage2D which accept a texture object ID, but using those to set the intial data fails with InvalidOperation.

I'm pretty sure there should be such a method... comparing textures to array buffers, array buffers do have a DSA version to set their initial data, glNamedBufferData.

According to the documentation, the DSA methods are all named ...Texture... unlike the "old" methods which are named ...Tex..., but searching through them didn't reveal me something like glTextureImage2D.

Anyone knows if there even is a DSA method to set the initial texture data?


1 Answer 1



There is none.

Issue 5 in the DSA specification reads (in part):

This extension omits TextureImageND (mutable texture definitions)...

Specifically, glTexImage/glTextureImage is the older "mutable textures" API which DSA omits, requiring you to use the immutable textures API instead. Therefore the non-DSA API is glTexStorage, whereas the DSA API is glTextureStorage.

Note that glTexStorage/glTextureStorage creates the texture object and it's backing storage but does not set the data; you must make a further call to glTexSubImage/glTextureSubImage in order to do that.

There are several advantages to using glTexStorage/glTextureStorage, and I refer you to the GL_ARB_texture_storage specification for a fuller discussion; for the purposes of this answer it's sufficient to quote the first paragraph of the overview:

The texture image specification commands in OpenGL allow each level to be separately specified with different sizes, formats, types and so on, and only imposes consistency checks at draw time. This adds overhead for implementations.

And issue 24 of the DSA specification confirms the reason why mutable textures were omitted:

24) Do we need DSA functions for mutable textures?

RESOLVED: No. Immutable texture is a more robust approach to handle textures

  • 1
    \$\begingroup\$ @RayKoopa - A pleasure. I believe it's always useful and interesting to know the reasons why certain API decisions were made; it can help you get a better understanding of how things work (in this case the fact that mutable textures were such a poor API demonstrates that hardware really prefers many things to be fully specified up-front). \$\endgroup\$ Commented Dec 10, 2016 at 13:40
  • \$\begingroup\$ For completeness, GL_EXT_direct_state_access does have glTextureImage*EXT functions. But this extension is not always supported even when the ARB one is. \$\endgroup\$
    – Ruslan
    Commented Jul 26, 2023 at 7:26
  • \$\begingroup\$ @Ruslan - that is correct but it's not what the OP asked. We should also note that EXT_direct_state_access uses a mutable texture API, whereas ARB_direct_state_access uses an immutable texture API, so they're not functionally equivalent. \$\endgroup\$ Commented Aug 2, 2023 at 8:03
  • \$\begingroup\$ Well, the OP asked for a DSA version of glTexImage2D. This non-DSA function also represents mutable texture API, so the direct answer is glTextureImage2DEXT. The pure unextended-OpenGL answer, though, is indeed yours, I just mentioned the EXT version, as I said, for completeness. \$\endgroup\$
    – Ruslan
    Commented Aug 2, 2023 at 11:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .