Package arc.backend.sdl
Class SdlGraphics
java.lang.Object
arc.Graphics
arc.backend.sdl.SdlGraphics
- All Implemented Interfaces:
Disposable
-
Nested Class Summary
Nested classes/interfaces inherited from class arc.Graphics
Graphics.BufferFormat, Graphics.Cursor
-
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Releases all resources of this object.int
int
float
float
This is a scaling factor for the Density Independent Pixel unit, following the same conventions as android.util.DisplayMetrics#density, where one DIP is one pixel on an approximately 160 dpi screen.long
Returns the id of the current frame.int
getGL20()
getGL30()
int
float
getPpcX()
float
getPpcY()
float
getPpiX()
float
getPpiY()
int
getWidth()
boolean
boolean
Whether the app is fullscreen or notboolean
Returns whether OpenGL ES 3.0 is available.Create a new cursor represented by thePixmap
.void
Requests a new frame to be rendered if the rendering mode is non-continuous.void
setBorderless
(boolean borderless) Sets the window decoration as enabled or disabled.void
setContinuousRendering
(boolean isContinuous) Sets whether to render continuously.protected void
setCursor
(Graphics.Cursor cursor) Only viable on desktop and web.boolean
Sets the window to full-screen mode.void
Set the GL20 instancevoid
Set the GL30 instancevoid
setResizable
(boolean resizable) Sets whether or not the window should be resizable.protected void
Sets one of the predefinedGraphics.Cursor.SystemCursor
s.void
Sets the title of the window.void
setVSync
(boolean vsync) Enable/Disable vsynching.boolean
setWindowedMode
(int width, int height) Sets the window to windowed mode.boolean
supportsExtension
(String extension) Methods inherited from class arc.Graphics
clear, clear, cursor, getAspect, getSafeInsets, isHidden, isPortrait, newCursor, newCursor, newCursor, newCursor, restoreCursor
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface arc.util.Disposable
isDisposed
-
Method Details
-
isGL30Available
public boolean isGL30Available()Description copied from class:Graphics
Returns whether OpenGL ES 3.0 is available. If it is you can get an instance ofGL30
viaGraphics.getGL30()
to access OpenGL ES 3.0 functionality. Note that this functionality will only be available if you instructed theApplication
instance to use OpenGL ES 3.0!- Overrides:
isGL30Available
in classGraphics
- Returns:
- whether OpenGL ES 3.0 is available
-
getGL20
-
setGL20
Description copied from class:Graphics
Set the GL20 instance -
getGL30
-
setGL30
Description copied from class:Graphics
Set the GL30 instance -
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getBackBufferWidth
public int getBackBufferWidth()- Specified by:
getBackBufferWidth
in classGraphics
- Returns:
- the width of the framebuffer in physical pixels
-
getBackBufferHeight
public int getBackBufferHeight()- Specified by:
getBackBufferHeight
in classGraphics
- Returns:
- the height of the framebuffer in physical pixels
-
getFrameId
public long getFrameId()Description copied from class:Graphics
Returns the id of the current frame. The general contract of this method is that the id is incremented only when the application is in the running state right before calling theApplicationListener.update()
method. Also, the id of the first frame is 0; the id of subsequent frames is guaranteed to take increasing values for 263-1 rendering cycles.- Specified by:
getFrameId
in classGraphics
- Returns:
- the id of the current frame
-
getDeltaTime
public float getDeltaTime()- Specified by:
getDeltaTime
in classGraphics
- Returns:
- the time span between the current frame and the last frame in seconds. Might be smoothed over n frames.
-
getFramesPerSecond
public int getFramesPerSecond()- Specified by:
getFramesPerSecond
in classGraphics
- Returns:
- the average number of frames per second
-
getGLVersion
- Specified by:
getGLVersion
in classGraphics
- Returns:
- the
GLVersion
of this Graphics instance
-
getPpiX
public float getPpiX() -
getPpiY
public float getPpiY() -
getPpcX
public float getPpcX() -
getPpcY
public float getPpcY() -
getDensity
public float getDensity()Description copied from class:Graphics
This is a scaling factor for the Density Independent Pixel unit, following the same conventions as android.util.DisplayMetrics#density, where one DIP is one pixel on an approximately 160 dpi screen. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc.- Specified by:
getDensity
in classGraphics
- Returns:
- the logical density of the Display.
-
setFullscreen
public boolean setFullscreen()Description copied from class:Graphics
Sets the window to full-screen mode.- Overrides:
setFullscreen
in classGraphics
- Returns:
- whether the operation succeeded.
-
setWindowedMode
public boolean setWindowedMode(int width, int height) Description copied from class:Graphics
Sets the window to windowed mode.- Specified by:
setWindowedMode
in classGraphics
- Parameters:
width
- the width in pixelsheight
- the height in pixels- Returns:
- whether the operation succeeded
-
setTitle
Description copied from class:Graphics
Sets the title of the window. Ignored on Android. -
setBorderless
public void setBorderless(boolean borderless) Description copied from class:Graphics
Sets the window decoration as enabled or disabled. On Android, this will enable/disable the menu bar.Note that immediate behavior of this method may vary depending on the implementation. It may be necessary for the window to be recreated in order for the changes to take effect. Consult the documentation for the backend in use for more information.
Supported on all desktop backends and on Android (to disable the menu bar).
- Specified by:
setBorderless
in classGraphics
- Parameters:
borderless
- true if the window border or status bar should be hidden. false otherwise.
-
setResizable
public void setResizable(boolean resizable) Description copied from class:Graphics
Sets whether or not the window should be resizable. Ignored on Android.Note that immediate behavior of this method may vary depending on the implementation. It may be necessary for the window to be recreated in order for the changes to take effect. Consult the documentation for the backend in use for more information.
Supported on all desktop backends.
- Specified by:
setResizable
in classGraphics
-
setVSync
public void setVSync(boolean vsync) Description copied from class:Graphics
Enable/Disable vsynching. This is a best-effort attempt which might not work on all platforms. -
getBufferFormat
- Specified by:
getBufferFormat
in classGraphics
- Returns:
- the format of the color, depth and stencil buffer in a
Graphics.BufferFormat
instance
-
supportsExtension
- Specified by:
supportsExtension
in classGraphics
- Parameters:
extension
- the extension name- Returns:
- whether the extension is supported
-
isContinuousRendering
public boolean isContinuousRendering()- Specified by:
isContinuousRendering
in classGraphics
- Returns:
- whether rendering is continuous.
-
setContinuousRendering
public void setContinuousRendering(boolean isContinuous) Description copied from class:Graphics
Sets whether to render continuously. In case rendering is performed non-continuously, the following events will trigger a redraw:- A call to
Graphics.requestRendering()
- Input events from the touch screen/mouse or keyboard
- A
Runnable
is posted to the rendering thread viaApplication.post(Runnable)
. In the case of a multi-window app, all windows will request rendering if a runnable is posted to the application. To avoid this, post a runnable to the window instead.
Life-cycle events will also be reported as usual, see
ApplicationListener
. This method can be called from any thread.- Specified by:
setContinuousRendering
in classGraphics
- Parameters:
isContinuous
- whether the rendering should be continuous or not.
- A call to
-
requestRendering
public void requestRendering()Description copied from class:Graphics
Requests a new frame to be rendered if the rendering mode is non-continuous. This method can be called from any thread.- Specified by:
requestRendering
in classGraphics
-
isFullscreen
public boolean isFullscreen()Description copied from class:Graphics
Whether the app is fullscreen or not- Specified by:
isFullscreen
in classGraphics
-
newCursor
Description copied from class:Graphics
Create a new cursor represented by thePixmap
. The Pixmap must be in RGBA8888 format, width & height must be powers-of-two greater than zero (not necessarily equal) and of a certain minimum size (32x32 is a safe bet), and alpha transparency must be single-bit (i.e., 0x00 or 0xFF only). This function returns a Cursor object that can be set as the system cursor by callingGraphics.setCursor(Cursor)
.- Specified by:
newCursor
in classGraphics
- Parameters:
pixmap
- the mouse cursor image as aPixmap
xHotspot
- the x location of the hotspot pixel within the cursor image (origin top-left corner)yHotspot
- the y location of the hotspot pixel within the cursor image (origin top-left corner)- Returns:
- a cursor object that can be used by calling
Graphics.setCursor(Cursor)
or null if not supported
-
setCursor
Description copied from class:Graphics
Only viable on desktop and web. Browsers that support cursor:url() and support the png format (the pixmap is converted to a data-url of type image/png) should also support custom cursors. Will set the mouse cursor image to the image represented by theGraphics.Cursor
. It is recommended to call this function in the main render thread, and maximum one time per frame. Internal use only!- Specified by:
setCursor
in classGraphics
- Parameters:
cursor
- the mouse cursor as aGraphics.Cursor
-
setSystemCursor
Description copied from class:Graphics
Sets one of the predefinedGraphics.Cursor.SystemCursor
s. Internal use only!- Specified by:
setSystemCursor
in classGraphics
-
dispose
public void dispose()Description copied from interface:Disposable
Releases all resources of this object.- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classGraphics
-