Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid blank textures (lazy loading textures)
    primarykey
    data
    text
    <p>I have a GLSurfaceView where I render my scene. My scene display correctly except for some textures where I have white squares instead of the real texture. I use 2 types of texture :</p> <ul> <li>Some textures are in the resources of the project. I create them in <code>onSurfaceCreated</code>, everything works fine with them</li> <li>Some other needs to be downloaded from a remote location. Those are the textures that don't display correctly.</li> </ul> <p>I download and create the "lazy texture" with the following code :</p> <pre><code>public void onDrawFrame(GL10 gl) { ... Texture3D.getDynamicTexture(gl, object.avatar).bind(gl); ... } public static Texture3D getDynamicTexture(GL10 gl, int key) { Texture3D texture = dynamicTextures.get(key); if (texture == null) { dynamicTextures.put(key, new Texture3D(gl, key, Type.DYNAMIC)); texture = getStaticTexture(R.drawable.broken_img); } return texture; } public Texture3D(final GL10 gl, final int id, Type type) { gl.glEnable(GL10.GL_TEXTURE_2D); gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); texture = newTextureID(gl); gl.glBindTexture(GL10.GL_TEXTURE_2D, texture); gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); Utils.loadImage(id, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { _pBitmap = loadedImage; GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, _pBitmap, 0); _pBitmap = null; gl.glEnable(GL10.GL_BLEND); } }); </code></pre> <p>I see that the download works because R.drawable.broken_img got replaced by a white square. The textures seems to appears but they are all stacked on top of the screen on a single line (see the picture).</p> <p><img src="https://i.stack.imgur.com/PcMnt.png" alt="Stacked textures on top of the screen"></p> <p>I also tried <a href="https://stackoverflow.com/questions/5691365/android-opengl-es-1-1-white-box-textures?rq=1#comment7340488_5692352">Android OpenGL ES 1.1 white box textures</a> but that didn't work either. The only difference I saw was that the textures didn't appear anymore on top of the screen.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload