This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
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::Splash Class

Header: #include <UnigineSplash.h>

Controls the settings of the splash screen. Demonstration of it gives Unigine the time to load all world and compile shaders. For a splash screen a two-part texture can be set.

Function that displays a texture splash screen is usually divided into two parts — intro and outro, though there can be more of them; this is achieved with the yield operator. At this point the intro part is displayed. Intro parts usually consist of two images, which are gradually blended with different coefficients to show the progress.

See Also#

  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/widgets/ folder:
    • splash_00
    • splash_01
    • splash_03
    • splash_04

Example

Here's a code example on how to add your own splash screens for application (system splash) and world loading (world splash).

Splash screens are defined inside the init() method of the SystemLogic class. Here we also display the system splash screen:

Source code (C++)
// AppSystemLogic.cpp

#include "UnigineSplash.h"
#include "UnigineApp.h"

/* ... */
int AppSystemLogic::init() {
	// define new transform for splash screen
	Unigine::Math::vec4 transform = Unigine::Math::vec4(1.0f, 1.0f, 0.0f, 0.0f);

	// enable the splash
	Splash::setEnabled(true);
	
	// set transform to the system and world splash screens
	Unigine::Splash::setSystemTransform(transform);
	Unigine::Splash::setWorldTransform(transform);

	// compute the aspect ratio to show corresponding texture
	float aspect_ratio = (float)App::getWidth() / (float)App::getHeight();

	// if the aspect ratio is 4:3 show these splash screens
	// during application and world load
	if (aspect_ratio < 1.5f) {
		Unigine::Splash::setSystem("splash_4x3_system.png");
		Unigine::Splash::setWorld("splash_4x3_world.png");
	}
	else {
		// if the aspect ratio is 16:9 show these splash screens
		// during application and world load
		Unigine::Splash::setSystem("splash_16x9_system.png");
		Unigine::Splash::setWorld("splash_16x9_world.png");
	}
	// set the text to be displayed on the system splash screen
	// with a certain displacement along the X and Y axes
	Splash::setSystemText("<xy x=%50 dx=0 y=%50 dy=0/>SYSTEM SPLASH TEXT");
	
	// set duration (in milliseconds) and display the system splash on application loading
	float splashDuration = 5000.0f;
	float begin = clock();

	while (clock() - begin < splashDuration)
		Splash::renderSystem((clock() - begin) / splashDuration * 100.0f);
	
	// disable the splash
	Splash::setEnabled(false);
	
	return 1;
}

/* ... */

World splash screen should be displayed in the init() method of the WorldLogic class:

Source code (C++)
// AppWorldLogic.cpp
#include "UnigineSplash.h"

/* ... */
int AppWorldLogic::init() {
	// define new transform for splash screen
	Unigine::Math::vec4 transform = Unigine::Math::vec4(1.0f, 1.0f, 0.0f, 0.0f);

	// enable the splash
	Splash::setEnabled(true);
	
	// set the text to be displayed on the world splash screen,
	// specifying a color, a font, and a certain displacement along the X and Y axes
	Splash::setWorldText("<p align=\"center\"><font size=20 color=#FF0000FF>WORLD SPLASH TEXT</font></p>");
	
	// set duration (in milliseconds) and display the world splash on world loading
	float splashDuration = 5000.0f;
	float begin = clock();

	while (clock() - begin < splashDuration)
		Splash::renderWorld((clock() - begin) / splashDuration * 100.0f);

	// disable the splash
	Splash::setEnabled(false);
	
	return 1;
}

/* ... */

Splash Class

Members


void setColor ( const Math::vec4 & color ) #

Sets the color of the text LOADING on the black background. This text is displayed, when a splash screen being called is cleared.

Arguments

  • const Math::vec4 & color - Text color.

void setEnabled ( int enabled ) #

Specifies if manual rendering of a splash screen (on system loading, world loading or of a custom one) can be started or should be stopped. This function is used only together with corresponding render functions (engine.splash.renderSystem(), engine.splash.renderWorld() or engine.splash.renderSplash()). This function cannot be used to enable or disable rendering of a system or a world splash screen during the initialization stage of the script.

Arguments

  • int enabled - 1 to enable rendering of the splash screen; 0 to disable.

int isEnabled ( ) #

Returns a value indicating if manual rendering of a splash screen (on system loading, world loading or of a custom one) is allowed.
Notice
Setter function engine.splash.setEnabled() is used only together with correspondingrender functions (engine.splash.renderSystem(), engine.splash.renderWorld() orengine.splash.renderSplash()). It cannot be used to enable or disable rendering of a system or a world splash screen during the initialization stage of the script.

Return value

1 if the rendering of the splash screen was enabled; otherwise, 0.

void setSplash ( const char * name, int threshold = 0 ) #

Sets basic properties of a custom splash screen. This splash screen can be called from the script any time you need it. The splash screen can is a two-part texture.

Arguments

  • const char * name - Name of the file with the custom splash screen. If NULL (0) is passed, the splash screen is cleared.
  • int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.

