My goals were:
- Create an OpenGL ES sample program that's more complex than hello_triangle
- Measure the impact of screen resolution, model complexity, shader type, and other rendering settings on frame rate
The program draws many copies of the same model in a grid layout on the screen, and shows real-time rendering performance data. You can use the keyboard to change the current rendering settings, and see how it affects 3D performance and frame rate. Here's a screenshot of 81 dinosaur models, each about 19K triangles:
The source code compiles on a stock install of Raspbian Wheezy, with no extra libraries needed. X Windows is not required or used.
Some of the more interesting things demonstrated in the code are:
- basic vertex and fragment shaders for Phong and Gouraud shading
- rendering with vertex buffer objects
- drawing text with a bitmap font
- dynamically changing the screen resolution
- dynamically enabling multi-sampling
- taking a screen shot
Press S to hide all but the first row of text - this improves performance slightly. Use the keyboard to modify these settings:
- Number of objects rendered. Each object is 1 draw call.
- Type of object: Five choices, from a 12 triangle cube, to a 55K triangle robot.
- Screen resolution. From 1920 x 1080 down to 568 x 320.
- 4x Multi-sampling: on/off.
- Shader: textured with per-pixel lighting, textured with per-vertex lighting, untextured with per-pixel lighting, untextured with per-vertex lighting, flat colored.
- Texture filter: linear or nearest.
- Mipmaps: on/off.
- Backface culling: on/off.
- Depth test: on/off.
- Wireframe view: on/off.
- Camera distance away from the "wall of objects".
- Camera yaw angle - view the wall of objects at an oblique angle, or edge-on.
- Camera look away - rotate the camera 180 degrees, so that all triangles will get clipped out.
- Secret feature: press R to take a screenshot.
I hope somebody finds this useful, and I welcome all feedback on how the tool could be improved. Thanks!