Namespaces
Variants
Actions

Archived:Selecting the correct OpenGL configuration based on display mode using Symbian C++

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.



Article Metadata

Compatibility
Platform(s): S60 3rd Edition and FP1

Article
Created: User:Technical writer 2 (10 May 2007)
Last edited: lpvalente (31 Oct 2012)

Overview

How to select the correct OpenGL configuration based on display mode.

Description

Since devices support different display modes, it is important to select an EGL frame buffer configuration that matches the display mode being used.

For example, let's assume that the display mode is EColor64K. EColor64K display mode uses RGBA5650 format. That is, 16 bits-per-pixel, 5 for red, 6 for blue, 5 for green, and 0 for alpha component. Checking the display mode and selecting the buffer size is done as follows:

    TDisplayMode mode = Window().DisplayMode();
TInt BufferSize = 0;
switch(mode)
{
case( EColor64K ):
BufferSize = 16;
break;
...
}

Configurations are matched against the following attributes:

    const EGLint attrib_list[] =
{
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_BUFFER_SIZE, BufferSize,
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, EGL_NONE
};

Then,

eglChooseConfig( iEglDisplay, attrib_list, configList, configSize, &numOfConfigs );

may return also RGBA8880 configurations along with RGBA5650 ones, since the results are filtered so that their attributes are equal or greater to requested ones. If the first configuration in configList is selected, the result may be that it does not match the current display mode. In this case, rendering will fail or result in a blank screen being displayed. Solution:

Use the following code to filter the returned configuration list

    for ( TInt i = 0; i < numOfConfigs; i++ )
{
EGLint red, green, blue, alpha;
eglGetConfigAttrib( iEglDisplay, configList[i], EGL_RED_SIZE, &red );
eglGetConfigAttrib( iEglDisplay, configList[i], EGL_GREEN_SIZE, &green );
eglGetConfigAttrib( iEglDisplay, configList[i], EGL_BLUE_SIZE, &blue );
eglGetConfigAttrib( iEglDisplay, configList[i], EGL_ALPHA_SIZE, &alpha );
if ( red == 5 && green == 6 && blue == 5 && alpha == 0 )
{
iSelectedConfig = configList[i];
break;
}
}
This page was last modified on 31 October 2012, at 20:41.
121 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved