- jMonkeyEngine 3.0 Beginner’s Guide
- Ruth Kusterer
- 324字
- 2025-04-04 22:38:53
Time for action – checking vital stats
The com.jme3.app.StatsView
UI element provides various counts, which it gathers using com.jme3.renderer.Statistics
:
- Run the
BasicGame
template once more. - Look at the statistics on the bottom left-hand side; they display the object counts for the various elements.
- Have a look at the bottom number in the HUD. It displays the frames per second (FPS).
To interpret the numbers correctly, consider that the 14 lines of text themselves already count as 14 objects with 914 vertices.
What just happened?
The StatsView
window displays internal info about Textures
, FrameBuffers
(rendering surfaces), and Shaders
(effects). The three values tell you how many are in memory (M
), how many were used in the last frame (F
), and how many were switched during the last frame (S
).
During the development phase, keep an eye on these statistics because they can warn you about performance issues:
- If
Textures
(S
) is significantly higher thanTextures
(F
), you know you are using textures inefficiently (for example, there are too many transparent ones). - If any (
M
) value is significantly higher than its (F
) counterpart, then you have more objects of this type in memory than you are actually using. Determine which ones to deallocate. - If a small scene with a few models has tens of thousands of triangles, you need to get rid of some high-polygon objects in the scene. The hard limit for the slowest current graphics card is around 100,000 vertices per scene. 10,000 to 50,000 vertices is a typical value.
- If your
FPS
stays below 30 frames or any counts are steadily increasing, you are looking at, for example, suboptimal loops or a memory leak. This should never happen in the final release.
In general, verify that the numbers are plausible for your scene.
Tip
For releases, or when you take screenshots, you will want to deactivate these StatView
HUDs. To switch off the statistics and FPS views, use the following commands:
setDisplayFps(false); setDisplayStatView(false);