KanziStudio应用程序配置详解

  • 在 C++ 应用程序中,使用 onConfigure() 函数。
  • 在 application.cfg 中,使用或不使用 C++ 应用程序设置 Kanzi Studio 工程的参数。

While you can configure your Kanzi application in the onConfigure() function, in application.cfg you can configure some parameters without recompiling your application or even without a C++ application. The configuration you specify in application.cfg overrides the configuration you specify in onConfigure().

For example, in application.cfg you can tell your Kanzi application which kzb file to load, enable performance information in your application, and set how many threads you want to use for loading the application resources.

See Configuring your application.

You can use these application configuration settings.

Loading
  BinaryName
ModuleNames
LoadingThreadCount
MaxPendingResources
UseMemoryMappedLoading

Performance
  ApplicationIdleState
MaximumFPS
PerformanceInfoLevel
ProfilingCategoryFilter

Glyph cache texture size
  GlyphCacheHeight
GlyphCacheWidth
Graphics performance logging
  GraphicsLoggingEnabled
LogOpenGLExtensions
LogOpenGLInformation
LogSurfaceInformation

Graphics library
  GraphicsBackend
GraphicsContextAPI

Surface properties
  SurfaceBitsStencil
SurfaceBitsDepthBuffer
SurfaceBitsRed
SurfaceBitsGreen
SurfaceBitsBlue
SurfaceBitsAlpha
SurfaceBitsPadding
SurfaceSamplesAntialiasing
SurfaceSwapBehavior
Application window position and size
  WindowX
WindowY
WindowWidth
WindowHeight
DefaultDisplayIndex
WindowOrder

Application window style
  WindowStyle

Input handling and screen transformation
  InputTransform
InputTranslation
InputDiscardPointer
InputDiscardTouch

Input event devices on Linux
  InputEventDevice

Loading

BinaryName

You can set which kzb file or configuration file your Kanzi application loads when you launch your Kanzi application.

See 使用 kzb 文件.

In application.cfg BinaryName = "name"
In onConfigure() configuration.binaryName = "name";
Value
name Path to a single kzb file, or to the binary configuration file listing all kzb files that your Kanzi application loads.
application.cfg example

 

# Loads the kzb file named MyApplication.kzb.
BinaryName = "MyApplication.kzb"

 

 

# Loads the binary configuration file MyApplicationKzbs.cfg that lists
# all kzb files that your Kanzi application loads.
BinaryName = "MyApplication.kzb.cfg"

 

onConfigure() example

 

// Loads kzb file named MyApplication.kzb.
configuration.binaryName = "MyApplication.kzb";

 

 

// Loads the binary configuration file MyApplicationKzbs.cfg that lists
// all kzb files that your Kanzi application loads.
configuration.binaryName = "MyApplication.kzb.cfg";

 

ModuleNames

You can set which plugins your Kanzi application loads when you launch your Kanzi application.

In application.cfg ModuleNames= "names"
In onConfigure() configuration.moduleNames = names;
Values
names List of plugins to load.
application.cfg example

 

# Loads the plugin DLL files MyPlugin1.dll and MyPlugin2.dll.
ModuleNames = "MyPlugin1; MyPlugin1"

 

onConfigure() example
// Loads the plugin DLL files MyPlugin1.dll and MyPlugin2.dll. 
configuration.moduleNames = {"MyPlugin1", "MyPlugin1"};

LoadingThreadCount

当用户在具有多核处理器的环境中运行 Kanzi 应用程序时,Kanzi 会自动使用多个 CPU 内核将 kzb 文件中的 GPU 资源加载到 RAM 中。 See 并行加载资源.

GPU 资源 Kanzi 并行加载包括所有类型在内的纹理、着色器和网格。为将这些资源从 RAM 部署到 GPU 内存并加载预设件模板,Kanzi 始终使用主线程。请参阅图像和纹理最佳实践、着色器最佳实践、网格最佳实践。

In application.cfg LoadingThreadCount = threads
In onConfigure() configuration.loadingThreadCount = threads;
Values
threads Number of CPU cores used for loading the resources. The default value is 3.
application.cfg example
# Switches off the use of multiple cores for loading your application.
# Loads your application resources using the main thread.
LoadingThreadCount = 0
# Uses six threads to load your application.
LoadingThreadCount = 5
onConfigure() example
// Switches off the use of multiple cores for loading your application.
// Loads your application resources using the main thread.
configuration.loadingThreadCount = 0;
// Uses six threads to load your application.
configuration.loadingThreadCount = 5;

MaxPendingResources

You can set the maximum number of resources that the loading threads process at the same time. By increasing the number of resources you can speed up the loading, but at the same time you increase the peak memory use during loading because you can load more resources to the memory before they are deployed to the GPU.

In application.cfg MaxPendingResources = resources
In onConfigure() configuration.maxPendingResources = resources;
Values
resources The maximum number of resources processed at the same time by the loading threads. The default value is 0 and sets the maximum number of resources to the number of loading threads +1.
application.cfg example
# Sets the maximum number of resources processed by the loading
# threads to the number of loading threads + 1. This is the default value.
MaxPendingResources = 0
# Sets the maximum number of resources processed by the loading
# threads to 20 resources.
MaxPendingResources = 20
onConfigure() example
// Sets the maximum number of resources processed by the loading
// threads to the number of loading threads + 1. This is the default value.
configuration.maxPendingResources = 0;
// Sets the maximum number of resources processed by the loading
// threads to 20 resources.
configuration.maxPendingResources = 20;

UseMemoryMappedLoading

在支持内存映射文件的操作系统上运行 Kanzi 应用程序时,您可以为 Kanzi 应用程序使用的 kzb 文件启用内存映射加载。您启用内存映射加载后,因为它减少了文件访问量,所以可缩短 Kanzi 应用程序的加载时间。

内存映射文件受 Windows、Linux 和 QNX 等操作系统的支持。在启用内存映射加载前,请检查它是否受运行 Kanzi 应用程序的平台支持。

要检查您的平台是否支持内存映射加载,请调用 kzsMemoryMappedFileIsSupported() 函数。如支持内存映射加载,函数返回 True,如不支持,则返回 False。

如果您在不支持功能的平台上启用内存映射加载,Kanzi 会显示警告并使用常规文件访问来加载 kzb 文件。

In application.cfg UseMemoryMappedLoading = value
In onConfigure() configuration.useMemoryMappedLoading = value;
Values
0 Disable the memory mapped loading. Default value.
1 Enable the memory mapped loading.
application.cfg example
# Enables the memory mapped loading for the kzb files in your Kanzi application.
UseMemoryMappedLoading = 1
onConfigure() example
// Enables the memory mapped loading for the kzb files in your Kanzi application.
configuration.useMemoryMappedLoading = 1;

Performance

ApplicationIdleState

如果没有输入、任务、定时器、动画,又或是应用程序中没有可以更新渲染的任何内容,Kanzi 会暂停主循环。 See 应用程序空闲状态.

当使用应用程序空闲状态时,请考虑下面这些使用案例:

  • 如果您的 Kanzi 应用程序正在显示动画,Kanzi 默认会调节 CPU 运行速度以获得最高的 FPS。如果没有显示任何动画,Kanzi 会将应用程序设置为空闲状态。因此,为了节省 CPU 资源和能耗,Kanzi 默认会将最高帧速率限制为 60 帧/秒。请使用应用程序配置来设置您的应用程序的最高帧速率。 See MaximumFPS.
  • 如果您的应用程序需要连续调用 Application::updateOverride,请禁用应用程序空闲状态。
In application.cfg ApplicationIdleState = value
In onConfigure() configuration.applicationIdleStateEnabled = value;
Values
0 Disable the application idle state.
1 Enable the application idle state. Default value.
application.cfg example
# Disables the application idle state.
ApplicationIdleState = 0
onConfigure() example
// Disables the application idle state.
configuration.applicationIdleStateEnabled = 0;

MaximumFPS

You can limit the number of frames rendered per second by setting the maximum frame rate.

如果您的 Kanzi 应用程序正在显示动画,Kanzi 默认会调节 CPU 运行速度以获得最高的 FPS。如果没有显示任何动画,Kanzi 会将应用程序设置为空闲状态。因此,为了节省 CPU 资源和能耗,Kanzi 默认会将最高帧速率限制为 60 帧/秒。请使用应用程序配置来设置您的应用程序的最高帧速率。

See PerformanceInfoLevel.

In application.cfg MaximumFPS = limit
In onConfigure() configuration.frameRateLimit = limit;
Value
limit The maximum frame rate of the application in frames per second.
application.cfg example
# Sets the maximum application frame rate to 32 frames per second.
MaximumFPS = 32
# Disables the limit.
MaximumFPS = 0
onConfigure() example
// Sets the maximum application frame rate to 32 frames per second.
configuration.frameRateLimit = 32;
// Disables the limit.
configuration.frameRateLimit = 0;

PerformanceInfoLevel

