开发者

android opengl set bitmap to sprite

开发者 https://www.devze.com 2023-02-22 15:10 出处:网络
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 triedsetti

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消