For every incoming tweet, I was asked to put a point (corresponding to tweet location) on world map (opengl scene). Some thing like this. I tried to learn OpenGL. I cried. With time, OpenGL started feeling like my friend. He was on the way to become my best friend. Now, I used GLSurfaceView
on Android and assumed like I can simply draw points one by one, one after another with out ever calling glCear()
. This way I only have to keep current tweet coordinate in memory. Told to myself, you are a genius. I suffered like others, whose have explained there pains here, here and here. Now comes a master, who taught me the basics and told me, kiddo, you have to call glClear
no matter what.
I cannot keep adding/storing coordinates of all points in memory and call glDrawArrarys
since this has to keep running for ever on mobile device. So the choices now are
n
points. After that, try some thing like 'render to texture' and use that texture as background for the next drawing next n
points.EGL_BUFFER_PRESERVED
as in EGL Preserve sample at Mali sdk . Needs NDK as Android EGL14
cannot be used before Android API 17. Khronos EGL11 is not yet implemented in Android. People closest to my new friend tells, he doesn't like this at all.Do I have any other choices or am I solving the wrong problem ? I would like to know what is OpenGL's approach to updating a scene for ever.
I believe EGL_BUFFER_PRESERVED
is not supported on all devices. So even if you could use API level 17, that might not be your solution.
You could do the primary rendering to a texture, using a FBO. You would then clear that texture once while you initialize the whole thing, after you finished setting up the FBO. Then, every time you get a new point, you draw it to the texture, and then copy the texture to the primary framebuffer.
Roughly, you have the following steps on startup:
glViewport()
, etc.glClear()
.Then each time a point is added:
Renderer
implementation, and trigger a redraw.onDrawFrame()
, bind FBO for rendering.