Gr/Framework
is used to build scenes with the GR library. Display buffer processing, allocators, and other operations are handled by the framework. The GR sample demos all use this framework.
The framework allows you to use the following common operations.
Input | Operation |
---|---|
A Button | Toggle between single and double command lists. This is "single" by default. |
B Button | Enable/disable VSync waits. The default setting is to wait. |
START Button | Measure performance and output data to a log. Further details are given below. |
Log messages such as the following are output when START is pressed (DEBUG_PRINT
must be true
in a Release build).
CPU : 1077 (usec), 6.46 (%) GPU : 3046 (usec), 18.28 (%) Total : 4123 (usec), 24.74 (%) CMD : used size = 17984, max size = 524288, used = 3.43 (%) REQ : used num = 13, max num = 128, used = 10.16 (%)
Their meanings are as follows.
Type | Description |
---|---|
CPU | The CPU time and CPU usage for loading commands. |
GPU | The GPU time and GPU usage for executing loaded commands. |
Total | The combined CPU and GPU time as well as the combined CPU and GPU usage. This is not shown for double command lists, for which the CPU and GPU are run in parallel. |
CMD | The used command list size, the maximum command list size, and the percentage of the command list that is used. |
REQ | The number of command requests, the maximum number of command requests, and the percentage of command requests used. |
Specify the Framework
directory as a subdirectory. By defining CreateScene
and GetGraphicsMemoryMgrFunctor
, you can use the framework to render images. Pass the CreateScene
function a pointer to a scene class derived from IScene
.
You must override the following functions from the IScene
class.
Function Name | Role |
---|---|
Initialize |
Performs initialization. |
Finalize |
Performs finalization. |
Enter |
Called immediately after Initialize . |
Calc |
Called every frame before a scene is rendered. This returns a bool ; if it is false , execution breaks out of the loop and Finalize is called. |
PreDraw |
Called every frame before the screen is rendered. Rendering processes are defined here rather than in Calc . |
DrawTop |
Renders the upper screen (for the left eye). This returns a GLuint ; if it is 0 , data is not transferred to the display buffer. |
DrawExt |
Renders the upper screen (for the right eye). This returns a GLuint ; if it is 0 , data is not transferred to the display buffer. |
DrawBtm |
Renders the lower screen. This returns a GLuint ; if it is 0 , data is not transferred to the display buffer. |
PostDraw |
Called every frame after the screen is rendered. |
GetGrColorBufferPointer |
Gets a pointer to the color buffer. |
For more detailed usage, refer to each of the sample demos.
PostDraw
function to How to Use.CONFIDENTIAL