You can enable the display of 性能 HUD (Performance HUD) that shows the performance information for your Kanzi application. Use the 性能 HUD (Performance HUD) to see how your application performs on target devices and to find performance bottlenecks.

性能 HUD (Performance HUD) shows this performance information for your Kanzi application:

  • FPS shows the number of frames rendered every second.
  • Last Frame shows this information for the last frame:
    • Time shows the time in milliseconds it took to render the frame.
    • 批处理数 (Batch count) shows how many individual draw calls were executed (glDrawElements and glDrawArrays).
      You can access the batch count using the Kanzi Engine API by calling getBatchCount().
    • Triangle Count shows how many individual triangles were drawn in total during a frame.
      You can access the triangle count in the Kanzi Engine API by calling getTriangleCount().
    • Texture Switches shows how many times a new texture was bound to GPU.
      You can access the texture switch count in the Kanzi Engine API by calling getTextureSwitchCount().
    • FBO Switches shows how many framebuffer objects were bound to GPU. See 渲染最佳实践.
      You can access the buffer switch count in the Kanzi Engine API by calling getFramebufferSwitchCount().
    • Timeline Clock shows the time in milliseconds it took to execute all animations in the application.
  • Shader shows how many times a new shader was bound for the newly applied batch and how many individual shader uniforms were sent for the last frame. See 减少着色器切换.
    You can access the shader switch count in the Kanzi Engine API by calling getShaderSwitchCount().
    You can access the uniforms sent in the Kanzi Engine API by calling getUniformSendCount().
  • Resource Memory Usage shows an estimated amount of local GPU memory (VRAM) and non-local GPU memory (RAM) that your Kanzi application uses.
    The values that the 性能 HUD (Performance HUD) shows in the Kanzi Studio 预览 (Preview) and when you run the Kanzi application on a target device differ because Kanzi Studio loads and keeps in memory all resources in the application.

See 最佳实践.

In application.cfg PerformanceInfoLevel = level
In onConfigure() configuration.performanceInfoLevel = ApplicationProperties::level;
Values
level

The level of display of performance information.

To disable the display of the 性能 HUD (Performance HUD):

  • In application.cfg use 0. Default value.
  • In onConfigure() use PerformanceInfoLevelDisabled. Default value.

To enable the display of the frames rendered per second (FPS):

  • In application.cfg use 1.
  • In onConfigure() use PerformanceInfoLevelFPS.

To enable the display of the full 性能 HUD (Performance HUD):

  • In application.cfg use 2.
  • In onConfigure() use PerformanceInfoLevelFull.
application.cfg example
# Enables the full 性能 HUD (Performance HUD) in a Kanzi application.
PerformanceInfoLevel = 2
onConfigure() example
// Enables the full 性能 HUD (Performance HUD) in a Kanzi application.
configuration.performanceInfoLevel = ApplicationProperties::PerformanceInfoLevelFull;

ProfilingCategoryFilter

You can control the state of performance profiling categories, which you use to group performance profilers, and set which profilers you want to show in the 性能 HUD (Performance HUD). See Measuring application performance.

In application.cfg ProfilingCategoryFilter = "category=state"
In onConfigure() configuration.profilingCategoryFilter = "category=state";
Values
category

The names of one or more profiling categories separated by pipes (|).
To set the state of all categories, use asterisk (*).

state
off Disable performance profiling category.
on Enable performance profiling category.
show Enable performance profiling category and show the graph in the 性能 HUD (Performance HUD).
To use this state, enable the full 性能 HUD (Performance HUD). See PerformanceInfoLevel.
You can use this state to profile the performance of tasks that happen in the Kanzi main loop.
See Showing performance measurement graphs in the 性能 HUD (Performance HUD) and Measuring the performance of custom main loop tasks.

Separate a list of category-state pairs with semicolons (;).

application.cfg examples
# Enables the full 性能 HUD (Performance HUD).
PerformanceInfoLevel = 2
# Enables performance profiling for animations running in the main loop and shows the performance graph in the 性能 HUD (Performance HUD).
ProfilingCategoryFilter="MainLoopAnimation=show"
# Enables the MyFunctionProfiler category and disables the MainLoopRendering category.
ProfilingCategoryFilter="MyFunctionProfiler=on;MainLoopRendering=off"
# Enables all performance profiling categories.
ProfilingCategoryFilter="*=on"
# Enables categories Generic and MyProfilingCategory.
ProfilingCategoryFilter="Generic|MyProfilingCategory=on"
onConfigure() examples
// Enables the full 性能 HUD (Performance HUD).
configuration.performanceInfoLevel = ApplicationProperties::PerformanceInfoLevelFull;
// Enables performance profiling for animations running in the main loop and shows the performance graph in the 性能 HUD (Performance HUD).
configuration.profilingCategoryFilter = "MainLoopAnimation=show";
# Enables the MyFunctionProfiler category and disables the MainLoopRendering category.
configuration.profilingCategoryFilter="MyFunctionProfiler=on;MainLoopRendering=off"
// Enables all performance profiling categories.
configuration.profilingCategoryFilter = "*=on";
// Enables categories Generic and MyProfilingCategory.
configuration.profilingCategoryFilter = "Generic|MyProfilingCategory=on";

