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. |
Modifier and Type | Method and Description |
---|---|
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 |
getDesktopDisplayMode() |
Graphics.DisplayMode[] |
getDisplayModes() |
long |
getFrameId()
Returns the id of the current frame.
|
int |
getFramesPerSecond() |
GL20 |
getGL20() |
GL30 |
getGL30() |
int |
getHeight() |
float |
getPpcX() |
float |
getPpcY() |
float |
getPpiX() |
float |
getPpiY() |
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 |
setDisplayMode(Graphics.DisplayMode displayMode)
Sets the current
Graphics.DisplayMode . |
boolean |
setDisplayMode(int width,
int height,
boolean fullscreen)
Tries to set the display mode width the given width and height in pixels.
|
void |
setTitle(String title)
Sets the title of the window.
|
void |
setVSync(boolean vsync)
Enable/Disable vsynching.
|
boolean |
supportsDisplayModeChange()
Whether the given backend supports a display mode change via calling
setDisplayMode(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!int getWidth()
int getHeight()
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()
setDisplayMode(DisplayMode)
Graphics.DisplayMode[] getDisplayModes()
Graphics.DisplayMode
(s).Graphics.DisplayMode getDesktopDisplayMode()
boolean setDisplayMode(Graphics.DisplayMode displayMode)
Graphics.DisplayMode
. Returns false in case the operation failed. Not all backends support this method. See
supportsDisplayModeChange()
.displayMode
- the display mode.boolean setDisplayMode(int width, int height, boolean fullscreen)
getDisplayModes()
to get a list of
supported fullscreen modes.width
- the width in pixelsheight
- the height in pixelsfullscreen
- whether to use fullscreen rendering or notvoid setTitle(String title)
title
- the title.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)
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 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
. To revert to the default operating system cursor,
pass in a null 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
, or null to revert to the default operating
system cursorCopyright © 2015. All rights reserved.