Hi all! I want some suggestion about my first fragment shader using textures.

The problem is that I cannot texture a simple box. I’ve checked everything, but I still miss something…

I use a forward compatible context.

Here is the vertex shader code:

```
#version 150
// Pragmas directives
#pragma optimization(off)
#pragma debug(on)
// Transform uniform state
uniform mat4 dsModelProjection;
vec4 ProjectModelVertexPosition(vec3 v) {
return (dsModelProjection * vec4( v.xyz , 1.0 ) );
}
// Vertex shader inputs & outputs
in vec3 dvi_Position;
in vec2 texcoordV;
centroid out vec2 texcoordF;
// Vertex shader etry point
void main() {
// Compute transformed vertex position
gl_Position = ProjectModelVertexPosition(dvi_Position);
texcoordF = texcoordV;
}
```

Fragment shader:

```
#version 150
// Pragmas directives
#pragma optimization(off)
#pragma debug(on)
// Fragment shader inputs & outputs
out vec4 FragmentColor;
uniform sampler2D texsample;
centroid in vec2 texcoordF;
void main() {
FragmentColor = texture(texsample, texcoordF);
}
```

I see my rotating cube, I can transform it, coloring it with uniform color and per vertex color. Varying are set correctly and uniform correctly then.

But when I use texture (it is 480x480 (white or random color, RGB 24 bit, internal format RGB8)) I see the cube all black.

Every operation is executed in the same thread. Shader, Texture and objects are loaded in the same thread.

Each operation is checked with GetError and every go well.

I don’t really know how to solve this problem.

Another thing: why tex2D, texture2D and texture sampler functions are the same (all fragment shader compile correctly if I use any those functions…), links…

I want simply texturing,

… but outputs black fragments… sigh

If anyone can imaging what am I missing, very thanks!

EDIT: for the sake of completeness, I’ve logged the OpenGL calls. Values are in decimal and they cannot be decoded easily, but better than nothing!

The log is a rendering loop cycle (many calls are for debugging purpose).

glClear(16640, )

glGetError() = 0

glViewport(0, 0, 800, 600, )

glGetError() = 0

glGetError() = 0

glGetError() = 0

glClearColor(1, 1, 1, 0, )

glEnable(2929, )

glGetError() = 0

glDepthFunc(513, )

glGetError() = 0

glClearColor(1, 1, 1, 0, )

glUseProgram(2, )

glGetError() = 0

glGetIntegerv(35725, 2, )

glGetError() = 0

glGetUniformLocation(2, dsModelProjection, ) = 0

glGetError() = 0

glGetProgramiv(2, 35719, 18, )

glGetError() = 0

glGetActiveUniform(2, 0, 18, 17, 1, 35676, dsModelProjection, )

glGetError() = 0

glUniformMatrix4fv(0, 1, False, System.Single[], )

glGetError() = 0

glValidateProgram(2, )

glGetError() = 0

glGetProgramiv(2, 35715, 1, )

glGetError() = 0

// Apply Texture State

glActiveTexture(33984, )

glGetError() = 0

glBindTexture(3553, 1, )

glGetError() = 0

glGetIntegerv(35725, 2, )

glGetError() = 0

glGetUniformLocation(2, texsample, ) = 1

glGetError() = 0

glGetProgramiv(2, 35719, 18, )

glGetError() = 0

glGetActiveUniform(2, 1, 18, 9, 1, 35678, texsample, )

glGetError() = 0

glUniform1i(1, 0, )

glGetError() = 0

glValidateProgram(2, )

glGetError() = 0

glGetProgramiv(2, 35715, 1, )

glGetError() = 0

// Setup Shader Inputs

glBindVertexArray(1, )

glGetError() = 0

glDrawArrays(4, 0, 36, )

glGetError() = 0

glUseProgram(0, )

glGetError() = 0

You can note I use vertex arrays. Here is the log when creating vertex array:

// Setup Shader Inputs

glGenVertexArrays(1, 1, )

glGetError() = 0

glBindVertexArray(1, )

glGetError() = 0

glGenBuffers(1, 1, )

glGetError() = 0

glBindBuffer(34962, 1, )

glGetError() = 0

glBufferData(34962, 432, Derm.Render.Vertex3f[], 35046, )

glGetError() = 0

glGetIntegerv(35725, 2, )

glGetError() = 0

glBindBuffer(34962, 1, )

glGetError() = 0

glGetError() = 0

glEnableVertexAttribArray(0, )

glGetError() = 0

glBindBuffer(34962, 0, )

glGetError() = 0

glValidateProgram(2, )

glGetError() = 0

glGetProgramiv(2, 35715, 1, )

glGetError() = 0

glGenBuffers(1, 2, )

glGetError() = 0

glBindBuffer(34962, 2, )

glGetError() = 0

glBufferData(34962, 288, Derm.Render.Vertex2f[], 35046, )

glGetError() = 0

glGetIntegerv(35725, 2, )

glGetError() = 0

glBindBuffer(34962, 2, )

glGetError() = 0

glGetError() = 0

glEnableVertexAttribArray(2, )

glGetError() = 0

glBindBuffer(34962, 0, )

glGetError() = 0

glValidateProgram(2, )

glGetError() = 0

glGetProgramiv(2, 35715, 1, )

glGetError() = 0