[英]What is the right way to choose an EGL config in Android?
I'm using my own GLSurfaceView and have been struggling with crashes related to the EGL config chooser for a while. 我正在使用自己的GLSurfaceView,并且一直在努力解决与EGL配置选择器相关的崩溃问题。
It seems as though requesting RGB_565 by calling setEGLConfigChooser(5, 6, 5, 0, 16, 0)
should be the most supported. 看起来好像通过调用
setEGLConfigChooser(5, 6, 5, 0, 16, 0)
5,6,5,0,16,0)来请求RGB_565应该是最受支持的。 However, running this code on the emulator using host GPU I still get a crash, seemingly because my graphics card does not natively support RGB_565. 但是,使用主机GPU在模拟器上运行此代码我仍然会崩溃,似乎是因为我的显卡本身不支持RGB_565。 Setting to RGBA_8888 by calling
setEGLConfigChooser(8, 8, 8, 8, 16, 0)
seems to run fine on my emulator and HTC Rezound device, but I'm seeing a small number of crash reports in the market still. 通过调用
setEGLConfigChooser(8, 8, 8, 8, 16, 0)
设置为RGBA_8888似乎在我的模拟器和HTC Rezound设备上正常运行,但我仍然看到市场上的少量崩溃报告。
My guess is that most phones support RGBA_8888 natively now but a small number of my users have phones which are only compatible with RGB_565, which prevents my config chooser from getting a config. 我的猜测是大多数手机现在支持RGBA_8888,但是我的少数用户只有与RGB_565兼容的手机,这会阻止我的配置选择器获得配置。
Seeing as how I don't need the alpha channel, is there a right way to try RGBA_8888 first and then fall back to RGB_565? 看到我不需要alpha通道,是否有正确的方法首先尝试RGBA_8888然后再回到RGB_565? Is there a cleaner way to just ask for any ol' config without caring about the alpha value?
有没有更简洁的方式来询问任何ol'配置而不关心alpha值?
I saw a possible solution to determine ahead of time what the default display config was and request that specifically here: https://stackoverflow.com/a/20918779/234256 . 我看到了一个可能的解决方案,提前确定默认显示配置是什么,并在此特别请求: https : //stackoverflow.com/a/20918779/234256 。 Unfortunately, it looks like the suggested getPixelFormat function is deprecated as of API level 17.
不幸的是,从API级别17开始,不推荐使用建议的getPixelFormat函数。
From my experience I do not think setEGLConfigChooser() actually works correctly, ie it has a bug in its implementation. 根据我的经验,我不认为setEGLConfigChooser()实际上工作正常,即它的实现有一个错误。 Across a number of devices I have seen crashes where setEGLConfigChooser() fails to select a valid context even if the underlying surface is of the correct type.
在许多设备中,我看到崩溃,即使底层表面的类型正确,setEGLConfigChooser()也无法选择有效的上下文。
I have found the only reliable way to choose an EGL context is with a custom EGLConfigChooser. 我发现选择EGL上下文的唯一可靠方法是使用自定义EGLConfigChooser。 This also has the added benefit of choosing a config based on your own rules, eg surface must have depth and preferably RGB888 but can settle for RGB565.
这还有一个额外的好处,就是根据你自己的规则选择配置,例如,表面必须有深度,最好是RGB888,但可以适应RGB565。 This is actually pretty straightforward to use eglChooseConfig() to get a list of possible configurations and then return one of them that matches your selection criteria.
实际上,使用eglChooseConfig()获取可能的配置列表然后返回符合您选择条件的其中一个配置非常简单。
This gsoc code sample is for enabling MSAA. 此gsoc代码示例用于启用MSAA。 But it also contains code to select configurations, checking if they are available.
但它还包含选择配置的代码,检查它们是否可用。
https://code.google.com/p/gdc2011-android-opengl/source/browse/trunk/src/com/example/gdc11/MultisampleConfigChooser.java#90 https://code.google.com/p/gdc2011-android-opengl/source/browse/trunk/src/com/example/gdc11/MultisampleConfigChooser.java#90
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.