Game Development Reference
In-Depth Information
Video Handlers
Video handlers are probably the most laborious part of this project. Any Quake II video
handler must implement six handler functions. Of the lot, only the following three require
actual implementations; the rest are just empty declarations:
GLimp_Init(void *hinstance, void *hWnd) : This function is used to
initialize the OpenGL renderer. The arguments hinstance and hWnd are
Windows-only variables and do not apply in the Android/Linux world.
GLimp_SetMode(int *pwidth, int *pheight, int mode, qboolean
fullscreen) : This function is used to set the video mode of the game,
including the width and height of the screen. The argument fullscreen
does not apply in this case.
GLimp_EndFrame () : This function gets called after the rendering of each
frame completes. It is meant to tell the OpenGL ES pipeline it is time to
draw.
The following video functions are called from various points of the drawing cycle and must
be declared but don't apply to this project; thus they will be empty:
GLimp_Shutdown( ) : Called when the OpenGL renderer is shut down.
It can fire many times during the life cycle of the game.
GLimp_BeginFrame(float camera_separation) : Called before each frame
of the game is drawn.
GLimp_AppActivate(qboolean active) : Called once when the application
is activated.
Video Initialization
During video initialization, you load the NanoGL handlers and tell the engine that the
renderer is ready to perform OpenGL calls, as shown in Listing 7-8.
Listing 7-8. Video Initialization
// gl_glx.c
static qboolean gl_initialized = false;
int GLimp_Init( void *hinstance, void *wndproc )
{
if ( ! gl_initialized ) {
// init NanoGL
if ( ! nanoGL_Init() ) {
return false;
}
gl_initialized = true;
}
return true;
}
 
Search WWH ::




Custom Search