OpenGL context attributions setting

This commit is contained in:
huangshiwu 2014-08-21 09:35:32 +08:00
parent 46cdd6f8dd
commit 2a03bea1a4
27 changed files with 217 additions and 22 deletions

View File

@ -102,6 +102,8 @@ public:
*/ */
virtual void setAnimationInterval(double interval) = 0; virtual void setAnimationInterval(double interval) = 0;
virtual bool setOGLCntattrs() { return false; }
/** /**
@brief Get current language config @brief Get current language config
@return Current language config @return Current language config

View File

@ -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() GLView::GLView()
: _scaleX(1.0f) : _scaleX(1.0f)
, _scaleY(1.0f) , _scaleY(1.0f)

View File

@ -98,6 +98,9 @@ public:
virtual bool windowShouldClose() { return false; }; virtual bool windowShouldClose() { return false; };
static void setOGLCntattrs(int* OGLCntattrs);
static int* _OGLCntattrs;
/** /**
* Polls input events. Subclass must implement methods if platform * Polls input events. Subclass must implement methods if platform
* does not provide event callbacks. * does not provide event callbacks.

View File

@ -30,13 +30,13 @@ THE SOFTWARE.
#include "base/CCDirector.h" #include "base/CCDirector.h"
#include "base/ccMacros.h" #include "base/ccMacros.h"
#include "jni/IMEJni.h" #include "jni/IMEJni.h"
#include "jni/JniHelper.h"
#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#include "CCGL.h" #include "CCGL.h"
#include <stdlib.h> #include <stdlib.h>
#include <android/log.h> #include <android/log.h>
// <EGL/egl.h> exists since android 2.3 // <EGL/egl.h> exists since android 2.3
#include <EGL/egl.h> #include <EGL/egl.h>
PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0; PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0;
@ -73,6 +73,13 @@ GLViewImpl* GLViewImpl::create(const std::string& viewName)
return nullptr; return nullptr;
} }
GLViewImpl* GLViewImpl::createWithOGLCntattrs(const std::string& viewName)
{
activityInitWithOGLCntattrsJni(_OGLCntattrs);
return nullptr;
}
GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName) GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)
{ {
auto ret = new GLViewImpl(); auto ret = new GLViewImpl();

View File

@ -41,6 +41,7 @@ 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);

View File

@ -84,11 +84,15 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
Cocos2dxHelper.init(this); Cocos2dxHelper.init(this);
this.init(); preCreateOGLCtx();
if (mVideoHelper == null) { //this.init();
mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout); //this.reinit();
} //if (mVideoHelper == null) {
//mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
//}
} }
private static native void preCreateOGLCtx();
// =========================================================== // ===========================================================
// Getter & Setter // Getter & Setter
@ -190,6 +194,49 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
// Set framelayout as the content view // Set framelayout as the content view
setContentView(mFrameLayout); 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() { public Cocos2dxGLSurfaceView onCreateView() {
return new Cocos2dxGLSurfaceView(this); return new Cocos2dxGLSurfaceView(this);

View File

@ -102,6 +102,10 @@ public class Cocos2dxHelper {
public static Activity getActivity() { public static Activity getActivity() {
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

@ -64,7 +64,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
glview->setFrameSize(w, h); glview->setFrameSize(w, h);
director->setOpenGLView(glview); director->setOpenGLView(glview);
cocos_android_app_init(env, thiz); //cocos_android_app_init(env, thiz);
cocos2d::Application::getInstance()->run(); cocos2d::Application::getInstance()->run();
} }
@ -79,7 +79,13 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
director->getEventDispatcher()->dispatchEvent(&recreatedEvent); director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
director->setGLDefaultValues(); 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) void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h)

View File

@ -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 // functions for UserDefault
bool getBoolForKeyJNI(const char* key, bool defaultValue) bool getBoolForKeyJNI(const char* key, bool defaultValue)
{ {

View File

@ -39,6 +39,7 @@ 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);
// functions for UserDefault // functions for UserDefault
extern bool getBoolForKeyJNI(const char* key, bool defaultValue); extern bool getBoolForKeyJNI(const char* key, bool defaultValue);
extern int getIntegerForKeyJNI(const char* key, int defaultValue); extern int getIntegerForKeyJNI(const char* key, int defaultValue);

View File

@ -328,6 +328,15 @@ 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)
{ {
@ -336,6 +345,7 @@ 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();
_mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor, _mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor,
rect.size.height * _frameZoomFactor, rect.size.height * _frameZoomFactor,

View File

@ -148,6 +148,7 @@ 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

@ -52,6 +52,12 @@ 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* _pixelFormat;
static int _depthFormat;
void setSize();
/** sets the content scale factor */ /** sets the content scale factor */
bool setContentScaleFactor(float contentScaleFactor); bool setContentScaleFactor(float contentScaleFactor);

View File

