Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

OpenGL:根据显示模式选择正确的配置信息

From Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 09 Jul 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑
  • 设备, 软件 版本:

S60 3rd Edition and FP1


  • 详细描述:

自从手机支持不同的显示模式后,我们为当前使用的显示模式选择一个适当的EGL帧缓冲就显得尤为重要了。


举例来说,假设目前显示模式为EColor64K,EColor64K显示模式使用的RGBA5650格式,也就是说,每个像素16bit,红色5位,蓝色6位,绿色5位,Alpha透明0位。


如下代码所示,检查一下当前显示模式,然后选择帧缓冲:

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


根据相面属性选择适当配置信息:

    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
 
};


然后使用:

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


可能会返回RGBA8880配置信息,因为结果是被过滤过的,其属性可能等于或大于请求值。如果configList中第一个配置信息被选中,结果可能和当前显示模式不匹配,这种情况下,绘制将会发生错误,导致空白屏幕出现。


  • 解决方案:

使用下列代码来过滤返回的配置信息列表:

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 15 December 2011, at 10:03.
194 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×