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.

Unigine::App Class

Header:#include <UnigineApp.h>

Controls the appearance of the Unigine application window, its update parameters and handles window input from the keyboard and mouse.

App Class

Members


App * get()

void 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 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 setClipboard(const char * str)

Updates the contents of the system clipboard.

Arguments

  • const char * str - Contents to set.

const char * getClipboard()

Retrieves the contents of the system clipboard.

Return value

Contents of the system clipboard.

void * getD3D11Context()

Returns a pointer to the existing ID3D11DeviceContext interface.

void * getD3D11Device()

Returns a pointer to the existing ID3D11Device interface.

int isD3D11Initialized()

Returns the status of the Direct3D11 render.

Return value

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

int isDone()

Returns a value indicating if the application is closed.

Return value

Returns 1 if the application is closed; otherwise, 0.

void setFilter(float filter)

Sets a filter for the FPS counter value. If the filter value is 0, filtering is disabled and the current FPS value is always shown.

Arguments

  • float filter - Filter value in range [0;1). The default value is 0.9f (10 percent of the current FPS is taken into account).

int 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 getFps()

Returns the application FPS counter value.

Return value

Application FPS counter value.

float getFTime()

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

Return value

Application frame duration in seconds.

int 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

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

int isGLInitialized()

Returns the status of the OpenGL render.

Return value

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

void * getHandle()

Returns a pointer to the application handle.

Return value

Pointer to the application handle.

void setHeight(int value)

Arguments

  • int value

int getHeight()

Returns the current video height.

Return value

Current video height in pixels.

int setIcon(uchar[] data)

Sets an icon for the application window.

Arguments

  • uchar[] data

Return value

Returns 1 if the icon is set successfully; otherwise, 0.

float getIFps()

Returns an inverse value of the application FPS counter.

Return value

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

const char * 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 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 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 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 setKeyState(int key, int state)

Sets the keyboard key state.

Arguments

  • 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.
  • int state - Key state: 1 to set the button pressed; 0 to set the button unpressed.

int getKeyState(int key)

Returns the keyboard key state.

Arguments

  • 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.

Return value

Returns 1 if the key is pressed, 0 if not.

void setMouse(int x, int y)

Sets a mouse pointer to a given 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 setMouseAxis(int axis, int value)

Sets the mouse axis position delta.

Arguments

  • int axis - Mouse axis. Possible values are AXIS_X, AXIS_Y.
  • int value - Mouse axis delta, integer value.

int getMouseAxis(int axis)

Returns the current mouse axis position delta.

Arguments

  • int axis - Mouse axis. Possible values are AXIS_X, AXIS_Y.

Return value

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

void setMouseButton(int arg1)

Sets the mouse button to be pressed.

Arguments

  • int arg1 - Mouse button to be pressed. Possible values are BUTTON_LEFT, BUTTON_RIGHT, etc. For full list of the values see App:: Enumeration at the end of the article.

int getMouseButton()

Returns the current states of all mouse buttons. Each bit of the returned bit mask will specify the state of the buttons (BUTTON_LEFT, BUTTON_MIDDLE, etc.) in the order specified in App:: Enumeration at the end of the article.

Return value

Mouse button status.

const char * getMouseButtonName(int button)

Returns a name of a given button.

Arguments

Return value

Button name.

int getMouseButtonState(int button)

Returns the mouse button state.

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.

Return value

Returns 1 if the button is pressed; otherwise, 0.

int setMouseCursor(uchar[] data, int x = 0, int y = 0)

Sets a custom image for the OS mouse cursor. The image must be of the squire size and RGBA8 format.

Arguments

  • uchar[] data
  • int x
  • int y

Return value

Returns 1 if the image is set successfully; otherwise, 0.

void setMouseGrab(int arg1)

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

Arguments

  • int arg1 - Grabbing parameter: 1 if the mouse pointer cannot leave the application window; otherwise, 0.

int getMouseGrab()

Returns the current mouse grab parameter, which indicates if the mouse pointer is bound to the application window.

Return value

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

void setMouseShow(int arg1)

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

Arguments

  • int arg1 - Display parameter: 1 if the OS mouse pointer should be displayed; 0 if the application cursor is used only.

int getMouseShow()

Returns the current mouse display parameter, which indicates if the operating system pointer is displayed.

Return value

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

int 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 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.

const char * 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 isNULLInitialized()

Returns a value indicating whether the NULL renderer is initialized.

Return value

1 is the renderer is initialized; otherwise, 0.

int getNumTouches()

Returns the number of touches.

Return value

Number of touches.

int setPosition(int x, int y)

Sets the window position.

Arguments

  • int x - Position of the left side of the window.
  • int y - Position of the top side of the window.

Return value

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

int getPositionX()

Returns the window position.

Return value

Returns position of the left side of window.

int getPositionY()

Returns the window position.

Return value

Returns position of the top side of window.

int setTitle(const char * title)

Sets a title for the application window.

Arguments

  • const char * title - Window title to set.

Return value