@ -36,6 +36,9 @@
NS_CC_BEGIN NS_CC_BEGIN
void* GLViewImpl::_pixelFormat = kEAGLColorFormatRGB565;
int GLViewImpl::_depthFormat = GL_DEPTH_COMPONENT16;
GLViewImpl* GLViewImpl::createWithEAGLView(void *eaglview) GLViewImpl* GLViewImpl::createWithEAGLView(void *eaglview)
{ {
auto ret = new GLViewImpl; auto ret = new GLViewImpl;
@ -80,6 +83,18 @@ GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)
return nullptr; 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() GLViewImpl::GLViewImpl()
{ {
} }
@ -105,17 +120,19 @@ 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);
CCEAGLView *eaglview = [CCEAGLView viewWithFrame: r CCEAGLView *eaglview = [CCEAGLView viewWithFrame: r
pixelFormat: kEAGLColorFormatRGB565 pixelFormat: (NSString*)_pixelFormat
depthFormat: GL_DEPTH24_STENCIL8_OES depthFormat: _depthFormat
preserveBackbuffer: NO preserveBackbuffer: NO
sharegroup: nil sharegroup: nil
multiSampling: NO multiSampling: NO
numberOfSamples: 0]; numberOfSamples: 0];
[eaglview setMultipleTouchEnabled:YES]; [eaglview setMultipleTouchEnabled:YES];
_screenSize.width = _designResolutionSize.width = [eaglview getWidth]; //_screenSize.width = _designResolutionSize.width = [eaglview getWidth];
_screenSize.height = _designResolutionSize.height = [eaglview getHeight]; //_screenSize.height = _designResolutionSize.height = [eaglview getHeight];
// _scaleX = _scaleY = [eaglview contentScaleFactor]; // _scaleX = _scaleY = [eaglview contentScaleFactor];
_eaglview = eaglview; _eaglview = eaglview;
@ -123,6 +140,13 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
return true; 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) bool GLViewImpl::initWithFullScreen(const std::string& viewName)
{ {
CGRect rect = [[UIScreen mainScreen] bounds]; CGRect rect = [[UIScreen mainScreen] bounds];

View File

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

View File

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

View File

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

View File

@ -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() { bool AppDelegate::applicationDidFinishLaunching() {
// initialize director // initialize director
auto director = Director::getInstance(); auto director = Director::getInstance();

View File

@ -14,6 +14,8 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
virtual bool setOGLCntattrs();
/** /**
@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

@ -38,19 +38,25 @@ static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
cocos2d::Application *app = cocos2d::Application::getInstance();
app->setOGLCntattrs();
// 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]];
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 pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH_COMPONENT16 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
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES; viewController.wantsFullScreenLayout = YES;
viewController.view = eaglView; viewController.view = eaglView;
@ -71,11 +77,12 @@ 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(); //cocos2d::Application *app = cocos2d::Application::getInstance();
app->run(); app->run();
return YES; return YES;
} }

View File

@ -43,6 +43,17 @@ AppDelegate::~AppDelegate()
cocostudio::ArmatureDataManager::destroyInstance(); 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() bool AppDelegate::applicationDidFinishLaunching()
{ {
// As an example, load config file // As an example, load config file

View File

@ -39,6 +39,8 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
virtual bool setOGLCntattrs();
/** /**
@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

@ -42,20 +42,23 @@ static AppDelegate s_sharedApplication;
{ {
cocos2d::Application *app = cocos2d::Application::getInstance(); cocos2d::Application *app = cocos2d::Application::getInstance();
app->setOGLCntattrs();
// 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]];
// Init the CCEAGLView // 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 pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH24_STENCIL8_OES 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];
@ -79,9 +82,11 @@ static AppDelegate s_sharedApplication;
[window makeKeyAndVisible]; [window makeKeyAndVisible];
[[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,6 +21,15 @@ AppDelegate::~AppDelegate()
//CCScriptEngineManager::destroyInstance(); //CCScriptEngineManager::destroyInstance();
} }
bool AppDelegate::setOGLCntattrs()
{
int OGLCntattrs[] = {8, 8, 8, 8, 24, 8};
GLView::setOGLCntattrs(OGLCntattrs);
return true;
}
bool AppDelegate::applicationDidFinishLaunching() bool AppDelegate::applicationDidFinishLaunching()
{ {
// register lua engine // register lua engine

View File

@ -14,6 +14,7 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
virtual bool setOGLCntattrs();
/** /**
@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,6 +18,15 @@ AppDelegate::~AppDelegate()
SimpleAudioEngine::end(); SimpleAudioEngine::end();
} }
bool AppDelegate::setOGLCntattrs()
{
int OGLCntattrs[] = {8, 8, 8, 8, 24, 8};
GLView::setOGLCntattrs(OGLCntattrs);
return true;
}
bool AppDelegate::applicationDidFinishLaunching() bool AppDelegate::applicationDidFinishLaunching()
{ {
// register lua engine // register lua engine

View File

@ -14,6 +14,7 @@ public:
AppDelegate(); AppDelegate();
virtual ~AppDelegate(); virtual ~AppDelegate();
bool setOGLCntattrs();
/** /**
@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.