Hi,
Thanks, @petros.
After identifying that the only difference in OpenGL extensions is that on the OF side there is GL_ARB_compatibility
extension which is not installed on cinder side, I decided this is not a probable cause.
To summarise what I’ve found out so far: the GL_INVALID_OPERATION
happens in line:
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &dataLength);
The code leading to this is as follows:
texData.setWidth(1920);
texData.setHeight(1080);
texData.setDataFormat(GL_UNSIGNED_INT_8_8_8_8_REV);
texData.setInternalFormat(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
gl::Texture2d::Format fmt;
fmt.setInternalFormat(GL_COMPRESSED_RGBA);
fmt.setTarget(GL_TEXTURE_2D);
mTexture = gl::Texture2d::create(texData, fmt);
glBindTexture( GL_TEXTURE_2D, mTexture->getId()); //we get no gl_error here
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &dataLength);
The same GL_INVALID_OPERATION
error happens in:
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, mTexture->getInternalFormat(), dataLength, mSurface->getData());
which is a few lines further down.
Based on glGetTexLevelParameteriv specifications I would suspect that the reason behind GL_INVALID_OPERATION
error is:
GL_INVALID_OPERATION is generated if GL_TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed internal format or on proxy targets.
However, I’ve tried a couple of format combinations, but no success.
The specifications for glCompressedTexSubImage2D offer more reasons for GL_INVALID_OPERATION
error, half of which I don’t really understand at the moment.
I am going to keep poking at it, but am a bit rudderless right now.
If anyone spots anything obviously wrong please let me know.
UPDATE 1: I did the following check:
GLint isCompressed = true;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED, &isCompressed);
And after these 2 lines execute on cinder side the isCompressed variable is false whereas on OF it stays true. On to discovering why is that and how does OpenGL determine whether a texture is compressed or not.
UPDATE 2: another check:
GLint intFormat
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &intFormat);
returns 6408 (RGBA) on cinder side and 33776 on OF side (DXT one). Apparently, the internal format is not set correctly on the texture.
UPDATE 3: the latest hypothesis is that somehow glBindTexture(GL_TEXTURE_2D, texID) is not working correctly. Does anyone have any ideas? For example, texID refers to a texture of 720x480px and yet the code below:
glBindTexture(GL_TEXTURE_2D, mTexID);
GLint intFormat;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &intFormat);
sets intFormat to 0 whereas it should be 720.
Any ideas?
Thanks so much.
Best regards,
M