void setSplashBackground ( const Math::vec4 & color ) #

Sets the background color of the splash screen.

Arguments

  • const Math::vec4 & color - Color.

void setSplashImage ( const Ptr<Image> & image, int threshold = 0 ) #

Sets an image for a custom splash screen. This splash screen can be called from the script any time you need it. The splash screen is a two-part texture shown according to the threshold.

Arguments

  • const Ptr<Image> & image - Image smart pointer to an image to be used as a custom splash screen.
  • int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.

void setSplashText ( const char * str ) #

Sets the text of the splash screen.

Arguments

  • const char * str - Text of the splash screen.

void setSplashTransform ( const Math::vec4 & transform ) #

Sets transformation of the splash.

Arguments

  • const Math::vec4 & transform - Transformation of the splash.

void setSystem ( const char * name, int threshold = 0 ) #

Sets basic properties of a system splash screen, which is displayed while resources like shaders and materials are being loaded on the engine start-up. The splash screen is a two-part texture.
Notice
If NULL is set for a splash screen texture, LOADING text will be shown instead.

Arguments

  • const char * name - Name of the file with the system splash screen. If NULL (0) is passed, the splash screen is cleared.
  • int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.

void setSystemBackground ( const Math::vec4 & color ) #

Sets the background color of the system splash screen.

Arguments

  • const Math::vec4 & color - Color.

void setSystemImage ( const Ptr<Image> & image, int threshold = 0 ) #

Sets an image for a system splash screen, which is displayed while resources like shaders and materials are being loaded on the engine start-up. The splash screen is a two-part texture shown according to the threshold.

Arguments

  • const Ptr<Image> & image - Image smart pointer to an image to be used as a custom splash screen.
  • int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.

void setSystemText ( const char * str ) #

Sets the text of the system splash screen.

Arguments

  • const char * str - Text of the system splash screen.

void setSystemTransform ( const Math::vec4 & transform ) #

Sets transformation of the system splash.

Arguments

  • const Math::vec4 & transform - Transformation of the system splash.

void setWorld ( const char * name, int threshold = 0 ) #

Sets basic properties of a world splash screen, which is displayed while the world is being loaded. The splash screen is a two-part texture.
Notice
If NULL is set for a splash screen texture, LOADING text will be shown instead.

Arguments

  • const char * name - Name of the file with the world splash screen. If NULL (0) is passed, the splash screen is cleared.
  • int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.

void setWorldBackground ( const Math::vec4 & color ) #

Sets the background color of the world splash screen.

Arguments

  • const Math::vec4 & color - Color.

void setWorldImage ( const Ptr<Image> & image, int threshold = 0 ) #

Sets an image for a world splash screen, which is displayed while the world is being loaded. The splash screen is a two-part texture shown according to the threshold.

Arguments

  • const Ptr<Image> & image - Image smart pointer to an image to be used as a custom splash screen.
  • int threshold - Amount of blur in the alpha channel when interpolating between states of the splash screen. This is an optional parameter; if it is not passed, 0 will be used instead.

void setWorldText ( const char * str ) #

Sets the text of the world splash screen.

Arguments

  • const char * str - Text of the world splash screen

void setWorldTransform ( const Math::vec4 & transform ) #

Sets transformation of the world splash.

Arguments

  • const Math::vec4 & transform - Transformation of the world splash.

void renderInterface ( ) #

Renders a static splash screen. Such a splash screen does not display any progress.

void renderSplash ( int progress ) #

Renders a custom splash screen in a given progress state. Use this function in a loop to create a gradual change between the initial (upper opaque part) and the final states (bottom transparent part) of the splash screen texture.

Arguments

  • int progress - Progress of alpha blending between 2 splash screens stored in the texture. The value in range [0;100] sets an alpha channel threshold, according to which pixels from the initial (opaque) or final (transparent) splash screen in the texture are rendered. If the value is 0, the initial screen is loaded. If the value is 100, the final screen is loaded.

void renderSystem ( int progress ) #

Renders a splash screen image, that is displayed by the system script reload, in a given progress state. Use this function in a loop to create a gradual change between the initial (upper opaque part) and the final states (bottom transparent part) of the splash screen texture.

Arguments

  • int progress - Progress of alpha blending between 2 splash screens stored in the texture. The value in range [0;100] sets an alpha channel threshold, according to which pixels from the initial (opaque) or final (transparent) parts of the texture are rendered. By the value of 0, the initial screen is loaded. By the value of 100, the final screen is loaded.

void renderWorld ( int progress ) #

Renders a splash screen image, that is displayed by the world load, in a given progress state. Use this function in a loop to create a gradual change between the initial (upper opaque part) and the final states (bottom transparent part) of the splash screen texture.

Arguments

  • int progress - Progress of alpha blending between 2 splash screens stored in the texture. The value in range [0;100] sets an alpha channel threshold, according to which pixels from the initial (opaque) or final (transparent) parts of the texture are rendered. By the value of 0, the initial screen is loaded. By the value of 100, the final screen is loaded.
Last update: 2020-04-21
Build: ()