Changing texture pixels values during gameplay

Started by Bamirov, August 07, 2006, 09:58:07

Previous topic - Next topic

Bamirov

Hi all!

I have the following problem - now I'm trying to write a xonix clone, so I have 2 textures in this game
1) A picture that should be opened by player
2) A picture that closes first picture, player should cut off parts of this texture to win.

I have a big screen resolution - 1024*768
game field is about 700*700
In current realisation I have a ByteBuffer which represents second texture, and I'm drawing it on the canvas using glDrawPixels method.

During the gameplay I'm changing second texture (the values of alpha channel of some pixels) when player cuts off a part of game field, so the part of picture 2 becomes invisible and the corresponding part of picture 1 becomes visible.
The problem is that this process is extremely slow and when I'm changing the content of ByteBuffer a perceptible delay happens.

So the question is next: is there any other way to implement a functionality of texture which sould change the values of it's pixels during the gameplay?

May be using glTexImage2D and glTexSubImage2D (to change the values of alpha-channel of parts of a texture during gameplay) would be faster?
I think that the slowness comes from it's ByteBuffer operations (especially put method), and in the glTexSubimage method ByteBuffer parameter is using, too.

Or may be there are some other way to solve this problem?

napier

glDrawPixels copies image data from system memory to the graphics card, and it's generally not optimized very well at all.  glTexSubImage2D should be substantially faster.  

I wouldn't expect the ByteBuffer operation to be that slow, if all you're doing is clearing out rectangular areas of the pixel data.
penGL/Java/LWJGL demos and code: http://potatoland.org/code/gl