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)
{
CC_UNUSED_PARAM(newWindowSize);
if (m_pobOpenGLView)
{
m_obWinSizeInPoints = m_pobOpenGLView->getSize();
m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor,
m_obWinSizeInPoints.height * m_fContentScaleFactor);
setProjection(m_eProjection);
}
}
// scene management

View File

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

View File

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

View File

@ -26,15 +26,13 @@ THE SOFTWARE.
#define __CC_EGLVIEW_IPHONE_H__
#include "CCCommon.h"
#include "CCEGLViewProtocol.h"
NS_CC_BEGIN
class CCSet;
class CCTouch;
class EGLTouchDelegate;
class CCSize;
class CC_DLL CCEGLView
class CC_DLL CCEGLView : public CCEGLViewProtocol
{
public:
CCEGLView();
@ -47,16 +45,9 @@ public:
void setContentScaleFactor(float contentScaleFactor);
// keep compatible
void release();
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void end();
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();
@ -64,8 +55,6 @@ public:
static CCEGLView& sharedOpenGLView();
private:
EGLTouchDelegate *m_pDelegate;
};
NS_CC_END

View File

@ -31,7 +31,6 @@ THE SOFTWARE.
NS_CC_BEGIN
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]);
return size;
}
@ -69,7 +69,7 @@ bool CCEGLView::isOpenGLReady()
[view setNeedsLayout];
}
void CCEGLView::release()
void CCEGLView::end()
{
[CCDirectorCaller destroy];
@ -77,53 +77,12 @@ void CCEGLView::release()
[[EAGLView sharedEGLView] removeFromSuperview];
}
void CCEGLView::setTouchDelegate(EGLTouchDelegate * pDelegate)
{
m_pDelegate = pDelegate;
}
void CCEGLView::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)
{

View File

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

View File

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