Using OpenGL ES 3.0+ in Kanzi

Kanzi supports the OpenGL ES 3.0, 3.1, and 3.2 shading languages (GLSL ES versions 300, 310, 320). With OpenGL ES 3.0+, you can use integer textures, floating point, and multiple render targets. For example, this allows you to have more precision with the rendered images, you can apply better looking post-processing effects, use HDR for textures and cubemap textures, and create seamless cubemaps. With OpenGL ES 3.2, you can use geometry and tessellation shaders.

Before you use OpenGL ES 3.0+, make sure that your target platform supports the API version.

To use OpenGL ES 3.0+ in Kanzi:

  1. In the Kanzi Studio main menu, select Project > Properties and set the Target Graphics API to OpenGL ES 3.0, OpenGL ES 3.1, or OpenGL ES 3.2.

    ../../_images/project-properties8.png ../../_images/target-graphics-api-opengl-es-301.png
  2. In your shader source files, add as the first line the OpenGL ES 3.0+ version tag:

    • For OpenGL ES 3.0, add

      #version 300 es
      
    • For OpenGL ES 3.1, add

      #version 310 es
      
    • For OpenGL ES 3.2, add

      #version 320 es
      

Setting the color format of textures

You can import to your Kanzi Studio project HDR and floating point images in .dds format and set the color format of the textures that use these images.

To set the color format of textures:

  1. In the Kanzi Studio main menu, select Project > Properties and set the Target Graphics API to OpenGL ES 3.0 or newer.

    ../../_images/project-properties8.png ../../_images/target-graphics-api-opengl-es-301.png
  2. In the Library > Resource Files > Images, select the image whose color format you want to set.

    ../../_images/library-resource-files-images1.png
  3. In the Properties, set:

    • Target Format to Raw

    • Color Format in Raw to the color format that you want Kanzi to use to interpret the texture

    ../../_images/target-format-raw.png ../../_images/color-format-in-raw.png
  4. In the Library > Materials and Textures > Textures, select the texture that uses the image whose color format you set in the previous step. In the Properties, set:

    • Wrap Mode to Clamp

    • Mipmap Mode to Linear or Nearest

    ../../_images/mipmapmode-linear-wrap-mode-clamp.png

Setting the format of a render target texture

Set the format of a render target texture to define the target pixel format used by the GPU.

To set the format of a render target texture:

  1. In the Kanzi Studio main menu, select Project > Properties and set the Target Graphics API to OpenGL ES 3.0 or newer.

    ../../_images/project-properties8.png ../../_images/target-graphics-api-opengl-es-301.png
  2. In the Library > Materials and Textures > Textures, select or create a Render Target Texture.

  3. In the Properties, set the Format to the target pixel format that you want to use.

    ../../_images/render-target-texture-es-30-format.png
  4. If your render target textures are in integer target format, set the Minification Filter and Magnification Filter properties to Nearest.

Selecting runtime graphics backend

On the Windows operating system you can select whether you want to use OpenGL ES or OpenGL in the Application::onConfigure() function, in the application.cfg, or using the command line arguments, if your target supports command line arguments.

On the command line use:

  • -gles to use OpenGL ES

  • -gl to use OpenGL

  • -egl to use EGL

  • -wgl to use WGL

  • -glx to use GLX

In application.cfg

SurfaceClientAPI = clientApi

GraphicsContextAPI = contextApi

In onConfigure()

configuration.defaultSurfaceProperties.clientAPI = clientApi;

configuration.defaultSurfaceProperties.contextAPI = contextApi;

Values

clientApi

To use OpenGL ES:

  • In application.cfg use gles.

  • In onConfigure() use SurfaceClientAPI::OpenGLES.

To use OpenGL:

  • In application.cfg use gl.

  • In onConfigure() use SurfaceClientAPI::OpenGL.

contextApi

To use WGL:

  • In application.cfg use wgl.

  • In onConfigure() use GraphicsContextAPI::WGL.

To use EGL:

  • In application.cfg use egl.

  • In onConfigure() use GraphicsContextAPI::EGL.

To use GLX:

  • In application.cfg use glx.

  • In onConfigure() use GraphicsContextAPI::GLX.

application.cfg example

# Sets the surface target for OpenGL rendering and WGL graphics context.
SurfaceClientAPI = gl
GraphicsContextAPI = wgl

onConfigure() example

// Sets the surface target for OpenGL rendering and WGL graphics context.
configuration.defaultSurfaceProperties.clientAPI = SurfaceClientAPI::OpenGL;
configuration.defaultSurfaceProperties.contextAPI = GraphicsContextAPI::WGL;