This table lists the Kanzi startup performance profiling categories and profilers that are included in the Profiling build.

Category Configuration name Profiler
Application initialization StartupInitialization m_initializationProfiler
Default resource registration StartupRegisterDefaultResources m_registerDefaultResourcesProfiler
Graphics initialization StartupInitializeGraphics m_initializeGraphicsProfiler
GL subsystem initialization StartupInitializeGL m_initializeGLProfiler
Startup kzb file opening StartupOpenKzb m_openKzbProfiler
Loading threads initialization StartupInitializeLoadingThreads m_initializeLoadingThreadsProfiler
Metadata registration StartupRegisterMetadata m_registerMetadataProfiler
Plugins loading StartupLoadPlugins m_loadPluginsProfiler
Prefabs loading StartupLoadPrefab m_loadPrefabProfiler
Prefabs instantiation StartupInstantiatePrefab m_instantiatePrefabProfiler
Prefabs attachment StartupAttachPrefab m_attachPrefabProfiler
Renderer reset StartupResetRenderer m_resetRendererProfiler
Runtime assets registration StartupRegisterRuntimeAssets m_registerRuntimeAssetsProfiler
     

 

This table lists the Kanzi main loop task performance profiling categories and profilers that are included in the Profiling build.

Category Configuration name Title in HUD Profiler
Animations
Measures the time spent rendering animations.
MainLoopAnimation Main loop: animation m_animationProfiler
Application events handling
Measures the time spent gathering and handling events from all available event sources, such as keyboard, mouse, and other available manipulators.
MainLoopApplicationEvents Main loop: application events m_applicationEventsProfiler
Application logic updating
Measures the time spent inside the user-provided Application::update override.
MainLoopAppUpdate Main loop: application update m_appUpdateProfiler
User-provided application logic updating
Measures the time spent executing the user-provided update logic callback Application::onUpdate.
MainLoopUserUpdate Main loop: user update m_userUpdateProfiler
Graphics events handling
Measures the time spent processing events that affect graphics output, such as resizing a window.
MainLoopGraphicsEvents Main loop: graphics events m_graphicsEventsProfiler
性能 HUD (Performance HUD)
Measures the overhead caused by rendering the information in the 性能 HUD (Performance HUD).
MainLoopHUD Main loop: HUD m_hudProfiler
Input events handling
Measures the time that the InputManager spends processing input events, such as keyboard and mouse events.
MainLoopInput Main loop: input m_inputProfiler
Layout
Measures the performance of the layout pass.
MainLoopLayout Main loop: layout m_layoutProfiler
Rendering
Measures the time spent rendering the screen in Application::renderOverride.
MainLoopRendering Main loop: rendering m_renderingProfiler
Resource deployment
Measures the time spent processing the asynchronous task deployment queue.
MainLoopResourceDeployment Main loop: resource deployment m_resourceDeploymentProfiler
Resource manager update
Measures the time that the ResourceManager spends processing load and deployment queues.
MainLoopResourceManagerUpdate Main loop: resource manager update m_resourceManagerUpdateProfiler
Task dispatcher
Measures the time spent executing tasks added to the task scheduler.
MainLoopTaskDispatcher Main loop: task dispatcher m_taskDispatcherProfiler
Task scheduler
Measures the time spent executing periodic tasks added to the task dispatcher, such as animations.
MainLoopTaskScheduler Main loop: task scheduler m_taskSchedulerProfiler

 

Glyph cache texture size

当使用文本块 (Text Block) Kanzi 时,为字体与字号的每种组合创建图形缓存纹理。 您可以设置图形缓存纹理的高度和宽度,以便在图形缓存纹理填满时或者为了优化 Kanzi 应用程序的性能而调整图形缓存纹理的大小。

Because larger glyph cache textures use more VRAM, try different sizes before you set the final size . The upper limit of the glyph cache texture size depends on the GPU, but usually it is 2048 by 2048 pixels. The default size of the glyph cache texture is 512 by 512 pixels.

