public class LwjglCanvas extends java.lang.Object implements Application
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.Application.ApplicationTypeLOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_NONE| Constructor and Description |
|---|
LwjglCanvas(ApplicationListener listener) |
LwjglCanvas(ApplicationListener listener,
LwjglApplicationConfiguration config) |
| Modifier and Type | Method and Description |
|---|---|
void |
addLifecycleListener(LifecycleListener listener)
Adds a new
LifecycleListener to the application. |
void |
debug(java.lang.String tag,
java.lang.String message)
Logs a debug message to the console or logcat
|
void |
debug(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Logs a debug message to the console or logcat
|
void |
error(java.lang.String tag,
java.lang.String message)
Logs an error message to the console or logcat
|
void |
error(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Logs an error message to the console or logcat
|
protected void |
exception(java.lang.Throwable ex) |
boolean |
executeRunnables() |
void |
exit()
Schedule an exit from the application.
|
ApplicationListener |
getApplicationListener() |
ApplicationLogger |
getApplicationLogger() |
Audio |
getAudio() |
java.awt.Canvas |
getCanvas() |
Clipboard |
getClipboard() |
Files |
getFiles() |
protected int |
getFrameRate() |
Graphics |
getGraphics() |
Input |
getInput() |
long |
getJavaHeap() |
int |
getLogLevel()
Gets the log level.
|
long |
getNativeHeap() |
Net |
getNet() |
Preferences |
getPreferences(java.lang.String name)
Returns the
Preferences instance of this Application. |
Application.ApplicationType |
getType() |
int |
getVersion() |
void |
log(java.lang.String tag,
java.lang.String message)
Logs a message to the console or logcat
|
void |
log(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Logs a message to the console or logcat
|
protected void |
postedException(java.lang.Throwable ex,
java.lang.Throwable caller) |
void |
postRunnable(java.lang.Runnable runnable)
Posts a
Runnable on the main loop thread. |
void |
removeLifecycleListener(LifecycleListener listener)
Removes the
LifecycleListener. |
protected void |
resize(int width,
int height)
Called when the canvas size changes.
|
void |
setApplicationLogger(ApplicationLogger applicationLogger)
Sets the current Application logger.
|
void |
setCursor(java.awt.Cursor cursor) |
protected void |
setDisplayMode(int width,
int height) |
void |
setLogLevel(int logLevel)
Sets the log level.
|
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 |
setTitle(java.lang.String title) |
protected void |
start()
Called after
ApplicationListener create and resize, but before the game loop iteration. |
void |
stop() |
protected void |
stopped()
Called when the game loop has stopped.
|
public LwjglCanvas(ApplicationListener listener)
public LwjglCanvas(ApplicationListener listener, LwjglApplicationConfiguration config)
protected void setDisplayMode(int width,
int height)
protected void setTitle(java.lang.String title)
public ApplicationListener getApplicationListener()
getApplicationListener in interface ApplicationApplicationListener instancepublic java.awt.Canvas getCanvas()
public Audio getAudio()
getAudio in interface ApplicationAudio instancepublic Files getFiles()
getFiles in interface ApplicationFiles instancepublic Graphics getGraphics()
getGraphics in interface ApplicationGraphics instancepublic Input getInput()
getInput in interface ApplicationInput instancepublic Net getNet()
getNet in interface ApplicationNet instancepublic Application.ApplicationType getType()
getType in interface ApplicationApplication.ApplicationType this application has, e.g. Android or Desktoppublic int getVersion()
getVersion in interface Applicationpublic boolean executeRunnables()
protected void postedException(java.lang.Throwable ex,
@Null
java.lang.Throwable caller)
protected void exception(java.lang.Throwable ex)
protected int getFrameRate()
protected void start()
ApplicationListener create and resize, but before the game loop iteration.protected void resize(int width,
int height)
protected void stopped()
public void stop()
public long getJavaHeap()
getJavaHeap in interface Applicationpublic long getNativeHeap()
getNativeHeap in interface Applicationpublic Preferences getPreferences(java.lang.String name)
ApplicationPreferences instance of this Application. It can be used to store application settings across runs.getPreferences in interface Applicationname - the name of the preferences, must be useable as a file name.public Clipboard getClipboard()
getClipboard in interface Applicationpublic void postRunnable(java.lang.Runnable runnable)
ApplicationRunnable 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;
postRunnable in interface Applicationrunnable - the runnable.public void debug(java.lang.String tag,
java.lang.String message)
Applicationdebug in interface Applicationpublic void debug(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Applicationdebug in interface Applicationpublic void log(java.lang.String tag,
java.lang.String message)
Applicationlog in interface Applicationpublic void log(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Applicationlog in interface Applicationpublic void error(java.lang.String tag,
java.lang.String message)
Applicationerror in interface Applicationpublic void error(java.lang.String tag,
java.lang.String message,
java.lang.Throwable exception)
Applicationerror in interface Applicationpublic void setLogLevel(int logLevel)
ApplicationApplication.LOG_NONE will mute all log output. Application.LOG_ERROR will only let error messages through.
Application.LOG_INFO will let all non-debug messages through, and Application.LOG_DEBUG will let all messages through.setLogLevel in interface ApplicationlogLevel - Application.LOG_NONE, Application.LOG_ERROR, Application.LOG_INFO, Application.LOG_DEBUG.public int getLogLevel()
ApplicationgetLogLevel in interface Applicationpublic void setApplicationLogger(ApplicationLogger applicationLogger)
ApplicationApplication.log(String, String) are delegated to this ApplicationLoggersetApplicationLogger in interface Applicationpublic ApplicationLogger getApplicationLogger()
getApplicationLogger in interface ApplicationApplicationLoggerpublic void exit()
Applicationexit in interface Applicationpublic void setCursor(java.awt.Cursor cursor)
cursor - May be null.public void addLifecycleListener(LifecycleListener listener)
ApplicationLifecycleListener 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.addLifecycleListener in interface Applicationpublic void removeLifecycleListener(LifecycleListener listener)
ApplicationLifecycleListener.removeLifecycleListener in interface Applicationpublic void setPostedRunnableStacktraces(boolean postedRunnableStacktraces)
postRunnable(Runnable) keeps the stacktrace (which is an allocation) so it can be included if the
runnable later throws an exception. Default is false.