This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

engine.app Functions

This class contains functions to control the Unigine application graphic context, which includes:

  • Update parameters.
  • Events of the controls (keyboard, mouse).
  • FPS.
  • Window parameters (height, width, name, etc.).

App Class

Members


int engine.app.isActive()

Returns the value indicating if the current application is active.
Notice
The sounds will be automatically disabled, if the application is not active.

Return value

1 if application is active; otherwise - 0.

void engine.app.setButtonPressFunc(int ( * func)(int button) )

Application event which is called on button press. The engine will stop event processing if the event function Returns 1.

Arguments

  • int ( * func)(int button) - Event function pointer.

void engine.app.setButtonReleaseFunc(int ( * func)(int button) )

Application event which is called on button release. The engine will stop event processing if the event function Returns 1.

Arguments

  • int ( * func)(int button) - Event function pointer.

void engine.app.setClipboard(string str)

Updates the contents of the system clipboard.

Arguments

  • string str - Contents to set.

string engine.app.getClipboard()

Retrieves the contents of the system clipboard.

Return value

Contents of the system clipboard.

void * engine.app.getD3D11Context()

Returns a pointer to the existing ID3D11DeviceContext interface.

void * engine.app.getD3D11Device()

Returns a pointer to the existing ID3D11Device interface.

int engine.app.isD3D11Initialized()

Returns the status of the Direct3D11 render.

Return value

1 if the render is initialized; otherwise, 0.

int engine.app.isDone()

Returns a value indicating if the application is closed.

Return value

1 if the application is closed; otherwise, 0.

void engine.app.setFilter(float filter)

Filters the FPS counter value. By the value of 0, filtering is disabled and the current FPS value is always shown. The default is 0.9 (10 percent of the current FPS is taken into account).

Arguments

  • float filter - Filter in range [0;1).

int engine.app.getFlags()

Returns the current video mode flags.

Return value

Video mode flags: DESTROY, RESIZABLE, FULSCREEN, etc. For full list of available flags see App:: Enumeration at the end of the article.

float engine.app.getFps()

Returns a value of the application FPS counter.

Return value

FPS counter value.

float engine.app.getFTime()

Returns time spent between a previous update and a current one.

Return value

Frame duration.

int engine.app.setGamma(float gamma)

Sets the gamma correction value.

Arguments

  • float gamma - Gamma correction value. If the 1.0f value is provided, no gamma correction is applied.

Return value

1 if the gamma correction value is set successfully; otherwise, 0.

int engine.app.isGLInitialized()

Returns the status of the OpenGL renderer.

Return value

1 if the OpenGL render is initialized; otherwise, 0.

void * engine.app.getHandle()

Returns a pointer to the application handle.

Return value

Pointer to the application handle.

void engine.app.setHeight(int value)

Sets the new application window height.

Arguments

  • int value - Application window height, in pixels.

int engine.app.getHeight()

Returns the current application window height.

Return value

Current application window height, in pixels.

float engine.app.getIFps()

Returns an inverse value of the application FPS counter.

Return value

Inverse value of the application FPS counter (1/FPS).

string engine.app.getKeyName(int key)

Returns a name of a given key.

Arguments

  • int key - Key in one of the following formats:
    • Character format (for example, 'a')
    • Standard ASCII key code (for example, 97)
    • One of APP_KEY_* variables

Return value

Key name.

void engine.app.setKeyPressFunc(int ( * func)(unsigned int key) )

Application event which is called on key press. The engine will stop event processing if the event function returns 1.

Arguments

  • int ( * func)(unsigned int key) - Event function pointer.

void engine.app.setKeyPressUnicodeFunc(int ( * func)(unsigned int key) )

Application event which is called on unicode key press. The engine will stop event processing if the event function returns 1.

Arguments

  • int ( * func)(unsigned int key) - Event function pointer.

void engine.app.setKeyReleaseFunc(int ( * func)(unsigned int key) )

Application event which is called on key release. The engine will stop event processing if the event function returns 1.

