Used to create and track ports (GUI Only) More...
Public Member Functions | |
| closeGraphicsPort (Port port=MAIN_PORT) | |
| close given port, along with its window and restore screen mode if changed  More... | |
| Font | createFont (string fontName, number scalingFactor=1.0) | 
| get a font with optional scaling adjust  More... | |
| Port | createFullScreenPort (Rect rect, int screenNum=PRIMARY_SCREEN, boolean allowResChange=true, int bpp=0) | 
| create full screen drawing port with given dimensions on given screen, optionally changing depth  More... | |
| Port | createWindowPort (Rect rect, string windName="", int bpp=0) | 
| create windowed drawing port with given dimensions, title and depth  More... | |
| object | getCurrentScreenMode (int screenNum=PRIMARY_SCREEN) | 
| get width, height, depth and maxWindowRect for specified screen  More... | |
| number | getFPS () | 
| get current frame rate  More... | |
| Port | getMainPort () | 
| return the primary graphics port  More... | |
| Point | getMouse (int mouseNumber=0) | 
| get mouse position  More... | |
| object | getNthSupportedScreenMode (int n, int screenNum=PRIMARY_SCREEN) | 
| get the details of the Nth screen mode from the supported ones for a screen  More... | |
| number | getNumScreens () | 
| get the total number of display screens available  More... | |
| number | getNumSupportedScreenModes (int screen=PRIMARY_SCREEN) | 
| get the total number of display modes available for a screen  More... | |
| number | getTargetFPS () | 
| get the intended frame rate  More... | |
| boolean | inFullScreenMode () | 
| return whether primary graphics port is fullscreen or not  More... | |
| setScreenMode (int width, int height, int screenNum=PRIMARY_SCREEN, int bpp=0) | |
| changes specified screen to closest matching mode  More... | |
| GraphicsManager | setTargetFPS (number inTargetFPS) | 
| set the frames per second you would like the graphics system to display  More... | |
| boolean | switchToFullScreenMode (boolean allowResChange=false, Port port=MAIN_PORT) | 
| switch a port to full screen  More... | |
| boolean | switchToWindowMode (Port port=MAIN_PORT, string windName="") | 
| switch a port to be in a window  More... | |
Related Functions | |
(Note that these are not member functions.)  | |
| getGraphicsManager | |
| get the singleton instance of the GraphicsManager used by the pdg framework  More... | |
| gfx | |
| the singleton instance of the GraphicsManager  More... | |
Used to create and track ports (GUI Only)
There are 3 primary ways to deal with fullscreen:
Use createWindowPort() to create a window. The window will be movable and resizable, and you'll get eventType_PortResize events if it is resized by the user.
The Graphics system has the concept of a target display rate in frames per second, which is used to limit the frame rate, particularly important on mobile devices. This is independent of the animation and physics system. See getFPS(), getTargetFPS() and setTargetFPS().
| closeGraphicsPort | ( | Port | port = MAIN_PORT | ) | 
close given port, along with its window and restore screen mode if changed
| port | the port to close, default to the main port if none passed | 
| createFont | ( | string | fontName, | 
| number | scalingFactor = 1.0  | 
        ||
| ) | 
| createFullScreenPort | ( | Rect | rect, | 
| int | screenNum = PRIMARY_SCREEN,  | 
        ||
| boolean | allowResChange = true,  | 
        ||
| int | bpp = 0  | 
        ||
| ) | 
create full screen drawing port with given dimensions on given screen, optionally changing depth
Unless allowResChange is passed as false, the monitor resolution will be changed to match the closest allowable screen size for the given dimension. If no other port is open, this becomes the main port.
If no is screen specified, the primary screen will be used. If no depth is specified, the current depth of the specified screen will be used.
| rect | the dimensions of the drawing area | 
| screenNum | which screen to work with (optional) | 
| allowResChange | pass false to prevent monitor resolution from changing (optional) | 
| bpp | the depth of the drawing buffer in bits per pixel (optional) | 
| createWindowPort | ( | Rect | rect, | 
| string | windName = "",  | 
        ||
| int | bpp = 0  | 
        ||
| ) | 
create windowed drawing port with given dimensions, title and depth
Matches the depth of the screen if depth not given. If no other port is open, this becomes the main port.
| rect | the visible area of the window in screen coordinates | 
| windName | the window title (optional) | 
| bpp | the depth of the drawing buffer in bits per pixel (optional) | 
| getCurrentScreenMode | ( | int | screenNum = PRIMARY_SCREEN | ) | 
get width, height, depth and maxWindowRect for specified screen
| screenNum | the number of the screen, defaults to the primary screen if no screen number given | 
| getFPS | ( | ) | 
get current frame rate
gets the current frame rate in frames per second that the rendering engine is producing. This should always be at or slightly below the target FPS.
| getMainPort | ( | ) | 
return the primary graphics port
| getMouse | ( | int | mouseNumber = 0 | ) | 
get mouse position
Gets the screen location of the given mouse or finger touch. For touch devices the number represents the order the fingers went down rather than specific numbered devices.
| mouseNumber | the particular mouse; defaults to zero, the primary mouse or first touch | 
| getNthSupportedScreenMode | ( | int | n, | 
| int | screenNum = PRIMARY_SCREEN  | 
        ||
| ) | 
get the details of the Nth screen mode from the supported ones for a screen
| n | the index into the list of supported screen modes, from 0 to number of support modes − 1 | 
| screenNum | the screen you are interested in, defaults to the primary screen if not passed | 
Example**
PDG terminal v0.9.4 > pdg.gfx.getNthSupportedScreenMode(1); { width: 1440, height: 900, depth: 16 }
| getNumScreens | ( | ) | 
get the total number of display screens available
| getNumSupportedScreenModes | ( | int | screen = PRIMARY_SCREEN | ) | 
get the total number of display modes available for a screen
| screen | the screen number, defaults to the primary screen if not passed | 
| getTargetFPS | ( | ) | 
get the intended frame rate
| inFullScreenMode | ( | ) | 
return whether primary graphics port is fullscreen or not
| setScreenMode | ( | int | width, | 
| int | height, | ||
| int | screenNum = PRIMARY_SCREEN,  | 
        ||
| int | bpp = 0  | 
        ||
| ) | 
changes specified screen to closest matching mode
| width | the desired width in pixels | 
| height | the desired height in pixels | 
| screenNum | the screen to change, defaults to the primary screen if not passed | 
| bpp | the screen depth in bits per pixel, uses current screen depth if not passed | 
| setTargetFPS | ( | number | inTargetFPS | ) | 
set the frames per second you would like the graphics system to display
The graphics system will attempt to display that many frames per second on most systems. It will issue warnings in the logs if the frame rate falls below 80% of that rate.
Animations, Sprite movement, Network and other kinds of Events work independently of the display timer, so this will not affect collision detection even at lower frame rates.
| inTargetFPS | the desired frame rate in Frames Per Second | 
| switchToFullScreenMode | ( | boolean | allowResChange = false,  | 
        
| Port | port = MAIN_PORT  | 
        ||
| ) | 
switch a port to full screen
| allowResChange | if true, the monitor resolution will be changed to match the window size; defaults to false | 
| port | the port to change, defaults to the main port if not passed | 
| switchToWindowMode | ( | Port | port = MAIN_PORT,  | 
        
| string | windName = ""  | 
        ||
| ) | 
switch a port to be in a window
If the monitor resolution was changed to go into full screen, it will be changed back to it's original value
| port | the port to change, defaults to the main port if not passed | 
| windName | the name to give the window (optional) | 
      
  | 
  related | 
get the singleton instance of the GraphicsManager used by the pdg framework
 and a whole mess of custom scripts.