com.badlogic.gdx
Interface Graphics


public interface Graphics

This interface encapsulates communication with the graphics processor. Depending on the available hardware and the current Application configuration, access to the GL10, GL11, GL20, and/or GLCommon 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, SpriteBatch 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.

Author:
mzechner

Nested Class Summary
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.
 
Method Summary
 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()
           
 int getFramesPerSecond()
           
 GL10 getGL10()
           
 GL11 getGL11()
           
 GL20 getGL20()
           
 GLCommon getGLCommon()
           
 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 isGL11Available()
          Returns whether OpenGL ES 1.1 is available.
 boolean isGL20Available()
          Returns whether OpenGL ES 2.0 is available.
 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.
 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)
           
 

Method Detail

isGL11Available

boolean isGL11Available()
Returns whether OpenGL ES 1.1 is available. If it is you can get an instance of GL11 via getGL11() to access OpenGL ES 1.1 functionality. This also implies that getGL10() will return an instance.

Returns:
whether OpenGL ES 1.1 is available

isGL20Available

boolean isGL20Available()
Returns whether OpenGL ES 2.0 is available. If it is you can get an instance of GL20 via getGL20() to access OpenGL ES 2.0 functionality. Note that this functionality will only be available if you instructed the Application instance to use OpenGL ES 2.0!

Returns:
whether OpenGL ES 2.0 is available

getGLCommon

GLCommon getGLCommon()
Returns:
a GLCommon instance

getGL10

GL10 getGL10()
Returns:
the GL10 instance or null if not supported

getGL11

GL11 getGL11()
Returns:
the GL11 instance or null if not supported

getGL20

GL20 getGL20()
Returns:
the GL20 instance or null if not supported

getWidth

int getWidth()
Returns:
the width in pixels of the display surface

getHeight

int getHeight()
Returns:
the height in pixels of the display surface

getDeltaTime

float getDeltaTime()
Returns:
the time span between the current frame and the last frame in seconds. Might be smoothed over n frames.

getRawDeltaTime

float getRawDeltaTime()
Returns:
the time span between the current frame and the last frame in seconds, without smoothing

getFramesPerSecond

int getFramesPerSecond()
Returns:
the average number of frames per second

getType

Graphics.GraphicsType getType()
Returns:
the Graphics.GraphicsType of this Graphics instance

getPpiX

float getPpiX()
Returns:
the pixels per inch on the x-axis

getPpiY

float getPpiY()
Returns:
the pixels per inch on the y-axis

getPpcX

float getPpcX()
Returns:
the pixels per centimeter on the x-axis

getPpcY

float getPpcY()
Returns:
the pixels per centimeter on the y-axis.

getDensity

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. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc.

Returns:
the logical density of the Display.

supportsDisplayModeChange

boolean supportsDisplayModeChange()
Whether the given backend supports a display mode change via calling setDisplayMode(DisplayMode)

Returns:
whether display mode changes are supported or not.

getDisplayModes

Graphics.DisplayMode[] getDisplayModes()
Returns:
the supported fullscreen Graphics.DisplayMode(s).

getDesktopDisplayMode

Graphics.DisplayMode getDesktopDisplayMode()
Returns:
the display mode of the primary graphics adapter.

setDisplayMode

boolean setDisplayMode(Graphics.DisplayMode displayMode)
Sets the current Graphics.DisplayMode. Returns false in case the operation failed. Not all backends support this method. See supportsDisplayModeChange().

Parameters:
displayMode - the display mode.
Returns:
whether the operation succeeded.

setDisplayMode

boolean setDisplayMode(int width,
                       int height,
                       boolean fullscreen)
Tries to set the display mode width the given width and height in pixels. Will always succeed if fullscreen is set to false, in which case the application will be run in windowed mode. Use getDisplayModes() to get a list of supported fullscreen modes.

Parameters:
width - the width in pixels
height - the height in pixels
fullscreen - whether to use fullscreen rendering or not

setTitle

void setTitle(String title)
Sets the title of the window. Ignored on Android.

Parameters:
title - the title.

setVSync

void setVSync(boolean vsync)
Enable/Disable vsynching. This is a best-effort attempt which might not work on all platforms.

Parameters:
vsync - vsync enabled or not.

getBufferFormat

Graphics.BufferFormat getBufferFormat()
Returns:
the format of the color, depth and stencil buffer in a Graphics.BufferFormat instance

supportsExtension

boolean supportsExtension(String extension)
Parameters:
extension - the extension name
Returns:
whether the extension is supported

setContinuousRendering

void setContinuousRendering(boolean isContinuous)
Sets whether to render continuously. In case rendering is performed non-continuously, the following events will trigger a redraw: Life-cycle events will also be reported as usual, see ApplicationListener. This method can be called from any thread.

Parameters:
isContinuous - whether the rendering should be continuous or not.

isContinuousRendering

boolean isContinuousRendering()
Returns:
whether rendering is continuous.

requestRendering

void requestRendering()
Requests a new frame to be rendered if the rendering mode is non-continuous. This method can be called from any thread.


isFullscreen

boolean isFullscreen()
Whether the app is fullscreen or not



Copyright © 2013. All Rights Reserved.