Kanzi applies the size of the glyph cache texture to all glyph cache textures.

In application.cfg GlyphCacheHeight = size
GlyphCacheWidth = size
In onConfigure() configuration.glyphCacheHeight = size;
configuration.glyphCacheWidth = size;
Values
size Size of the glyph cache texture in pixels. The default value is 512.
application.cfg example
# Sets the glyph cache texture height to 768, and width to 1024 pixels.
GlyphCacheHeight = 768
GlyphCacheWidth = 1024
onConfigure() example
// Sets the glyph cache texture height to 768, and width to 1024 pixels.
configuration.glyphCacheHeight = 768;
configuration.glyphCacheWidth = 1024;

Graphics performance logging

GraphicsLoggingEnabled

You can enable Kanzi to print to the debug console the graphics API calls of your application in the Application::onConfigure() function, in the application.cfg, or using the command line argument, if your target supports command line arguments.

On the command line use:

  • -log-graphics to log the graphics API calls
In application.cfg GraphicsLoggingEnabled = value
In onConfigure() configuration.graphicsLoggingEnabled = value;
Values
0 Disable the logging of the graphics API calls. Default value.
1 Enable the logging of the graphics API calls.
application.cfg example
# Enables the logging of the graphics API calls.
GraphicsLoggingEnabled = 1
onConfigure() example
// Enables the logging of the graphics API calls.
configuration.graphicsLoggingEnabled = 1;

LogOpenGLExtensions

You can enable Kanzi to print to the debug console a list of the graphics-related extensions on application startup.

In application.cfg LogOpenGLExtensions = value
In onConfigure() configuration.extensionOutputEnabled = value;
Values
0 Disable the logging of the graphics-related extensions. Default value.
1 Enable the logging of the graphics-related extensions.
application.cfg example
# Enables the logging of the graphics-related extensions.
LogOpenGLExtensions = 1
onConfigure() example
// Enables the logging of the graphics-related extensions.
configuration.extensionOutputEnabled = 1;

LogOpenGLInformation

You can enable Kanzi to print to the debug console this graphics-related information on application startup:

  • GL vendor
  • GL renderer
  • GL version
  • Shading language version
In application.cfg LogOpenGLInformation = value
In onConfigure() configuration.informationOutputEnabled = value;
Values
0 Disable the logging of the graphics-related information. Default value.
1 Enable the logging of the graphics-related information.
application.cfg example
# Enables the logging of the graphics-related information.
LogOpenGLInformation = 1
onConfigure() example
// Enables the logging of the graphics-related information.
configuration.informationOutputEnabled= 1;

LogSurfaceInformation

You can enable Kanzi to print to the debug console these graphics-related properties on application startup:

  • Requested and acquired surface properties. See Surface properties.
  • Size of the entire desktop and each display.
  • Size of the application window. See Application window position and size.
In application.cfg LogSurfaceInformation = value
In onConfigure() configuration.propertyOutputEnabled = value;
Values
0 Disable the logging of the graphics-related properties. Default value.
1 Enable the logging of the graphics-related properties.
application.cfg example
# Enables the logging of the graphics-related properties.
LogSurfaceInformation = 1
onConfigure() example
// Enables the logging of the graphics-related properties.
configuration.propertyOutputEnabled= 1;

Graphics library

您可以选择您 想在 application.cfg 的 Application::onConfigure() 函数中使用 ES 或 GL,还是想使用命令行参数,前提是您的目标支持命令行参数。

在命令行使用:

  • -gles 以使用 ES
  • -gl 以使用 GL
  • -egl 以使用 EGL
  • -wgl 以使用 WGL
对于 application.cfg GraphicsBackend = type
GraphicsContextAPI = contextAPI
对于 onConfigure() configuration.defaultSurfaceProperties.type = type;
configuration.defaultSurfaceProperties.contextApi = contextAPI;
type

要使用 OpenGLES 2.0:

  • 对于 application.cfg 使用 GLES
  • 对于 onConfigure() 使用 KZS_SURFACE_TYPE_ES2_ONLY

要使用 OpenGL:

  • 对于 application.cfg 使用 OpenGL
  • 对于 onConfigure() 使用 KZS_SURFACE_TYPE_GL_ONLY
contextAPI

要使用 WGL:

  • 对于 application.cfg 使用 WGL
  • 对于 onConfigure() 使用 KZS_GRAPHICS_CONTEXT_API_WGL

要使用 EGL:

  • 对于 application.cfg 使用 EGL
  • 对于 onConfigure() 使用 KZS_GRAPHICS_CONTEXT_API_EGL

要使用 GLX,对于 onConfigure() 使用 KZS_GRAPHICS_CONTEXT_API_GLX

application.cfg 示例
# 为 OpenGLES 2.0 渲染和 EGL 图形上下文设置表面目标。
GraphicsBackend = GLESGraphicsContextAPI = EGL
onConfigure() 示例
//为 OpenGLES 2.0 渲染和 EGL 图形上下文设置表面目标。
configuration.defaultSurfaceProperties.type = KZS_SURFACE_TYPE_ES2_ONLY;
configuration.defaultSurfaceProperties.contextApi = KZS_GRAPHICS_CONTEXT_API_EGL;

Surface properties

Surface properties control the properties of the hardware accelerated graphics surface on which Kanzi renders. They control the relation between image quality and rendering speed. The surface properties you set are considered requests to be matched by the graphics system of the target hardware. Whether a given request is considered an upper bound, a lower bound, or an exact value is platform dependent.

The default values of surface properties are platform dependent. You can get them by calling kzsSurfaceGetDefaultProperties().

In application.cfg

SurfaceBitsStencil = stencil
SurfaceBitsDepthBuffer = buffer
SurfaceBitsRed = red
SurfaceBitsGreen = green
SurfaceBitsBlue = blue
SurfaceBitsAlpha = alpha
SurfaceBitsPadding = padding
SurfaceSamplesAntialiasing = anti
SwapBehavior = swap

In onConfigure() configuration.defaultSurfaceProperties.bitsStencil = stencil;
configuration.defaultSurfaceProperties.bitsDepthBuffer = buffer;
configuration.defaultSurfaceProperties.bitsColorR = red;
configuration.defaultSurfaceProperties.bitsColorG = green;
configuration.defaultSurfaceProperties.bitsColorB = blue;
configuration.defaultSurfaceProperties.bitsAlpha = alpha;
configuration.defaultSurfaceProperties.bitsPadding = padding;
configuration.defaultSurfaceProperties.antiAliasing = anti;
configuration.defaultSurfaceProperties.swapBehaviorCopy = swap;
configuration.defaultSurfaceProperties.priority = priority;
Values
stencil Size of the stencil buffer in bits.
buffer Size of the depth buffer in bits.
red Size of the red color channel in bits.
green Size of the green color channel in bits.
blue Size of the blue color channel in bits.
alpha Size of the alpha channel in bits.
padding Size of the padding in bits that is added to the application window.
Setting the padding size is supported only on the QNX operating system.
anti Number of anti-aliasing samples used.
swap During the swap buffer, are the buffers swapped or copied. Use 1 for copy, 0 for swap, KZS_SURFACE_PROPERTY_DONT_CARE for automatic selection. Default value is 0 (swap).
priority Enables the creation of EGL content with a priority hint. The default value is KZS_SURFACE_PROPERTY_DONT_CARE, which does not apply the priority. You can set the priority only in the onConfigure() function.
application.cfg example

 

# An example configuration for a typical high-speed rendering application
SurfaceBitsStencil = 1
SurfaceBitsDepthBuffer = 16
SurfaceBitsRed = 5
SurfaceBitsGreen = 6
SurfaceBitsBlue = 5
SurfaceBitsAlpha = 0
SurfaceSamplesAntialiasing = 0

 

 

# An example configuration for a high image quality application
SurfaceBitsStencil = 8
SurfaceBitsDepthBuffer = 24
SurfaceBitsRed = 8
SurfaceBitsGreen = 8
SurfaceBitsBlue = 8
SurfaceBitsAlpha = 8
SurfaceSamplesAntialiasing = 4

 

onConfigure() example

 

// An example configuration for a typical high-speed rendering application
configuration.defaultSurfaceProperties.bitsStencil = 1;
configuration.defaultSurfaceProperties.bitsDepthBuffer = 16;
configuration.defaultSurfaceProperties.bitsColorR = 5;
configuration.defaultSurfaceProperties.bitsColorG = 6;
configuration.defaultSurfaceProperties.bitsColorB = 5;
configuration.defaultSurfaceProperties.bitsAlpha = 0;
configuration.defaultSurfaceProperties.antiAliasing = 0;

 

 

// An example configuration for a high image quality application
configuration.defaultSurfaceProperties.bitsStencil = 8;
configuration.defaultSurfaceProperties.bitsDepthBuffer = 24;
configuration.defaultSurfaceProperties.bitsColorR = 8;
configuration.defaultSurfaceProperties.bitsColorG = 8;
configuration.defaultSurfaceProperties.bitsColorB = 8;
configuration.defaultSurfaceProperties.bitsAlpha = 8;
configuration.defaultSurfaceProperties.antiAliasing = 4;

 

