APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.backends.lwjgl

public Class LwjglCanvas

extends Object
implements LwjglApplicationBase
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.backends.lwjgl.LwjglApplicationBase, com.badlogic.gdx.Application
Imports
java.io.PrintWriter, .StringWriter, java.util.HashMap, .Map, com.badlogic.gdx.backends.lwjgl.audio.LwjglAudio, .OpenALLwjglAudio, com.badlogic.gdx.utils.*, org.lwjgl.opengl.AWTGLCanvas, .Display, com.badlogic.gdx.ApplicationListener, .ApplicationLogger, .Audio, .Files, .Gdx, .Graphics, .Input, .LifecycleListener, .Net, .Preferences, java.awt.Canvas, .Container, .Cursor, .Dimension, .EventQueue, java.awt.geom.AffineTransform

An OpenGL surface on an AWT Canvas, allowing OpenGL to be embedded in a Swing application. This uses Display#setParent(Canvas), which is preferred over AWTGLCanvas but is limited to a single LwjglCanvas in an application. All OpenGL calls are done on the EDT. Note that you may need to call stop() or a Swing application may deadlock on System.exit due to how LWJGL and/or Swing deal with shutdown hooks.
Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
pack-priv ApplicationLogger
pack-priv LwjglAudio
pack-priv Canvas
pack-priv Cursor
pack-priv final Array<T>
pack-priv Files
pack-priv LwjglGraphics
pack-priv LwjglInput
pack-priv static boolean
pack-priv final Array<LifecycleListener>
pack-priv ApplicationListener
pack-priv int
pack-priv LwjglNet
pack-priv boolean
pack-priv final Map<String, Preferences>
pack-priv final Array<T>
pack-priv boolean
pack-priv float
pack-priv float

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public void
protected void
pack-priv void
public LwjglAudio
protected Files
public LwjglInput
public void
debug(String tag, String message)

Implements com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

public void
debug(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

protected void
disposed()

Called after dispose is complete.

public void
error(String tag, String message)

Implements com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

public void
error(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

protected void
public boolean
public void
exit()

Implements com.badlogic.gdx.Application.exit.

Schedule an exit from the application.

public ApplicationListener
public ApplicationLogger
public Audio
public Canvas
public Clipboard
public Files
protected int
public Graphics
public Input
public long
public int
getLogLevel()

Implements com.badlogic.gdx.Application.getLogLevel.

Gets the log level.

public long
public Net
public Preferences
getPreferences(String name)

Implements com.badlogic.gdx.Application.getPreferences.

Returns the Preferences instance of this Application.

public Application.ApplicationType
public int
private void
public void
log(String tag, String message)

Implements com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

public void
log(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

protected void
public void
postRunnable(Runnable runnable)

Implements com.badlogic.gdx.Application.postRunnable.

Posts a Runnable on the main loop thread.

public void
protected void
resize(int width, int height)

Called when the canvas size changes.

public void
setApplicationLogger(ApplicationLogger applicationLogger)

Implements com.badlogic.gdx.Application.setApplicationLogger.

Sets the current Application logger.

public void
setCursor(Cursor
May be null.
cursor
)

protected void
setDisplayMode(int width, int height)

public void
setLogLevel(int logLevel)

Implements com.badlogic.gdx.Application.setLogLevel.

Sets the log level.

public void
setPostedRunnableStacktraces(boolean postedRunnableStacktraces)

When true, postRunnable(Runnable) keeps the stacktrace (which is an allocation) so it can be included if the runnable later throws an exception.

protected void
protected void
start()

Called after ApplicationListener create and resize, but before the game loop iteration.

public void
stop()

protected void
stopped()

Called when the game loop has stopped.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationLoggerback to summary
pack-priv ApplicationLogger applicationLogger
audioback to summary
pack-priv LwjglAudio audio
canvasback to summary
pack-priv Canvas canvas
cursorback to summary
pack-priv Cursor cursor
executedRunnablesback to summary
pack-priv final Array<T> executedRunnables
filesback to summary
pack-priv Files files
graphicsback to summary
pack-priv LwjglGraphics graphics
inputback to summary
pack-priv LwjglInput input
isWindowsback to summary
pack-priv static boolean isWindows
lifecycleListenersback to summary
pack-priv final Array<LifecycleListener> lifecycleListeners
listenerback to summary
pack-priv ApplicationListener listener
logLevelback to summary
pack-priv int logLevel
netback to summary
pack-priv LwjglNet net
postedRunnableStacktracesback to summary
pack-priv boolean postedRunnableStacktraces
preferencesback to summary
pack-priv final Map<String, Preferences> preferences
runnablesback to summary
pack-priv final Array<T> runnables
runningback to summary
pack-priv boolean running
scaleXback to summary
pack-priv float scaleX
scaleYback to summary
pack-priv float scaleY

Constructor Detail

LwjglCanvasback to summary
public LwjglCanvas(ApplicationListener listener)
LwjglCanvasback to summary
public LwjglCanvas(ApplicationListener listener, LwjglApplicationConfiguration config)

Method Detail

addLifecycleListenerback to summary
public void addLifecycleListener(LifecycleListener listener)

Implements com.badlogic.gdx.Application.addLifecycleListener.

Doc from com.badlogic.gdx.Application.addLifecycleListener.

Adds a new LifecycleListener to the application. This can be used by extensions to hook into the lifecycle more easily. The ApplicationListener methods are sufficient for application level development.

Annotations
@Override
applyCursorback to summary
protected void applyCursor(Cursor cursor)
createback to summary
pack-priv void create()
createAudioback to summary
public LwjglAudio createAudio(LwjglApplicationConfiguration config)

Implements com.badlogic.gdx.backends.lwjgl.LwjglApplicationBase.createAudio.

Annotations
@Override
createFilesback to summary
protected Files createFiles()
createInputback to summary
public LwjglInput createInput(LwjglApplicationConfiguration config)

Implements com.badlogic.gdx.backends.lwjgl.LwjglApplicationBase.createInput.

Annotations
@Override
debugback to summary
public void debug(String tag, String message)

Implements com.badlogic.gdx.Application.debug.

Doc from com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

Annotations
@Override
debugback to summary
public void debug(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.debug.

Doc from com.badlogic.gdx.Application.debug.

Logs a debug message to the console or logcat

Annotations
@Override
disposedback to summary
protected void disposed()

Called after dispose is complete.

errorback to summary
public void error(String tag, String message)

Implements com.badlogic.gdx.Application.error.

Doc from com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

Annotations
@Override
errorback to summary
public void error(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.error.

Doc from com.badlogic.gdx.Application.error.

Logs an error message to the console or logcat

Annotations
@Override
exceptionback to summary
protected void exception(Throwable ex)
executeRunnablesback to summary
public boolean executeRunnables()
exitback to summary
public void exit()

Implements com.badlogic.gdx.Application.exit.

Doc from com.badlogic.gdx.Application.exit.

Schedule an exit from the application. On android, this will cause a call to pause() and dispose() some time in the future, it will not immediately finish your application. On iOS this should be avoided in production as it breaks Apples guidelines

Annotations
@Override
getApplicationListenerback to summary
public ApplicationListener getApplicationListener()

Implements com.badlogic.gdx.Application.getApplicationListener.

Annotations
@Override
getApplicationLoggerback to summary
public ApplicationLogger getApplicationLogger()

Implements com.badlogic.gdx.Application.getApplicationLogger.

Annotations
@Override
getAudioback to summary
public Audio getAudio()

Implements com.badlogic.gdx.Application.getAudio.

Annotations
@Override
getCanvasback to summary
public Canvas getCanvas()
getClipboardback to summary
public Clipboard getClipboard()

Implements com.badlogic.gdx.Application.getClipboard.

Annotations
@Override
getFilesback to summary
public Files getFiles()

Implements com.badlogic.gdx.Application.getFiles.

Annotations
@Override
getFrameRateback to summary
protected int getFrameRate()
getGraphicsback to summary
public Graphics getGraphics()

Implements com.badlogic.gdx.Application.getGraphics.

Annotations
@Override
getInputback to summary
public Input getInput()

Implements com.badlogic.gdx.Application.getInput.

Annotations
@Override
getJavaHeapback to summary
public long getJavaHeap()

Implements com.badlogic.gdx.Application.getJavaHeap.

Annotations
@Override
getLogLevelback to summary
public int getLogLevel()

Implements com.badlogic.gdx.Application.getLogLevel.

Doc from com.badlogic.gdx.Application.getLogLevel.

Gets the log level.

Annotations
@Override
getNativeHeapback to summary
public long getNativeHeap()

Implements com.badlogic.gdx.Application.getNativeHeap.

Annotations
@Override
getNetback to summary
public Net getNet()

Implements com.badlogic.gdx.Application.getNet.

Annotations
@Override
getPreferencesback to summary
public Preferences getPreferences(String name)

Implements com.badlogic.gdx.Application.getPreferences.

Doc from com.badlogic.gdx.Application.getPreferences.

Returns the Preferences instance of this Application. It can be used to store application settings across runs.

Annotations
@Override
getTypeback to summary
public Application.ApplicationType getType()

Implements com.badlogic.gdx.Application.getType.

Annotations
@Override
getVersionback to summary
public int getVersion()

Implements com.badlogic.gdx.Application.getVersion.

Annotations
@Override
initializeback to summary
private void initialize(ApplicationListener listener, LwjglApplicationConfiguration config)
logback to summary
public void log(String tag, String message)

Implements com.badlogic.gdx.Application.log.

Doc from com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

Annotations
@Override
logback to summary
public void log(String tag, String message, Throwable exception)

Implements com.badlogic.gdx.Application.log.

Doc from com.badlogic.gdx.Application.log.

Logs a message to the console or logcat

Annotations
@Override
postedExceptionback to summary
protected void postedException(Throwable ex, Throwable caller)
postRunnableback to summary
public void postRunnable(Runnable runnable)

Implements com.badlogic.gdx.Application.postRunnable.

Doc from com.badlogic.gdx.Application.postRunnable.

Posts a Runnable on the main loop thread. In a multi-window application, the Gdx#graphics and Gdx#input values may be unpredictable at the time the Runnable is executed. If graphics or input are needed, they can be copied to a variable to be used in the Runnable. For example:

final Graphics graphics = Gdx.graphics;

Annotations
@Override
removeLifecycleListenerback to summary
public void removeLifecycleListener(LifecycleListener listener)

Implements com.badlogic.gdx.Application.removeLifecycleListener.

Doc from com.badlogic.gdx.Application.removeLifecycleListener.

Removes the LifecycleListener.

Annotations
@Override
resizeback to summary
protected void resize(int width, int height)

Called when the canvas size changes.

setApplicationLoggerback to summary
public void setApplicationLogger(ApplicationLogger applicationLogger)

Implements com.badlogic.gdx.Application.setApplicationLogger.

Doc from com.badlogic.gdx.Application.setApplicationLogger.

Sets the current Application logger. Calls to log(String, String) are delegated to this ApplicationLogger

Annotations
@Override
setCursorback to summary
public void setCursor(Cursor cursor)
Parameters
cursor:Cursor

May be null.

setDisplayModeback to summary
protected void setDisplayMode(int width, int height)
setLogLevelback to summary
public void setLogLevel(int logLevel)

Implements com.badlogic.gdx.Application.setLogLevel.

Doc from com.badlogic.gdx.Application.setLogLevel.

Sets the log level. LOG_NONE will mute all log output. LOG_ERROR will only let error messages through. LOG_INFO will let all non-debug messages through, and LOG_DEBUG will let all messages through.

Annotations
@Override
setPostedRunnableStacktracesback to summary
public void setPostedRunnableStacktraces(boolean postedRunnableStacktraces)

When true, postRunnable(Runnable) keeps the stacktrace (which is an allocation) so it can be included if the runnable later throws an exception. Default is false.

setTitleback to summary
protected void setTitle(String title)
startback to summary
protected void start()

Called after ApplicationListener create and resize, but before the game loop iteration.

stopback to summary
public void stop()
stoppedback to summary
protected void stopped()

Called when the game loop has stopped.