<p>You seem to not change <code>GL_TEXTURE_MIN_FILTER</code> and not fill all the mipmap layers. This will usually result in the texture not being applied, since by default the filter uses mipmapping.</p>

CC BY-SA 4.0
2018-08-23T19:08:08.787Z
2018-08-23T19:08:08.787Z
Ruslan
<p>I’ve been trying to render a texture on the whole screen in OpenGL 4.1 using the Core profile and followed a few tutorials on the matter, but all I have so far is a blank screen.</p>

<p>I tried using my texture coordinates as color components and got the result I expected so the vertice data must be in order, but using the dimensions of the texture as color components I determined the size of the texture in my shader is 1x1 when it should be 2x2, so I guess I am doing something wrong when uploading it to the GPU.</p>

<p>This is my pixel data:</p>

<pre><code>const GLubyte pixels[] = {
    255, 255, 255, 255,     0, 0, 0, 255,
    0, 0, 0, 255,           255, 255, 255, 255,
};
</code></pre>

<p>This is how I load my texture:</p>

<pre><code>glGenTextures(1, &amp;texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)pixels);
</code></pre>

<p>I also tried using a buffer:</p>

<pre><code>glGenTextures(1, &amp;texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glGenBuffers(1, &amp;texture_buffer);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_buffer);
glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(pixels), pixels, GL_STATIC_DRAW);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)0);
</code></pre>

<p>And this is how I render:</p>

<pre><code>glUseProgram(shader_program);
// Binding my vba and vbo, uploading vertices.
glUniform1i(texture_location, 0);
// Enabling vertex attrib arrays.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
// Drawing arrays, disabling vertex attrib arrays.
</code></pre>

<p>I have also put the whole source file <a href="https://pastebin.com/gmN50u50" rel="nofollow noreferrer">on pastebin</a>, it uses GLFW for windowing and does some basic error checking.</p>

<p>I’d be really grateful if someone could point out what I am missing here.</p>

<opengl><texture>
Issue with loading a texture on the GPU with OpenGL 4.1 Core profile
Fougère
# Issue with loading a texture on the GPU with OpenGL 4.1 Core profile

(Asked by: username_0 on 2018-08-21)

I’ve been trying to render a texture on the whole screen in OpenGL 4.1 using the Core profile and followed a few tutorials on the matter, but all I have so far is a blank screen.

I tried using my texture coordinates as color components and got the result I expected so the vertice data must be in order, but using the dimensions of the texture as color components I determined the size of the texture in my shader is 1x1 when it should be 2x2, so I guess I am doing something wrong when uploading it to the GPU.

This is my pixel data:

```
const GLubyte pixels[] = {
    255, 255, 255, 255,     0, 0, 0, 255,
    0, 0, 0, 255,           255, 255, 255, 255,
};

```

This is how I load my texture:

```
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)pixels);

```

I also tried using a buffer:

```
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glGenBuffers(1, &texture_buffer);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture_buffer);
glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(pixels), pixels, GL_STATIC_DRAW);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)0);

```

And this is how I render:

```
glUseProgram(shader_program);
// Binding my vba and vbo, uploading vertices.
glUniform1i(texture_location, 0);
// Enabling vertex attrib arrays.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
// Drawing arrays, disabling vertex attrib arrays.

```

I have also put the whole source file [on pastebin](https://pastebin.com/gmN50u50), it uses GLFW for windowing and does some basic error checking.

I’d be really grateful if someone could point out what I am missing here.

**Tags:** opengl, texture


---

## 1 answers

### Answer by username_1 on 2018-08-23. Score: 2 | Accepted answer

You seem to not change `GL_TEXTURE_MIN_FILTER` and not fill all the mipmap layers. This will usually result in the texture not being applied, since by default the filter uses mipmapping.


---

