OK, I'm at my wits' end here. I'm developing an openGL-enabled live
wallpaper and it seems to work fine on the Nexus but I've had someone
tell me that on their Milestone (basically a GSM Droid), all the
textures are white. I only have a Nexus to test with.

I've done lots of Googling on the issue and the big thing that seems
to come up most is having power of two sized textures - which I have.
I also put them in the /res/drawable-nodpi folder and set my manifest
to all screen sizes/densities. At one point, I thought maybe it was
the way I was implementing mipmaps so I turned them off. No dice. I'm
sure it's something simple that I'm overlooking but my brain is
completely fried at this point. Maybe some fresh eyes will help. Here
is the relevant code:

My texture loader:

public GLTextures(GL10 gl, Context context) {
                this.context = context;
                this.textureMap = new java.util.HashMap<Integer, Integer>();
                sBitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565;
        }

public void loadTextures() {
                if(gl==null)return;
                int[] tmp_tex = new int[textureFiles.length];
                gl.glGenTextures(textureFiles.length, tmp_tex, 0);
                textures = tmp_tex;
                for (int i = 0; i < textureFiles.length; i++) {
                        this.textureMap.put(new Integer(textureFiles[i]), new 
Integer(i));
                        int tex = tmp_tex[i];

           gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
           gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
           gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR_MIPMAP_NEAREST);


            gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT);
            gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);
            gl.glTexEnvf(GL10.GL_TEXTURE_ENV,
GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);

            InputStream is =
context.getResources().openRawResource(textureFiles[i]);
            Bitmap bitmap;
            try {
                bitmap = BitmapFactory.decodeStream(is, null,
sBitmapOptions);
            } finally {
                try {
                    is.close();
                } catch (IOException e) {
                    // Ignore.
                }
            }
            buildMipmap(gl, bitmap, tex);
            bitmap.recycle();
}


private void buildMipmap(GL10 gl, Bitmap bmp, int tex) {
                int level = 0;
                int height = bmp.getHeight();
                int width = bmp.getWidth();

                while (height >= 1 || width >= 1) {

                        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, level, bmp, 0);

                        if (height == 1 || width == 1) {
                                break;
                        }
                        // Increase the mipmap level
                        level++;
                        //
                        height /= 2;
                        width /= 2;
                        Bitmap bitmap2 = Bitmap.createScaledBitmap(bmp, width, 
height,
true);
                        // Clean up
                        bmp.recycle();
                        bmp = bitmap2;
                }



Here's part of my renderer's onSurfaceCreated method:

gl.glDisable(GL10.GL_DEPTH_TEST);
                gl.glEnable(GL10.GL_BLEND);
                gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
                gl.glDepthFunc(GL10.GL_LEQUAL);
                gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
                gl.glDisable(GL10.GL_DITHER);

                //Enable textures
                gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,GL10.GL_NICEST);
                gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
                gl.glEnable(GL10.GL_TEXTURE_2D);


And here's what I'm doing in the manifest:

<supports-screens
        android:largeScreens="true"
                android:smallScreens="true"
                android:normalScreens="true"
                android:resizeable="true"
                android:anyDensity="true">
        </supports-screens>

If you want to see the app itself or even unzip it and look at the
textures themselves, the link is here:
http://forum.xda-developers.com/showthread.php?t=746565

Oh, and the textures are 16bit PNGs.

Thanks for any help you can give me.

-mike

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to