OpenGL ES 2.0 support
Support for OpenGL ES 2.0
jPCT-AE supports OpenGL ES 2.0 since version 1.24. To use it, you have to enable it when creating your GLSurfaceView like so
GLSurfaceView mGLView = new GLSurfaceView(getApplication()); mGLView.setEGLContextClientVersion(2);
Then, when creating the FrameBuffer, you have to use the constructor without the GL10 instance, i.e.
FrameBuffer buffer=new FrameBuffer(800, 480);
FrameBuffer buffer=new FrameBuffer(<GL10>, 800, 480);
If you are mixing them, you'll run into trouble when jPCT-AE tries to execute any GL related command.
Naming conventions for user defined shaders
Support for OpenGL ES 2.0 is implemented in a way that a set of default shaders tries to mimic the behaviour of ES 1.x unless you assign your own shaders to some objects. If you do, you have to make sure that your attributes/uniforms follow a naming convention if you want jPCT-AE to inject some data:
uniform mat4 modelViewMatrix; - The model view matrix, i.e. the matrix that makes the transformation from object into camera space uniform mat4 modelViewProjectionMatrix; - The model view projection matrix, i.e. the model view matrix * project matrix uniform mat4 textureMatrix; - The texture matrix uniform mat4 projectionMatrix - The projection matrix uniform vec4 additionalColor; - An object's additional color (stored in .rgb of the uniform). uniform vec4 ambientColor; - The world's ambient color (stored in .rgb of the uniform). uniform float alpha; - The alpha value of the object. uniform float shininess; - The shininess if specular lighting is being used. uniform bool useColors; - true, if the object contains additional vertex colors. uniform float fogStart; - The depth coordinate, at which the fog starts. -1.0 if there is no fog. uniform float fogEnd; - The depth coordinate of maximum fog. uniform vec3 fogColor; - The fog color. uniform int lightCount; - The number of lights that light this object. uniform vec3 lightPositions; - The light positions in camera space. uniform vec3 diffuseColors; - The diffuse color of each light source. uniform vec3 specularColors; - The specular color of each light source. uniform sampler2D textureUnit0; - The texture sampler for the first texture layer. uniform sampler2D textureUnit1; - The texture sampler for the second texture layer. uniform sampler2D textureUnit2; - The texture sampler for the third texture layer. uniform sampler2D textureUnit3; - The texture sampler for the forth texture layer. uniform int textureCount; - The number of texture layers. uniform int blendingMode; - The blending modes between these layers (0==MODULATE, 1==ADD, 2==REPLACE, 3==BLEND). attribute vec4 position; - The vertex positions in object space. attribute vec3 normal; - The vertex normals in object space. attribute vec4 color; - The additional vertex colors (if any). attribute vec4 tangent; - The tangent vectors. The presence of this attribute in a shader's source code will trigger the tangent vector calculation when calling build(). attribute vec2 texture0; - The texture coordinates for the first stage. attribute vec2 texture1; - The texture coordinates for the second stage. attribute vec2 texture2; - The texture coordinates for the third stage. attribute vec2 texture3; - The texture coordinates for the forth stage.
When using ES 2.0 support, you also have the option to use anti aliasing by using the AAConfigChooser in the util-package. To use it, simply extend the initialization code above by
As mentioned, jPCT-AE comes with a set of default shaders that will be used if nothing else is specified. These shaders are written to be compatible with every device that i could test them on, which is why they look really ugly (Adreno based devices for example have serious problems with loops, so they are all unrolled...). The sources of these shaders can be found in the jar. If you want to override one or more default shaders, you can do so by using addReplacement in the GLSLShader-class.