+ // Just change the image in some (quick) way to show that it's really being
+ // updated on screen.
+ void UpdateRGB(unsigned char* data, int n)
+ {
+ for ( int y = 0; y < opts.height; ++y )
+ {
+ memset(data, n % 256, 3*opts.width);
+
+ data += 3*opts.width;
+ n++;
+ }
+ }
+
+#if wxUSE_GLCANVAS
+ void OnGLRender(wxPaintEvent& WXUNUSED(event))
+ {
+ m_glContext->SetCurrent(*m_glCanvas);
+ glEnable(GL_TEXTURE_2D);
+
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ wxPrintf("Benchmarking %s: ", "OpenGL images");
+ fflush(stdout);
+
+ wxStopWatch sw;
+ for ( int n = 0; n < opts.numIters; n++ )
+ {
+ UpdateRGB(g_image.GetData(), n);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ 0, 0, opts.width, opts.height,
+ GL_RGB, GL_UNSIGNED_BYTE, g_image.GetData());
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0);
+ glVertex2f(-1.0, -1.0);
+
+ glTexCoord2f(0, 1);
+ glVertex2f(-1.0, 1.0);
+
+ glTexCoord2f(1, 1);
+ glVertex2f(1.0, 1.0);
+
+ glTexCoord2f(1, 0);
+ glVertex2f(1.0, -1.0);
+ glEnd();
+
+ m_glCanvas->SwapBuffers();
+ }
+
+ const long t = sw.Time();
+
+ wxPrintf("%ld images done in %ldms = %gus/image or %ld FPS\n",
+ opts.numIters, t, (1000. * t)/opts.numIters,
+ (1000*opts.numIters + t - 1)/t);
+
+ wxTheApp->ExitMainLoop();
+ }
+#endif // wxUSE_GLCANVAS
+