opengl es – Texture loading challenge with open gl es on android

opengl es – Texture loading challenge with open gl es on android

[ad_1]

I am programming an app with OpenGL ES on Android in Java. The app makes use of 9 textures throughout a render loop go. A depth, place, regular, albedo, noise, SSAO, SSAO blur and two picture textures for the fashions I draw. The issue is that 9/10 occasions, the picture textures fail to load. I get no GL error throughout or after loading the feel. I get an error 1282 once I bind the feel 8 and 9 through the draw name. However solely once they do not load/present up. After they load and present up I get no error and they’re displayed accurately on the primitives.

enter image description here
enter image description here

In keeping with the documentation of glBindTexture, the strategy generates the error code 1282 (GL_INVALID_OPERATION) if texture was beforehand created with a goal that does not match that of the goal. The one goal I exploit in the entire utility is GL_TEXTURE_2D, so I do not perceive why I get this error.

Since I am utilizing a deferred rendering pipeline, I assumed that possibly the albedo buffer is tousled, however I may rule that out by setting fixed colours for the entire scene instantly within the fragment shader of the geometry go, and that’s working superb each time.

I managed to take GPU-snapshots of each circumstances utilizing snapdragon profiler to debug the app/profile the GPU (Adreno 630). I may confirm that every one the uniforms are appropriate, the attribute arrays are additionally appropriate and the proper items are lively in each circumstances. The distinction I may discover within the error case is that each picture textures are lacking, the remainder is there.
These are all of the textures on the GPU once they load:

enter image description here

Right here, within the different snapshot they’re lacking, regardless that it’s the very same code that hundreds the textures. In each circumstances I get legitimate handles/indexes once I name glGenTexture.

enter image description here

It simply appears that by some means the textures aren’t loaded anymore through the draw name.

The picture textures are being loaded like this:

AssetManager assetManager = context.getAssets();
InputStream stream = assetManager.open(id.getResourceName());
int[] textureHandle = new int[1];

BitmapFactory.Choices choice = new BitmapFactory.Choices();
choice.inScaled = false;
Bitmap bitmap = BitmapFactory.decodeStream(stream, null, choice);
//GLES30.glActiveTexture(GLES30.GL_TEXTURE5);
GLES30.glGenTextures(1, textureHandle, 0);
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, textureHandle[0]);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_MIRRORED_REPEAT);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_MIRRORED_REPEAT);
if (bitmap != null) {
    Log.d(TextureLoader.class.getSimpleName(), "Texture format: " + GLUtils.getInternalFormat(bitmap));
    GLUtils.texImage2D(GLES30.GL_TEXTURE_2D, 0, bitmap, 0);
    bitmap.recycle();
}
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
        
ShaderUtil.checkGLError(TextureLoader.class.getSimpleName(), "Did not load texture");

Log.d("Texture id", String.valueOf(textureHandle[0]));

return textureHandle[0];
  • The code above is executed through the onSurfaceCreated invocation, so I’ve a legitimate OpenGL context.
  • The code above is executed two occasions, as soon as per picture texture in sequential order.
  • Each textures are of sort 32 bit RGBA (PNG) 512px x 512px

The code under is executed within the render loop. I’ve a number of fashions, some are utilizing one texture and a few the opposite one.

GLES30.glActiveTexture(GLES30.GL_TEXTURE5);
GLES30.glUniform1i(shaderHandles.getTextureMapHandle(), 5);
ShaderUtil.checkGLError("Render loop", "Activate unit");
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, textureDataHandle);
ShaderUtil.checkGLError("Render loop", "Activate " + textureDataHandle);

I have been debugging for a number of days now, so I recognize any assist. Thanks

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply