ApplicationPhoton main class, contains functions that control creation of the display, setting the OpenGL view, input handling, timing, and State management. Application is a Singleton and therefore should be accessed through Application::getInstance(). (Application Singleton is created/destroyed automatically) Summary | Photon main class, contains functions that control creation of the display, setting the OpenGL view, input handling, timing, and State management. | | | | Default constructor, initializes the internal state & dependencies. | | Default destructor, shuts down dependencies. | | | | Runs application until a quit is requested either via the operating system (ex. | | Sets Quit flag, terminating application. | | | | | | Checks if application is active, which on most systems simply means it has focus. | | | | This function attempts to create a display with the given parameters. | | This function attempts to create a display with the given parameters. | | Sets title of application that shows up in title bar. | | Get the width of the display. | | Get the height of the display. | | | | Sets new ortho viewport within a rectangular portion of the screen. | | Sets entire screen as current viewport with a given ortho perspective. | | Sets entire screen as current viewport with a 1:1 perspective. | | | | Creates a viewport with a given 3D perspective inside of a rectangular portion of the screen. | | Sets entire screen as current viewport with a given 3D perspective. | | These functions are called by the above Ortho/Perspective functions, very rarely do they need to be called directly. | | Set the current viewport rectangle within the screen. | | Sets an orthographic projection matrix. | | Sets a perspective projection matrix. | | Toggle depth testing and clearing of depth buffer. | | | | Check if a given key is currently pressed. | | Obtain a list of all keys which are currently pressed. | | Check if a given mouse button is currently pressed. | | Gets current x location of mouse with respect to screen coordinates. | | Gets current y location of mouse with respect to screen coordinates. | | Gets current location of mouse wheel, treated as if wheel describes a third axis of movement for the mouse. | | | | Get time, in seconds, that application has been running. | | Sets number of frames used to smooth the timeDelta so that minor jitters in frramerate do not cause severe stuttering. | | Finds the amount of time passed between frames, or average of a number of frames if setFrameTimeSmoothing has been called. | | Gets number of frames per second the application is currently processing subject to smoothing by setFrameTimeSmoothing. | | Sets a fixed timestep to be used in calls to the current State’s update method. | | | | Set the current Application State, removing all other States. | | | | Pop the current State, returning to the prior State on the stack. | | | | | | |
ApplicationApplication( | const std:: | string | & | arg0 | ) |
|
Default constructor, initializes the internal state & dependencies.
~ApplicationDefault destructor, shuts down dependencies.
runRuns application until a quit is requested either via the operating system (ex. Alt-F4) or through a call to quit. Should not be called before a State has been set and a display has been created via createDisplay.
quitSets Quit flag, terminating application.
getUpdateTaskManagerutil::TaskManager& getUpdateTaskManager() |
Access the application’s update TaskManager, Tasks registered with this TaskManager are executed after the current State::update. ReturnsReference to “Update TaskManager”
getRenderTaskManagerutil::TaskManager& getRenderTaskManager() |
Access the application’s render TaskManager, Tasks registered with this TaskManager are executed after the current State::render. ReturnsReference to “Render TaskManager”
isActiveChecks if application is active, which on most systems simply means it has focus. ReturnsTrue if application is active, false otherwise.
createDisplayvoid createDisplay( | | uint | | width, | | | | | uint | | height, | | | | | uint | | redBits, | | | | | uint | | greenBits, | | | | | uint | | blueBits, | | | | | uint | | alphaBits, | | | | | uint | | depthBits, | | | | | uint | | stencilBits, | | | | | bool | | fullscreen, | | | | const std:: | string | & | title | = | "Photon App" | ) |
|
This function attempts to create a display with the given parameters. Parameterswidth | desired width of display | height | desired height of display | redBits | desired bits per pixel for red value | greenBits | desired bits per pixel for green value | blueBits | desired bits per pixel for blue value | alphaBits | desired bits per pixel for alpha value | depthBits | desired bitdepth of depth buffer | stencilBits | desired bitdepth of stencil buffer | fullscreen | true: fullscreen, false: windowed | [title | title of application, optional] |
createDisplayvoid createDisplay( | | uint | | width, | | | | | uint | | height, | | | | | uint | | bpp, | | | | | uint | | depthBits, | | | | | uint | | stencilBits, | | | | | bool | | fullscreen, | | | | const std:: | string | & | title | = | "Photon App" | ) |
|
This function attempts to create a display with the given parameters. Parameterswidth | desired width of display | height | desired height of display | bpp | desired bits per pixel (aka bitdepth) of display | depthBits | desired bitdepth of depth buffer | stencilBits | desired bitdepth of stencil buffer | fullscreen | true: fullscreen, false: windowed | [title | title of application, optional] |
setTitlevoid setTitle( | const std:: | string | & | title | ) |
|
Sets title of application that shows up in title bar. Parameterstitle | New title of application. |
getDisplayWidthGet the width of the display. ReturnsWidth of display in pixels.
getDisplayHeightGet the height of the display. ReturnsHeight of display in pixels.
setOrthoViewvoid setOrthoView( | int | x, | | int | y, | | int | viewWidth, | | int | viewHeight, | | scalar | orthoWidth, | | scalar | orthoHeight | ) |
|
Sets new ortho viewport within a rectangular portion of the screen. All drawing is relative to the rectangle, x,y becomes 0,0 and anything drawn outside rect is clipped. Parametersx | X coord for top left corner of new viewport. | y | Y coord for top left corner of new viewport. | viewWidth | Width of new viewport. | viewHeight | Height of new viewport. | orthoWidth | Width of ortho perspective. | orthoHeight | Height of ortho perspective. |
setOrthoViewvoid setOrthoView( | scalar | width, | | scalar | height | ) |
|
Sets entire screen as current viewport with a given ortho perspective. Parameterswidth | Width of view. | height | Height of view. |
setOrthoViewSets entire screen as current viewport with a 1:1 perspective.
setPerspectiveViewvoid setPerspectiveView( | int | x, | | int | y, | | int | width, | | int | height, | | scalar | fovy, | | scalar | zNear, | | scalar | zFar | ) |
|
Creates a viewport with a given 3D perspective inside of a rectangular portion of the screen. Note that <setDepthTestMode>(true) will be called as a side effect. Parametersx | X coord for top left corner of new viewport. | y | Y coord for top left corner of new viewport. | width | Width of new viewport. | height | Height of new viewport. | fovy | The y axis field of view angle, in degrees. | zNear | Distance from viewer to near clipping plane. | zFar | Distance from viewer to far clipping plane. |
setPerspectiveViewvoid setPerspectiveView( | scalar | fovy, | | scalar | zNear, | | scalar | zFar | ) |
|
Sets entire screen as current viewport with a given 3D perspective. Note that <setDepthTestMode>(true) will be called as a side effect. Parametersfovy | The y axis field of view angle, in degrees. | zNear | Distance from viewer to near clipping plane. | zFar | Distance from viewer to far clipping plane. |
Viewport/ ProjectionThese functions are called by the above Ortho/Perspective functions, very rarely do they need to be called directly.
setViewportvoid setViewport( | int | x, | | int | y, | | int | width, | | int | height | ) |
|
Set the current viewport rectangle within the screen.
setOrthoProjectionvoid setOrthoProjection( | scalar | width, | | scalar | height | ) |
|
Sets an orthographic projection matrix. Parameterswidth | Width of view. | height | Height of view. |
setPerspectiveProjectionvoid setPerspectiveProjection( | scalar | fovy, | | scalar | zNear, | | scalar | zFar | ) |
|
Sets a perspective projection matrix. Note that <setDepthTestMode>(true) will be called as a side effect. Parametersfovy | The y axis field of view angle, in degrees. | zNear | Distance from viewer to near clipping plane. | zFar | Distance from viewer to far clipping plane. |
setDepthBufferParamsvoid setDepthBufferParams( | bool | enable, | | | | scalar | depth | = | 1 | ) |
|
Toggle depth testing and clearing of depth buffer. Parametersenable | if true, testing/clearing depth buffer is enabled, if false testing and clearing of depth buffer will be disabled. | depth | optional clear depth amount, clamped [0..1], default is 1 |
keyPressedbool keyPressed( | KeyCode | key | ) |
|
Check if a given key is currently pressed. Parameterskey | KeyCode of key to determine status of. |
Returnstrue: key is pressed, false: key isn’t pressed
getPressedKeysstd::vector<KeyCode> getPressedKeys() |
Obtain a list of all keys which are currently pressed. Returnsstd::vector of KeyCodes of any pressed keys.
mouseButtonPressedbool mouseButtonPressed( | MouseButton | button | ) |
|
Check if a given mouse button is currently pressed. ParametersReturnstrue: button is pressed, false: button isn’t pressed
getMouseXGets current x location of mouse with respect to screen coordinates. ReturnsMouse x-coordinate, with respect to screen coordinates.
getMouseYGets current y location of mouse with respect to screen coordinates. ReturnsMouse y-coordinate, with respect to screen coordinates.
getMouseWheelPosGets current location of mouse wheel, treated as if wheel describes a third axis of movement for the mouse. ReturnsMouse wheel position, zero assumed to be starting position.
getTimeGet time, in seconds, that application has been running. ReturnsTime, represented as a floating-point number in seconds, application has been running.
setFrameTimeSmoothingvoid setFrameTimeSmoothing( | int | numFrames | ) |
|
Sets number of frames used to smooth the timeDelta so that minor jitters in frramerate do not cause severe stuttering. ParametersnumFrames | Number of frames to average, setting to <= 1 turns off smoothing of timeDelta. (Recommend something >= 50, <= 500) |
getElapsedTimeFinds the amount of time passed between frames, or average of a number of frames if setFrameTimeSmoothing has been called. ReturnsTime (or average time) between frames.
getFramerateGets number of frames per second the application is currently processing subject to smoothing by setFrameTimeSmoothing. ReturnsCalculated number of frames per second.
setFixedUpdateStepvoid setFixedUpdateStep( | bool | enable, | | | scalar | fixedStep, | | | scalar | maxStep | = | ) |
|
Sets a fixed timestep to be used in calls to the current State’s update method. This allows stability in physics systems. Parametersenable | if true, will enable fixed timestepping (if false will disable) | fixedStep | the timestep to use for the fixed step, ignored if disabling | maxStep | if somehow the update portion get signifigantly behind the render portion, to avoid executing a large number of steps (hanging the program) an optional maxStep can be specified. [default = 5*fixedStep] |
setStatetemplate<class StateT> void setState() |
Set the current Application State, removing all other States. Template ParametersStateT | Class derived from State to set as current. |
pushStatetemplate<class StateT> void pushState() |
Push a new State, does not remove old State. Template ParametersStateT | Class derived from State to push. |
popStatePop the current State, returning to the prior State on the stack.
initAudioCorevoid initAudioCore( | const std:: | string | & | deviceName | = | "" | ) |
|
Initialize the AudioCore, should be done before attempting to access it via getAudioCore. ArgumentsdeviceName | Optional name for desired Audio device, will use default device if none specified. |
|