issue #1177: Updated ios project configuration.

This commit is contained in:
James Chen 2012-04-23 14:35:41 +08:00
parent 0c6d21c0f9
commit 24515f009e
8 changed files with 167 additions and 304 deletions

View File

@ -1 +1 @@
8241040b5b40344918b886a37a17003c74c0b3f0 602577df19c20f69c1a4ae96072923365b422b34

View File

@ -472,11 +472,15 @@ CCSize CCDirector::getWinSizeInPixels()
void CCDirector::reshapeProjection(const CCSize& newWindowSize) void CCDirector::reshapeProjection(const CCSize& newWindowSize)
{ {
CC_UNUSED_PARAM(newWindowSize); CC_UNUSED_PARAM(newWindowSize);
m_obWinSizeInPoints = m_pobOpenGLView->getSize(); if (m_pobOpenGLView)
m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor, {
m_obWinSizeInPoints = m_pobOpenGLView->getSize();
m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor,
m_obWinSizeInPoints.height * m_fContentScaleFactor); m_obWinSizeInPoints.height * m_fContentScaleFactor);
setProjection(m_eProjection); setProjection(m_eProjection);
}
} }
// scene management // scene management

View File

@ -6,14 +6,11 @@
#include "CCDictionary.h" #include "CCDictionary.h"
#include "CCInteger.h" #include "CCInteger.h"
#undef COCOS2D_DEBUG;
#define COCOS2D_DEBUG 1
NS_CC_BEGIN NS_CC_BEGIN
#define MAX_TOUCHES 5
static CCTouch* s_pTouches[MAX_TOUCHES] = { NULL }; static CCTouch* s_pTouches[CC_MAX_TOUCHES] = { NULL };
static unsigned int s_indexBitsUsed = 0; static unsigned int s_indexBitsUsed = 0;
static CCDictionary s_TouchesIntergerDict; static CCDictionary s_TouchesIntergerDict;
@ -22,7 +19,7 @@ static int getUnUsedIndex()
int i; int i;
int temp = s_indexBitsUsed; int temp = s_indexBitsUsed;
for (i = 0; i < MAX_TOUCHES; i++) { for (i = 0; i < CC_MAX_TOUCHES; i++) {
if (! (temp & 0x00000001)) { if (! (temp & 0x00000001)) {
s_indexBitsUsed |= (1 << i); s_indexBitsUsed |= (1 << i);
return i; return i;
@ -37,7 +34,7 @@ static int getUnUsedIndex()
static void removeUsedIndexBit(int index) static void removeUsedIndexBit(int index)
{ {
if (index < 0 || index >= MAX_TOUCHES) if (index < 0 || index >= CC_MAX_TOUCHES)
{ {
return; return;
} }

View File

@ -5,6 +5,8 @@
NS_CC_BEGIN NS_CC_BEGIN
#define CC_MAX_TOUCHES 5
class EGLTouchDelegate; class EGLTouchDelegate;
class CCSet; class CCSet;

View File

@ -26,15 +26,13 @@ THE SOFTWARE.
#define __CC_EGLVIEW_IPHONE_H__ #define __CC_EGLVIEW_IPHONE_H__
#include "CCCommon.h" #include "CCCommon.h"
#include "CCEGLViewProtocol.h"
NS_CC_BEGIN NS_CC_BEGIN
class CCSet;
class CCTouch;
class EGLTouchDelegate;
class CCSize;
class CC_DLL CCEGLView
class CC_DLL CCEGLView : public CCEGLViewProtocol
{ {
public: public:
CCEGLView(); CCEGLView();
@ -47,16 +45,9 @@ public:
void setContentScaleFactor(float contentScaleFactor); void setContentScaleFactor(float contentScaleFactor);
// keep compatible // keep compatible
void release(); void end();
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void swapBuffers(); void swapBuffers();
void setViewPortInPoints(float x, float y, float w, float h);
void setScissorInPoints(float x, float y, float w, float h);
void touchesBegan(CCSet *set);
void touchesMoved(CCSet *set);
void touchesEnded(CCSet *set);
void touchesCancelled(CCSet *set);
float getMainScreenScale(); float getMainScreenScale();
@ -64,8 +55,6 @@ public:
static CCEGLView& sharedOpenGLView(); static CCEGLView& sharedOpenGLView();
private:
EGLTouchDelegate *m_pDelegate;
}; };
NS_CC_END NS_CC_END

View File

@ -31,7 +31,6 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
CCEGLView::CCEGLView() CCEGLView::CCEGLView()
: m_pDelegate(0)
{ {
} }
@ -41,9 +40,10 @@ CCEGLView::~CCEGLView()
} }
cocos2d::CCSize CCEGLView::getSize() CCSize CCEGLView::getSize()
{ {
cocos2d::CCSize size([[EAGLView sharedEGLView] getWidth], [[EAGLView sharedEGLView] getHeight]); cocos2d::CCSize size([[EAGLView sharedEGLView] getWidth], [[EAGLView sharedEGLView] getHeight]);
return size; return size;
} }
@ -69,7 +69,7 @@ bool CCEGLView::isOpenGLReady()
[view setNeedsLayout]; [view setNeedsLayout];
} }
void CCEGLView::release() void CCEGLView::end()
{ {
[CCDirectorCaller destroy]; [CCDirectorCaller destroy];
@ -77,53 +77,12 @@ void CCEGLView::release()
[[EAGLView sharedEGLView] removeFromSuperview]; [[EAGLView sharedEGLView] removeFromSuperview];
} }
void CCEGLView::setTouchDelegate(EGLTouchDelegate * pDelegate)
{
m_pDelegate = pDelegate;
}
void CCEGLView::swapBuffers() void CCEGLView::swapBuffers()
{ {
[[EAGLView sharedEGLView] swapBuffers]; [[EAGLView sharedEGLView] swapBuffers];
} }
void CCEGLView::touchesBegan(CCSet *set)
{
if (m_pDelegate) {
m_pDelegate->touchesBegan(set, NULL);
}
}
void CCEGLView::touchesMoved(CCSet *set)
{
if (m_pDelegate) {
m_pDelegate->touchesMoved(set, NULL);
}
}
void CCEGLView::touchesEnded(CCSet *set)
{
if (m_pDelegate) {
m_pDelegate->touchesEnded(set, NULL);
}
}
void CCEGLView::touchesCancelled(CCSet *set)
{
if (m_pDelegate) {
m_pDelegate->touchesCancelled(set, NULL);
}
}
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
{
glViewport((GLint)x, (GLint)y, (GLint)w, (GLint)h);
}
void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
{
glScissor((GLint)x, (GLint)y, (GLint)w, (GLint)h);
}
void CCEGLView::setIMEKeyboardState(bool bOpen) void CCEGLView::setIMEKeyboardState(bool bOpen)
{ {

View File

@ -87,7 +87,7 @@
} }
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR();
} }
return self; return self;

View File

@ -62,7 +62,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
*/ */
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#import "CCEGLView.h"
#import "EAGLView.h" #import "EAGLView.h"
#import "CCES2Renderer.h" #import "CCES2Renderer.h"
#import "CCDirector.h" #import "CCDirector.h"
@ -74,7 +74,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
//CLASS IMPLEMENTATIONS: //CLASS IMPLEMENTATIONS:
static EAGLView *view; static EAGLView *view = 0;
@interface EAGLView (Private) @interface EAGLView (Private)
- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup; - (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup;
@ -142,8 +142,7 @@ static EAGLView *view;
[self release]; [self release];
return nil; return nil;
} }
touchesIntergerDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, NULL, NULL);
indexBitsUsed = 0x00000000;
view = self; view = self;
} }
@ -204,34 +203,6 @@ static EAGLView *view;
return bound.height; return bound.height;
} }
-(int) getUnUsedIndex
{
int i;
int temp = indexBitsUsed;
for (i = 0; i < MAX_TOUCHES; i++) {
if (! (temp & 0x00000001)) {
indexBitsUsed |= (1 << i);
return i;
}
temp >>= 1;
}
// all bits are used
return -1;
}
-(void) removeUsedIndexBit:(int) index
{
if (index < 0 || index >= MAX_TOUCHES) {
return;
}
unsigned int temp = 1 << index;
temp = ~temp;
indexBitsUsed &= temp;
}
-(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup -(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup
{ {
@ -265,7 +236,6 @@ static EAGLView *view;
- (void) dealloc - (void) dealloc
{ {
CFRelease(touchesIntergerDict);
[renderer_ release]; [renderer_ release];
[super dealloc]; [super dealloc];
} }
@ -394,124 +364,66 @@ static EAGLView *view;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{ {
cocos2d::CCSet set; int ids[CC_MAX_TOUCHES] = {0};
cocos2d::CCTouch *pTouch; float xs[CC_MAX_TOUCHES] = {0.0f};
float ys[CC_MAX_TOUCHES] = {0.0f};
int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch); ids[i] = (int)touch;
int unUsedIndex = 0; xs[i] = [touch locationInView: [touch view]].x;
ys[i] = [touch locationInView: [touch view]].y;
// it is a new touch ++i;
if (! index) {
unUsedIndex = [self getUnUsedIndex];
// The touches is more than MAX_TOUCHES ?
if (unUsedIndex == -1) {
return;
}
pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch();
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(x, y);
CFDictionaryAddValue(touchesIntergerDict, touch, [NSNumber numberWithInt:unUsedIndex]);
set.addObject(pTouch);
}
} }
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesBegin(i, ids, xs, ys);
if (set.count() == 0)
return;
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesBegan(&set);
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{ {
cocos2d::CCSet set; int ids[CC_MAX_TOUCHES] = {0};
float xs[CC_MAX_TOUCHES] = {0.0f};
float ys[CC_MAX_TOUCHES] = {0.0f};
int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch); ids[i] = (int)touch;
if (! index) { xs[i] = [touch locationInView: [touch view]].x;
// if the index doesn't exist, it is an error ys[i] = [touch locationInView: [touch view]].y;
return; ++i;
}
cocos2d::CCTouch *pTouch = s_pTouches[[index intValue]];
if (! pTouch) {
// if the pTouch is null, it is an error
return;
}
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(x, y);
set.addObject(pTouch);
} }
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesMove(i, ids, xs, ys);
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesMoved(&set);
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{ {
cocos2d::CCSet set; int ids[CC_MAX_TOUCHES] = {0};
float xs[CC_MAX_TOUCHES] = {0.0f};
float ys[CC_MAX_TOUCHES] = {0.0f};
int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch); ids[i] = (int)touch;
if (! index) { xs[i] = [touch locationInView: [touch view]].x;
// if the index doesn't exist, it is an error ys[i] = [touch locationInView: [touch view]].y;
return; ++i;
}
cocos2d::CCTouch *pTouch = s_pTouches[[index intValue]];
if (! pTouch) {
// if the pTouch is null, it is an error
return;
}
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(x, y);
set.addObject(pTouch);
CFDictionaryRemoveValue(touchesIntergerDict, touch);
pTouch->release();
s_pTouches[[index intValue]] = NULL;
[self removeUsedIndexBit:[index intValue]];
} }
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesEnd(i, ids, xs, ys);
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesEnded(&set);
} }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{ {
cocos2d::CCSet set; int ids[CC_MAX_TOUCHES] = {0};
float xs[CC_MAX_TOUCHES] = {0.0f};
float ys[CC_MAX_TOUCHES] = {0.0f};
int i = 0;
for (UITouch *touch in touches) { for (UITouch *touch in touches) {
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch); ids[i] = (int)touch;
if (! index) { xs[i] = [touch locationInView: [touch view]].x;
// if the index doesn't exist, it is an error ys[i] = [touch locationInView: [touch view]].y;
return; ++i;
}
cocos2d::CCTouch *pTouch = s_pTouches[[index intValue]];
if (! pTouch) {
// if the pTouch is null, it is an error
return;
}
float x = [touch locationInView: [touch view]].x;
float y = [touch locationInView: [touch view]].y;
pTouch->SetTouchInfo(x, y);
set.addObject(pTouch);
CFDictionaryRemoveValue(touchesIntergerDict, touch);
pTouch->release();
s_pTouches[[index intValue]] = NULL;
[self removeUsedIndexBit:[index intValue]];
} }
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesCancel(i, ids, xs, ys);
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesCancelled(&set);
} }
#pragma mark - #pragma mark -