<p>My issue was in the call to <code>glTextureStorage2D(texture, 1, GL_RGB, width, height);</code></p>

<p>From <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexStorage2D.xhtml" rel="nofollow noreferrer">the man page</a></p>

<blockquote>
  <p>internalformat must be one of the sized internal formats given in Table 1 below, one of the sized depth-component formats GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT16, one of the combined depth-stencil formats, GL_DEPTH32F_STENCIL8, or GL_DEPTH24_STENCIL8, or the stencil-only format, GL_STENCIL_INDEX8</p>
</blockquote>

<p>Changing <code>GL_RGB</code> to <code>GL_RGB8</code> fixed my issue. </p>

CC BY-SA 3.0
2017-07-19T00:25:35.180Z
2017-07-19T00:25:35.180Z
Startec
<p>My question is very similar to <a href="https://computergraphics.stackexchange.com/questions/4479/how-to-do-texturing-with-opengl-direct-state-access">this one</a> but the answers there did not help me.</p>

<p>I am trying to use the DSA approach to bind textures and it is not working.</p>

<p>Here is my attempt at the DSA code, which leads too all black in as my output:</p>

<pre><code>GLuint samplerName;
glCreateSamplers(1, &amp;samplerName);
glSamplerParameteri(samplerName, GL_TEXTURE_WRAP_S, GL_REPEAT);
glSamplerParameteri(samplerName, GL_TEXTURE_WRAP_T, GL_REPEAT);
glSamplerParameteri(samplerName, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glSamplerParameteri(samplerName, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindSampler(0, samplerName);

// Create texture
GLuint texture;
glCreateTextures(GL_TEXTURE_2D, 1, &amp;texture);
glTextureStorage2D(texture, 1, GL_RGB, width, height);
glTextureSubImage2D(texture, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
glTextureParameteri(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTextureUnit(0, texture);
</code></pre>

<p>If I add these two lines from the older approach:</p>

<pre><code>glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
</code></pre>

<p>it works so I do not think it is an issue with my sampler or my data. Does anybody have any advice here? </p>

<opengl>
How to use textures with DSA?
Startec
# How to use textures with DSA?

(Asked by: username_0 on 2017-07-18)

My question is very similar to [this one](https://computergraphics.stackexchange.com/questions/4479/how-to-do-texturing-with-opengl-direct-state-access) but the answers there did not help me.

I am trying to use the DSA approach to bind textures and it is not working.

Here is my attempt at the DSA code, which leads too all black in as my output:

```
GLuint samplerName;
glCreateSamplers(1, &samplerName);
glSamplerParameteri(samplerName, GL_TEXTURE_WRAP_S, GL_REPEAT);
glSamplerParameteri(samplerName, GL_TEXTURE_WRAP_T, GL_REPEAT);
glSamplerParameteri(samplerName, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glSamplerParameteri(samplerName, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindSampler(0, samplerName);

// Create texture
GLuint texture;
glCreateTextures(GL_TEXTURE_2D, 1, &texture);
glTextureStorage2D(texture, 1, GL_RGB, width, height);
glTextureSubImage2D(texture, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
glTextureParameteri(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTextureUnit(0, texture);

```

If I add these two lines from the older approach:

```
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);

```

it works so I do not think it is an issue with my sampler or my data. Does anybody have any advice here?

**Tags:** opengl


---

## 1 answers

### Answer by username_0 on 2017-07-19. Score: 4 | Accepted answer

My issue was in the call to `glTextureStorage2D(texture, 1, GL_RGB, width, height);`

From [the man page](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexStorage2D.xhtml)

> internalformat must be one of the sized internal formats given in Table 1 below, one of the sized depth-component formats GL\_DEPTH\_COMPONENT32F, GL\_DEPTH\_COMPONENT24, or GL\_DEPTH\_COMPONENT16, one of the combined depth-stencil formats, GL\_DEPTH32F\_STENCIL8, or GL\_DEPTH24\_STENCIL8, or the stencil-only format, GL\_STENCIL\_INDEX8

Changing `GL_RGB` to `GL_RGB8` fixed my issue.


---

