com.neovisionaries.android.opengl
Class GLESFactory

java.lang.Object
  extended by com.neovisionaries.android.opengl.GLESFactory

public final class GLESFactory
extends Object

The factory class to get an implementation of GLES interface.

If Android API Level is 8 (Android 2.2) or higher, an implementation for OpenGL ES 2.0 is returned by getInstance() method. Otherwise, an implementation for OpenGL ES 1.1 is returned. Note that if Android API Level were less than 4 (Android 1.6), this factory class itself would not be able to be loaded.

If you want to make getInstance() return another different GLES implementation, call initializeInstance(String) or set a class name to the system property GLES_IMPL_CLASS_PROPERTY. See the description of getInstance() for details.

Author:
Takahiko Kawasaki

Field Summary
static String GLES_IMPL_CLASS_PROPERTY
          The name of the system property to specify a class name of an implementation of GLES interface.
static String GLES_IMPL_GLES11
          The class name of the default implementation of GLES interface for OpenGL ES 1.1.
static String GLES_IMPL_GLES20
          The class name of the default implementation of GLES interface for OpenGL ES 2.0 in Android 2.2 (API Level 8).
static String GLES_IMPL_GLES20_9
          The class name of the default implementation of GLES interface for OpenGL ES 2.0 in Android 2.3 (API Level 9) and newer.
 
Method Summary
static GLES getInstance()
          Get an implementation of GLES interface.
static void initializeInstance(String className)
          Initialize the singleton instance of GLES implemetation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLES_IMPL_CLASS_PROPERTY

public static final String GLES_IMPL_CLASS_PROPERTY
The name of the system property to specify a class name of an implementation of GLES interface.

See Also:
Constant Field Values

GLES_IMPL_GLES20

public static final String GLES_IMPL_GLES20
The class name of the default implementation of GLES interface for OpenGL ES 2.0 in Android 2.2 (API Level 8).

See Also:
Constant Field Values

GLES_IMPL_GLES20_9

public static final String GLES_IMPL_GLES20_9
The class name of the default implementation of GLES interface for OpenGL ES 2.0 in Android 2.3 (API Level 9) and newer.

See Also:
Constant Field Values

GLES_IMPL_GLES11

public static final String GLES_IMPL_GLES11
The class name of the default implementation of GLES interface for OpenGL ES 1.1.

See Also:
Constant Field Values
Method Detail

initializeInstance

public static void initializeInstance(String className)
                               throws ClassNotFoundException,
                                      InstantiationException,
                                      IllegalAccessException
Initialize the singleton instance of GLES implemetation.

You do not have to call this method if the default implementation suits your needs. See the description of getInstance() for the case you need to call this method.

Parameters:
className - The name of a class that implements GLES interface.
Throws:
IllegalArgumentException - The given argument is null.
IllegalStateException - The singleton instance has aleady been created.
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
getInstance()

getInstance

public static GLES getInstance()
Get an implementation of GLES interface.

If initializeInstance(String) has been called before this method is called, the object created in the call of initializeInstance(String) is returned. In other words, to use another implementation of GLES that is different from the one selected by the steps described below, call initializeInstance(String) before this method. Note that because getInstance() method is called at various places in the implementation of this Java package, if you want to use initializeInstance(String), you must call it before not only calling getInstance() but also referring to any other class in this Java package.

The steps to select an implementation of GLES instance are as follows.

  1. The system property of GLES_IMPL_CLASS_PROPERTY is checked. If it holds a non-null value, the value is used as a class name of a GLES implementation.
  2. Otherwise, the API Level of the Android platform is checked. If the API Level is 9 (Android 2.3) or higher, the value of GLES_IMPL_GLES20_9 is used as a class name of a GLES implementation.
  3. Otherwise, if the API Level is 8 (Android 2.2), the value of GLES_IMPL_GLES20 is used as a class name of a GLES implementation.
  4. Otherwise, the value of GLES_IMPL_GLES11 is used as a class name of a GLES implementation.

If you want to use OpenGL ES 1.1 instead of OpenGL ES 2.0 on Android 2.2 (API Level 8) or newer, you need to call initializeInstance(String) or set a class name to the system property GLES_IMPL_CLASS_PROPERTY.

The default GLES implementation for OpenGL ES 2.0 is different between Android 2.2 and Android 2.3 (and newer). This is because android.opengl.GLES20 class in Anroid 2.2 does not have the method listed below although it should have.

Returns:
An implementation of GLES interface.
Throws:
UnsupportedOperationException - Failed to create an object implementing GLES interface.
See Also:
android.opengl.GLES11, android.opengl.GLES20