Can anyone tell me if there is a problem with the code below? The shaders result is only solid black. Possibly an incomplete texture?
int _width = 2;
int _height = 2;
GLubyte texels[16] =
{
0, 0, 0, 255,
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255,
};
glUseProgram(shader->program);
GLuint _buffer;
glGenTextures(1, &_buffer);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_ARRAY, _buffer);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, _width, _height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texels);
Fragment shader snippet;
#version 420
layout (binding = 0) uniform sampler2DArray arrayMap;
void main(void){
outcolor = texture(arrayMap, vec3(ex_texcoords0.x,ex_texcoords0.y,0));
I’m implementing this with a game engine but would just like to know if the above is the correct way of creating and reading texture arrays. That will tell me if the problem exists within the engine itself. Thank you.