OpenGL context attributions setting revise

This commit is contained in:
huangshiwu 2014-08-22 10:55:39 +08:00
parent 2369a5900d
commit 7dec715288
27 changed files with 95 additions and 150 deletions

View File

@ -102,7 +102,8 @@ public:
*/ */
virtual void setAnimationInterval(double interval) = 0; virtual void setAnimationInterval(double interval) = 0;
virtual bool setOGLCntattrs() { return false; } //initialize the OpenGL/OpenGL ES context attribution here for all platforms;
virtual void initContextAttrs() {}
/** /**
@brief Get current language config @brief Get current language config

View File

@ -70,14 +70,12 @@ namespace {
} }
int* GLView::_OGLCntattrs = new int[6]; //default context attributions are setted as follows
ContextAttrs GLView::_contextAttrs = {5, 6, 5, 0, 16, 0};
void GLView::setOGLCntattrs(int* OGLCntattrs) void GLView::setContextAttrs(ContextAttrs& contextAttrs)
{ {
for(int i = 0; i < 6; i++) _contextAttrs = contextAttrs;
{
_OGLCntattrs[i] = OGLCntattrs[i];
}
} }
GLView::GLView() GLView::GLView()

View File

@ -64,6 +64,16 @@ enum class ResolutionPolicy
UNKNOWN, UNKNOWN,
}; };
struct ContextAttrs
{
int redBits;
int greenBits;
int blueBits;
int alphaBits;
int depthBits;
int stencilBits;
};
NS_CC_BEGIN NS_CC_BEGIN
/** /**
@ -98,8 +108,9 @@ public:
virtual bool windowShouldClose() { return false; }; virtual bool windowShouldClose() { return false; };
static void setOGLCntattrs(int* OGLCntattrs); //static method and member so that we can modify it on all platforms before create OpenGL context
static int* _OGLCntattrs; static void setContextAttrs(ContextAttrs& contextAttrs);
static ContextAttrs _contextAttrs;
/** /**
* Polls input events. Subclass must implement methods if platform * Polls input events. Subclass must implement methods if platform

View File

@ -73,11 +73,9 @@ GLViewImpl* GLViewImpl::create(const std::string& viewName)
return nullptr; return nullptr;
} }
GLViewImpl* GLViewImpl::createWithOGLCntattrs(const std::string& viewName) ContextAttrs GLViewImpl::getContextAttrs()
{ {
activityInitWithOGLCntattrsJni(_OGLCntattrs); return _contextAttrs;
return nullptr;
} }
GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName) GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)

View File

@ -41,10 +41,13 @@ public:
// static function // static function
static GLViewImpl* create(const std::string &viewname); 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* createWithRect(const std::string& viewName, Rect rect, float frameZoomFactor = 1.0f);
static GLViewImpl* createWithFullScreen(const std::string& viewName); static GLViewImpl* createWithFullScreen(const std::string& viewName);
//return context attribution to Java class Cocos2dxActivity which really
//create OpenGL ES context on android platform only
static ContextAttrs getContextAttrs();
bool isOpenGLReady() override; bool isOpenGLReady() override;
void end() override; void end() override;
void swapBuffers() override; void swapBuffers() override;

View File

@ -95,15 +95,16 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
Cocos2dxHelper.init(this); Cocos2dxHelper.init(this);
preCreateOGLCtx(); int[] OGLCtxattrs = getContextAttrs();
//this.init(); this.initWithOGLCtxattrs(OGLCtxattrs);
//this.reinit();
//if (mVideoHelper == null) { if (mVideoHelper == null) {
//mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout); mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
//} }
} }
private static native void preCreateOGLCtx(); //native method,call GLViewImpl::getContextAttrs() to get the OpenGL ES context attributions
private static native int[] getContextAttrs();
// =========================================================== // ===========================================================
// Getter & Setter // Getter & Setter
@ -170,43 +171,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
// =========================================================== // ===========================================================
// Methods // Methods
// =========================================================== // ===========================================================
public void init() { public void initWithOGLCtxattrs(int[] OGLCtxattrs) {
// 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 = this.onCreateView();
// ...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);
}
public void initWithOGLCntattrs(int[] OGLCntattrs) {
// FrameLayout // FrameLayout
ViewGroup.LayoutParams framelayout_params = ViewGroup.LayoutParams framelayout_params =
@ -228,8 +193,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
// Cocos2dxGLSurfaceView // Cocos2dxGLSurfaceView
this.mGLSurfaceView = new Cocos2dxGLSurfaceView(this); this.mGLSurfaceView = new Cocos2dxGLSurfaceView(this);
//this.mGLSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); this.mGLSurfaceView.setEGLConfigChooser(OGLCtxattrs[0], OGLCtxattrs[1],OGLCtxattrs[2],OGLCtxattrs[3],OGLCtxattrs[4],OGLCtxattrs[5]);
this.mGLSurfaceView.setEGLConfigChooser(OGLCntattrs[0], OGLCntattrs[1],OGLCntattrs[2],OGLCntattrs[3],OGLCntattrs[4],OGLCntattrs[5]);
// ...add to FrameLayout // ...add to FrameLayout
mFrameLayout.addView(this.mGLSurfaceView); mFrameLayout.addView(this.mGLSurfaceView);
@ -243,10 +207,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
// Set framelayout as the content view // Set framelayout as the content view
setContentView(mFrameLayout); setContentView(mFrameLayout);
if (mVideoHelper == null) {
mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
}
} }
public Cocos2dxGLSurfaceView onCreateView() { public Cocos2dxGLSurfaceView onCreateView() {

View File

@ -103,10 +103,6 @@ public class Cocos2dxHelper {
return sActivity; return sActivity;
} }
public static void activityInitWithOGLCntattrs(int[] OGLCntattrs){
((Cocos2dxActivity)sActivity).initWithOGLCntattrs(OGLCntattrs);
}
public static void addOnActivityResultListener(OnActivityResultListener listener) { public static void addOnActivityResultListener(OnActivityResultListener listener) {
onActivityResultListeners.add(listener); onActivityResultListeners.add(listener);
} }

View File

@ -81,11 +81,20 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
} }
} }
void Java_org_cocos2dx_lib_Cocos2dxActivity_preCreateOGLCtx(JNIEnv* env, jobject thiz) jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getContextAttrs(JNIEnv* env, jobject thiz)
{ {
cocos_android_app_init(env, thiz); cocos_android_app_init(env, thiz);
cocos2d::Application::getInstance()->setOGLCntattrs(); cocos2d::Application::getInstance()->initContextAttrs();
GLViewImpl::createWithOGLCntattrs("Android app"); ContextAttrs _contextAttrs = GLViewImpl::getContextAttrs();
int tmp[6] = {_contextAttrs.redBits, _contextAttrs.greenBits, _contextAttrs.blueBits,
_contextAttrs.alphaBits, _contextAttrs.depthBits, _contextAttrs.stencilBits};
jintArray contextAttrsJava = env->NewIntArray(6);
env->SetIntArrayRegion(contextAttrsJava, 0, 6, tmp);
return contextAttrsJava;
} }
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h) void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h)

View File

@ -209,19 +209,6 @@ 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");
}
}
void setKeepScreenOnJni(bool value) { void setKeepScreenOnJni(bool value) {
JniMethodInfo t; JniMethodInfo t;

View File

@ -39,7 +39,6 @@ extern std::string getFileDirectoryJNI();
extern void enableAccelerometerJni(); extern void enableAccelerometerJni();
extern void disableAccelerometerJni(); extern void disableAccelerometerJni();
extern void setAccelerometerIntervalJni(float interval); extern void setAccelerometerIntervalJni(float interval);
extern void activityInitWithOGLCntattrsJni(int* OGLCntattrs);
extern void setKeepScreenOnJni(bool value); extern void setKeepScreenOnJni(bool value);
// functions for UserDefault // functions for UserDefault
extern bool getBoolForKeyJNI(const char* key, bool defaultValue); extern bool getBoolForKeyJNI(const char* key, bool defaultValue);

View File

@ -337,16 +337,6 @@ GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName, const
return nullptr; 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) bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{ {
setViewName(viewName); setViewName(viewName);
@ -354,7 +344,12 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
_frameZoomFactor = frameZoomFactor; _frameZoomFactor = frameZoomFactor;
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
convertattrs(); glfwWindowHint(GLFW_RED_BITS,_contextAttrs.redBits);
glfwWindowHint(GLFW_GREEN_BITS,_contextAttrs.greenBits);
glfwWindowHint(GLFW_BLUE_BITS,_contextAttrs.blueBits);
glfwWindowHint(GLFW_ALPHA_BITS,_contextAttrs.alphaBits);
glfwWindowHint(GLFW_DEPTH_BITS,_contextAttrs.depthBits);
glfwWindowHint(GLFW_STENCIL_BITS,_contextAttrs.stencilBits);
_mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor, _mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor,
rect.size.height * _frameZoomFactor, rect.size.height * _frameZoomFactor,

View File

@ -149,7 +149,6 @@ protected:
friend class GLFWEventHandler; friend class GLFWEventHandler;
private: private:
void convertattrs();
CC_DISALLOW_COPY_AND_ASSIGN(GLViewImpl); CC_DISALLOW_COPY_AND_ASSIGN(GLViewImpl);
}; };

View File

@ -53,7 +53,7 @@ public:
/** creates a GLViewImpl with a name in fullscreen mode */ /** creates a GLViewImpl with a name in fullscreen mode */
static GLViewImpl* createWithFullScreen(const std::string& viewName); static GLViewImpl* createWithFullScreen(const std::string& viewName);
static void convert(int* _OGLCntattrs); static void convertAttrs();
static void* _pixelFormat; static void* _pixelFormat;
static int _depthFormat; static int _depthFormat;

