Base interface for interactive real-time applications that are run by an ApplicationLoop.
interface
|
IApplication
|
extends
|
IConfigurable
|
||
IDisposable
|
|||||
IInputConsumer
|
|||||
IInputState
|
|||||
IRenderable
|
|||||
IUpdateableFrameTime
|
|||||
base of
|
ApplicationBase
|
The following methods will never be called from more than one thread at a time.
Optional limit for rendering frames.
property
|
FrameRateLimit
{
get
}
|
||
type
|
int32
|
||
value
|
|
The
frame
rate
limit,
in
Hz.
If
0
the
limit
will
be
disabled. |
Remarks:
Defaults
to
100
.
Returns the lifecycle state of this object.
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
ILifecycleState.LifecycleState
|
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
IDisposable.AcquireTry
|
Remarks:
The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.
This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.
Consumes the given user input event.
method
|
ConsumeInput
(InputEvent inputEvent)
|
||
type
|
bool
|
||
params
|
inputEvent
|
The user input event. | |
returns
|
true
if
the
input
event
has
been
consumed,
false
if
not. |
||
inherited
|
IInputConsumer.ConsumeInput
|
Remarks:
Input events are provided to an IInputConsumer object only if it has the input focus (see FocusGained and FocusLost). Mouse events are provided when the mouse cursor is inside of the input bounds (MouseEnter and MouseLeave). The Closing event can be provided at any time.
Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.
[Dispose, OwnerThis, ThreadSafe]
|
||||
method
|
Dispose
()
|
|||
inherited
|
IDisposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Attaches the application to its graphics context.
method
|
GraphicsContextAttach
(IGraphicsContext context)
|
||
params
|
context
|
[not-null]
|
The graphics context. |
Detaches the application from its graphics context.
method
|
GraphicsContextDetach
()
|
Is the given keyboard key pressed down?
[Pure]
|
||||
method
|
IsDown
(KeyboardKey key)
|
|||
type
|
bool
|
|||
params
|
key
|
The keyboard key. | ||
returns
|
true
if
the
key
is
pressed
down,
false
if
not. |
|||
inherited
|
IInputState.IsDown
|
Is the given mouse button pressed down?
[Pure]
|
||||
method
|
IsDown
(MouseButton button)
|
|||
type
|
bool
|
|||
params
|
button
|
The mouse button. | ||
returns
|
true
if
the
button
is
pressed
down,
false
if
not. |
|||
inherited
|
IInputState.IsDown
|
Performs rendering.
method
|
Render
()
|
||
inherited
|
IRenderable.Render
|
Remarks:
Implementing methods must not assume that any specific render state is in place when being called. Instead, the implementing method is responsible for setting up all state that is required for rendering.
Usually, implementing classes receive their current graphics context directly or indirectly from GraphicsContextAttach or GraphicsAttach.
In order to maximize parallelism between the CPU and GPU, only actual rendering (using the current graphics context) should be performed here. All other preparation resp. setup should be done in RenderPrepare instead.
See also:
GraphicsContextAttachPrepares rendering.
method
|
RenderPrepare
()
|
||
inherited
|
IRenderPreparable.RenderPrepare
|
Remarks:
This method is called before Render, when the graphics context has not yet begun to render the scene.
All setup work that does not require a graphics context (e.g. matrix computation, per-frame visibility determination) should be done here. This can help to maximize parallelism between the CPU and the GPU.
Runs the given operation within the lifecycle of this application.
method
|
RunOperation
([Owner]
IOperation operation)
|
||
type
|
RunningOperation
|
||
params
|
operation
|
[not-null]
|
The operation to run. |
returns
|
|
The running operation. |
Remarks:
The Update method is called from within the applications UpdateFrameTime method.
The returned RunningOperation can be used to track progress resp. errors and to cancel the running operation.
When the application is disposed, all running operations are canceled (see Cancel) and then disposed.
Provides runtime performance statistics to the application.
method
|
Statistics
(ApplicationStats stats)
|
||
params
|
stats
|
The performance statistic values. |
Remarks:
This information is gathered by the application loop which is running the application.
Calling this method is optional. Implementations of IApplication must never depend on the availability of ApplicationStats values.
Returns the configuration value that describes this object.
method
|
ToConfig
()
|
||
type
|
ConfigValue
|
||
returns
|
|
The configuration value. | |
inherited
|
IConfigurable.ToConfig
|
Remarks:
All configurable objects need to implement this interface. For simple types, it is preferable to delegate to ToValue.
The returned value may be of type Invalid, which means that this object in its current state cannot be described with the configuration API.
Before returning the resulting configuration value, Cache must be called on it, passing this IConfigurable object as parameter.
This method is called once per application frame.
method
|
UpdateFrameTime
(float32 time)
|
||
type
|
bool
|
||
params
|
time
|
[>0]
|
The amount of time that has elapsed since the last frame, in seconds. |
returns
|
true
if
the
object
needs
to
be
presented
again,
false
if
the
current
presentation
is
still
valid.
|
||
inherited
|
IUpdateableFrameTime.UpdateFrameTime
|
Attaches the application to its window.
method
|
WindowAttach
(IApplicationWindow window)
|
||
params
|
window
|
[not-null]
|
The application window. |
Remarks:
This is always the first callback that the application receives.
Informs the application about the client size of its window.
method
|
WindowSize
(Vec2I clientSize)
|
||
params
|
clientSize
|
The client size of the application window. |
Runs this application.
[OwnerThis]
|
||||
method
|
Run
(string source,
IGraphicsContextFactory context,
[Owner]
IApplicationWindow window)
|
|||
type
|
TinmanError
|
|||
params
|
source
|
[not-empty]
|
The error source to use in case an exception is thrown. | |
context
|
[not-null]
|
The graphics context factory to use. | ||
window
|
[not-null]
|
The application window to use. | ||
returns
|
The
error
in
case
of
a
crash,
null
if
the
application
has
ended
normally.
|
Runs this application.
[OwnerThis]
|
||||
method
|
Run
(string source,
IVectorConst<IGraphicsContextFactory> contexts,
[Owner]
IApplicationWindow window)
|
|||
type
|
TinmanError
|
|||
params
|
source
|
[not-empty]
|
The error source to use in case an exception is thrown. | |
contexts
|
[not-empty]
|
The graphics context factories to use. | ||
window
|
[not-null]
|
The application window to use. | ||
returns
|
The
error
in
case
of
a
crash,
null
if
the
application
has
ended
normally.
|
Runs this application.
[OwnerThis]
|
||||
method
|
Run
(string source,
IGraphicsContextFactory context,
string windowTitle = null,
Vec2I windowSize = default(Vec2I))
|
|||
type
|
TinmanError
|
|||
params
|
source
|
[not-empty]
|
The error source to use in case an exception is thrown. | |
context
|
[not-null]
|
The graphics context factory to use. | ||
windowTitle
|
The window title. | |||
windowSize
|
The window size. If zero, a full-screen window will be created. | |||
returns
|
The
error
in
case
of
a
crash,
null
if
the
application
has
ended
normally.
|
Runs this application.
[OwnerThis]
|
||||
method
|
Run
(string source,
IVectorConst<IGraphicsContextFactory> contexts,
string windowTitle = null,
Vec2I windowSize = default(Vec2I))
|
|||
type
|
TinmanError
|
|||
params
|
source
|
[not-empty]
|
The error source to use in case an exception is thrown. | |
contexts
|
[not-empty]
|
The graphics context factories to use. | ||
windowTitle
|
The window title. | |||
windowSize
|
The window size. If zero, a full-screen window will be created. | |||
returns
|
The
error
in
case
of
a
crash,
null
if
the
application
has
ended
normally.
|