The usage of glGetTexLevelParameteriv stalls the OpenGL pipeline. Can I suggest to execute this piece of code in ilutGLSubTex only in the debug builds?
ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff) { ILimage *Image; #ifdef IL_DEBUG ILint Width, Height; #endif ... glBindTexture(GL_TEXTURE_2D, TexID);
#ifdef IL_DEBUG glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, (GLint*)&Width); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, (GLint*)&Height);
if (Image->Width + XOff > (ILuint)Width || Image->Height + YOff > (ILuint)Height) { ilSetError(ILUT_BAD_DIMENSIONS); return IL_FALSE; } #endif
....
I think it's better leave the tests. XOff and YOff are user provided values, they may be wrong values.
Log in to post a comment.
The usage of glGetTexLevelParameteriv stalls the OpenGL pipeline.
Can I suggest to execute this piece of code in ilutGLSubTex only in the debug builds?
ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff)
{
ILimage *Image;
#ifdef IL_DEBUG
ILint Width, Height;
#endif
...
glBindTexture(GL_TEXTURE_2D, TexID);
#ifdef IL_DEBUG
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, (GLint*)&Width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, (GLint*)&Height);
if (Image->Width + XOff > (ILuint)Width || Image->Height + YOff > (ILuint)Height) {
ilSetError(ILUT_BAD_DIMENSIONS);
return IL_FALSE;
}
#endif
....
I think it's better leave the tests.
XOff and YOff are user provided values, they may be wrong values.