mirror of https://github.com/axmolengine/axmol.git
fixed #508 Dynamic switch retina display support.
This commit is contained in:
parent
533949a736
commit
ec23d7ed55
|
@ -306,7 +306,10 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
|
|||
{
|
||||
case kCCDirectorProjection2D:
|
||||
// glViewport((GLsizei)0, (GLsizei)0, (GLsizei)size.width, (GLsizei)size.height);
|
||||
CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
if (m_pobOpenGLView)
|
||||
{
|
||||
m_pobOpenGLView->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
}
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
ccglOrtho(0, size.width, 0, size.height, -1024 * CC_CONTENT_SCALE_FACTOR(),
|
||||
|
@ -317,7 +320,10 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
|
|||
|
||||
case kCCDirectorProjection3D:
|
||||
// glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height);
|
||||
CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
if (m_pobOpenGLView)
|
||||
{
|
||||
m_pobOpenGLView->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
}
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60, (GLfloat)size.width/size.height, 0.5f, 1500.0f);
|
||||
|
|
|
@ -60,7 +60,9 @@ bool CCEGLView::isOpenGLReady()
|
|||
|
||||
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
||||
{
|
||||
[[EAGLView sharedEGLView] setContentScaleFactor:contentScaleFactor];
|
||||
UIView * view = [EAGLView sharedEGLView];
|
||||
view.contentScaleFactor = contentScaleFactor;
|
||||
[view setNeedsLayout];
|
||||
}
|
||||
|
||||
void CCEGLView::release()
|
||||
|
|
|
@ -28,24 +28,23 @@ static AppDelegate s_sharedApplication;
|
|||
// Add the view controller's view to the window and display.
|
||||
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
||||
|
||||
// Init the View Controller
|
||||
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
|
||||
viewController.wantsFullScreenLayout = YES;
|
||||
|
||||
// Init the EAGLView
|
||||
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
|
||||
pixelFormat: kEAGLColorFormatRGBA8
|
||||
depthFormat: GL_DEPTH_COMPONENT16_OES
|
||||
preserveBackbuffer: NO
|
||||
sharegroup:nil
|
||||
multiSampling:NO
|
||||
numberOfSamples:0];
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
numberOfSamples: 0];
|
||||
[__glView setMultipleTouchEnabled:YES];
|
||||
|
||||
// make the OpenGLView a child of the view controller
|
||||
[viewController setView:__glView];
|
||||
|
||||
// make the View Controller a child of the main window
|
||||
[window addSubview: viewController.view];
|
||||
// Use RootViewController manage EAGLView
|
||||
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
|
||||
viewController.wantsFullScreenLayout = YES;
|
||||
viewController.view = __glView;
|
||||
|
||||
// Set RootViewController to window
|
||||
window.rootViewController = viewController;
|
||||
[window makeKeyAndVisible];
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:true];
|
||||
|
|
Loading…
Reference in New Issue