Arguments

  • int ( * func)(unsigned int key) - Event function pointer.

void engine.app.setKeyState(int key, int state)

Simulates pressing or unpressing of the specified keys.

Arguments

  • int key - Keys to change state (any of APP_KEY_* variables).
  • int state - 1 to press the key; 0 otherwise.

int engine.app.getKeyState(int key)

Returns the keyboard key state.

Arguments

  • int key - Key in one of the following formats:
    • Character format (for example, 'a')
    • Standard ASCII key code (for example, 97)
    • One of APP_KEY_* variables

Return value

1 if the key is pressed; otherwise, 0.

void engine.app.setMouse(int x, int y)

Sets the mouse pointer to a specified position in the coordinate system of the application window.

Arguments

  • int x - X coordinate of the mouse pointer.
  • int y - Y coordinate of the mouse pointer.

void engine.app.setMouseAxis(int axis, int value)

Sets the mouse position delta along the specified axis.

Arguments

  • int axis - Mouse axis. Possible values are APP_AXIS_X, APP_AXIS_Y.
  • int value - Mouse axis delta, integer value.

int engine.app.getMouseAxis(int axis)

Returns the current mouse position delta along the specified axis.

Arguments

Return value

Mouse axis delta regarding the last mouse axis position, integer value.

void engine.app.setMouseButton(int arg1)

Simulates pressing of the specified mouse buttons.

Arguments

  • int arg1 - Mouse buttons to be pressed (any of APP_BUTTON_* variables).

int engine.app.getMouseButton()

Returns the current states of all mouse buttons. Each bit of the returned bit mask will specify the state of the buttons in the following order:
  1. APP_BUTTON_LEFT = 1 << 0
  2. APP_BUTTON_MIDDLE
  3. APP_BUTTON_RIGHT
  4. APP_BUTTON_DCLICK
  5. APP_BUTTON_AUX_0
  6. APP_BUTTON_AUX_1
  7. APP_BUTTON_AUX_2
  8. APP_BUTTON_AUX_3

Return value

Current states of all mouse buttons.

string engine.app.getMouseButtonName(int button)

Returns a name of a given button.

Arguments

Return value

Button name.

int engine.app.getMouseButtonState(int button)

Returns a button state.

Arguments

Return value

1 if at least one of the buttons is pressed; otherwise, 0.

void engine.app.setMouseGrab(int arg1)

Sets a value indicating if the mouse pointer is bound to the application window.

Arguments

  • int arg1 - Positive integer if the mouse pointer cannot leave the application window; otherwise, 0.

int engine.app.getMouseGrab()

Returns a value indicating if the mouse pointer is bound to the application window.

Return value

1 if the mouse pointer cannot leave the application window; otherwise, 0.

void engine.app.setMouseShow(int arg1)

Sets a value indicating if the OS mouse pointer should be displayed.

Arguments

  • int arg1 - Positive integer if the OS mouse pointer should be displayed; otherwise, 0.

int engine.app.getMouseShow()

Returns a value indicating if the OS mouse pointer is displayed.

Return value

1 if the OS mouse pointer is displayed; otherwise, 0.

int engine.app.getMouseX()

Returns the current X coordinate of the mouse pointer in the coordinate system of the application window.

Return value

X coordinate of the mouse pointer.

int engine.app.getMouseY()

Returns the current Y coordinate of the mouse pointer in the coordinate system of the application window.

Return value

Y coordinate of the mouse pointer.

string engine.app.getName()

Returns a name of the graphics API used for application rendering.

Return value

Returns "opengl" for OpenGL, "opengles" for OpenGL ES, "direct3d11" for DirectX 11 or NULL if no graphics API is used for application rendering.

int engine.app.isNULLInitialized()

Returns a value indicating whether the NULL renderer is initialized.

Return value

1 is the renderer is initialized; otherwise, 0.

int engine.app.getNumTouches()

Returns the number of touches. The maximum number of touches is 16.

Return value

Number of touches.

int engine.app.setPosition(int x, int y)

Sets the window position.

