mirror of https://github.com/axmolengine/axmol.git
OpenGL context attributions setting revise
This commit is contained in:
parent
2369a5900d
commit
7dec715288
|
@ -102,7 +102,8 @@ public:
|
|||
*/
|
||||
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
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
_OGLCntattrs[i] = OGLCntattrs[i];
|
||||
}
|
||||
_contextAttrs = contextAttrs;
|
||||
}
|
||||
|
||||
GLView::GLView()
|
||||
|
|
|
@ -64,6 +64,16 @@ enum class ResolutionPolicy
|
|||
UNKNOWN,
|
||||
};
|
||||
|
||||
struct ContextAttrs
|
||||
{
|
||||
int redBits;
|
||||
int greenBits;
|
||||
int blueBits;
|
||||
int alphaBits;
|
||||
int depthBits;
|
||||
int stencilBits;
|
||||
};
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
|
@ -98,8 +108,9 @@ public:
|
|||
|
||||
virtual bool windowShouldClose() { return false; };
|
||||
|
||||
static void setOGLCntattrs(int* OGLCntattrs);
|
||||
static int* _OGLCntattrs;
|
||||
//static method and member so that we can modify it on all platforms before create OpenGL context
|
||||
static void setContextAttrs(ContextAttrs& contextAttrs);
|
||||
static ContextAttrs _contextAttrs;
|
||||
|
||||
/**
|
||||
* Polls input events. Subclass must implement methods if platform
|
||||
|
|
|
@ -73,11 +73,9 @@ GLViewImpl* GLViewImpl::create(const std::string& viewName)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
GLViewImpl* GLViewImpl::createWithOGLCntattrs(const std::string& viewName)
|
||||
ContextAttrs GLViewImpl::getContextAttrs()
|
||||
{
|
||||
activityInitWithOGLCntattrsJni(_OGLCntattrs);
|
||||
|
||||
return nullptr;
|
||||
return _contextAttrs;
|
||||
}
|
||||
|
||||
GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)
|
||||
|
|
|
@ -41,10 +41,13 @@ 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);
|
||||
|
||||
//return context attribution to Java class Cocos2dxActivity which really
|
||||
//create OpenGL ES context on android platform only
|
||||
static ContextAttrs getContextAttrs();
|
||||
|
||||
bool isOpenGLReady() override;
|
||||
void end() override;
|
||||
void swapBuffers() override;
|
||||
|
|
|
@ -95,15 +95,16 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
|
||||
Cocos2dxHelper.init(this);
|
||||
|
||||
preCreateOGLCtx();
|
||||
//this.init();
|
||||
//this.reinit();
|
||||
//if (mVideoHelper == null) {
|
||||
//mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
|
||||
//}
|
||||
int[] OGLCtxattrs = getContextAttrs();
|
||||
this.initWithOGLCtxattrs(OGLCtxattrs);
|
||||
|
||||
if (mVideoHelper == null) {
|
||||
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
|
||||
|
@ -170,43 +171,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
// ===========================================================
|
||||
// Methods
|
||||
// ===========================================================
|
||||
public void init() {
|
||||
|
||||
// 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) {
|
||||
public void initWithOGLCtxattrs(int[] OGLCtxattrs) {
|
||||
|
||||
// FrameLayout
|
||||
ViewGroup.LayoutParams framelayout_params =
|
||||
|
@ -228,8 +193,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
// 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]);
|
||||
this.mGLSurfaceView.setEGLConfigChooser(OGLCtxattrs[0], OGLCtxattrs[1],OGLCtxattrs[2],OGLCtxattrs[3],OGLCtxattrs[4],OGLCtxattrs[5]);
|
||||
|
||||
// ...add to FrameLayout
|
||||
mFrameLayout.addView(this.mGLSurfaceView);
|
||||
|
@ -243,10 +207,6 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
|
||||
// Set framelayout as the content view
|
||||
setContentView(mFrameLayout);
|
||||
|
||||
if (mVideoHelper == null) {
|
||||
mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
|
||||
}
|
||||
}
|
||||
|
||||
public Cocos2dxGLSurfaceView onCreateView() {
|
||||
|
|
|
@ -103,10 +103,6 @@ public class Cocos2dxHelper {
|
|||
return sActivity;
|
||||
}
|
||||
|
||||
public static void activityInitWithOGLCntattrs(int[] OGLCntattrs){
|
||||
((Cocos2dxActivity)sActivity).initWithOGLCntattrs(OGLCntattrs);
|
||||
}
|
||||
|
||||
public static void addOnActivityResultListener(OnActivityResultListener listener) {
|
||||
onActivityResultListeners.add(listener);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
cocos2d::Application::getInstance()->setOGLCntattrs();
|
||||
GLViewImpl::createWithOGLCntattrs("Android app");
|
||||
cocos2d::Application::getInstance()->initContextAttrs();
|
||||
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)
|
||||
|
|
|
@ -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) {
|
||||
JniMethodInfo t;
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ extern std::string getFileDirectoryJNI();
|
|||
extern void enableAccelerometerJni();
|
||||
extern void disableAccelerometerJni();
|
||||
extern void setAccelerometerIntervalJni(float interval);
|
||||
extern void activityInitWithOGLCntattrsJni(int* OGLCntattrs);
|
||||
extern void setKeepScreenOnJni(bool value);
|
||||
// functions for UserDefault
|
||||
extern bool getBoolForKeyJNI(const char* key, bool defaultValue);
|
||||
|
|
|
@ -337,16 +337,6 @@ 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)
|
||||
{
|
||||
setViewName(viewName);
|
||||
|
@ -354,7 +344,12 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
|
|||
_frameZoomFactor = frameZoomFactor;
|
||||
|
||||
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,
|
||||
rect.size.height * _frameZoomFactor,
|
||||
|
|
|
@ -149,7 +149,6 @@ protected:
|
|||
friend class GLFWEventHandler;
|
||||
|
||||
private:
|
||||
void convertattrs();
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(GLViewImpl);
|
||||
};
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
/** creates a GLViewImpl with a name in fullscreen mode */
|
||||
static GLViewImpl* createWithFullScreen(const std::string& viewName);
|
||||
|
||||
static void convert(int* _OGLCntattrs);
|
||||
static void convertAttrs();
|
||||
static void* _pixelFormat;
|
||||
static int _depthFormat;
|
||||
|
||||
|
|
|
@ -83,13 +83,13 @@ GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)
|
|||
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;
|
||||
}
|
||||
if(OGLCntattrs[4]==24 && OGLCntattrs[5]==8)
|
||||
if(_contextAttrs.depthBits==24 && _contextAttrs.stencilBits==8)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
CGRect r = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||
convert(_OGLCntattrs);
|
||||
convertAttrs();
|
||||
CCEAGLView *eaglview = [CCEAGLView viewWithFrame: r
|
||||
pixelFormat: (NSString*)_pixelFormat
|
||||
depthFormat: _depthFormat
|
||||
|
|
|
@ -63,7 +63,7 @@ Application::~Application()
|
|||
|
||||
int Application::run()
|
||||
{
|
||||
setOGLCntattrs();
|
||||
initContextAttrs();
|
||||
// Initialize instance and cocos2d.
|
||||
if (! applicationDidFinishLaunching())
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ Application::~Application()
|
|||
|
||||
int Application::run()
|
||||
{
|
||||
setOGLCntattrs();
|
||||
initContextAttrs();
|
||||
if(!applicationDidFinishLaunching())
|
||||
{
|
||||
return 1;
|
||||
|
|
|
@ -69,7 +69,7 @@ int Application::run()
|
|||
QueryPerformanceFrequency(&nFreq);
|
||||
QueryPerformanceCounter(&nLast);
|
||||
|
||||
setOGLCntattrs();
|
||||
initContextAttrs();
|
||||
|
||||
// Initialize instance and cocos2d.
|
||||
if (!applicationDidFinishLaunching())
|
||||
|
|
|
@ -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);
|
||||
|
||||
return true;
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching() {
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual bool setOGLCntattrs();
|
||||
virtual void initContextAttrs();
|
||||
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
|
|
|
@ -39,21 +39,21 @@ static AppDelegate s_sharedApplication;
|
|||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->setOGLCntattrs();
|
||||
app->initContextAttrs();
|
||||
cocos2d::GLViewImpl::convertAttrs();
|
||||
|
||||
// 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]];
|
||||
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
|
||||
|
||||
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
|
||||
depthFormat: cocos2d::GLViewImpl::_depthFormat
|
||||
preserveBackbuffer: NO
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
numberOfSamples: 0];*/
|
||||
numberOfSamples: 0];
|
||||
|
||||
|
||||
// Use RootViewController manage CCEAGLView
|
||||
|
@ -77,12 +77,10 @@ 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();
|
||||
app->run();
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -43,15 +43,15 @@ AppDelegate::~AppDelegate()
|
|||
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
|
||||
//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);
|
||||
|
||||
return true;
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual bool setOGLCntattrs();
|
||||
virtual void initContextAttrs();
|
||||
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
|
|
|
@ -42,7 +42,8 @@ static AppDelegate s_sharedApplication;
|
|||
{
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->setOGLCntattrs();
|
||||
app->initContextAttrs();
|
||||
cocos2d::GLViewImpl::convertAttrs();
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
||||
|
@ -50,15 +51,13 @@ static AppDelegate s_sharedApplication;
|
|||
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
||||
|
||||
// Init the CCEAGLView
|
||||
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
|
||||
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
|
||||
depthFormat: cocos2d::GLViewImpl::_depthFormat
|
||||
preserveBackbuffer: NO
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
numberOfSamples: 0 ];*/
|
||||
numberOfSamples: 0 ];
|
||||
|
||||
[eaglView setMultipleTouchEnabled:YES];
|
||||
|
||||
|
@ -83,10 +82,8 @@ static AppDelegate s_sharedApplication;
|
|||
|
||||
[[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();
|
||||
|
|
|
@ -21,13 +21,11 @@ AppDelegate::~AppDelegate()
|
|||
//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);
|
||||
|
||||
return true;
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual bool setOGLCntattrs();
|
||||
virtual void initContextAttrs();
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -18,13 +18,11 @@ AppDelegate::~AppDelegate()
|
|||
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);
|
||||
|
||||
return true;
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
bool setOGLCntattrs();
|
||||
void initContextAttrs();
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
Loading…
Reference in New Issue