View File

@ -83,13 +83,13 @@ GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)
return nullptr; return nullptr;
} }
void GLViewImpl::convert(int* OGLCntattrs) void GLViewImpl::convertAttrs()
{ {
if(OGLCntattrs[0]==8 && OGLCntattrs[1]==8 && OGLCntattrs[2]==8 && OGLCntattrs[3]==8) if(_contextAttrs.redBits==8 && _contextAttrs.greenBits==8 && _contextAttrs.blueBits==8 && _contextAttrs.alphaBits==8)
{ {
_pixelFormat = kEAGLColorFormatRGBA8; _pixelFormat = kEAGLColorFormatRGBA8;
} }
if(OGLCntattrs[4]==24 && OGLCntattrs[5]==8) if(_contextAttrs.depthBits==24 && _contextAttrs.stencilBits==8)
{ {
_depthFormat = GL_DEPTH24_STENCIL8_OES; _depthFormat = GL_DEPTH24_STENCIL8_OES;
} }
@ -120,7 +120,7 @@ bool GLViewImpl::initWithEAGLView(void *eaglview)
bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor) 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); CGRect r = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
convert(_OGLCntattrs); convertAttrs();
CCEAGLView *eaglview = [CCEAGLView viewWithFrame: r CCEAGLView *eaglview = [CCEAGLView viewWithFrame: r
pixelFormat: (NSString*)_pixelFormat pixelFormat: (NSString*)_pixelFormat
depthFormat: _depthFormat depthFormat: _depthFormat

View File

@ -63,7 +63,7 @@ Application::~Application()
int Application::run() int Application::run()
{ {
setOGLCntattrs(); initContextAttrs();
// Initialize instance and cocos2d. // Initialize instance and cocos2d.
if (! applicationDidFinishLaunching()) if (! applicationDidFinishLaunching())
{ {

View File

@ -64,7 +64,7 @@ Application::~Application()
int Application::run() int Application::run()
{ {
setOGLCntattrs(); initContextAttrs();
if(!applicationDidFinishLaunching()) if(!applicationDidFinishLaunching())
{ {
return 1; return 1;

View File

@ -69,7 +69,7 @@ int Application::run()
QueryPerformanceFrequency(&nFreq); QueryPerformanceFrequency(&nFreq);
QueryPerformanceCounter(&nLast); QueryPerformanceCounter(&nLast);
setOGLCntattrs(); initContextAttrs();
// Initialize instance and cocos2d. // Initialize instance and cocos2d.
if (!applicationDidFinishLaunching()) if (!applicationDidFinishLaunching())

View File

@ -17,13 +17,11 @@ AppDelegate::~AppDelegate()
{ {
} }
bool AppDelegate::setOGLCntattrs() void AppDelegate::initContextAttrs()
{ {
int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setOGLCntattrs(OGLCntattrs); GLView::setContextAttrs(contextAttrs);
return true;
} }
bool AppDelegate::applicationDidFinishLaunching() { bool AppDelegate::applicationDidFinishLaunching() {

View File

@ -14,7 +14,7 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
virtual bool setOGLCntattrs(); virtual void initContextAttrs();
/** /**
@brief Implement Director and Scene init code here. @brief Implement Director and Scene init code here.

View File

@ -39,21 +39,21 @@ static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
cocos2d::Application *app = cocos2d::Application::getInstance(); cocos2d::Application *app = cocos2d::Application::getInstance();
app->setOGLCntattrs(); app->initContextAttrs();
cocos2d::GLViewImpl::convertAttrs();
// Override point for customization after application launch. // Override point for customization after application launch.
// Add the view controller's view to the window and display. // Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
auto glview = cocos2d::GLViewImpl::createWithFullScreen("ios cpp-empty-test");
CCEAGLView *eaglView = (CCEAGLView*)glview->getEAGLView(); CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
/*CCEAGLView eaglView = [CCEAGLView viewWithFrame: [window bounds] pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
pixelFormat: kEAGLColorFormatRGBA8 depthFormat: cocos2d::GLViewImpl::_depthFormat
depthFormat: GL_DEPTH_COMPONENT16
preserveBackbuffer: NO preserveBackbuffer: NO
sharegroup: nil sharegroup: nil
multiSampling: NO multiSampling: NO
numberOfSamples: 0];*/ numberOfSamples: 0];
// Use RootViewController manage CCEAGLView // Use RootViewController manage CCEAGLView
@ -77,12 +77,10 @@ static AppDelegate s_sharedApplication;
[[UIApplication sharedApplication] setStatusBarHidden: YES]; [[UIApplication sharedApplication] setStatusBarHidden: YES];
glview->setSize();
// IMPORTANT: Setting the GLView should be done after creating the RootViewController // 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::Director::getInstance()->setOpenGLView(glview);
//cocos2d::Application *app = cocos2d::Application::getInstance();
app->run(); app->run();
return YES; return YES;
} }

View File

@ -43,15 +43,15 @@ AppDelegate::~AppDelegate()
cocostudio::ArmatureDataManager::destroyInstance(); cocostudio::ArmatureDataManager::destroyInstance();
} }
bool AppDelegate::setOGLCntattrs() //if you want a different context,just modify the value of contextAttrs
//it will takes effect on all platforms
void AppDelegate::initContextAttrs()
{ {
//set OpenGL context attributions //set OpenGL context attributions
//red,green,blue,alpha,depth,stencil //red,green,blue,alpha,depth,stencil
int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setOGLCntattrs(OGLCntattrs); GLView::setContextAttrs(contextAttrs);
return true;
} }
bool AppDelegate::applicationDidFinishLaunching() bool AppDelegate::applicationDidFinishLaunching()

View File

@ -39,7 +39,7 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
virtual bool setOGLCntattrs(); virtual void initContextAttrs();
/** /**
@brief Implement Director and Scene init code here. @brief Implement Director and Scene init code here.

View File

@ -42,7 +42,8 @@ static AppDelegate s_sharedApplication;
{ {
cocos2d::Application *app = cocos2d::Application::getInstance(); cocos2d::Application *app = cocos2d::Application::getInstance();
app->setOGLCntattrs(); app->initContextAttrs();
cocos2d::GLViewImpl::convertAttrs();
// Override point for customization after application launch. // Override point for customization after application launch.
@ -50,15 +51,13 @@ static AppDelegate s_sharedApplication;
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
// Init the CCEAGLView // Init the CCEAGLView
auto glview = cocos2d::GLViewImpl::createWithFullScreen("ios cpp-tests"); CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
CCEAGLView *eaglView = (CCEAGLView*)glview->getEAGLView(); pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
/*CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] depthFormat: cocos2d::GLViewImpl::_depthFormat
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH24_STENCIL8_OES
preserveBackbuffer: NO preserveBackbuffer: NO
sharegroup: nil sharegroup: nil
multiSampling: NO multiSampling: NO
numberOfSamples: 0 ];*/ numberOfSamples: 0 ];
[eaglView setMultipleTouchEnabled:YES]; [eaglView setMultipleTouchEnabled:YES];
@ -83,10 +82,8 @@ static AppDelegate s_sharedApplication;
[[UIApplication sharedApplication] setStatusBarHidden:true]; [[UIApplication sharedApplication] setStatusBarHidden:true];
glview->setSize();
// IMPORTANT: Setting the GLView should be done after creating the RootViewController // 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); cocos2d::Director::getInstance()->setOpenGLView(glview);
app->run(); app->run();

View File

@ -21,13 +21,11 @@ AppDelegate::~AppDelegate()
//CCScriptEngineManager::destroyInstance(); //CCScriptEngineManager::destroyInstance();
} }
bool AppDelegate::setOGLCntattrs() void AppDelegate::initContextAttrs()
{ {
int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setOGLCntattrs(OGLCntattrs); GLView::setContextAttrs(contextAttrs);
return true;
} }
bool AppDelegate::applicationDidFinishLaunching() bool AppDelegate::applicationDidFinishLaunching()

View File

@ -14,7 +14,7 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
virtual bool setOGLCntattrs(); virtual void initContextAttrs();
/** /**
@brief Implement Director and Scene init code here. @brief Implement Director and Scene init code here.
@return true Initialize success, app continue. @return true Initialize success, app continue.

View File

@ -18,13 +18,11 @@ AppDelegate::~AppDelegate()
SimpleAudioEngine::end(); SimpleAudioEngine::end();
} }
bool AppDelegate::setOGLCntattrs() void AppDelegate::initContextAttrs()
{ {
int OGLCntattrs[] = {8, 8, 8, 8, 24, 8}; ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setOGLCntattrs(OGLCntattrs); GLView::setContextAttrs(contextAttrs);
return true;
} }
bool AppDelegate::applicationDidFinishLaunching() bool AppDelegate::applicationDidFinishLaunching()

View File

@ -14,7 +14,7 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
bool setOGLCntattrs(); void initContextAttrs();
/** /**
@brief Implement Director and Scene init code here. @brief Implement Director and Scene init code here.
@return true Initialize success, app continue. @return true Initialize success, app continue.