Combing the basic knowledge of OpenGL - the process of building the OpenGLES operating environment

The simple routine of running OpenGLES on Windows has been completed in the previous blog, and now analyze its calling process.

1) EGL workflow

      First of all, you need to understand the process of calling EGL to create the OpenGLES operating environment related to the native window. For details, please refer to https://blog.csdn.net/afei__/article/details/84867104 ; the process is roughly divided into the following steps:

1) Call platform-related functions to create native windows (EGL is not responsible for this), and get the window handle EGLNativeWindowType

2) Call eglGetDisplay() to obtain the connection EGLDisplay related to the native window

3) Call eglInitialize() to initialize EGLDisplay

4) Obtain the available rendering surface configuration, generally call eglChooseConfig()

5) According to EGLDisplay, EGLNativeWindowType window handle and configuration, call eglCreateWindowSurface() to create the rendering surface EGLSurface

6) According to EGLDisplay and configuration, call eglCreateContext() to create GL context EGLContext

7) Call eglMakeCurrent() to use the configured context

2) Sample code calling process

      The routine code in the Red Book provides a development framework for accelerating OpenGLES development, encapsulates the above call to EGL to construct the operating environment into a function esCreateWindow(), and provides functions related to native window operations (creation, display, message) on different platforms. processing, etc.), so that developers can focus more on API calls in OpenGLES.

      Taking the Hello_Triangle project as an example, there is no main function in Hello_Triangle.c, and the main function exists in esUtil_win32.c in the Common library (corresponding to the Android platform is esUtil_Android.c). Apply for an ESContext variable in main(), and call esMain() to initialize the variable, including initializing the UserData variable, calling esCreateWindow() to build the GL operating environment, constructing the shader and program used for rendering, and specific drawing implementation; At the same time, assign the rendering function and the corresponding message function to the callback function interface of the ESContext object. In this way, developers can focus more on implementing rendering-related GLES API calls, without spending too much effort on constructing a platform-related GLES operating environment.

3) Compile the APK on the android platform

        The Red Book also gives the method of using NDK in Windows to compile the project into APK running on the mobile phone. I practiced it myself, and the process is as follows.

1) Download the JDK

Download from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html , I installed the 64bit version, after installation will "installation path\Java\jdk1.8.0_191\bin "Join the system path

2) Install ADT

I downloaded the 64bit version from https://www.androiddevtools.cn/ . After decompression, add "decompression path\sdk\tools" and "decompression path\sdk\platform-tools" to the system path

3) Install NDK

It is also downloaded from https://www.androiddevtools.cn/ , the r14b version I downloaded, after decompression, add the "decompression path" to the system path

4) Install Apache ant

Download from https://ant.apache.org/bindownload.cgi , add "decompression path\bin" to the system path after decompression

      So far, the required toolset has been installed and configured (Cygwin is not installed), and then according to the instructions in the Red Book, the APK is successfully compiled and generated, and it runs normally on the phone. The compilation operation is shown in the figure below, the only difference is that the ANDROID API version I installed is 20, so I changed the 18 in the first command to 20.

 

 

 

 

 

Guess you like

Origin blog.csdn.net/lwx309025167/article/details/102730963