Game Development Reference
In-Depth Information
public void onSurfaceCreated( GL10 gl,
EGLConfig config )
{
App13Activity.SetSurface(
App13Activity.m_View.getHolder().getSurface() );
}
}
}
How it works…
Frame rendering callbacks are declared in App13Activity.java :
public static native void SetSurface( Surface surface );
public static native void SetSurfaceSize(
int width, int height );
public static native void DrawFrame();
They are JNI calls that are implemented in the Wrappers.cpp ile:
JNIEXPORT void JNICALL
Java_com_packtpub_ndkcookbook_app13_App13Activity_SetSurface(
JNIEnv* env, jclass clazz, jobject javaSurface )
{
if ( LGL3 ) { delete( LGL3 ); }
Allocate a new sLGLAPI structure and reload the pointers to OpenGL functions:
LGL3 = new sLGLAPI;
LGL::clGLExtRetriever* OpenGL;
OpenGL = new LGL::clGLExtRetriever;
OpenGL->Reload( LGL3 );
delete( OpenGL );
}
JNIEXPORT void JNICALL
Java_com_packtpub_ndkcookbook_app13_App13Activity_SetSurfaceSize(
JNIEnv* env, jclass clazz, int Width, int Height )
{
Update the surface size. We don't need to do anything else here, since SetSurface() will be
called right after it:
g_Width = Width;
g_Height = Height;
}
 
Search WWH ::




Custom Search