diff --git a/cocos/platform/CCApplicationProtocol.h b/cocos/platform/CCApplicationProtocol.h index 32727027e2..f490e390e6 100644 --- a/cocos/platform/CCApplicationProtocol.h +++ b/cocos/platform/CCApplicationProtocol.h @@ -102,6 +102,8 @@ public: */ virtual void setAnimationInterval(double interval) = 0; + virtual bool setOGLCntattrs() { return false; } + /** @brief Get current language config @return Current language config diff --git a/cocos/platform/CCGLView.cpp b/cocos/platform/CCGLView.cpp index f7cdf090ac..52d42d473f 100644 --- a/cocos/platform/CCGLView.cpp +++ b/cocos/platform/CCGLView.cpp @@ -70,6 +70,16 @@ namespace { } +int* GLView::_OGLCntattrs = new int[6]; + +void GLView::setOGLCntattrs(int* OGLCntattrs) +{ + for(int i = 0; i < 6; i++) + { + _OGLCntattrs[i] = OGLCntattrs[i]; + } +} + GLView::GLView() : _scaleX(1.0f) , _scaleY(1.0f) diff --git a/cocos/platform/CCGLView.h b/cocos/platform/CCGLView.h index cb0e133702..9d829c3703 100644 --- a/cocos/platform/CCGLView.h +++ b/cocos/platform/CCGLView.h @@ -98,6 +98,9 @@ public: virtual bool windowShouldClose() { return false; }; + static void setOGLCntattrs(int* OGLCntattrs); + static int* _OGLCntattrs; + /** * Polls input events. Subclass must implement methods if platform * does not provide event callbacks. diff --git a/cocos/platform/android/CCGLViewImpl.cpp b/cocos/platform/android/CCGLViewImpl.cpp index 90fdc30df7..8f127ca176 100644 --- a/cocos/platform/android/CCGLViewImpl.cpp +++ b/cocos/platform/android/CCGLViewImpl.cpp @@ -30,13 +30,13 @@ THE SOFTWARE. #include "base/CCDirector.h" #include "base/ccMacros.h" #include "jni/IMEJni.h" +#include "jni/JniHelper.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "CCGL.h" #include #include - // exists since android 2.3 #include PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0; @@ -73,6 +73,13 @@ GLViewImpl* GLViewImpl::create(const std::string& viewName) return nullptr; } +GLViewImpl* GLViewImpl::createWithOGLCntattrs(const std::string& viewName) +{ + activityInitWithOGLCntattrsJni(_OGLCntattrs); + + return nullptr; +} + GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName) { auto ret = new GLViewImpl(); diff --git a/cocos/platform/android/CCGLViewImpl.h b/cocos/platform/android/CCGLViewImpl.h index 820189e148..c437793201 100644 --- a/cocos/platform/android/CCGLViewImpl.h +++ b/cocos/platform/android/CCGLViewImpl.h @@ -41,6 +41,7 @@ public: // static function static GLViewImpl* create(const std::string &viewname); + static GLViewImpl* createWithOGLCntattrs(const std::string& viewName); static GLViewImpl* createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor = 1.0f); static GLViewImpl* createWithFullScreen(const std::string& viewName); 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 78929fb300..a3be94bd7d 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java @@ -84,11 +84,15 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe Cocos2dxHelper.init(this); - this.init(); - if (mVideoHelper == null) { - mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout); - } + preCreateOGLCtx(); + //this.init(); + //this.reinit(); + //if (mVideoHelper == null) { + //mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout); + //} } + + private static native void preCreateOGLCtx(); // =========================================================== // Getter & Setter @@ -190,6 +194,49 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe // Set framelayout as the content view setContentView(mFrameLayout); } + + public void initWithOGLCntattrs(int[] OGLCntattrs) { + + // FrameLayout + ViewGroup.LayoutParams framelayout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT); + mFrameLayout = new FrameLayout(this); + mFrameLayout.setLayoutParams(framelayout_params); + + // Cocos2dxEditText layout + ViewGroup.LayoutParams edittext_layout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + Cocos2dxEditText edittext = new Cocos2dxEditText(this); + edittext.setLayoutParams(edittext_layout_params); + + // ...add to FrameLayout + mFrameLayout.addView(edittext); + + // Cocos2dxGLSurfaceView + this.mGLSurfaceView = new Cocos2dxGLSurfaceView(this); + + //this.mGLSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); + this.mGLSurfaceView.setEGLConfigChooser(OGLCntattrs[0], OGLCntattrs[1],OGLCntattrs[2],OGLCntattrs[3],OGLCntattrs[4],OGLCntattrs[5]); + + // ...add to FrameLayout + mFrameLayout.addView(this.mGLSurfaceView); + + // Switch to supported OpenGL (ARGB888) mode on emulator + if (isAndroidEmulator()) + this.mGLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0); + + this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer()); + this.mGLSurfaceView.setCocos2dxEditText(edittext); + + // Set framelayout as the content view + setContentView(mFrameLayout); + + if (mVideoHelper == null) { + mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout); + } + } public Cocos2dxGLSurfaceView onCreateView() { return new Cocos2dxGLSurfaceView(this); diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 3cabec4822..039b721e37 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -102,6 +102,10 @@ public class Cocos2dxHelper { public static Activity getActivity() { return sActivity; } + + public static void activityInitWithOGLCntattrs(int[] OGLCntattrs){ + ((Cocos2dxActivity)sActivity).initWithOGLCntattrs(OGLCntattrs); + } public static void addOnActivityResultListener(OnActivityResultListener listener) { onActivityResultListeners.add(listener); diff --git a/cocos/platform/android/javaactivity.cpp b/cocos/platform/android/javaactivity.cpp index b16482600e..c5ed358707 100644 --- a/cocos/platform/android/javaactivity.cpp +++ b/cocos/platform/android/javaactivity.cpp @@ -64,7 +64,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi glview->setFrameSize(w, h); director->setOpenGLView(glview); - cocos_android_app_init(env, thiz); + //cocos_android_app_init(env, thiz); cocos2d::Application::getInstance()->run(); } @@ -79,7 +79,13 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi director->getEventDispatcher()->dispatchEvent(&recreatedEvent); director->setGLDefaultValues(); } +} +void Java_org_cocos2dx_lib_Cocos2dxActivity_preCreateOGLCtx(JNIEnv* env, jobject thiz) +{ + cocos_android_app_init(env, thiz); + cocos2d::Application::getInstance()->setOGLCntattrs(); + GLViewImpl::createWithOGLCntattrs("Android app"); } void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h) diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index 3449bbbc9d..ad20af8993 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -209,6 +209,19 @@ void disableAccelerometerJni() { } } +void activityInitWithOGLCntattrsJni(int* OGLCntattrs) { + JniMethodInfo t; + + if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "activityInitWithOGLCntattrs", "([I)V")) { + jintArray OGLCntattrsJava = t.env->NewIntArray(6); + t.env->SetIntArrayRegion(OGLCntattrsJava, 0, 6, OGLCntattrs); + + t.env->CallStaticVoidMethod(t.classID, t.methodID, OGLCntattrsJava); + t.env->DeleteLocalRef(t.classID); + CCLOG("call Cocos2dxHelper activityInitWithOGLCntattrs"); + } +} + // functions for UserDefault bool getBoolForKeyJNI(const char* key, bool defaultValue) { diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h index 34d521a911..10f5e9d18b 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h @@ -39,6 +39,7 @@ extern std::string getFileDirectoryJNI(); extern void enableAccelerometerJni(); extern void disableAccelerometerJni(); extern void setAccelerometerIntervalJni(float interval); +extern void activityInitWithOGLCntattrsJni(int* OGLCntattrs); // functions for UserDefault extern bool getBoolForKeyJNI(const char* key, bool defaultValue); extern int getIntegerForKeyJNI(const char* key, int defaultValue); diff --git a/cocos/platform/desktop/CCGLViewImpl.cpp b/cocos/platform/desktop/CCGLViewImpl.cpp index 515e1272cf..4729009d25 100644 --- a/cocos/platform/desktop/CCGLViewImpl.cpp +++ b/cocos/platform/desktop/CCGLViewImpl.cpp @@ -328,6 +328,15 @@ GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName, const return nullptr; } +void GLViewImpl::convertattrs() +{ + glfwWindowHint(GLFW_RED_BITS,_OGLCntattrs[0]); + glfwWindowHint(GLFW_GREEN_BITS,_OGLCntattrs[1]); + glfwWindowHint(GLFW_BLUE_BITS,_OGLCntattrs[2]); + glfwWindowHint(GLFW_ALPHA_BITS,_OGLCntattrs[3]); + glfwWindowHint(GLFW_DEPTH_BITS,_OGLCntattrs[4]); + glfwWindowHint(GLFW_STENCIL_BITS,_OGLCntattrs[5]); +} bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor) { @@ -336,6 +345,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram _frameZoomFactor = frameZoomFactor; glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); + convertattrs(); _mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor, rect.size.height * _frameZoomFactor, diff --git a/cocos/platform/desktop/CCGLViewImpl.h b/cocos/platform/desktop/CCGLViewImpl.h index a9befbbd51..cbacea34ad 100644 --- a/cocos/platform/desktop/CCGLViewImpl.h +++ b/cocos/platform/desktop/CCGLViewImpl.h @@ -148,6 +148,7 @@ protected: friend class GLFWEventHandler; private: + void convertattrs(); CC_DISALLOW_COPY_AND_ASSIGN(GLViewImpl); }; diff --git a/cocos/platform/ios/CCGLViewImpl.h b/cocos/platform/ios/CCGLViewImpl.h index 795e0077b9..d3950e5f38 100644 --- a/cocos/platform/ios/CCGLViewImpl.h +++ b/cocos/platform/ios/CCGLViewImpl.h @@ -52,6 +52,12 @@ public: /** creates a GLViewImpl with a name in fullscreen mode */ static GLViewImpl* createWithFullScreen(const std::string& viewName); + + static void convert(int* _OGLCntattrs); + static void* _pixelFormat; + static int _depthFormat; + + void setSize(); /** sets the content scale factor */ bool setContentScaleFactor(float contentScaleFactor); diff --git a/cocos/platform/ios/CCGLViewImpl.mm b/cocos/platform/ios/CCGLViewImpl.mm index 567d55bc43..8438cc968a 100644 --- a/cocos/platform/ios/CCGLViewImpl.mm +++ b/cocos/platform/ios/CCGLViewImpl.mm @@ -36,6 +36,9 @@ NS_CC_BEGIN +void* GLViewImpl::_pixelFormat = kEAGLColorFormatRGB565; +int GLViewImpl::_depthFormat = GL_DEPTH_COMPONENT16; + GLViewImpl* GLViewImpl::createWithEAGLView(void *eaglview) { auto ret = new GLViewImpl; @@ -80,6 +83,18 @@ GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName) return nullptr; } +void GLViewImpl::convert(int* OGLCntattrs) +{ + if(OGLCntattrs[0]==8 && OGLCntattrs[1]==8 && OGLCntattrs[2]==8 && OGLCntattrs[3]==8) + { + _pixelFormat = kEAGLColorFormatRGBA8; + } + if(OGLCntattrs[4]==24 && OGLCntattrs[5]==8) + { + _depthFormat = GL_DEPTH24_STENCIL8_OES; + } +} + GLViewImpl::GLViewImpl() { } @@ -105,17 +120,19 @@ bool GLViewImpl::initWithEAGLView(void *eaglview) bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor) { CGRect r = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); + convert(_OGLCntattrs); CCEAGLView *eaglview = [CCEAGLView viewWithFrame: r - pixelFormat: kEAGLColorFormatRGB565 - depthFormat: GL_DEPTH24_STENCIL8_OES + pixelFormat: (NSString*)_pixelFormat + depthFormat: _depthFormat preserveBackbuffer: NO sharegroup: nil multiSampling: NO numberOfSamples: 0]; + [eaglview setMultipleTouchEnabled:YES]; - _screenSize.width = _designResolutionSize.width = [eaglview getWidth]; - _screenSize.height = _designResolutionSize.height = [eaglview getHeight]; + //_screenSize.width = _designResolutionSize.width = [eaglview getWidth]; + //_screenSize.height = _designResolutionSize.height = [eaglview getHeight]; // _scaleX = _scaleY = [eaglview contentScaleFactor]; _eaglview = eaglview; @@ -123,6 +140,13 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram return true; } +void GLViewImpl::setSize() +{ + CCEAGLView *eaglview = (CCEAGLView*) _eaglview; + _screenSize.width = _designResolutionSize.width = [eaglview getWidth]; + _screenSize.height = _designResolutionSize.height = [eaglview getHeight]; +} + bool GLViewImpl::initWithFullScreen(const std::string& viewName) { CGRect rect = [[UIScreen mainScreen] bounds]; diff --git a/cocos/platform/linux/CCApplication.cpp b/cocos/platform/linux/CCApplication.cpp index 14391ea3db..f95ba45e0b 100644 --- a/cocos/platform/linux/CCApplication.cpp +++ b/cocos/platform/linux/CCApplication.cpp @@ -63,6 +63,7 @@ Application::~Application() int Application::run() { + setOGLCntattrs(); // Initialize instance and cocos2d. if (! applicationDidFinishLaunching()) { diff --git a/cocos/platform/mac/CCApplication.mm b/cocos/platform/mac/CCApplication.mm index c635d445b4..3a41f1377e 100644 --- a/cocos/platform/mac/CCApplication.mm +++ b/cocos/platform/mac/CCApplication.mm @@ -64,6 +64,7 @@ Application::~Application() int Application::run() { + setOGLCntattrs(); if(!applicationDidFinishLaunching()) { return 1; diff --git a/cocos/platform/win32/CCApplication.cpp b/cocos/platform/win32/CCApplication.cpp index 01dd2d82f2..55d7a85b11 100644 --- a/cocos/platform/win32/CCApplication.cpp +++ b/cocos/platform/win32/CCApplication.cpp @@ -69,6 +69,8 @@ int Application::run() QueryPerformanceFrequency(&nFreq); QueryPerformanceCounter(&nLast); + setOGLCntattrs(); + // Initialize instance and cocos2d. if (!applicationDidFinishLaunching()) { diff --git a/tests/cpp-empty-test/Classes/AppDelegate.cpp b/tests/cpp-empty-test/Classes/AppDelegate.cpp index 036c732ca7..511f3530df 100644 --- a/tests/cpp-empty-test/Classes/AppDelegate.cpp +++ b/tests/cpp-empty-test/Classes/AppDelegate.cpp @@ -17,6 +17,15 @@ AppDelegate::~AppDelegate() { } +bool AppDelegate::setOGLCntattrs() +{ + int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; + + GLView::setOGLCntattrs(OGLCntattrs); + + return true; +} + bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); diff --git a/tests/cpp-empty-test/Classes/AppDelegate.h b/tests/cpp-empty-test/Classes/AppDelegate.h index 18ee8aeb63..2f4e608890 100644 --- a/tests/cpp-empty-test/Classes/AppDelegate.h +++ b/tests/cpp-empty-test/Classes/AppDelegate.h @@ -14,6 +14,8 @@ public: AppDelegate(); virtual ~AppDelegate(); + virtual bool setOGLCntattrs(); + /** @brief Implement Director and Scene init code here. @return true Initialize success, app continue. diff --git a/tests/cpp-empty-test/proj.ios/AppController.mm b/tests/cpp-empty-test/proj.ios/AppController.mm index daa056bca0..6171e0a739 100644 --- a/tests/cpp-empty-test/proj.ios/AppController.mm +++ b/tests/cpp-empty-test/proj.ios/AppController.mm @@ -38,19 +38,25 @@ static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + cocos2d::Application *app = cocos2d::Application::getInstance(); + app->setOGLCntattrs(); + // Override point for customization after application launch. // Add the view controller's view to the window and display. window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] + auto glview = cocos2d::GLViewImpl::createWithFullScreen("ios cpp-empty-test"); + CCEAGLView *eaglView = (CCEAGLView*)glview->getEAGLView(); + /*CCEAGLView eaglView = [CCEAGLView viewWithFrame: [window bounds] pixelFormat: kEAGLColorFormatRGBA8 depthFormat: GL_DEPTH_COMPONENT16 preserveBackbuffer: NO - sharegroup:nil - multiSampling:NO - numberOfSamples:0]; + sharegroup: nil + multiSampling: NO + numberOfSamples: 0];*/ - // Use RootViewController manage CCEAGLView + + // Use RootViewController manage CCEAGLView viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; viewController.wantsFullScreenLayout = YES; viewController.view = eaglView; @@ -71,11 +77,12 @@ static AppDelegate s_sharedApplication; [[UIApplication sharedApplication] setStatusBarHidden: YES]; + glview->setSize(); // IMPORTANT: Setting the GLView should be done after creating the RootViewController - cocos2d::GLViewImpl *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); + //cocos2d::GLViewImpl *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); cocos2d::Director::getInstance()->setOpenGLView(glview); - cocos2d::Application *app = cocos2d::Application::getInstance(); + //cocos2d::Application *app = cocos2d::Application::getInstance(); app->run(); return YES; } diff --git a/tests/cpp-tests/Classes/AppDelegate.cpp b/tests/cpp-tests/Classes/AppDelegate.cpp index b5daf4a333..f97219d86f 100644 --- a/tests/cpp-tests/Classes/AppDelegate.cpp +++ b/tests/cpp-tests/Classes/AppDelegate.cpp @@ -43,6 +43,17 @@ AppDelegate::~AppDelegate() cocostudio::ArmatureDataManager::destroyInstance(); } +bool AppDelegate::setOGLCntattrs() +{ + //set OpenGL context attributions + //red,green,blue,alpha,depth,stencil + int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; + + GLView::setOGLCntattrs(OGLCntattrs); + + return true; +} + bool AppDelegate::applicationDidFinishLaunching() { // As an example, load config file diff --git a/tests/cpp-tests/Classes/AppDelegate.h b/tests/cpp-tests/Classes/AppDelegate.h index 4cc79a14eb..44cb8cace2 100644 --- a/tests/cpp-tests/Classes/AppDelegate.h +++ b/tests/cpp-tests/Classes/AppDelegate.h @@ -39,6 +39,8 @@ public: AppDelegate(); virtual ~AppDelegate(); + virtual bool setOGLCntattrs(); + /** @brief Implement Director and Scene init code here. @return true Initialize success, app continue. diff --git a/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm b/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm index 2e725af131..ffa2939402 100644 --- a/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm +++ b/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm @@ -42,20 +42,23 @@ static AppDelegate s_sharedApplication; { cocos2d::Application *app = cocos2d::Application::getInstance(); + app->setOGLCntattrs(); // Override point for customization after application launch. // Add the view controller's view to the window and display. window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - + // Init the CCEAGLView - CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] + auto glview = cocos2d::GLViewImpl::createWithFullScreen("ios cpp-tests"); + CCEAGLView *eaglView = (CCEAGLView*)glview->getEAGLView(); + /*CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] pixelFormat: kEAGLColorFormatRGBA8 depthFormat: GL_DEPTH24_STENCIL8_OES preserveBackbuffer: NO sharegroup: nil multiSampling: NO - numberOfSamples: 0 ]; + numberOfSamples: 0 ];*/ [eaglView setMultipleTouchEnabled:YES]; @@ -79,9 +82,11 @@ static AppDelegate s_sharedApplication; [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden:true]; - + + glview->setSize(); + // IMPORTANT: Setting the GLView should be done after creating the RootViewController - cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); + //cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); cocos2d::Director::getInstance()->setOpenGLView(glview); app->run(); diff --git a/tests/lua-empty-test/project/Classes/AppDelegate.cpp b/tests/lua-empty-test/project/Classes/AppDelegate.cpp index 295ebc76a1..d07d5656af 100644 --- a/tests/lua-empty-test/project/Classes/AppDelegate.cpp +++ b/tests/lua-empty-test/project/Classes/AppDelegate.cpp @@ -21,6 +21,15 @@ AppDelegate::~AppDelegate() //CCScriptEngineManager::destroyInstance(); } +bool AppDelegate::setOGLCntattrs() +{ + int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; + + GLView::setOGLCntattrs(OGLCntattrs); + + return true; +} + bool AppDelegate::applicationDidFinishLaunching() { // register lua engine diff --git a/tests/lua-empty-test/project/Classes/AppDelegate.h b/tests/lua-empty-test/project/Classes/AppDelegate.h index b708f4bdca..848945dd5c 100644 --- a/tests/lua-empty-test/project/Classes/AppDelegate.h +++ b/tests/lua-empty-test/project/Classes/AppDelegate.h @@ -14,6 +14,7 @@ public: AppDelegate(); virtual ~AppDelegate(); + virtual bool setOGLCntattrs(); /** @brief Implement Director and Scene init code here. @return true Initialize success, app continue. diff --git a/tests/lua-tests/project/Classes/AppDelegate.cpp b/tests/lua-tests/project/Classes/AppDelegate.cpp index c38a9a1949..121b74f4bb 100644 --- a/tests/lua-tests/project/Classes/AppDelegate.cpp +++ b/tests/lua-tests/project/Classes/AppDelegate.cpp @@ -18,6 +18,15 @@ AppDelegate::~AppDelegate() SimpleAudioEngine::end(); } +bool AppDelegate::setOGLCntattrs() +{ + int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; + + GLView::setOGLCntattrs(OGLCntattrs); + + return true; +} + bool AppDelegate::applicationDidFinishLaunching() { // register lua engine diff --git a/tests/lua-tests/project/Classes/AppDelegate.h b/tests/lua-tests/project/Classes/AppDelegate.h index 5cf478d052..b6791cc935 100644 --- a/tests/lua-tests/project/Classes/AppDelegate.h +++ b/tests/lua-tests/project/Classes/AppDelegate.h @@ -14,6 +14,7 @@ public: AppDelegate(); virtual ~AppDelegate(); + bool setOGLCntattrs(); /** @brief Implement Director and Scene init code here. @return true Initialize success, app continue.