Time for action – clearing and swapping buffers
Let's clear the display buffers with a color fading from black to white:
While still being in
jni/GraphicsManager.cpp
, refresh the screen during each update step witheglSwapBuffers()
.To have a visual feedback, change the display background color gradually with the help of
glClearColor()
before erasing the Framebuffer withglClear()
:... status GraphicsManager::update() { static float clearColor = 0.0f; clearColor += 0.001f; glClearColor(clearColor, clearColor, clearColor, 1.0f); glClear(GL_COLOR_BUFFER_BIT); if (eglSwapBuffers(mDisplay, mSurface) != EGL_TRUE) { Log::error("Error %d swapping buffers.", eglGetError()); return STATUS_KO; } else { return STATUS_OK; } }
Update the
Android.mk
file to linkthe EGL
andGLESv2
libraries:LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LS_CPP=$(subst $(1)/,,$(wildcard $(1)/*.cpp)) LOCAL_MODULE := droidblaster LOCAL_SRC_FILES := $(call LS_CPP,$(LOCAL_PATH...