Application window position and size

You can set the position of the application on the screen relative to the upper-left corner of the screen and the size of the application window in pixels. The default size of the window is 640x480 pixels and center of the device screen.

When you run your Kanzi application in full-screen mode on a system with more than one display, you can set the default display where your Kanzi application window appears.

Note that in order to use the default application display, you have to set the window style of your Kanzi application to full-screen.

To make the application window fixed size, resizable, fullscreen, or without borders, see Application window style.

In application.cfg WindowX = positionX
WindowY = positionY
WindowWidth = width
WindowHeight = height
DefaultDisplayIndex = index
WindowOrder = order
In onConfigure() configuration.defaultWindowProperties.x = positionX;
configuration.defaultWindowProperties.y = positionY;
configuration.defaultWindowProperties.width = width;
configuration.defaultWindowProperties.height = height;
configuration.defaultWindowProperties.defaultDisplayIndex = index;
configuration.defaultWindowProperties.order = order;
Value
positionX Horizontal position of the top-left corner of the application window from the top-left corner of the screen in pixels. Use 0 to position the window to the left of the device screen.
positionY Vertical position of the top-left corner of the application window from the top-left corner of the screen in pixels. Use 0 to position the window to the top of the device screen.
width Window width in pixels.
height Window height in pixels.
index Index number of the display. Default value is 0.
order Z-order of the application window. The value is target platform dependent. The default value is NativeWindowProperties::WindowPositionUnspecified, which does not apply the order.
application.cfg example
# Set the width to 1280 and height to 720 pixels and place it 100 pixels
# from the top and 1 pixel from the left side of the device screen.
WindowWidth = 1280
WindowHeight = 720
WindowX = 100
WindowY = 1
# Place the application window in the top-left corner of the device screen.
WindowX = 0
WindowY = 0
# Sets the second display as the default display for the full-screen application window.
DefaultDisplayIndex = 1
# On Windows, places the application window on top of other windows.
WindowOrder = 0
onConfigure() example
// Set the width to 1280 and height to 720 pixels and place it 100 pixels
// from the top and 1 pixel from the left side of the device screen.
configuration.defaultWindowProperties.width = 1280;
configuration.defaultWindowProperties.height = 720;
configuration.defaultWindowProperties.x = 100;
configuration.defaultWindowProperties.y = 1;
// Place the application window in the top-left corner of the device screen.
configuration.defaultWindowProperties.x = 0;
configuration.defaultWindowProperties.y = 0;
// Sets the second display as the default display for the full-screen application window.
configuration.defaultWindowProperties.defaultDisplayIndex = 1;
// On Windows, places the application window on top of other windows.
configuration.defaultWindowProperties.order = 0;

Application window style

You can set the style of the window of your Kanzi application. Besides the default window with a border that users can resize, you can set your Kanzi application to launch in a window without a border, in a window of fixed size, and in a window that occupies the entire device screen.

To set the position and size of the application window, see Application window position and size.

In application.cfg WindowStyle = "style"
In onConfigure() configuration.defaultWindowProperties.style = style;
Value
style

To set a window without borders or any other decorations that users cannot resize:

  • In application.cfg use borderless.
  • In onConfigure() use KZS_WINDOW_STYLE_BORDERLESS.

To set a window that users cannot resize:

  • In application.cfg use fixed.
  • In onConfigure() use KZS_WINDOW_STYLE_FIXED.

To set a window that occupies the whole device screen:

  • In application.cfg use fullscreen.
  • In onConfigure() use KZS_WINDOW_STYLE_FULL_SCREEN.

To set a window that users can resize:

  • In application.cfg use resizable.
  • In onConfigure() use KZS_WINDOW_STYLE_RESIZABLE.
application.cfg example

 

# Launch the application in a window that occupies the whole screen of the device.
WindowStyle = "fullscreen"

 

onConfigure() example
// Launch the application in a window that occupies the whole screen of the device.
configuration.defaultWindowProperties.style = KZS_WINDOW_STYLE_FULL_SCREEN;

Input handling and screen transformation

You can define how your application handles touch and pointer input, and configure the orientation of your application screen. When you run your application on a device, you can set whether the application reacts to the pointer of the device, uses a touch screen, or both.

InputTransform

You can set the transformation matrix of the application screen. For example, use this to rotate the application screen.

