mirror of https://github.com/axmolengine/axmol.git
OpenGL context attributions setting revise -2
This commit is contained in:
parent
7f57d15cb3
commit
07af58c0c2
|
@ -102,8 +102,14 @@ public:
|
|||
*/
|
||||
virtual void setAnimationInterval(double interval) = 0;
|
||||
|
||||
//initialize the OpenGL/OpenGL ES context attribution here for all platforms;
|
||||
virtual void initContextAttrs() {}
|
||||
//subclass override the function to set OpenGL context attribution instead of use default value
|
||||
//and now can only set six attributions:redBits,greenBits,blueBits,alphaBits,depthBits,stencilBits
|
||||
//default value are(5,6,5,0,16,0), usually use as follows:
|
||||
/*void AppDelegate::initGLContextAttrs(){
|
||||
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
GLView::setGLContextAttrs(glContextAttrs);
|
||||
}*/
|
||||
virtual void initGLContextAttrs() {}
|
||||
|
||||
/**
|
||||
@brief Get current language config
|
||||
|
|
|
@ -71,11 +71,16 @@ namespace {
|
|||
}
|
||||
|
||||
//default context attributions are setted as follows
|
||||
ContextAttrs GLView::_contextAttrs = {5, 6, 5, 0, 16, 0};
|
||||
GLContextAttrs GLView::_glContextAttrs = {5, 6, 5, 0, 16, 0};
|
||||
|
||||
void GLView::setContextAttrs(ContextAttrs& contextAttrs)
|
||||
void GLView::setGLContextAttrs(GLContextAttrs& glContextAttrs)
|
||||
{
|
||||
_contextAttrs = contextAttrs;
|
||||
_glContextAttrs = glContextAttrs;
|
||||
}
|
||||
|
||||
GLContextAttrs GLView::getGLContextAttrs()
|
||||
{
|
||||
return _glContextAttrs;
|
||||
}
|
||||
|
||||
GLView::GLView()
|
||||
|
|
|
@ -64,7 +64,7 @@ enum class ResolutionPolicy
|
|||
UNKNOWN,
|
||||
};
|
||||
|
||||
struct ContextAttrs
|
||||
struct GLContextAttrs
|
||||
{
|
||||
int redBits;
|
||||
int greenBits;
|
||||
|
@ -109,8 +109,9 @@ public:
|
|||
virtual bool windowShouldClose() { return false; };
|
||||
|
||||
//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;
|
||||
static void setGLContextAttrs(GLContextAttrs& glContextAttrs);
|
||||
static GLContextAttrs getGLContextAttrs();
|
||||
static GLContextAttrs _glContextAttrs;
|
||||
|
||||
/**
|
||||
* Polls input events. Subclass must implement methods if platform
|
||||
|
|
|
@ -73,11 +73,6 @@ GLViewImpl* GLViewImpl::create(const std::string& viewName)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ContextAttrs GLViewImpl::getContextAttrs()
|
||||
{
|
||||
return _contextAttrs;
|
||||
}
|
||||
|
||||
GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)
|
||||
{
|
||||
auto ret = new GLViewImpl();
|
||||
|
|
|
@ -44,10 +44,6 @@ public:
|
|||
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;
|
||||
|
|
|
@ -51,6 +51,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
// ===========================================================
|
||||
|
||||
private Cocos2dxGLSurfaceView mGLSurfaceView;
|
||||
private int[] glContextAttrs;
|
||||
private Cocos2dxHandler mHandler;
|
||||
private static Cocos2dxActivity sContext = null;
|
||||
private Cocos2dxVideoHelper mVideoHelper = null;
|
||||
|
@ -95,16 +96,16 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
|
||||
Cocos2dxHelper.init(this);
|
||||
|
||||
int[] OGLCtxattrs = getContextAttrs();
|
||||
this.initWithOGLCtxattrs(OGLCtxattrs);
|
||||
this.glContextAttrs = getGLContextAttrs();
|
||||
this.init();
|
||||
|
||||
if (mVideoHelper == null) {
|
||||
mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
|
||||
}
|
||||
}
|
||||
|
||||
//native method,call GLViewImpl::getContextAttrs() to get the OpenGL ES context attributions
|
||||
private static native int[] getContextAttrs();
|
||||
//native method,call GLViewImpl::getGLContextAttrs() to get the OpenGL ES context attributions
|
||||
private static native int[] getGLContextAttrs();
|
||||
|
||||
// ===========================================================
|
||||
// Getter & Setter
|
||||
|
@ -171,7 +172,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
// ===========================================================
|
||||
// Methods
|
||||
// ===========================================================
|
||||
public void initWithOGLCtxattrs(int[] OGLCtxattrs) {
|
||||
public void init() {
|
||||
|
||||
// FrameLayout
|
||||
ViewGroup.LayoutParams framelayout_params =
|
||||
|
@ -191,16 +192,14 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
mFrameLayout.addView(edittext);
|
||||
|
||||
// Cocos2dxGLSurfaceView
|
||||
this.mGLSurfaceView = new Cocos2dxGLSurfaceView(this);
|
||||
|
||||
this.mGLSurfaceView.setEGLConfigChooser(OGLCtxattrs[0], OGLCtxattrs[1],OGLCtxattrs[2],OGLCtxattrs[3],OGLCtxattrs[4],OGLCtxattrs[5]);
|
||||
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.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
|
||||
|
||||
this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
|
||||
this.mGLSurfaceView.setCocos2dxEditText(edittext);
|
||||
|
@ -210,7 +209,12 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
}
|
||||
|
||||
public Cocos2dxGLSurfaceView onCreateView() {
|
||||
return new Cocos2dxGLSurfaceView(this);
|
||||
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
|
||||
|
||||
glSurfaceView.setEGLConfigChooser(this.glContextAttrs[0], this.glContextAttrs[1],this.glContextAttrs[2],
|
||||
this.glContextAttrs[3],this.glContextAttrs[4],this.glContextAttrs[5]);
|
||||
|
||||
return glSurfaceView;
|
||||
}
|
||||
|
||||
private final static boolean isAndroidEmulator() {
|
||||
|
|
|
@ -81,20 +81,20 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
}
|
||||
}
|
||||
|
||||
jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getContextAttrs(JNIEnv* env, jobject thiz)
|
||||
jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz)
|
||||
{
|
||||
cocos_android_app_init(env, thiz);
|
||||
cocos2d::Application::getInstance()->initContextAttrs();
|
||||
ContextAttrs _contextAttrs = GLViewImpl::getContextAttrs();
|
||||
cocos2d::Application::getInstance()->initGLContextAttrs();
|
||||
GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs();
|
||||
|
||||
int tmp[6] = {_contextAttrs.redBits, _contextAttrs.greenBits, _contextAttrs.blueBits,
|
||||
_contextAttrs.alphaBits, _contextAttrs.depthBits, _contextAttrs.stencilBits};
|
||||
int tmp[6] = {_glContextAttrs.redBits, _glContextAttrs.greenBits, _glContextAttrs.blueBits,
|
||||
_glContextAttrs.alphaBits, _glContextAttrs.depthBits, _glContextAttrs.stencilBits};
|
||||
|
||||
|
||||
jintArray contextAttrsJava = env->NewIntArray(6);
|
||||
env->SetIntArrayRegion(contextAttrsJava, 0, 6, tmp);
|
||||
jintArray glContextAttrsJava = env->NewIntArray(6);
|
||||
env->SetIntArrayRegion(glContextAttrsJava, 0, 6, tmp);
|
||||
|
||||
return contextAttrsJava;
|
||||
return glContextAttrsJava;
|
||||
}
|
||||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
|
|
|
@ -344,12 +344,12 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
|
|||
_frameZoomFactor = frameZoomFactor;
|
||||
|
||||
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
||||
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);
|
||||
glfwWindowHint(GLFW_RED_BITS,_glContextAttrs.redBits);
|
||||
glfwWindowHint(GLFW_GREEN_BITS,_glContextAttrs.greenBits);
|
||||
glfwWindowHint(GLFW_BLUE_BITS,_glContextAttrs.blueBits);
|
||||
glfwWindowHint(GLFW_ALPHA_BITS,_glContextAttrs.alphaBits);
|
||||
glfwWindowHint(GLFW_DEPTH_BITS,_glContextAttrs.depthBits);
|
||||
glfwWindowHint(GLFW_STENCIL_BITS,_glContextAttrs.stencilBits);
|
||||
|
||||
_mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor,
|
||||
rect.size.height * _frameZoomFactor,
|
||||
|
|
|
@ -56,8 +56,6 @@ public:
|
|||
static void convertAttrs();
|
||||
static void* _pixelFormat;
|
||||
static int _depthFormat;
|
||||
|
||||
void setSize();
|
||||
|
||||
/** sets the content scale factor */
|
||||
bool setContentScaleFactor(float contentScaleFactor);
|
||||
|
|
|
@ -85,11 +85,11 @@ GLViewImpl* GLViewImpl::createWithFullScreen(const std::string& viewName)
|
|||
|
||||
void GLViewImpl::convertAttrs()
|
||||
{
|
||||
if(_contextAttrs.redBits==8 && _contextAttrs.greenBits==8 && _contextAttrs.blueBits==8 && _contextAttrs.alphaBits==8)
|
||||
if(_glContextAttrs.redBits==8 && _glContextAttrs.greenBits==8 && _glContextAttrs.blueBits==8 && _glContextAttrs.alphaBits==8)
|
||||
{
|
||||
_pixelFormat = kEAGLColorFormatRGBA8;
|
||||
}
|
||||
if(_contextAttrs.depthBits==24 && _contextAttrs.stencilBits==8)
|
||||
if(_glContextAttrs.depthBits==24 && _glContextAttrs.stencilBits==8)
|
||||
{
|
||||
_depthFormat = GL_DEPTH24_STENCIL8_OES;
|
||||
}
|
||||
|
@ -131,8 +131,8 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
|
|||
|
||||
[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;
|
||||
|
@ -140,13 +140,6 @@ 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];
|
||||
|
|
|
@ -63,7 +63,7 @@ Application::~Application()
|
|||
|
||||
int Application::run()
|
||||
{
|
||||
initContextAttrs();
|
||||
initGLContextAttrs();
|
||||
// Initialize instance and cocos2d.
|
||||
if (! applicationDidFinishLaunching())
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ Application::~Application()
|
|||
|
||||
int Application::run()
|
||||
{
|
||||
initContextAttrs();
|
||||
initGLContextAttrs();
|
||||
if(!applicationDidFinishLaunching())
|
||||
{
|
||||
return 1;
|
||||
|
|
|
@ -69,7 +69,7 @@ int Application::run()
|
|||
QueryPerformanceFrequency(&nFreq);
|
||||
QueryPerformanceCounter(&nLast);
|
||||
|
||||
initContextAttrs();
|
||||
initGLContextAttrs();
|
||||
|
||||
// Initialize instance and cocos2d.
|
||||
if (!applicationDidFinishLaunching())
|
||||
|
|
|
@ -38,6 +38,10 @@ static AppDelegate s_sharedApplication;
|
|||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->initGLContextAttrs();
|
||||
cocos2d::GLViewImpl::convertAttrs();
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
||||
// Add the view controller's view to the window and display.
|
||||
|
@ -45,12 +49,12 @@ static AppDelegate s_sharedApplication;
|
|||
|
||||
// Init the CCEAGLView
|
||||
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||
pixelFormat: kEAGLColorFormatRGBA8
|
||||
depthFormat: GL_DEPTH24_STENCIL8_OES
|
||||
preserveBackbuffer: NO
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
numberOfSamples: 0];
|
||||
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
|
||||
depthFormat: cocos2d::GLViewImpl::_depthFormat
|
||||
preserveBackbuffer: NO
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
numberOfSamples: 0 ];
|
||||
|
||||
// Use RootViewController manage CCEAGLView
|
||||
_viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
|
||||
|
@ -77,7 +81,7 @@ static AppDelegate s_sharedApplication;
|
|||
cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
|
||||
cocos2d::Director::getInstance()->setOpenGLView(glview);
|
||||
|
||||
cocos2d::Application::getInstance()->run();
|
||||
app->run();
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,17 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
//if you want a different context,just modify the value of glContextAttrs
|
||||
//it will takes effect on all platforms
|
||||
void AppDelegate::initGLContextAttrs()
|
||||
{
|
||||
//set OpenGL context attributions,now can only set six attributions:
|
||||
//red,green,blue,alpha,depth,stencil
|
||||
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
|
||||
GLView::setGLContextAttrs(glContextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching() {
|
||||
// initialize director
|
||||
auto director = Director::getInstance();
|
||||
|
|
|
@ -14,6 +14,8 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual void initGLContextAttrs();
|
||||
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -17,11 +17,11 @@ AppDelegate::~AppDelegate()
|
|||
{
|
||||
}
|
||||
|
||||
void AppDelegate::initContextAttrs()
|
||||
void AppDelegate::initGLContextAttrs()
|
||||
{
|
||||
ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
GLView::setGLContextAttrs(glContextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching() {
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual void initContextAttrs();
|
||||
virtual void initGLContextAttrs();
|
||||
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
|
|
|
@ -39,7 +39,7 @@ static AppDelegate s_sharedApplication;
|
|||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->initContextAttrs();
|
||||
app->initGLContextAttrs();
|
||||
cocos2d::GLViewImpl::convertAttrs();
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
|
|
@ -43,15 +43,15 @@ AppDelegate::~AppDelegate()
|
|||
cocostudio::ArmatureDataManager::destroyInstance();
|
||||
}
|
||||
|
||||
//if you want a different context,just modify the value of contextAttrs
|
||||
//if you want a different context,just modify the value of glContextAttrs
|
||||
//it will takes effect on all platforms
|
||||
void AppDelegate::initContextAttrs()
|
||||
void AppDelegate::initGLContextAttrs()
|
||||
{
|
||||
//set OpenGL context attributions
|
||||
//set OpenGL context attributions,now can only set six attributions:
|
||||
//red,green,blue,alpha,depth,stencil
|
||||
ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
GLView::setGLContextAttrs(glContextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual void initContextAttrs();
|
||||
virtual void initGLContextAttrs();
|
||||
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
|
|
|
@ -27,12 +27,4 @@ import org.cocos2dx.lib.Cocos2dxActivity;
|
|||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
|
||||
|
||||
public class AppActivity extends Cocos2dxActivity {
|
||||
|
||||
public Cocos2dxGLSurfaceView onCreateView() {
|
||||
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
|
||||
// TestCpp should create stencil buffer
|
||||
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
|
||||
|
||||
return glSurfaceView;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ static AppDelegate s_sharedApplication;
|
|||
{
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->initContextAttrs();
|
||||
app->initGLContextAttrs();
|
||||
cocos2d::GLViewImpl::convertAttrs();
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
|
|
@ -21,11 +21,11 @@ AppDelegate::~AppDelegate()
|
|||
//CCScriptEngineManager::destroyInstance();
|
||||
}
|
||||
|
||||
void AppDelegate::initContextAttrs()
|
||||
void AppDelegate::initGLContextAttrs()
|
||||
{
|
||||
ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
GLView::setGLContextAttrs(glContextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual void initContextAttrs();
|
||||
virtual void initGLContextAttrs();
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -38,14 +38,17 @@
|
|||
static AppDelegate s_sharedApplication;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->initGLContextAttrs();
|
||||
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]];
|
||||
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||
pixelFormat: kEAGLColorFormatRGBA8
|
||||
depthFormat: GL_DEPTH_COMPONENT16
|
||||
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
|
||||
depthFormat: cocos2d::GLViewImpl::_depthFormat
|
||||
preserveBackbuffer: NO
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
|
@ -76,7 +79,6 @@ static AppDelegate s_sharedApplication;
|
|||
cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
|
||||
cocos2d::Director::getInstance()->setOpenGLView(glview);
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->run();
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ AppDelegate::~AppDelegate()
|
|||
SimpleAudioEngine::end();
|
||||
}
|
||||
|
||||
void AppDelegate::initContextAttrs()
|
||||
void AppDelegate::initGLContextAttrs()
|
||||
{
|
||||
ContextAttrs contextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
|
||||
GLView::setContextAttrs(contextAttrs);
|
||||
GLView::setGLContextAttrs(glContextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
void initContextAttrs();
|
||||
void initGLContextAttrs();
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
|
|
|
@ -39,13 +39,16 @@ static AppDelegate s_sharedApplication;
|
|||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->initGLContextAttrs();
|
||||
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]];
|
||||
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||
pixelFormat: kEAGLColorFormatRGBA8
|
||||
depthFormat: GL_DEPTH24_STENCIL8_OES
|
||||
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
|
||||
depthFormat: cocos2d::GLViewImpl::_depthFormat
|
||||
preserveBackbuffer: NO
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
|
@ -79,7 +82,7 @@ static AppDelegate s_sharedApplication;
|
|||
cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
|
||||
cocos2d::Director::getInstance()->setOpenGLView(glview);
|
||||
|
||||
cocos2d::Application::getInstance()->run();
|
||||
app->run();
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue