Imagination PowerVR SDK Blog

glGenTextures triggering GL_INVALID_OPERATION


#1

Hi – I’m using SDK 3.1 to develop a OpenGL ES 2.0 application on windows.



I’ve got much working, but have ran into a situation where glGenTextures sets the handle to 0 and triggers a GL_INVALID_OPERATION error (I’ve called glGetError before and after, it is glGenTextures creating the errors). I’ve checked to make sure a EGLContext is current, and am unsure why this error is happening. Other textures have been created earlier in initialization successfully.



I’m sure there is something I have put in an invalid state, but I am unable to figure out exactly what it is.



FWIW – I’ve also used Google’s ANGLE libEGL and libGLES2 instead of the PVR SDK libraries, and I’ve not run into this problem, but they might not have as strict error checking.



Thanks for any pointers!


#2

Hi Pete,



There’s not any reason that function should generate that call besides not having a valid OpenGL ES context. It might be worth checking that the config you used to setup your context actually supports OpenGL ES 2.



You’ll need to call:



EGLint configAttrib;

eglGetConfigAttrib(display, configUsedToSetupTheContext, EGL_RENDERABLE_TYPE, &configAttrib);



if (configAttrib & EGL_OPENGL_ES2_BIT)

{

//Supports OpenGL ES 2

}

else

{

//Doesn’t support OpenGL ES 2, and this will be the problem.

}



If you’ve verified that it does support ES2, then it’s likely a bug in ANGLE, so I’d raise an issue in the ANGLE project (here I believe: https://code.google.com/p/angleproject/issues/list).



Regards,

Tobias


#3

Thanks Tobias for the response!



Unfortunately I’m pretty sure that it’s an ES2 context since I’ve already successfully compiled and linked all my shaders by the time glGenTextures starts failing on me. Our engine does unset and re-set the context a few times during loading (via eglMakeCurrent), I’m starting to think that the GLES2 lib provided gets a little confused by this perhaps? I do know that it’s set since when I try to create textures since eglGetCurrentContext is not returning EGL_NO_CONTEXT.



Fortunately I just got things running on iOS and am not running into this problem, so as much as I’d love to use the PVR SDK for better debugging and profiling, it’s less of a pressing need now!



Thanks for your help.


#4

Hi Peted,



Ok well thanks for the information - our emulation libraries are going through a large number of changes anyway with regards to the contexts - so it’s probable that this will be fixed for the next release. I’ll get the engineer responsible to have a look regardless.



If we find anything we’ll be sure to let you know.



Thanks,

Tobias