+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ /* In the olden days, one could just render directly into the front buffer,
+ or fail to clear the back buffer and assume that one's bits were still
+ there. Not so on modern devices, particularly mobile. So to achieve
+ the effect of frame N+1 accumulating atop frame N, we must save and
+ restore a screenshot of frame N.
+ */
+ if (bp->screenshot_texture)
+ {
+ GLfloat tw = MI_WIDTH(mi) / (GLfloat) bp->tex_w;
+ GLfloat th = MI_HEIGHT(mi) / (GLfloat) bp->tex_h;
+ glDisable (GL_BLEND);
+ glEnable (GL_TEXTURE_2D);
+ glBindTexture (GL_TEXTURE_2D, bp->screenshot_texture);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glBegin (GL_QUADS);
+ glTexCoord2f (0, 0); glVertex3f (0, 0, 0);
+ glTexCoord2f (tw, 0); glVertex3f (bp->wd, 0, 0);
+ glTexCoord2f (tw, th); glVertex3f (bp->wd, bp->ht, 0);
+ glTexCoord2f (0, th); glVertex3f (0, bp->ht, 0);
+ glEnd();
+ glDisable (GL_TEXTURE_2D);
+ glClear (GL_DEPTH_BUFFER_BIT);
+ }
+