Hi All,

I have a texture-mapped cube based in part on the Kube API demo and
the Textured Cube example from anddev.org,  It is working fine using
bitmaps loaded from R.drawable.. what I need to do now is to make the
texture for each face dynamic (using Bitmaps created in code).  I'm
having trouble understanding how to change the textures on the fly and
I'm hoping someone can point me in the right direction..

This is the code that initially sets a texture:

                gl.glBindTexture(GL10.GL_TEXTURE_2D, texBuf.get(num));
                Bitmap bmp = 
BitmapFactory.decodeResource(context.getResources(),
id);
                int pixels[] = new int[TEX_SIZE * TEX_SIZE];
                bmp.getPixels(pixels, 0, TEX_SIZE, 0, 0, TEX_SIZE, TEX_SIZE);
                int pix1[] = new int[TEX_SIZE * TEX_SIZE];
                for (int i = 0; i < TEX_SIZE; i++)
                {
                        for (int j = 0; j < TEX_SIZE; j++)
                        {
                                //correction of R and B
                                int pix = pixels[i * TEX_SIZE + j];
                                int pb = (pix >> 16) & 0xff;
                                int pr = (pix << 16) & 0x00ff0000;
                                int px1 = (pix & 0xff00ff00) | pr | pb;
                                //correction of rows
                                pix1[(TEX_SIZE - i - 1) * TEX_SIZE + j] = px1;
                        }
                }

                IntBuffer tbuf = IntBuffer.wrap(pix1);
                tbuf.position(0);
                gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, TEX_SIZE,
TEX_SIZE, 0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, tbuf);
                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);

What would I need to change in this code to allow an existing texture
to be replaced (eg. a new Bitmap would be passed in instead of loading
the resource, but when I try this the texture remains unchanged).

Thanks!


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

Reply via email to