In application.cfg InputTransform = transformation
In onConfigure() configuration.defaultEventSourceProperties.transformation = transformation;
Values
transformation Transformation matrix of the application screen.
application.cfg example

 

# Rotate an application screen sized 1280x720 pixels by 180 degrees.
InputTransform = -1, 0, 0, 0, -1, 0, 1280, 720, 1

 

onConfigure() example
// Rotate an application screen sized 1280x720 pixels by 180 degrees.
configuration.defaultEventSourceProperties.transformation = Matrix3x3::createTranslation(1280, 720) * Matrix3x3::createRotationInDegrees(180.0f);
 

The examples use this equation to calculate the transformation matrix:

KanziStudio应用程序配置详解_第1张图片

InputTranslation

You can set how Kanzi translates pointer and touch events.

In application.cfg InputTranslation = translation
In onConfigure() configuration.defaultEventSourceProperties.translation = translation;
Values
translation

Translation of pointer and touch events.

To not apply any translation:

  • In application.cfg use none. Default value.
  • In onConfigure() use KZS_INPUT_TRANSLATE_NONE. Default value.

To translate pointer events to touch events:

  • In application.cfg use PointerToTouch.
  • In onConfigure() use KZS_INPUT_TRANSLATE_POINTER_TO_TOUCH.

To translate pointer events to touch events, and preserve pointer events:

  • In application.cfg use PointerToTouchPreserve.
  • In onConfigure() use KZS_INPUT_TRANSLATE_POINTER_TO_TOUCH_PRESERVE.

To translate touch events to pointer events:

  • In application.cfg use TouchToPointer.
  • In onConfigure() use KZS_INPUT_TRANSLATE_TOUCH_TO_POINTER.

To translate touch events to pointer events, and preserve touch events:

  • In application.cfg use TouchToPointerPreserve.
  • In onConfigure() use KZS_INPUT_TRANSLATE_TOUCH_TO_POINTER_PRESERVE.
application.cfg example

 

# Translate pointer events to touch events.
InputTranslation = PointerToTouch

 

onConfigure() example
// Translate pointer events to touch events.
configuration.defaultEventSourceProperties.translation = KZS_INPUT_TRANSLATE_POINTER_TO_TOUCH;

InputDiscardPointer

You can set whether the application reacts to the pointer of the device.

In application.cfg InputDiscardPointer = value
In onConfigure() configuration.defaultEventSourceProperties.discardPointerEvents = value;
Values
value
0 Do not ignore pointer input. Default value.
1 Ignore pointer input.
application.cfg example

 

# Ignore pointer input.
InputDiscardPointer = 1

 

onConfigure() example
// Ignore pointer input.
configuration.defaultEventSourceProperties.discardPointerEvents = 1;

InputDiscardTouch

You can set whether the application reacts to touch input.

In application.cfg InputDiscardTouch = value
In onConfigure() configuration.defaultEventSourceProperties.discardTouchEvents = value;
Values
value
0 Do not ignore touch input. Default value.
1 Ignore touch input.
application.cfg example

 

# Ignore touch input.
InputDiscardTouch = 1

 

onConfigure() example
// Ignore touch input.
configuration.defaultEventSourceProperties.discardTouchEvents = 1;

Input event devices on Linux

如果本地窗口系统不提供输入设备处理,您可以在 Linux 端口配置 Kanzi 听从的输入事件设备。 This way Kanzi can listen to events directly from the input event devices provided by the operating system.
For example, in Vivante fbdev and WSEGL ports you can configure the input event devices that Kanzi listens to. In X11 and Wayland ports the native windowing system handles input devices.

Kanzi by default listens to all input event devices named eventN, where N is an integer, in the /dev/input directory.

In application.cfg InputEventDevice = path
In onConfigure() configuration.defaultEventSourceProperties.inputEventDevice = path;
Values
path Full path to one or more input event devices. Separate a list of several paths with a semicolon.
application.cfg example
# Listens to events from one input event device.
InputEventDevice = "/dev/input/event1"
# Listens to events from two input event devices.
InputEventDevice = "/dev/input/event0;/dev/input/event1"
# Disables listening to events from input event devices.
InputEventDevice = "none"
onConfigure() example
// Listens to events from one input event device.
configuration.defaultEventSourceProperties.inputEventDevice = "/dev/input/event1";
// Listens to events from two input event devices.
configuration.defaultEventSourceProperties.inputEventDevice = "/dev/input/event0;/dev/input/event1";
// Disables listening to events from input event devices.
configuration.defaultEventSourceProperties.inputEventDevice = "none";

你可能感兴趣的:(KanziStudio)