Game Development Reference
In-Depth Information
Listing 6-1. NanoGL Initializer for Android: nanogl.cpp
// nanogl.cpp: Some code has been removed for simplicity
// GL ES structure with GL function pointers
#include "glesinterface.h"
#define GL_ENTRY(_r, _api, ...) #_api,
// function pointer names. Must match glesinterface.h
static char const * const gl_names[] = {
#include "gl_entries.in"
NULL
};
// OpenGL ES lib pointer
static void* glesLib = NULL;
GlESInterface* glEsImpl = NULL;
extern void InitGLStructs();
static void gl_unimplemented() {
LOGE ("Called unimplemented OpenGL ES API\n");
}
// Create GLES interface
// name : Library name
// lib, lib1: 2 shared libraries to try to load GL symbols from
// defaut_func: Function to call if load symbol fails
static int CreateGlEsInterface( const char * name, void * lib, void * lib1, void *
default_func )
{
// alloc space
if ( !glEsImpl )
glEsImpl = (GlESInterface *) malloc(sizeof(GlESInterface));
if (!glEsImpl) {
return 0;
}
// load GL API calls
char const * const * api;
api = gl_names;
// nanoGL interface pointer
void ** ptr = (void **)(glEsImpl);
while (*api)
{
void * f;
f = dlsym(lib, *api); // try ibGLESxx_CM.so
 
Search WWH ::




Custom Search