Shaders through OpenGL
In Android, OpenGL supports implementing shaders for Android 3D games. OpenGL ES 2.0 is the supporting platform in Android for shaders. It has two functional segments while manually creating the shader:
Shader
Program
The shader is converted into intermediate code to support the program to run on GPU. In the compiling stage, the shaders are converted. This is the reason why shaders need to be recompiled before the program execution.
We will work with GLSurfaceView
of the android.opengl
package in our example.
For 3D games, an Android developer can use this package to play with shaders on the Android SDK. This package provides the API to create and use an OpenGL shader with Java.
We will use GLSurfaceView
instead of the normal Android View
or SurfaceView
. The implementation will look like this:
import android.opengl.GLSurfaceView; import android.content.Context; public class MyGLExampleView extends GLSurfaceView { private final GLRenderer mRenderer; public MyGLExampleView...