Returns 1 if the title for the application window is set successfully; otherwise, 0.

int getTouchX(int touch)

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

Arguments

  • int touch - The toucn number.

Return value

X coordinate of the touch.

int getTouchY(int touch)

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

Arguments

  • int touch - The toucn number.

Return value

Y coordinate of the touch.

int setUpdate(int update)

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

Arguments

  • int update - Window update mode: 1 is for constantly repeating update cycle (i.e. the application is updated if the window is hidden); otherwise, 0.

Return value

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

int getUpdate()

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

Return value

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

int 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, FULSCREEN, etc. For full list of available flags see App:: Enumeration at the end of the article.
  • int refresh - Force refresh rate in Hz; if 0 is provided, default refresh rate is used.

Return value

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

const char * getVideoModeName()

Returns the name of the current video mode.

Return value

Returns the name of the current video mode.

void setWidth(int value)

Arguments

  • int value

int getWidth()

Returns the current video width.

Return value

Current video width in pixels.

void 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 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 clearKeyState(int key)

Returns the keyboard key state and clear it to zero.

Arguments

  • 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.

Return value

Returns 1 if the key state is cleared; otherwise, 0.

int clearMouseAxis(int axis)

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

Arguments

  • int axis - Mouse axis. Possible values are AXIS_X, AXIS_Y.

Return value

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

int clearMouseButtonState(int button)

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

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.

Return value

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

void destroy()

Application requests the engine to destroy.

int dialogFile(const char * title, char * name, int size, const char * filter = 0, const char * flags = 0)

Creates a system modal file dialog. Since the dialog is modal, all other actions are stopped until this function returns a value.

Arguments

  • const char * title - Title of the dialog window.
  • char * name - Current file name.
  • int size - Size of the name buffer.
  • const char * filter - File extension filter. Accepts dot-separated file extensions: ".tga.jpg.png.tif.psd"
  • const char * flags - Dialog file flags. Accepts string: "o" - open file dialog; "s" - save file dialog; "d" - directory dialog.

Return value

Returns 1 if the OK button is pressed; 0 if the Cancel button is pressed.

int dialogMessage(const char * title, const char * str, const char * flags = 0)

Creates a system modal message dialog. Since the dialog is modal, all other actions are stopped until this function returns a value.

Arguments

  • const char * title - Title of the dialog window.
  • const char * str - Content of the dialog window.
  • const char * flags - Dialog window flags. Accepts string with button names: "Oc" - "OK, cancel"; "Yn" - "YES, no"; "ynC"; "yes, no, CANCEL".

Return value

Returns 1 if the OK button is pressed; 0 if the Cancel button is pressed.

void doRender()

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

void doSwap()

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

void doUpdate()

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

void exit()

The engine requests to exit the application.

int 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

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

int initGL()

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

Return value

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

int 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 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 keyPressUnicode(unsigned int key)

Application notifies the engine that a key is pressed.

Arguments

  • unsigned int key - Unicode symbol ID.

void 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 render()

Application requests the engine to render.

int restoreVideoMode()

Restores the video mode of the operating system.

Return value

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

int shutdownD3D11()

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

Return value

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

int shutdownGL()

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

Return value

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

int shutdownNULL()

Shuts down the NULL renderer.

Return value

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

void startFps()

Starts the FPS counter if it was stopped. All function calls are placed into stack, so the number of calls to this function should correspond to the number of calls to the stopFps() function.

void stopFps()

Stops the FPS counter. This function should be called if application window is hidden or some heavy non-rendering tasks are processing. All function calls are placed into stack, so the number of calls to this function should correspond to the number of calls to the startFps() function.

void swap()

Application requests the engine to swap.

void update()

Application requests the engine to update.

int AXIS_X

int AXIS_Y

int BUTTON_AUX_0

int BUTTON_AUX_1

int BUTTON_AUX_2

int BUTTON_AUX_3

int BUTTON_DCLICK

int BUTTON_LEFT

int BUTTON_MIDDLE

int BUTTON_RIGHT

int DEBUG_CONTEXT

int DESTROY

int FULLSCREEN

int FULLWINDOW

int KEY_ALT

int KEY_BACKSPACE

int KEY_CAPS

int KEY_CMD

int KEY_CTRL

int KEY_DELETE

int KEY_DOWN

int KEY_END

int KEY_ESC

int KEY_F1

int KEY_F10

int KEY_F11

int KEY_F12

int KEY_F2

int KEY_F3

int KEY_F4

int KEY_F5

int KEY_F6

int KEY_F7

int KEY_F8

int KEY_F9

int KEY_HOME

int KEY_INSERT

int KEY_LEFT

int KEY_NUM

int KEY_PGDOWN

int KEY_PGUP

int KEY_RETURN

int KEY_RIGHT

int KEY_SCROLL

int KEY_SHIFT

int KEY_TAB

int KEY_UP

int NUM_AXES

int NUM_KEYS

int NUM_TOUCHES

int RESIZABLE

int VSYNC

Last update: 2017-07-03
Build: ()