您当前的位置: 首页 >  3d

鱼儿-1226

暂无认证

  • 0浏览

    0关注

    1100博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

cocos2d-x 3D模型 抗锯齿方法

鱼儿-1226 发布时间:2020-09-21 10:10:47 ,浏览量:0

随着cocos2d-x对3D特性的支持,很多开发者开始尝试在自己的游戏中载入3D模型,不过最近有些开发者表示不能接受3D模型显示时边缘的锯齿现象,特别是在windows上看着会更明显,这里给大家提供一个方法在不同平台上解决这个问题。Windows/Mac平台: 在cocos/platform/desktop/CCGLViewImpl.cpp 然后在GLViewImpl::initWithRect函数中添加下面语句 glfwWindowHint(GLFW_SAMPLES,4);4是一个采样的等级,你可以输入2,4,8 数值越大抗锯齿的效果越好,不过经过本人测试一般的android机器也就支持到4再高就无法运行了。IOS平台: 找到工程目录下proj.ios_mac/ios/AppController.mm文件,然后找到下面这行代码 CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] 修改 multiSampling: NO 为 multiSampling: YES 修改 numberOfSamples: 0 为 numberOfSamples: 4Android平台: 首先,在cocos\platform\android\java\src\org\cocos2dx\lib目录下找到Cocos2dxActivity.java文件,在文件头包含下面几项: import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLDisplay; import android.opengl.GLSurfaceView.EGLConfigChooser; 接下来,在Cocos2dxActivity类的内部添加一个类 如下:  public class BaseConfigChooser implements EGLConfigChooser { public BaseConfigChooser(){ } public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display){ int CONFIG_ATTRIBS[] =   {   EGL10.EGL_RED_SIZE,       5,   EGL10.EGL_GREEN_SIZE,     6,   EGL10.EGL_BLUE_SIZE,      5,   EGL10.EGL_DEPTH_SIZE,     16,   EGL10.EGL_ALPHA_SIZE,     EGL10.EGL_DONT_CARE,   EGL10.EGL_STENCIL_SIZE,   EGL10.EGL_DONT_CARE,   EGL10.EGL_SURFACE_TYPE,   EGL10.EGL_WINDOW_BIT, EGL10.EGL_SAMPLES, 4, EGL10.EGL_NONE  };           int[] num_config = new int[1];           egl.eglChooseConfig(display, CONFIG_ATTRIBS, null, 0, num_config);           int numConfigs = num_config[0];           if (numConfigs

关注
打赏
1604459285
查看更多评论
立即登录/注册

微信扫码登录

0.0452s