Package com.jme3.system.android
Class OGLESContext
java.lang.Object
com.jme3.system.android.OGLESContext
- All Implemented Interfaces:
android.opengl.GLSurfaceView.Renderer
,SoftTextDialogInput
,JmeContext
public class OGLESContext
extends 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
Modifier and TypeFieldDescriptionprotected AndroidInputHandler
protected boolean
protected final AtomicBoolean
protected long
protected SystemListener
protected long
protected final AtomicBoolean
protected final AtomicBoolean
protected GLRenderer
protected AppSettings
protected Timer
Fields inherited from interface com.jme3.input.SoftTextDialogInput
NUMERIC_ENTRY_DIALOG, NUMERIC_KEYPAD_DIALOG, TEXT_ENTRY_DIALOG
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
void
create
(boolean waitFor) Creates the context and makes it active.android.opengl.GLSurfaceView
createView
(android.content.Context context) createView
creates the GLSurfaceView that the renderer will draw to.protected void
De-initialize in the OpenGL thread.void
destroy()
void
destroy
(boolean waitFor) Destroys the context completely, making it inactive.int
Returns the height of the input surface.int
Returns the width of the input surface.Accesses the listener that receives events related to this context.getTimer()
getType()
int
Returns the screen X coordinate of the left edge of the content area.int
Returns the screen Y coordinate of the top edge of the content area.protected void
boolean
boolean
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, String title, 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
Sets the title of the display (if available).protected void
waitFor
(boolean createdVal)
-
Field Details
-
created
-
renderable
-
needClose
-
settings
-
renderer
-
timer
-
listener
-
autoFlush
protected boolean autoFlush -
androidInput
-
minFrameDuration
protected long minFrameDuration -
lastUpdateTime
protected long lastUpdateTime
-
-
Constructor Details
-
OGLESContext
public OGLESContext()
-
-
Method Details
-
getType
- Specified by:
getType
in interfaceJmeContext
- Returns:
- The type of the context.
-
createView
public android.opengl.GLSurfaceView createView(android.content.Context context) 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:
context
- (not null)- 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 interfaceandroid.opengl.GLSurfaceView.Renderer
-
initInThread
protected void initInThread() -
deinitInThread
protected void deinitInThread()De-initialize in the OpenGL thread. -
setSettings
- Specified by:
setSettings
in interfaceJmeContext
- Parameters:
settings
- the display settings to use for the created context. If the context has already been created, thenrestart()
must be called for the changes to be applied.
-
getSystemListener
Accesses the listener that receives events related to this context.- Specified by:
getSystemListener
in interfaceJmeContext
- Returns:
- the pre-existing instance
-
setSystemListener
Description copied from interface:JmeContext
Sets the listener that will receive events relating to context creation, update, and destroy.- Specified by:
setSystemListener
in interfaceJmeContext
- Parameters:
listener
- the desired listener
-
getSettings
- Specified by:
getSettings
in interfaceJmeContext
- 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
- Specified by:
getRenderer
in interfaceJmeContext
- Returns:
- The renderer for this context, or null if not created yet.
-
getMouseInput
- Specified by:
getMouseInput
in interfaceJmeContext
- Returns:
- Mouse input implementation. May be null if not available.
-
getKeyInput
- Specified by:
getKeyInput
in interfaceJmeContext
- Returns:
- Keyboard input implementation. May be null if not available.
-
getJoyInput
- Specified by:
getJoyInput
in interfaceJmeContext
- Returns:
- Joystick input implementation. May be null if not available.
-
getTouchInput
- Specified by:
getTouchInput
in interfaceJmeContext
- Returns:
- Touch device input implementation. May be null if not available.
-
getTimer
- Specified by:
getTimer
in interfaceJmeContext
- Returns:
- The timer for this context, or null if not created yet.
-
setTitle
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 interfaceJmeContext
- Parameters:
title
- The new title of the display.
-
isCreated
public boolean isCreated()- Specified by:
isCreated
in interfaceJmeContext
- Returns:
- True if the context has been created but not yet destroyed.
-
setAutoFlushFrames
public void setAutoFlushFrames(boolean enabled) - Specified by:
setAutoFlushFrames
in interfaceJmeContext
- 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 interfaceandroid.opengl.GLSurfaceView.Renderer
-
onDrawFrame
public void onDrawFrame(javax.microedition.khronos.opengles.GL10 gl) - Specified by:
onDrawFrame
in interfaceandroid.opengl.GLSurfaceView.Renderer
-
isRenderable
public boolean isRenderable()- Specified by:
isRenderable
in interfaceJmeContext
- Returns:
- True if the context contains a valid render surface,
if any of the rendering methods in
Renderer
are called while this isfalse
, 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 interfaceJmeContext
- 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 interfaceJmeContext
-
destroy
public void destroy(boolean waitFor) Description copied from interface:JmeContext
Destroys the context completely, making it inactive.- Specified by:
destroy
in interfaceJmeContext
- Parameters:
waitFor
- If true, will wait until the context is destroyed fully.
-
destroy
public void destroy() -
waitFor
protected void waitFor(boolean createdVal) -
requestDialog
public void requestDialog(int id, String title, String initialValue, SoftTextDialogInputListener listener) - Specified by:
requestDialog
in interfaceSoftTextDialogInput
-
getOpenCLContext
- Specified by:
getOpenCLContext
in interfaceJmeContext
- Returns:
- The OpenCL context if available.
-
getFramebufferHeight
public int getFramebufferHeight()Returns the height of the input surface.- Specified by:
getFramebufferHeight
in interfaceJmeContext
- Returns:
- the height (in pixels)
-
getFramebufferWidth
public int getFramebufferWidth()Returns the width of the input surface.- Specified by:
getFramebufferWidth
in interfaceJmeContext
- Returns:
- the width (in pixels)
-
getWindowXPosition
public int getWindowXPosition()Returns the screen X coordinate of the left edge of the content area.- Specified by:
getWindowXPosition
in interfaceJmeContext
- Returns:
- the screen X coordinate
- Throws:
UnsupportedOperationException
-
getWindowYPosition
public int getWindowYPosition()Returns the screen Y coordinate of the top edge of the content area.- Specified by:
getWindowYPosition
in interfaceJmeContext
- Returns:
- the screen Y coordinate
- Throws:
UnsupportedOperationException
-