Arguments

  • int x - X coordinate of the upper-left corner of the window.
  • int y - Y coordinate of the upper-left corner of the window.

Return value

1 if the position of the window is set successfully; otherwise, 0.

int engine.app.getPositionX()

Returns the X coordinate of the upper-left corner of the window.

Return value

X coordinate of the upper-left corner.

int engine.app.getPositionY()

Returns the Y coordinate of the upper-left corner of the window.

Return value

Y coordinate of the upper-left corner.

int engine.app.setTitle(string title)

Sets a title for the application window.

Arguments

  • string title - Title to set.

Return value

1 if the title is set successfully; otherwise, 0.

int engine.app.getTouchX(int touch)

Returns the X coordinate of the touch in the coordinate system of the application window.

Arguments

  • int touch - Number of the touch.

Return value

X coordinate of the touch.

int engine.app.getTouchY(int touch)

Returns the Y coordinate of the touch in the coordinate system of the application window.

Arguments

  • int touch - Number of the touch.

Return value

Y coordinate of the touch.

int engine.app.setUpdate(int update)

Sets the value indicating whether the application is updated when the window is hidden.

Arguments

  • int update - Positive integer if the application should update if the window is hidden; otherwise, 0.

Return value

1 if the window update mode is set successfully; otherwise, 0.

int engine.app.getUpdate()

Returns the current window update mode (i.e. a value indicating whether the application is updated when the window is hidden).

Return value

1 if the update cycle is constantly repeated; otherwise, 0.

int engine.app.setVideoMode(int width, int height, int flags = 0, int refresh = 0)

Sets a video mode and initializes application.

Arguments

  • int width - Video width in pixels.
  • int height - Video height in pixels.
  • int flags - Video mode flags: DESTROY, RESIZABLE, FULLSCREEN, etc.
  • int refresh - Force refresh rate in Hz; if 0 is provided, default refresh rate is used.

Return value

1 if the video mode is set successfully and the application is also initialized successfully; otherwise, 0.

string engine.app.getVideoModeName()

Returns the name of the current video mode.

Return value

Returns the name of the current video mode.

void engine.app.setWidth(int value)

Sets the new width of the application window.

Arguments

  • int value - Window width, in pixels.

int engine.app.getWidth()

Returns the current application window width.

Return value

Window width, in pixels.

void engine.app.buttonPress(int button)

Application notifies the engine that a mouse button is pressed.

Arguments

  • int button - Button ID. Possible values are BUTTON_LEFT, BUTTON_RIGHT, etc. For full list of the values see App:: Enumeration at the end of the article.

void engine.app.buttonRelease(int button)

Application notifies the engine that a mouse button is released.

Arguments

  • int button - Button ID. Possible values are BUTTON_LEFT, BUTTON_RIGHT, etc. For full list of the values see App:: Enumeration at the end of the article.

int engine.app.clearKeyState(int key)

Returns a key state and clears it to 0 (not pressed). This function allows to return key state only once even if it is kept pressed over several frames.

Arguments

  • int key - Key in one of the following formats:
    • Character format (for example, 'a')
    • Standard ASCII key code (for example, 97)
    • One of APP_KEY_* variables

Return value

1 if the key is pressed, and this function was not called previously in the current frame; otherwise, 0.

int engine.app.clearMouseAxis(int axis)

Returns the current mouse axis position delta and clears it to 0.

Arguments

Return value

Mouse axis delta regarding the last mouse axis position, integer value.

int engine.app.clearMouseButtonState(int button)

Returns a button state and clears it to 0 (not pressed). This function allows to return button state only once even if it is kept pressed over several frames.

Arguments

Return value

1 if at least one of the buttons is pressed, and this function was not called previously in the current frame; otherwise, 0.

void engine.app.destroy()

Application requests the engine to destroy.

int engine.app.dialogMessage(string title, string str, string flags = 0)

Creates a system modal message dialog. Since the dialog is modal, all other actions are stopped until this function returns a value.
Notice
If you don't specify flags, the Oc combination will be used by default.

