O'Reilly logo

Android NDK Beginner's Guide by Sylvain Ratabouil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – initializing OpenGL ES

First, let's encapsulate OpenGL ES initialization code in a dedicated C++ class:

  1. Create header file GraphicsService.hpp in jni folder. It needs to include EGL/egl.h which defines EGL API to bind OpenGL ES to the Android platform. This header declares among others EGLDisplay, EGLSurface, and EGLContext types which are handles to system resources.

    Our GrapicsService lifecycle is composed of three main steps:

    • start(): This binds an OpenGL rendering context to the Android native window and loads graphic resources (textures and meshes later in this chapter).
    • stop(): This unbinds rendering context from Android window and frees allocated graphic resources.
    • update(): This performs rendering operations during each refresh ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required