libgdx API

com.badlogic.gdx.backends.lwjgl
Class LwjglCanvas

java.lang.Object
  extended by com.badlogic.gdx.backends.lwjgl.LwjglCanvas
All Implemented Interfaces:
Application

public class LwjglCanvas
extends java.lang.Object
implements Application

An OpenGL surface on an AWT Canvas, allowing OpenGL to be embedded in a Swing application. All OpenGL calls are done on the EDT. This is slightly less efficient then a dedicated thread, but greatly simplifies synchronization. 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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.badlogic.gdx.Application
Application.ApplicationType
 
Field Summary
 
Fields inherited from interface com.badlogic.gdx.Application
LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_NONE
 
Constructor Summary
LwjglCanvas(ApplicationListener listener, boolean useGL2)
           
LwjglCanvas(ApplicationListener listener, LwjglApplicationConfiguration config)
           
 
Method Summary
 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)
           
 void exit()
          Exits the application.
 Audio getAudio()
           
 java.awt.Canvas getCanvas()
           
 Clipboard getClipboard()
           
 Files getFiles()
           
 Graphics getGraphics()
           
 Input getInput()
           
 long getJavaHeap()
           
 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.Exception exception)
          Logs a message to the console or logcat
 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 setCursor(java.awt.Cursor cursor)
           
protected  void setDisplayMode(int width, int height)
           
 void setLogLevel(int logLevel)
          Sets the log level.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LwjglCanvas

public LwjglCanvas(ApplicationListener listener,
                   boolean useGL2)

LwjglCanvas

public LwjglCanvas(ApplicationListener listener,
                   LwjglApplicationConfiguration config)
Method Detail

setDisplayMode

protected void setDisplayMode(int width,
                              int height)

setTitle

protected void setTitle(java.lang.String title)

getCanvas

public java.awt.Canvas getCanvas()

getAudio

public Audio getAudio()
Specified by:
getAudio in interface Application
Returns:
the Audio instance

getFiles

public Files getFiles()
Specified by:
getFiles in interface Application
Returns:
the Files instance

getGraphics

public Graphics getGraphics()
Specified by:
getGraphics in interface Application
Returns:
the Graphics instance

getInput

public Input getInput()
Specified by:
getInput in interface Application
Returns:
the Input instance

getNet

public Net getNet()
Specified by:
getNet in interface Application
Returns:
the Net instance

getType

public Application.ApplicationType getType()
Specified by:
getType in interface Application
Returns:
what Application.ApplicationType this application has, e.g. Android or Desktop

getVersion

public int getVersion()
Specified by:
getVersion in interface Application
Returns:
the Android API level on Android or 0 on the desktop.

exception

protected void exception(java.lang.Throwable ex)

start

protected void start()
Called after ApplicationListener create and resize, but before the game loop iteration.


resize

protected void resize(int width,
                      int height)
Called when the canvas size changes.


stopped

protected void stopped()
Called when the game loop has stopped.


stop

public void stop()

getJavaHeap

public long getJavaHeap()
Specified by:
getJavaHeap in interface Application
Returns:
the Java heap memory use in bytes

getNativeHeap

public long getNativeHeap()
Specified by:
getNativeHeap in interface Application
Returns:
the Native heap memory use in bytes

getPreferences

public Preferences getPreferences(java.lang.String name)
Description copied from interface: Application
Returns the Preferences instance of this Application. It can be used to store application settings across runs.

Specified by:
getPreferences in interface Application
Parameters:
name - the name of the preferences, must be useable as a file name.
Returns:
the preferences.

getClipboard

public Clipboard getClipboard()
Specified by:
getClipboard in interface Application

postRunnable

public void postRunnable(java.lang.Runnable runnable)
Description copied from interface: Application
Posts a Runnable on the main loop thread.

Specified by:
postRunnable in interface Application
Parameters:
runnable - the runnable.

debug

public void debug(java.lang.String tag,
                  java.lang.String message)
Description copied from interface: Application
Logs a debug message to the console or logcat

Specified by:
debug in interface Application

debug

public void debug(java.lang.String tag,
                  java.lang.String message,
                  java.lang.Throwable exception)
Description copied from interface: Application
Logs a debug message to the console or logcat

Specified by:
debug in interface Application

log

public void log(java.lang.String tag,
                java.lang.String message)
Description copied from interface: Application
Logs a message to the console or logcat

Specified by:
log in interface Application

log

public void log(java.lang.String tag,
                java.lang.String message,
                java.lang.Exception exception)
Description copied from interface: Application
Logs a message to the console or logcat

Specified by:
log in interface Application

error

public void error(java.lang.String tag,
                  java.lang.String message)
Description copied from interface: Application
Logs an error message to the console or logcat

Specified by:
error in interface Application

error

public void error(java.lang.String tag,
                  java.lang.String message,
                  java.lang.Throwable exception)
Description copied from interface: Application
Logs an error message to the console or logcat

Specified by:
error in interface Application

setLogLevel

public void setLogLevel(int logLevel)
Description copied from interface: Application
Sets the log level. Application.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.

Specified by:
setLogLevel in interface Application
Parameters:
logLevel - Application.LOG_NONE, Application.LOG_ERROR, Application.LOG_INFO, Application.LOG_DEBUG.

exit

public void exit()
Description copied from interface: Application
Exits 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.

Specified by:
exit in interface Application

setCursor

public void setCursor(java.awt.Cursor cursor)
Parameters:
cursor - May be null.

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Description copied from interface: Application
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.

Specified by:
addLifecycleListener in interface Application

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Description copied from interface: Application
Removes the LifecycleListener.

Specified by:
removeLifecycleListener in interface Application

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)