Arguments

  • string title - Title of the dialog window.
  • string str - Content of the dialog window.
  • string flags - Dialog window flags. The argument accepts a string with names of buttons. The following combinations are available:
    • Oc or oC - OK, Cancel.
    • Yn or yN - Yes, No
    • ynC, yNc or Ync - Yes, No, Cancel
    Notice
    The uppercase letter indicates which button will be in focus.
    If you send any other combination, only the OK button will appear in the window.

Return value

The function returns one of the following values:
  • 1 if the OK button has been pressed.
  • 2 if the Yes button has been pressed.
  • -1 if the No button has been pressed.
  • 0 if the Cancel button has been pressed.

void engine.app.doRender()

The engine requests to call render() function. Application can ignore this request if it handles the main loop by itself.

void engine.app.doSwap()

The engine requests to call swap() function. Application can ignore this request if it handles the main loop by itself.

void engine.app.doUpdate()

The engine requests to call update() function. Application can ignore this request if it handles the main loop by itself.

void engine.app.exit()

The engine requests to exit the application.

int engine.app.initD3D11(void * adapter, void * device, void * context)

Initializes the Direct3D11 render. This function should be called when the Direct3D11 device is ready for rendering.

Arguments

  • void * adapter - Pointer to the IDXGIAdapter interface.
  • void * device - Pointer to the ID3D11Device interface.
  • void * context - Pointer to ID3D11DeviceContext interface.

Return value

1 if the Direct3D11 render is initialized successfully; otherwise, 0.

int engine.app.initGL()

Initializes the OpenGL render. This function should be called when OpenGL context is created.

Return value

1 if the render is initialized successfully; otherwise, 0.

int engine.app.initNULL()

Initializes the NULL renderer: nothing is rendered onto the screen. This mode is used, for example, for servers in case of playing over the network.

Return value

1 is the renderer is initialized successfully; otherwise, 0.

void engine.app.keyPress(unsigned int key)

Application notifies the engine that a key on a keyboard is pressed.

Arguments

  • unsigned int key - Key ID. Possible values can be in range [0;255], which are standard ASCII code symbols, or in range [KEY_ESC;KEY_NUM], which are used for control buttons. For full list of control button see App:: Enumeration at the end of the article.

void engine.app.keyPressUnicode(unsigned int key)

Application notifies the engine that a key is pressed.

Arguments

  • unsigned int key - Unicode symbol ID.

void engine.app.keyRelease(unsigned int key)

Application notifies the engine that a key on a keyboard is released.

Arguments

  • unsigned int key - Key ID. Possible values can be in range [0;255], which are standard ASCII code symbols, or in range [KEY_ESC;KEY_NUM], which are used for control buttons. For full list of control button see App:: Enumeration at the end of the article.

void engine.app.render()

Application requests the engine to render.

int engine.app.restoreVideoMode()

Restores the video mode of the operating system.

Return value

1 if the video mode is restored successfully; otherwise, 0.

int engine.app.shutdownD3D11()

Shuts down the Direct3D11 render. This function should be called when the Direct3D11 device is released.

Return value

1 if the Direct3D11 render is shut down successfully; otherwise, 0.

int engine.app.shutdownGL()

Shuts down the OpenGL render. This function should be called when OpenGL context is destroyed.

Return value

1 if the render is shut down successfully; otherwise, 0.

int engine.app.shutdownNULL()

Shuts down the NULL renderer.

Return value

1 is the renderer is shut down successfully; otherwise, 0.

void engine.app.startFps()

Starts the FPS counter if it was stopped.
Notice
Number of calls to this function should correspond to the number of calls to the engine.app.stopFps() function.

void engine.app.stopFps()

Stops the FPS counter.
Notice
Number of calls to this function should correspond to the number of calls to the engine.app.startFps() function.

void engine.app.swap()

Application requests the engine to swap.

void engine.app.update()

Application requests the engine to update.

void engine.app.updateFps()

Updates all FPS statistics.

int APP_AXIS_X

Description

