System: Android 4.03, OpenGL ES 2.0
Problem: When glAttachShader is called after the first frame has already been processed by another program / shader, some devices (Galaxy S3) crash with the error "GL_INVALID_VALUE" (details are not available on the error stack). Other devices (Asus eee TF101) do a great job of this. An error does not always occur, and sometimes "GL_INVALID_ENUM". If I force all the shaders to compile immediately upon the first call to onDrawFrame, it works on all (my) devices.
Questions: Are there any states in which the openGL (ES) machine is unable to compile the shader? Is it possible that linked buffers, textures, or activated attribute arrays prevent the shader from attaching to the program? If so, what is the ideal state to ensure before connecting shaders and linking the program? Is it really possible to compile shaders after other objects have already been processed using other shaders?
Background: I am developing an Android library that will allow me to use openGL graphics in a more object-oriented way (using objects such as "scene", "material", "model", etc.) to easily write games. Scenes, models, etc. Created in a thread other than the GL context. Only when onDrawFrame collides with one of these objects will it bind the buffer object, bind textures, and compile the shader within the correct stream. I would like to avoid compiling all the shaders at the beginning of my code. The shader source is compiled depending on the requirements of the material, model and scene (for example: Material: include bump-mapping, Model: include matrix-palette-skimming, scene: include fog). When the model is removed from the scene, I will remove the shader again - and if I add another model, the new shader must be compiled ad-hoc.
At this stage, I try to be as concise as possible without publishing the code - you can imagine that extracting the appropriate parts from this library is difficult.
Jan_K source share