The access violation “Access violation at 03E7C870 in module ‘atioglxx.dll’. Read of address 00000000” occurs at the glTexImage2D call, but only when a buffer object is bound to GL_PIXEL_UNPACK_BUFFER.
eg. This doesn’t throw an AV:
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glGenTextures(1, @tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, twidth, theight, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
and uploading to a level >= GL_TEXTURE_BASE_LEVEL works fine, but this throws an AV:
glGenBuffers(1, @PBO);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PBO);
glBufferData(GL_PIXEL_UNPACK_BUFFER, twidth*theight*4, nil, GL_STATIC_DRAW); // nil = NULL equivalent
glGenTextures(1, @tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 4);
// AV when (0 <= level < GL_TEXTURE_BASE_LEVEL)
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, twidth, theight, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
The 2nd issue appears to be fixed, since:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 4);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
no longer causes an AV on draw calls in 11.9, but correctly detects an incomplete texture + renders a white triangle.
Another issue with glTexImage2D when a PBO is bound is that if you try loading a high image level, you get an out of memory error (or potentially a very big texture allocated), which you don’t get if no PBO is bound.
glGenBuffers(1, @PBO);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, PBO);
glBufferData(GL_PIXEL_UNPACK_BUFFER, twidth*theight*4, nil, GL_STATIC_DRAW);
// adding this line prevents out of memory error
// glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glGenTextures(1, @tex);
glBindTexture(GL_TEXTURE_2D, tex);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 9);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 10);
glTexImage2D(GL_TEXTURE_2D, 10, GL_RGBA, 32, 32, 0, GL_BGRA, GL_UNSIGNED_BYTE, nil);
CheckOpenGLError(); // out of memory