cocos2d-x 3.3的ScrollView在android模拟器中的白底蓝底问题
发布时间:2020-12-14 20:14:43 所属栏目:百科 来源:网络整理
导读:首先可以参考:http://www.cocoachina.com/bbs/read.php?tid=195955 无论是真机还是模拟器,只要出现白底蓝底问题,基本上都可以通过修改 glSurfaceView.setEGLConfigChooser的参数进行修正。 在默认情况下,cocos2dx会将C++中的AppDelegate::initGLContextA
首先可以参考:http://www.cocoachina.com/bbs/read.php?tid=195955 无论是真机还是模拟器,只要出现白底蓝底问题,基本上都可以通过修改glSurfaceView.setEGLConfigChooser的参数进行修正。 在默认情况下,cocos2dx会将C++中的AppDelegate::initGLContextAttrs()中设置的glContextAttrs传给java中的glSurfaceView.setEGLConfigChooser。 C++:
void AppDelegate::initGLContextAttrs() { //set OpenGL context attributions,now can only set six attributions: //red,green,blue,alpha,depth,stencil GLContextAttrs <span style="color:#ff0000;">glContextAttrs = {8,8,24,8}</span>; GLView::setGLContextAttrs(glContextAttrs); } Cocos2dxActivity.java:
<span style="font-family:helvetica neue;color: rgb(51,51);"> public Cocos2dxGLSurfaceView onCreateView() { Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); //this line is need on some device if we specify an alpha bits if(this.mGLContextAttrs[3] > 0) glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);</span><span style="color:#333333;"> </span><span style="color: rgb(51,51); font-family: 'helvetica neue';">...</span><span style="font-family: 'helvetica neue';"><span style="color:#333333;"> cocos2dEGLConfigChooser chooser = new cocos2dEGLConfigChooser(</span><strong><span style="color:#ff0000;">this.mGLContextAttrs</span></strong><span style="color:#333333;">); glSurfaceView.setEGLConfigChooser(chooser); return glSurfaceView; }</span></span>如果是模拟器,cocos2dx还作了特别处理: Cocos2dxActivity.java:
public void init() { ... // Switch to supported OpenGL (ARGB888) mode on emulator if (isAndroidEmulator()) <span style="color:#ff0000;">this.mGLSurfaceView.setEGLConfigChooser(8,16,0);</span> ... }最后一个参数是0,禁止了模板缓冲,导致了渲染错误。 本人用的是android自带的模拟器,而不是android x86虚拟机,前者可以使用Host GPU,后者,本人安装的是4.0rc,不支持OpenGL ES(据说4.4之后才支持),根本无法运行cocos2dx程序。 解决办法就是将下列语句删除:
if (isAndroidEmulator()) <span style="color:#ff0000;">this.mGLSurfaceView.setEGLConfigChooser(8,0);</span> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- azure-pipelines-release-pipeline – 如何在使用VSTS Api获
- 《Python Web开发》作者Harry Percival:TDD就是微小而渐进
- c#,Textbox.Text编码
- Oracle(1):windows 10 安装与配置
- net.sf.json.JSONException: There is a cycle in the hier
- 将场景导出XML或JSON或二进制并且解析还原场景
- postgresql – postgres中varchar的最小和最大长度?
- 设计模式-OOD的设计原则(2)-"里氏代换原则"
- SQLite的空字串“”、0、NULL、“NULL”的区别
- c# – 如何使代码合同相信变量不为null?