com.jme3.system.android
Class OGLESContext

java.lang.Object
  extended by com.jme3.system.android.OGLESContext
All Implemented Interfaces:
android.opengl.GLSurfaceView.Renderer, SoftTextDialogInput, JmeContext

public class OGLESContext
extends java.lang.Object
implements JmeContext, android.opengl.GLSurfaceView.Renderer, SoftTextDialogInput


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jme3.system.JmeContext
JmeContext.Type
 
Field Summary
protected  AndroidInput androidInput
           
protected  boolean autoFlush
           
protected  int clientOpenGLESVersion
          EGL_RENDERABLE_TYPE: EGL_OPENGL_ES_BIT = OpenGL ES 1.0 | EGL_OPENGL_ES2_BIT = OpenGL ES 2.0
protected  java.util.concurrent.atomic.AtomicBoolean created
           
protected  SystemListener listener
           
protected  int minFrameDuration
           
protected  java.util.concurrent.atomic.AtomicBoolean needClose
           
protected  java.util.concurrent.atomic.AtomicBoolean renderable
           
protected  OGLESShaderRenderer renderer
           
protected  AppSettings settings
           
protected  Timer timer
           
protected  AndroidGLSurfaceView view
           
 
Fields inherited from interface com.jme3.input.SoftTextDialogInput
NUMERIC_ENTRY_DIALOG, NUMERIC_KEYPAD_DIALOG, TEXT_ENTRY_DIALOG
 
Constructor Summary
OGLESContext()
           
 
Method Summary
 void create()
           
 void create(boolean waitFor)
          Creates the context and makes it active.
 android.opengl.GLSurfaceView createView(AndroidConfigChooser.ConfigType configType, boolean eglConfigVerboseLogging)
          createView creates the GLSurfaceView that the renderer will draw to.
protected  void deinitInThread()
          De-initialize in the OpenGL thread.
 void destroy()
           
 void destroy(boolean waitFor)
          Destroys the context completely, making it inactive.
 int getClientOpenGLESVersion()
           
 JoyInput getJoyInput()
           
 KeyInput getKeyInput()
           
 MouseInput getMouseInput()
           
 Renderer getRenderer()
           
 AppSettings getSettings()
           
 Timer getTimer()
           
 TouchInput getTouchInput()
           
 JmeContext.Type getType()
           
protected  void initInThread()
           
 boolean isCreated()
           
 boolean isRenderable()
           
 void onDrawFrame(javax.microedition.khronos.opengles.GL10 gl)
           
 void onSurfaceChanged(javax.microedition.khronos.opengles.GL10 gl, int width, int height)
           
 void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 gl, javax.microedition.khronos.egl.EGLConfig cfg)
           
 void requestDialog(int id, java.lang.String title, java.lang.String initialValue, SoftTextDialogInputListener listener)
           
 void restart()
          Destroys and then re-creates the context.
 void setAutoFlushFrames(boolean enabled)
           
 void setSettings(AppSettings settings)
           
 void setSystemListener(SystemListener listener)
          Sets the listener that will receive events relating to context creation, update, and destroy.
 void setTitle(java.lang.String title)
          Sets the title of the display (if available).
protected  void waitFor(boolean createdVal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

created

protected final java.util.concurrent.atomic.AtomicBoolean created

renderable

protected final java.util.concurrent.atomic.AtomicBoolean renderable

needClose

protected final java.util.concurrent.atomic.AtomicBoolean needClose

settings

protected final AppSettings settings

renderer

protected OGLESShaderRenderer renderer

timer

protected Timer timer

listener

protected SystemListener listener

autoFlush

protected boolean autoFlush

androidInput

protected AndroidInput androidInput

view

protected AndroidGLSurfaceView view

minFrameDuration

protected int minFrameDuration

clientOpenGLESVersion

protected int clientOpenGLESVersion
EGL_RENDERABLE_TYPE: EGL_OPENGL_ES_BIT = OpenGL ES 1.0 | EGL_OPENGL_ES2_BIT = OpenGL ES 2.0

Constructor Detail

OGLESContext

public OGLESContext()
Method Detail

getType

public JmeContext.Type getType()
Specified by:
getType in interface JmeContext
Returns:
The type of the context.

createView

public android.opengl.GLSurfaceView createView(AndroidConfigChooser.ConfigType configType,
                                               boolean eglConfigVerboseLogging)
createView creates the GLSurfaceView that the renderer will draw to.

The result GLSurfaceView will receive input events and forward them to the Application. Any rendering will be done into the GLSurfaceView. Only one GLSurfaceView can be created at this time. The given configType specifies how to determine the display configuration.

Parameters:
configType - ConfigType.FASTEST (Default) | ConfigType.LEGACY | ConfigType.BEST
eglConfigVerboseLogging - if true show all found configs
Returns:
GLSurfaceView The newly created view

onSurfaceCreated

public void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 gl,
                             javax.microedition.khronos.egl.EGLConfig cfg)
Specified by:
onSurfaceCreated in interface android.opengl.GLSurfaceView.Renderer

initInThread

protected void initInThread()

deinitInThread

protected void deinitInThread()
De-initialize in the OpenGL thread.


setSettings

public void setSettings(AppSettings settings)
Specified by:
setSettings in interface JmeContext
Parameters:
settings - the display settings to use for the created context. If the context has already been created, then restart() must be called for the changes to be applied.

setSystemListener

public void setSystemListener(SystemListener listener)
Description copied from interface: JmeContext
Sets the listener that will receive events relating to context creation, update, and destroy.

Specified by:
setSystemListener in interface JmeContext

getSettings

public AppSettings getSettings()
Specified by:
getSettings in interface JmeContext
Returns:
The current display settings. Note that they might be different from the ones set with setDisplaySettings() if the context was restarted or the settings changed internally.

getRenderer

public Renderer getRenderer()
Specified by:
getRenderer in interface JmeContext
Returns:
The renderer for this context, or null if not created yet.

getMouseInput

public MouseInput getMouseInput()
Specified by:
getMouseInput in interface JmeContext
Returns:
Mouse input implementation. May be null if not available.

getKeyInput

public KeyInput getKeyInput()
Specified by:
getKeyInput in interface JmeContext
Returns:
Keyboard input implementation. May be null if not available.

getJoyInput

public JoyInput getJoyInput()
Specified by:
getJoyInput in interface JmeContext
Returns:
Joystick input implementation. May be null if not available.

getTouchInput

public TouchInput getTouchInput()
Specified by:
getTouchInput in interface JmeContext
Returns:
Touch device input implementation. May be null if not available.

getTimer

public Timer getTimer()
Specified by:
getTimer in interface JmeContext
Returns:
The timer for this context, or null if not created yet.

setTitle

public void setTitle(java.lang.String title)
Description copied from interface: JmeContext
Sets the title of the display (if available). This does nothing for fullscreen, headless, or canvas contexts.

Specified by:
setTitle in interface JmeContext
Parameters:
title - The new title of the display.

isCreated

public boolean isCreated()
Specified by:
isCreated in interface JmeContext
Returns:
True if the context has been created but not yet destroyed.

setAutoFlushFrames

public void setAutoFlushFrames(boolean enabled)
Specified by:
setAutoFlushFrames in interface JmeContext
Parameters:
enabled - If enabled, the context will automatically flush frames to the video card (swap buffers) after an update cycle.

onSurfaceChanged

public void onSurfaceChanged(javax.microedition.khronos.opengles.GL10 gl,
                             int width,
                             int height)
Specified by:
onSurfaceChanged in interface android.opengl.GLSurfaceView.Renderer

onDrawFrame

public void onDrawFrame(javax.microedition.khronos.opengles.GL10 gl)
Specified by:
onDrawFrame in interface android.opengl.GLSurfaceView.Renderer

isRenderable

public boolean isRenderable()
Specified by:
isRenderable in interface JmeContext
Returns:
True if the context contains a valid render surface, if any of the rendering methods in Renderer are called while this is false, then the result is undefined.

create

public void create(boolean waitFor)
Description copied from interface: JmeContext
Creates the context and makes it active.

Specified by:
create in interface JmeContext
Parameters:
waitFor - If true, will wait until context has initialized.

create

public void create()

restart

public void restart()
Description copied from interface: JmeContext
Destroys and then re-creates the context. This should be called after the display settings have been changed.

Specified by:
restart in interface JmeContext

destroy

public void destroy(boolean waitFor)
Description copied from interface: JmeContext
Destroys the context completely, making it inactive.

Specified by:
destroy in interface JmeContext
Parameters:
waitFor - If true, will wait until the context is destroyed fully.

destroy

public void destroy()

waitFor

protected void waitFor(boolean createdVal)

getClientOpenGLESVersion

public int getClientOpenGLESVersion()

requestDialog

public void requestDialog(int id,
                          java.lang.String title,
                          java.lang.String initialValue,
                          SoftTextDialogInputListener listener)
Specified by:
requestDialog in interface SoftTextDialogInput