im trying to set a new bitmap to a sprite every 2 seconds. The code im using r开发者_Go百科equires a GL10 object but can not be done in onDraw() because it reduces the framerate too much. I tried setting a gl object to equal the one passed in onSurfaceCreated(), but it doesnt work. How can i do this?
Allocate all your textures in onSurfaceCreated()
, create a Texture
object (which contains a GL
pointer for your texture) and assign that loaded texture (from OpenGL
memory) to your Texture
object's GL
pointer id.
Later, in onDrawFrame()
, just change glBindTexture(GL10.GL_TEXTURE_2D, textureObjectId)
to glBindTexture(GL10.GL_TEXTURE_2D, anotherTextureObjectId)
.
This is how you change a texture without allocating during runtime using simple images/sprites.
精彩评论