Thanks for the tips, much appreciated! I'll try the other approach to avoid the pixel buffer stuff. My biggest problem was I was attempting this from another thread and it wasn't doing anything.
On Jul 4, 1:26 pm, gjs <garyjamessi...@gmail.com> wrote: > Hi Tom, > > Thanks for the suggestion about GLUtils. > > I went back & found that the TriangleRenderer.java example had been > updated some time ago to use this method which is as you say is *much* > more efficient (faster) & simpler than using a ByteBuffer and doing > the color conversions. > > ( It pays to revisit the examples with new sdk releases ! ) > > Regards Gary > > On Jul 3, 11:04 pm, Tom Gibara <m...@tomgibara.com> wrote: > > > > > Also you can use glTexSubImage2D() if only a portion of your bitmap is > > changing. For these sorts of operations android.opengl.GLUtils will be > > *much* more efficient (and simpler) than your current approach of populating > > a ByteBuffer since the native helper methods can access the Bitmap pixel > > data directly. > > Tom > > > 2009/7/2 Bruce Rees <baree...@gmail.com> > > > > 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 -~----------~----~----~----~------~----~------~--~---