From 5d006192aa896b033836245405902e8cfe7e47e2 Mon Sep 17 00:00:00 2001 From: newnon Date: Fri, 19 Jan 2018 04:28:22 +0300 Subject: [PATCH] V3 multisampling support (#18632) * Multisampling support * fix opengl initialization with multisampling * fix merge conflict * reverted default attributes --- cocos/platform/CCGLView.cpp | 2 +- cocos/platform/CCGLView.h | 1 + .../org/cocos2dx/lib/Cocos2dxActivity.java | 23 ++++++++++++++++--- .../platform/android/javaactivity-android.cpp | 8 +++---- .../platform/desktop/CCGLViewImpl-desktop.cpp | 5 ++++ cocos/platform/ios/CCGLViewImpl-ios.h | 1 + cocos/platform/ios/CCGLViewImpl-ios.mm | 3 +++ .../Classes/AppDelegate.cpp | 4 ++-- .../proj.ios_mac/ios/RootViewController.mm | 4 ++-- .../runtime-src/Classes/AppDelegate.cpp | 2 +- .../runtime-src/Classes/AppDelegate.cpp | 4 ++-- .../runtime-src/proj.win32/SimulatorWin.cpp | 4 ++-- tests/cpp-empty-test/Classes/AppDelegate.cpp | 2 +- .../cpp-empty-test/proj.ios/AppController.mm | 4 ++-- tests/cpp-tests/Classes/AppDelegate.cpp | 2 +- .../proj.ios/Classes/testsAppDelegate.mm | 4 ++-- .../js-tests/project/Classes/AppDelegate.cpp | 2 +- .../project/Classes/AppDelegate.cpp | 2 +- .../project/proj.ios/AppController.mm | 4 ++-- .../lua-tests/project/Classes/AppDelegate.cpp | 2 +- .../project/proj.ios_mac/ios/AppController.mm | 4 ++-- .../performance-tests/Classes/AppDelegate.cpp | 2 +- .../proj.ios/AppController.mm | 4 ++-- .../runtime-src/Classes/AppDelegate.cpp | 4 ++-- .../proj.ios_mac/ios/AppController.mm | 4 ++-- .../runtime-src/proj.win32/SimulatorWin.cpp | 4 ++-- .../lib/platform/win32/SimulatorWin.cpp | 4 ++-- 27 files changed, 68 insertions(+), 41 deletions(-) diff --git a/cocos/platform/CCGLView.cpp b/cocos/platform/CCGLView.cpp index e1f15fd912..2145e31bde 100644 --- a/cocos/platform/CCGLView.cpp +++ b/cocos/platform/CCGLView.cpp @@ -91,7 +91,7 @@ namespace { } //default context attributions are set as follows -GLContextAttrs GLView::_glContextAttrs = {8, 8, 8, 8, 24, 8}; +GLContextAttrs GLView::_glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; void GLView::setGLContextAttrs(GLContextAttrs& glContextAttrs) { diff --git a/cocos/platform/CCGLView.h b/cocos/platform/CCGLView.h index 6c24f4454c..9f7e80210b 100644 --- a/cocos/platform/CCGLView.h +++ b/cocos/platform/CCGLView.h @@ -82,6 +82,7 @@ struct GLContextAttrs int alphaBits; int depthBits; int stencilBits; + int multisamplingCount; }; NS_CC_BEGIN diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java index 2a2d139509..b58c480068 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -347,9 +347,9 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe private int[] mConfigAttributes; private final int EGL_OPENGL_ES2_BIT = 0x04; private final int EGL_OPENGL_ES3_BIT = 0x40; - public Cocos2dxEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize) + public Cocos2dxEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize, int multisamplingCount) { - mConfigAttributes = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize}; + mConfigAttributes = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize, multisamplingCount}; } public Cocos2dxEGLConfigChooser(int[] attributes) { @@ -368,17 +368,34 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe EGL10.EGL_ALPHA_SIZE, mConfigAttributes[3], EGL10.EGL_DEPTH_SIZE, mConfigAttributes[4], EGL10.EGL_STENCIL_SIZE, mConfigAttributes[5], + EGL10.EGL_SAMPLE_BUFFERS, (mConfigAttributes[6] > 0) ? 1 : 0, + EGL10.EGL_SAMPLES, mConfigAttributes[6], EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }, { - // GL ES 2 with user set + // GL ES 2 with user set 16 bit depth buffer EGL10.EGL_RED_SIZE, mConfigAttributes[0], EGL10.EGL_GREEN_SIZE, mConfigAttributes[1], EGL10.EGL_BLUE_SIZE, mConfigAttributes[2], EGL10.EGL_ALPHA_SIZE, mConfigAttributes[3], EGL10.EGL_DEPTH_SIZE, mConfigAttributes[4] >= 24 ? 16 : mConfigAttributes[4], EGL10.EGL_STENCIL_SIZE, mConfigAttributes[5], + EGL10.EGL_SAMPLE_BUFFERS, (mConfigAttributes[6] > 0) ? 1 : 0, + EGL10.EGL_SAMPLES, mConfigAttributes[6], + EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL10.EGL_NONE + }, + { + // GL ES 2 with user set 16 bit depth buffer without multisampling + EGL10.EGL_RED_SIZE, mConfigAttributes[0], + EGL10.EGL_GREEN_SIZE, mConfigAttributes[1], + EGL10.EGL_BLUE_SIZE, mConfigAttributes[2], + EGL10.EGL_ALPHA_SIZE, mConfigAttributes[3], + EGL10.EGL_DEPTH_SIZE, mConfigAttributes[4] >= 24 ? 16 : mConfigAttributes[4], + EGL10.EGL_STENCIL_SIZE, mConfigAttributes[5], + EGL10.EGL_SAMPLE_BUFFERS, 0, + EGL10.EGL_SAMPLES, 0, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }, diff --git a/cocos/platform/android/javaactivity-android.cpp b/cocos/platform/android/javaactivity-android.cpp index 50f6d982c2..2b9125efc8 100644 --- a/cocos/platform/android/javaactivity-android.cpp +++ b/cocos/platform/android/javaactivity-android.cpp @@ -114,12 +114,12 @@ JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNI cocos2d::Application::getInstance()->initGLContextAttrs(); GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs(); - int tmp[6] = {_glContextAttrs.redBits, _glContextAttrs.greenBits, _glContextAttrs.blueBits, - _glContextAttrs.alphaBits, _glContextAttrs.depthBits, _glContextAttrs.stencilBits}; + int tmp[7] = {_glContextAttrs.redBits, _glContextAttrs.greenBits, _glContextAttrs.blueBits, + _glContextAttrs.alphaBits, _glContextAttrs.depthBits, _glContextAttrs.stencilBits, _glContextAttrs.multisamplingCount}; - jintArray glContextAttrsJava = env->NewIntArray(6); - env->SetIntArrayRegion(glContextAttrsJava, 0, 6, tmp); + jintArray glContextAttrsJava = env->NewIntArray(7); + env->SetIntArrayRegion(glContextAttrsJava, 0, 7, tmp); return glContextAttrsJava; } diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index 0381545fcd..00a15c911a 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -288,6 +288,8 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram glfwWindowHint(GLFW_ALPHA_BITS,_glContextAttrs.alphaBits); glfwWindowHint(GLFW_DEPTH_BITS,_glContextAttrs.depthBits); glfwWindowHint(GLFW_STENCIL_BITS,_glContextAttrs.stencilBits); + + glfwWindowHint(GLFW_SAMPLES, _glContextAttrs.multisamplingCount); int neededWidth = rect.size.width * _frameZoomFactor; int neededHeight = rect.size.height * _frameZoomFactor; @@ -360,6 +362,9 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram // Enable point size by default. glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); + + if(_glContextAttrs.multisamplingCount > 0) + glEnable(GL_MULTISAMPLE); // // GLFW v3.2 no longer emits "onGLFWWindowSizeFunCallback" at creation time. Force default viewport: // setViewPortInPoints(0, 0, neededWidth, neededHeight); diff --git a/cocos/platform/ios/CCGLViewImpl-ios.h b/cocos/platform/ios/CCGLViewImpl-ios.h index 051a1abbd1..489f79df2a 100644 --- a/cocos/platform/ios/CCGLViewImpl-ios.h +++ b/cocos/platform/ios/CCGLViewImpl-ios.h @@ -56,6 +56,7 @@ public: static void convertAttrs(); static void* _pixelFormat; static int _depthFormat; + static int _multisamplingCount; /** sets the content scale factor */ virtual bool setContentScaleFactor(float contentScaleFactor) override; diff --git a/cocos/platform/ios/CCGLViewImpl-ios.mm b/cocos/platform/ios/CCGLViewImpl-ios.mm index a58a7afa00..3d45c04c6e 100644 --- a/cocos/platform/ios/CCGLViewImpl-ios.mm +++ b/cocos/platform/ios/CCGLViewImpl-ios.mm @@ -38,6 +38,7 @@ NS_CC_BEGIN void* GLViewImpl::_pixelFormat = kEAGLColorFormatRGB565; int GLViewImpl::_depthFormat = GL_DEPTH_COMPONENT16; +int GLViewImpl::_multisamplingCount = 0; GLViewImpl* GLViewImpl::createWithEAGLView(void *eaglview) { @@ -106,6 +107,8 @@ void GLViewImpl::convertAttrs() { CCASSERT(0, "Unsupported format for depth and stencil buffers. Using default"); } + + _multisamplingCount = _glContextAttrs.multisamplingCount; } GLViewImpl::GLViewImpl() diff --git a/templates/cpp-template-default/Classes/AppDelegate.cpp b/templates/cpp-template-default/Classes/AppDelegate.cpp index 5073abfb0a..9f76af5e71 100644 --- a/templates/cpp-template-default/Classes/AppDelegate.cpp +++ b/templates/cpp-template-default/Classes/AppDelegate.cpp @@ -40,8 +40,8 @@ AppDelegate::~AppDelegate() // it will affect all platforms void AppDelegate::initGLContextAttrs() { - // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + // set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/templates/cpp-template-default/proj.ios_mac/ios/RootViewController.mm b/templates/cpp-template-default/proj.ios_mac/ios/RootViewController.mm index 7a215b064d..d69e213ae2 100644 --- a/templates/cpp-template-default/proj.ios_mac/ios/RootViewController.mm +++ b/templates/cpp-template-default/proj.ios_mac/ios/RootViewController.mm @@ -48,8 +48,8 @@ depthFormat: cocos2d::GLViewImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; + multiSampling: cocos2d::GLViewImpl::_multisamling + numberOfSamples: cocos2d::GLViewImpl::_samples ]; // Enable or disable multiple touches [eaglView setMultipleTouchEnabled:NO]; diff --git a/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index 182e9537c1..a8510b0e51 100644 --- a/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -76,7 +76,7 @@ AppDelegate::~AppDelegate() void AppDelegate::initGLContextAttrs() { - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index 5dbdcb1753..60e6a364db 100644 --- a/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/lua-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -44,8 +44,8 @@ AppDelegate::~AppDelegate() // it will affect all platforms void AppDelegate::initGLContextAttrs() { - // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + // set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0 }; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.win32/SimulatorWin.cpp b/templates/lua-template-default/frameworks/runtime-src/proj.win32/SimulatorWin.cpp index 25b65d5a1c..e8a29548da 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.win32/SimulatorWin.cpp +++ b/templates/lua-template-default/frameworks/runtime-src/proj.win32/SimulatorWin.cpp @@ -95,8 +95,8 @@ std::string getCurAppPath(void) static void initGLContextAttrs() { - // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + // set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tests/cpp-empty-test/Classes/AppDelegate.cpp b/tests/cpp-empty-test/Classes/AppDelegate.cpp index 5df55445c1..35c9dfc1e5 100644 --- a/tests/cpp-empty-test/Classes/AppDelegate.cpp +++ b/tests/cpp-empty-test/Classes/AppDelegate.cpp @@ -22,7 +22,7 @@ AppDelegate::~AppDelegate() void AppDelegate::initGLContextAttrs() { - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tests/cpp-empty-test/proj.ios/AppController.mm b/tests/cpp-empty-test/proj.ios/AppController.mm index 4310cbe5a6..ee613e904a 100644 --- a/tests/cpp-empty-test/proj.ios/AppController.mm +++ b/tests/cpp-empty-test/proj.ios/AppController.mm @@ -52,8 +52,8 @@ static AppDelegate s_sharedApplication; depthFormat: cocos2d::GLViewImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil - multiSampling: NO - numberOfSamples: 0]; + multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO + numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount]; // Use RootViewController manage CCEAGLView diff --git a/tests/cpp-tests/Classes/AppDelegate.cpp b/tests/cpp-tests/Classes/AppDelegate.cpp index 7d88491d79..c82daa36b4 100644 --- a/tests/cpp-tests/Classes/AppDelegate.cpp +++ b/tests/cpp-tests/Classes/AppDelegate.cpp @@ -48,7 +48,7 @@ AppDelegate::~AppDelegate() void AppDelegate::initGLContextAttrs() { // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm b/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm index 4e7a469e87..38d920273b 100644 --- a/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm +++ b/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm @@ -56,8 +56,8 @@ static AppDelegate s_sharedApplication; depthFormat: cocos2d::GLViewImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; + multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO + numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ]; #if !defined(CC_TARGET_OS_TVOS) [eaglView setMultipleTouchEnabled:YES]; diff --git a/tests/js-tests/project/Classes/AppDelegate.cpp b/tests/js-tests/project/Classes/AppDelegate.cpp index 0c2193ff5d..c6897a9d69 100644 --- a/tests/js-tests/project/Classes/AppDelegate.cpp +++ b/tests/js-tests/project/Classes/AppDelegate.cpp @@ -69,7 +69,7 @@ AppDelegate::~AppDelegate() void AppDelegate::initGLContextAttrs() { - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tests/lua-empty-test/project/Classes/AppDelegate.cpp b/tests/lua-empty-test/project/Classes/AppDelegate.cpp index c0bded8c06..860f67a35a 100644 --- a/tests/lua-empty-test/project/Classes/AppDelegate.cpp +++ b/tests/lua-empty-test/project/Classes/AppDelegate.cpp @@ -23,7 +23,7 @@ AppDelegate::~AppDelegate() void AppDelegate::initGLContextAttrs() { - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tests/lua-empty-test/project/proj.ios/AppController.mm b/tests/lua-empty-test/project/proj.ios/AppController.mm index 67ab321d93..010bccb235 100644 --- a/tests/lua-empty-test/project/proj.ios/AppController.mm +++ b/tests/lua-empty-test/project/proj.ios/AppController.mm @@ -51,8 +51,8 @@ static AppDelegate s_sharedApplication; depthFormat: cocos2d::GLViewImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; + multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO + numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ]; // Use RootViewController manage CCEAGLView viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; diff --git a/tests/lua-tests/project/Classes/AppDelegate.cpp b/tests/lua-tests/project/Classes/AppDelegate.cpp index 23db260da5..e487dffe55 100644 --- a/tests/lua-tests/project/Classes/AppDelegate.cpp +++ b/tests/lua-tests/project/Classes/AppDelegate.cpp @@ -21,7 +21,7 @@ AppDelegate::~AppDelegate() void AppDelegate::initGLContextAttrs() { - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm b/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm index 298756c484..b715d797c1 100644 --- a/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm +++ b/tests/lua-tests/project/proj.ios_mac/ios/AppController.mm @@ -51,8 +51,8 @@ static AppDelegate s_sharedApplication; depthFormat: cocos2d::GLViewImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; + multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO + numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ]; #if !defined(CC_TARGET_OS_TVOS) [eaglView setMultipleTouchEnabled:YES]; diff --git a/tests/performance-tests/Classes/AppDelegate.cpp b/tests/performance-tests/Classes/AppDelegate.cpp index 43ae410038..f6c460fca2 100644 --- a/tests/performance-tests/Classes/AppDelegate.cpp +++ b/tests/performance-tests/Classes/AppDelegate.cpp @@ -21,7 +21,7 @@ AppDelegate::~AppDelegate() void AppDelegate::initGLContextAttrs() { // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tests/performance-tests/proj.ios/AppController.mm b/tests/performance-tests/proj.ios/AppController.mm index e5806715cc..afd39c68f0 100644 --- a/tests/performance-tests/proj.ios/AppController.mm +++ b/tests/performance-tests/proj.ios/AppController.mm @@ -53,8 +53,8 @@ static AppDelegate s_sharedApplication; depthFormat: cocos2d::GLViewImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; + multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO + numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ]; // Enable or disable multiple touches [eaglView setMultipleTouchEnabled:NO]; diff --git a/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp b/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp index 863b4b24a5..63d3dec1fa 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -21,8 +21,8 @@ AppDelegate::~AppDelegate() // it will affect all platforms void AppDelegate::initGLContextAttrs() { - // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + // set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm b/tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm index e4bf02c46d..2b06dbd024 100755 --- a/tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm +++ b/tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm @@ -55,8 +55,8 @@ static AppDelegate s_sharedApplication; depthFormat: cocos2d::GLViewImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil - multiSampling: NO - numberOfSamples: 0 ]; + multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO + numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ]; [eaglView setMultipleTouchEnabled:YES]; diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp b/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp index 3b18cce946..13e5358b51 100644 --- a/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp +++ b/tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp @@ -116,8 +116,8 @@ static bool stringEndWith(const std::string& str, const std::string& needle) static void initGLContextAttrs() { - // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + // set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); } diff --git a/tools/simulator/libsimulator/lib/platform/win32/SimulatorWin.cpp b/tools/simulator/libsimulator/lib/platform/win32/SimulatorWin.cpp index c29d23a081..0c338d3ebe 100644 --- a/tools/simulator/libsimulator/lib/platform/win32/SimulatorWin.cpp +++ b/tools/simulator/libsimulator/lib/platform/win32/SimulatorWin.cpp @@ -88,8 +88,8 @@ std::string getCurAppPath(void) static void initGLContextAttrs() { - // set OpenGL context attributes: red,green,blue,alpha,depth,stencil - GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + // set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0}; GLView::setGLContextAttrs(glContextAttrs); }