A mouse wheel is scrolled horizontally (along the X axis; a horizontal mouse wheel is required).

int APP_AXIS_Y

Description

A mouse wheel is scrolled vertically (along the Y axis; a vertical mouse wheel is used).

int APP_BREAK_ON_ERROR

Description

Break if an error occurs.

int APP_BUTTON_AUX_0

Description

A detected activity of the first auxiliary mouse button.

int APP_BUTTON_AUX_1

Description

Detected activity belongs to the second auxiliary mouse button.

int APP_BUTTON_AUX_2

Description

Detected activity belongs to the third auxiliary mouse button.

int APP_BUTTON_AUX_3

Description

Detected activity belongs to the fourth auxiliary mouse button.

int APP_BUTTON_DCLICK

Description

A mouse button is double-clicked.

int APP_BUTTON_LEFT

Description

Detected activity belongs to the left mouse button.

int APP_BUTTON_MIDDLE

Description

Detected activity belongs to the middle mouse button (scrolling wheel).

int APP_BUTTON_RIGHT

Description

Detected activity belongs to the right mouse button.

int APP_DEBUG_CONTEXT

Description

A debug context is enabled.

int APP_DESTROY

Description

A fullscreen mode is destroyed.

int APP_FULLSCREEN

Description

A fullscreen mode.

int APP_FULLWINDOW

Description

A full window mode.

int APP_KEY_ALT

Description

The ALT key is pressed.

int APP_KEY_BACKSPACE

Description

The Backspace key is pressed.

int APP_KEY_CAPS

Description

The Caps Lock key is pressed.

int APP_KEY_CMD

Description

The Command key is pressed (for OS X).

int APP_KEY_CTRL

Description

The Ctrl key is pressed.

int APP_KEY_DELETE

Description

The Delete key is pressed.

int APP_KEY_DOWN

Description

The Down Arrow key is pressed.

int APP_KEY_END

Description

The End key is pressed.

int APP_KEY_ESC

Description

The Esc key is pressed.

int APP_KEY_F1

Description

The F1 key is pressed.

int APP_KEY_F10

Description

The F10 key is pressed.

int APP_KEY_F11

Description

The F11 key is pressed.

int APP_KEY_F12

Description

The F12 key is pressed.

int APP_KEY_F2

Description

The F2 key is pressed.

int APP_KEY_F3

Description

The F3 key is pressed.

int APP_KEY_F4

Description

The F4 key is pressed.

int APP_KEY_F5

Description

The F5 key is pressed.

int APP_KEY_F6

Description

The F6 key is pressed.

int APP_KEY_F7

Description

The F7 key is pressed.

int APP_KEY_F8

Description

The F8 key is pressed.

int APP_KEY_F9

Description

The F9 key is pressed.

int APP_KEY_HOME

Description

The Home key is pressed.

int APP_KEY_INSERT

Description

The Insert key is pressed.

int APP_KEY_LEFT

Description

The Left Arrow key is pressed.

int APP_KEY_NUM

Description

The Num Lock key is pressed.

int APP_KEY_PGDOWN

Description

The Page Down key is pressed.

int APP_KEY_PGUP

Description

The Page Up key is pressed.

int APP_KEY_RETURN

Description

The Enter (Return) key is pressed.

int APP_KEY_RIGHT

Description

The Right Arrow key is pressed.

int APP_KEY_SCROLL

Description

The Scroll Lock key is pressed.

int APP_KEY_SHIFT

Description

The Shift key is pressed.

int APP_KEY_TAB

Description

The Tab key is pressed.

int APP_KEY_UP

Description

The Page Up key is pressed.

int APP_NUM_AXES

Description

Number of axes, along which a mouse wheel can be scrolled.

int APP_NUM_KEYS

Description

Detected number of keyboard keys.

int APP_NUM_TOUCHES

Description

The number of the deteched touches (for touch-screen controls).

int APP_RESIZABLE

Description

A resizable window.

int APP_VSYNC

Description

Vertical syncronization.
Last update: 2017-07-03
Build: ()