I am trying to integrate a particle system in Android using OpenGL. I want several thousand particles, most of which are likely to be behind the scenes at any time. They are pretty simple particles visually, and my world is 2D, but they will move changing color (not size - they are 2x2), and I need to be able to add and remove then.
I currently have an array that I iterate over, handling speed changes, managing the life cycle (killing old, adding new ones) and drawing them using glDrawArrays. However, OpenGl points to this call; it is the only peak; I glTranslatex this to the appropriate coordinates for each particle that I want to build, one at a time, set the color with glColor4x, then glDrawArrays. It works, but it is a little slow and only works on a few hundred particles. I handle the clipping myself.
I wrote a system for supporting static particles that I uploaded to the / colourarray vertex and graph using glDrawArrays, but this approach seems only suitable for particles that will never change their relative location (i.e. I move them all with glTranslate), color and where I do not need to add / remove particles. Several tests on my phone (HTC Desire) show that trying to modify the contents of these arrays (which are the ByteBuffers that OpenGL points to) is extremely slow.
Perhaps there is a way to manually record the screen itself with the processor. If I just draw 1x1 / 2x2 points on the screen, and I'm just interested in writing and not doing blending / smoothing, is that an option? Will it be faster than any OpenGl?
(200 or so particles on a 1ghz mega-bar machine). This is slower than what I got 20 years ago on a machine with 7 MHz, and with 500,000 baht! I understand that I'm using Java here, but there certainly should be a better solution. Should I use NDK to get the power of C ++, or is this what is possible after me)
source share