public interface Graphics
Application
configuration, access to GL20
and GL30
are provided here.
If supported by the backend, this interface lets you query the available display modes (graphics resolution and color depth) and change it.
This interface can be used to switch between continuous and non-continuous rendering (see
setContinuousRendering(boolean)
), and to explicitly requestRendering()
.
There are many more utility classes that are not directly generated by the Graphics
interfaces. See VertexArray
, VertexBufferObject
, IndexBufferObject
, Mesh
, ShaderProgram
and FrameBuffer
,
BitmapFont
, Batch
and so on. All these classes are managed, meaning they don't need to be reloaded on a context
loss. Explore the com.badlogic.gdx.graphics package for more classes that might come in handy.
Modifier and Type | Interface and Description |
---|---|
static class |
Graphics.BufferFormat
Class describing the bits per pixel, depth buffer precision, stencil precision and number of MSAA samples.
|
static class |
Graphics.DisplayMode
Describe a fullscreen display mode
|
static class |
Graphics.GraphicsType
Enumeration describing different types of
Graphics implementations. |
static class |
Graphics.Monitor
Describes a monitor
|
Modifier and Type | Method and Description |
---|---|
int |
getBackBufferHeight() |
int |
getBackBufferWidth() |
Graphics.BufferFormat |
getBufferFormat() |
float |
getDeltaTime() |
float |
getDensity()
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.
|
Graphics.DisplayMode |
getDisplayMode() |
Graphics.DisplayMode |
getDisplayMode(Graphics.Monitor monitor) |
Graphics.DisplayMode[] |
getDisplayModes() |
Graphics.DisplayMode[] |
getDisplayModes(Graphics.Monitor monitor) |
long |
getFrameId()
Returns the id of the current frame.
|
int |
getFramesPerSecond() |
GL20 |
getGL20() |
GL30 |
getGL30() |
GLVersion |
getGLVersion() |
int |
getHeight() |
Graphics.Monitor |
getMonitor() |
Graphics.Monitor[] |
getMonitors() |
float |
getPpcX() |
float |
getPpcY() |
float |
getPpiX() |
float |
getPpiY() |
Graphics.Monitor |
getPrimaryMonitor() |
float |
getRawDeltaTime() |
Graphics.GraphicsType |
getType() |
int |
getWidth() |
boolean |
isContinuousRendering() |
boolean |
isFullscreen()
Whether the app is fullscreen or not
|
boolean |
isGL30Available()
Returns whether OpenGL ES 3.0 is available.
|
Cursor |
newCursor(Pixmap pixmap,
int xHotspot,
int yHotspot)
Create a new cursor represented by the
Pixmap . |
void |
requestRendering()
Requests a new frame to be rendered if the rendering mode is non-continuous.
|
void |
setContinuousRendering(boolean isContinuous)
Sets whether to render continuously.
|
void |
setCursor(Cursor cursor)
Only viable on the lwjgl-backend and on the gwt-backend.
|
boolean |
setFullscreenMode(Graphics.DisplayMode displayMode)
Sets the window to full-screen mode.
|
void |
setGL20(GL20 gl20)
Set the GL20 instance
|
void |
setGL30(GL30 gl30)
Set the GL30 instance
|
void |
setResizable(boolean resizable)
Sets whether or not the window should be resizable.
|
void |
setSystemCursor(Cursor.SystemCursor systemCursor)
Sets one of the predefined
Cursor.SystemCursor s |
void |
setTitle(String title)
Sets the title of the window.
|
void |
setUndecorated(boolean undecorated)
Sets the window decoration as enabled or disabled.
|
void |
setVSync(boolean vsync)
Enable/Disable vsynching.
|
boolean |
setWindowedMode(int width,
int height)
Sets the window to windowed mode.
|
boolean |
supportsDisplayModeChange()
Whether the given backend supports a display mode change via calling
setFullscreenMode(DisplayMode) |
boolean |
supportsExtension(String extension) |
boolean isGL30Available()
GL30
via getGL30()
to
access OpenGL ES 3.0 functionality. Note that this functionality will only be available if you instructed the
Application
instance to use OpenGL ES 3.0!void setGL20(GL20 gl20)
void setGL30(GL30 gl30)
int getWidth()
int getHeight()
int getBackBufferWidth()
int getBackBufferHeight()
long getFrameId()
ApplicationListener.render()
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.float getDeltaTime()
float getRawDeltaTime()
int getFramesPerSecond()
Graphics.GraphicsType getType()
Graphics.GraphicsType
of this Graphics instancefloat getPpiX()
float getPpiY()
float getPpcX()
float getPpcY()
float getDensity()
boolean supportsDisplayModeChange()
setFullscreenMode(DisplayMode)
Graphics.Monitor getPrimaryMonitor()
Graphics.Monitor getMonitor()
Graphics.Monitor[] getMonitors()
Graphics.Monitor
sGraphics.DisplayMode[] getDisplayModes()
Graphics.DisplayMode
(s) of the monitor the window is onGraphics.DisplayMode[] getDisplayModes(Graphics.Monitor monitor)
Graphics.DisplayMode
s of the given Graphics.Monitor
Graphics.DisplayMode getDisplayMode()
Graphics.DisplayMode
of the monitor the window is on.Graphics.DisplayMode getDisplayMode(Graphics.Monitor monitor)
Graphics.DisplayMode
of the given Graphics.Monitor
boolean setFullscreenMode(Graphics.DisplayMode displayMode)
displayMode
- the display mode.boolean setWindowedMode(int width, int height)
width
- the width in pixelsheight
- the height in pixelsvoid setTitle(String title)
title
- the title.void setUndecorated(boolean undecorated)
undecorated
- true if the window border or status bar should be hidden. false otherwise.void setResizable(boolean resizable)
resizable
- void setVSync(boolean vsync)
vsync
- vsync enabled or not.Graphics.BufferFormat getBufferFormat()
Graphics.BufferFormat
instanceboolean supportsExtension(String extension)
extension
- the extension namevoid setContinuousRendering(boolean isContinuous)
requestRendering()
Runnable
is posted to the rendering thread via Application.postRunnable(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. ApplicationListener
. This method can be called from any
thread.isContinuous
- whether the rendering should be continuous or not.boolean isContinuousRendering()
void requestRendering()
boolean isFullscreen()
Cursor newCursor(Pixmap pixmap, int xHotspot, int yHotspot)
Pixmap
. 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 calling setCursor(Cursor)
.pixmap
- the mouse cursor image as a Pixmap
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)setCursor(Cursor)
or null if not supportedvoid setCursor(Cursor cursor)
Cursor
. It is recommended to call this function in the main render thread, and maximum one time per frame.cursor
- the mouse cursor as a Cursor
void setSystemCursor(Cursor.SystemCursor systemCursor)
Cursor.SystemCursor
sCopyright © 2017. All rights reserved.