Game Development Reference
In-Depth Information
glGenTextures( 1, &g_Texture );
glBindTexture( GL_TEXTURE_2D, g_Texture );
Disable mip-mapping through the following code:
glTexParameteri( GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
ImageWidth, ImageHeight, 0, GL_RGBA,
GL_UNSIGNED_BYTE, g_FrameBuffer );
}
The second callback does the actual frame rendering:
JNIEXPORT void JNICALL Java_com_packtpub_ndkcookbook_app3_
App3Activity_DrawFrame( JNIEnv* env, jobject obj )
{
Invoke our frame rendering callback through the following code:
OnDrawFrame();
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, g_Texture );
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0,
ImageWidth, ImageHeight, GL_RGBA,
GL_UNSIGNED_BYTE, g_FrameBuffer );
GLDebug_RenderTriangle();
}
Going cross platform
The main idea is the possibility of cross-platform development in What You See (on a PC) is What
You Get (on a device), when most of the application logic can be developed in a familiar desktop
environment like Windows, and it can be built for Android using the NDK whenever necessary.
Getting ready
To perform what we just discussed, we have to implement some sort of abstraction on top of
the NDK, POSIX, and Windows API. Such an abstraction should feature at least the following:
F Ability to render buffer contents on the screen: Our framework should provide the
functions to build the contents of an off-screen framebuffer (a 2D array of pixels) to
the screen (for Windows we refer to the window as "the screen").
 
Search WWH ::




Custom Search