From cfc6a1db797df3b64f73c91fdd9f5e0a965c2a71 Mon Sep 17 00:00:00 2001 From: dsc Date: Thu, 26 May 2011 21:15:07 -0700 Subject: [PATCH] Attempts to add debug view support. No idea why the linker is bitching. --- src/game/QQGame.h | 2 + src/game/QQGame.mm | 10 +- src/physics/QQWorld.h | 7 +- src/physics/QQWorld.mm | 24 ++-- src/physics/debug/QQGLESDebugDraw.h | 16 ++- src/physics/debug/QQGLESDebugDraw.mm | 174 +++++++++++++------------- src/physics/debug/QQPhysicsDebugView.h | 41 +++++- src/physics/debug/QQPhysicsDebugView.mm | 167 +++++++++---------------- src/ui/QQAppDelegate.h | 3 + src/ui/QQAppDelegate.mm | 5 +- src/ui/iPad/en.lproj/MainWindow_iPad.xib | 7 +- src/ui/iPhone/en.lproj/MainWindow_iPhone.xib | 2 +- 12 files changed, 228 insertions(+), 230 deletions(-) diff --git a/src/game/QQGame.h b/src/game/QQGame.h index 835b132..e0a6ff1 100644 --- a/src/game/QQGame.h +++ b/src/game/QQGame.h @@ -21,6 +21,8 @@ @property (nonatomic, retain) QQWorld* world; @property (nonatomic, retain) NSSet* actors; +- (void) tick:(float)elapsed; + - (QQGame*) addActor:(QQActor*)actor; - (QQGame*) removeActor:(QQActor*)actor; diff --git a/src/game/QQGame.mm b/src/game/QQGame.mm index 1ed5ff4..fbfc2c5 100644 --- a/src/game/QQGame.mm +++ b/src/game/QQGame.mm @@ -69,22 +69,24 @@ static QQGame* _CurrentGame = NULL; - (void) onEnterFrame:(SPEnterFrameEvent*)event { + [self tick:event.passedTime]; +} + +- (void) tick:(float)elapsed { _ticks++; if ((_ticks % 100) == 0) { - NSLog(@"[%ld] Time passed since last 100 frames: %f", _ticks, event.passedTime); + NSLog(@"[%ld] Time passed since last 100 frames: %f", _ticks, elapsed); for (QQActor* actor in self.actors) { b2Vec2 v = actor.body->GetLinearVelocity(); NSLog(@"[%@ pos:(%f,%f) impulse:(%f,%f)]", actor, actor.x,actor.y, v.x,v.y); } } - for (QQActor* actor in self.actors) [actor tick:event.passedTime]; // XXX: self.awakeAgents + for (QQActor* actor in self.actors) [actor tick:elapsed]; // XXX: self.awakeAgents [self.world step]; for (QQActor* actor in self.actors) [actor draw]; // XXX: self.drawableAgents } - - + (QQGame*) current { if (!_CurrentGame) [[[QQGame alloc] init] // init assigns to singleton, but singleton is a weakref, diff --git a/src/physics/QQWorld.h b/src/physics/QQWorld.h index 91f505a..eeb4c96 100644 --- a/src/physics/QQWorld.h +++ b/src/physics/QQWorld.h @@ -5,14 +5,14 @@ @interface QQWorld : NSObject { @private - QQGLESDebugDraw debugDraw; + QQGLESDebugDraw* _debugDraw; b2World* _world; NSMutableArray* _walls; float _timestep; int _velocityIterations; int _positionIterations; - BOOL _drawDebugLayer; + BOOL _debugDrawingEnabled; float _scale; } @@ -21,7 +21,7 @@ @property (nonatomic, assign) float timestep; @property (nonatomic, assign) int velocityIterations; @property (nonatomic, assign) int positionIterations; -@property (nonatomic, assign) BOOL drawDebugLayer; +@property (nonatomic, assign) BOOL debugDrawingEnabled; @property (nonatomic, assign) float scale; // pixels per meter @@ -30,6 +30,7 @@ - (void) setGravityX:(float)x y:(float)y; - (void) step; +- (void) drawDebug; @end diff --git a/src/physics/QQWorld.mm b/src/physics/QQWorld.mm index ed986f9..d97bf1c 100644 --- a/src/physics/QQWorld.mm +++ b/src/physics/QQWorld.mm @@ -6,13 +6,13 @@ @implementation QQWorld -@synthesize timestep = _timestep; -@synthesize velocityIterations = _velocityIterations; -@synthesize positionIterations = _positionIterations; -@synthesize drawDebugLayer = _drawDebugLayer; -@synthesize scale = _scale; +@synthesize timestep = _timestep; +@synthesize velocityIterations = _velocityIterations; +@synthesize positionIterations = _positionIterations; +@synthesize debugDrawingEnabled = _debugDrawingEnabled; +@synthesize scale = _scale; -@synthesize world = _world; +@synthesize world = _world; - (QQWorld*) init { @@ -20,11 +20,12 @@ _timestep = 1.0f/60.0f; _velocityIterations = 10; _positionIterations = 10; - _drawDebugLayer = NO; + _debugDrawingEnabled = NO; _scale = 5.0f; _world = new b2World(b2Vec2(0.0f, 0.0f), true); // b2World(gravity, doSleep) - // _world->SetDebugDraw(&debugDraw); + _debugDraw = new QQGLESDebugDraw(); + _world->SetDebugDraw(_debugDraw); _walls = [[NSMutableArray alloc] initWithCapacity:4]; @@ -72,9 +73,10 @@ - (void) step { _world->Step(self.timestep, self.velocityIterations, self.positionIterations); - #ifdef DEBUG - if (_drawDebugLayer) _world->DrawDebugData(); - #endif +} + +- (void) drawDebug { + if (_debugDrawingEnabled) _world->DrawDebugData(); } - (void) setGravityX:(float)x y:(float)y { diff --git a/src/physics/debug/QQGLESDebugDraw.h b/src/physics/debug/QQGLESDebugDraw.h index 058ac90..eb08b8e 100644 --- a/src/physics/debug/QQGLESDebugDraw.h +++ b/src/physics/debug/QQGLESDebugDraw.h @@ -35,17 +35,21 @@ struct b2AABB; class QQGLESDebugDraw : public b2DebugDraw { public: - void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); + float32 globalAlpha; + + QQGLESDebugDraw(); + + void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); + void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); + void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); - void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); + void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); - void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); + void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); - void DrawTransform(const b2Transform& xf); + void DrawTransform(const b2Transform& xf); void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color); diff --git a/src/physics/debug/QQGLESDebugDraw.mm b/src/physics/debug/QQGLESDebugDraw.mm index 674f60e..7aaea54 100644 --- a/src/physics/debug/QQGLESDebugDraw.mm +++ b/src/physics/debug/QQGLESDebugDraw.mm @@ -26,124 +26,128 @@ #include +QQGLESDebugDraw::QQGLESDebugDraw() { + globalAlpha = 1; +} + void QQGLESDebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { - glColor4f(color.r, color.g, color.b,1); - glVertexPointer(2, GL_FLOAT, 0, vertices); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); + glColor4f(color.r, color.g, color.b, globalAlpha); + glVertexPointer(2, GL_FLOAT, 0, vertices); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); } void QQGLESDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { - glVertexPointer(2, GL_FLOAT, 0, vertices); - - glColor4f(color.r, color.g, color.b,0.5f); - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); - - glColor4f(color.r, color.g, color.b,1); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); + glVertexPointer(2, GL_FLOAT, 0, vertices); + + glColor4f(color.r, color.g, color.b, 0.5f*globalAlpha); + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); + + glColor4f(color.r, color.g, color.b, globalAlpha); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); } void QQGLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) { - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - GLfloat glVertices[vertexCount*2]; - for (int32 i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x; - glVertices[i*2+1]=v.y; - theta += k_increment; - } - - glColor4f(color.r, color.g, color.b,1); - glVertexPointer(2, GL_FLOAT, 0, glVertices); - - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); + const float32 k_segments = 16.0f; + int vertexCount=16; + const float32 k_increment = 2.0f * b2_pi / k_segments; + float32 theta = 0.0f; + + GLfloat glVertices[vertexCount*2]; + for (int32 i = 0; i < k_segments; ++i) + { + b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); + glVertices[i*2]=v.x; + glVertices[i*2+1]=v.y; + theta += k_increment; + } + + glColor4f(color.r, color.g, color.b, globalAlpha); + glVertexPointer(2, GL_FLOAT, 0, glVertices); + + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); } void QQGLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) { - const float32 k_segments = 16.0f; - int vertexCount=16; - const float32 k_increment = 2.0f * b2_pi / k_segments; - float32 theta = 0.0f; - - GLfloat glVertices[vertexCount*2]; - for (int32 i = 0; i < k_segments; ++i) - { - b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); - glVertices[i*2]=v.x; - glVertices[i*2+1]=v.y; - theta += k_increment; - } - - glColor4f(color.r, color.g, color.b,0.5f); - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); - glColor4f(color.r, color.g, color.b,1); - glDrawArrays(GL_LINE_LOOP, 0, vertexCount); - - // Draw the axis line - DrawSegment(center,center+radius*axis,color); + const float32 k_segments = 16.0f; + int vertexCount=16; + const float32 k_increment = 2.0f * b2_pi / k_segments; + float32 theta = 0.0f; + + GLfloat glVertices[vertexCount*2]; + for (int32 i = 0; i < k_segments; ++i) + { + b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta)); + glVertices[i*2]=v.x; + glVertices[i*2+1]=v.y; + theta += k_increment; + } + + glColor4f(color.r, color.g, color.b, 0.5f*globalAlpha); + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); + glColor4f(color.r, color.g, color.b, globalAlpha); + glDrawArrays(GL_LINE_LOOP, 0, vertexCount); + + // Draw the axis line + DrawSegment(center,center+radius*axis,color); } void QQGLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) { - glColor4f(color.r, color.g, color.b,1); - GLfloat glVertices[] = { - p1.x,p1.y,p2.x,p2.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_LINES, 0, 2); + glColor4f(color.r, color.g, color.b, globalAlpha); + GLfloat glVertices[] = { + p1.x,p1.y,p2.x,p2.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_LINES, 0, 2); } void QQGLESDebugDraw::DrawTransform(const b2Transform& xf) { - b2Vec2 p1 = xf.position, p2; - const float32 k_axisScale = 0.4f; - - p2 = p1 + k_axisScale * xf.R.col1; - DrawSegment(p1,p2,b2Color(1,0,0)); - - p2 = p1 + k_axisScale * xf.R.col2; - DrawSegment(p1,p2,b2Color(0,1,0)); + b2Vec2 p1 = xf.position, p2; + const float32 k_axisScale = 0.4f; + + p2 = p1 + k_axisScale * xf.R.col1; + DrawSegment(p1,p2,b2Color(1,0,0)); + + p2 = p1 + k_axisScale * xf.R.col2; + DrawSegment(p1,p2,b2Color(0,1,0)); } void QQGLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) { - glColor4f(color.r, color.g, color.b,1); - glPointSize(size); - GLfloat glVertices[] = { - p.x,p.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_POINTS, 0, 1); - glPointSize(1.0f); + glColor4f(color.r, color.g, color.b, globalAlpha); + glPointSize(size); + GLfloat glVertices[] = { + p.x,p.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_POINTS, 0, 1); + glPointSize(1.0f); } void QQGLESDebugDraw::DrawString(int x, int y, const char *string, ...) { - /* Unsupported as yet. Could replace with bitmap font renderer at a later date */ + /* Unsupported as yet. Could replace with bitmap font renderer at a later date */ } void QQGLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& c) { - - glColor4f(c.r, c.g, c.b,1); - - GLfloat glVertices[] = { - aabb->lowerBound.x, aabb->lowerBound.y, - aabb->upperBound.x, aabb->lowerBound.y, - aabb->upperBound.x, aabb->upperBound.y, - aabb->lowerBound.x, aabb->upperBound.y - }; - glVertexPointer(2, GL_FLOAT, 0, glVertices); - glDrawArrays(GL_LINE_LOOP, 0, 8); - + + glColor4f(c.r, c.g, c.b, globalAlpha); + + GLfloat glVertices[] = { + aabb->lowerBound.x, aabb->lowerBound.y, + aabb->upperBound.x, aabb->lowerBound.y, + aabb->upperBound.x, aabb->upperBound.y, + aabb->lowerBound.x, aabb->upperBound.y + }; + glVertexPointer(2, GL_FLOAT, 0, glVertices); + glDrawArrays(GL_LINE_LOOP, 0, 8); + } diff --git a/src/physics/debug/QQPhysicsDebugView.h b/src/physics/debug/QQPhysicsDebugView.h index a8f63b6..261b7b5 100644 --- a/src/physics/debug/QQPhysicsDebugView.h +++ b/src/physics/debug/QQPhysicsDebugView.h @@ -5,21 +5,50 @@ #include -#import "physics/QQPhysicsView.h" +#import "physics/QQWorld.h" + /* This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. The view content is basically an EAGL surface you render your OpenGL scene into. Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. */ -@interface QQPhysicsDebugView : QQPhysicsView {} +@interface QQPhysicsDebugView : UIView { +@private + QQWorld* _world; + BOOL _panning; -@property (nonatomic, readonly, getter=isRunning) BOOL running; -@property (nonatomic, assign) NSTimeInterval animationInterval; + // Position offset and scale + float sceneScale; + CGPoint positionOffset; + + CGPoint lastWorldTouch; + CGPoint lastScreenTouch; + + b2MouseJoint* mouseJoint; + b2Vec2 mouseWorld; + int32 stepCount; + + /// OpenGL /// + + /* The pixel dimensions of the backbuffer */ + GLint backingWidth; + GLint backingHeight; + + EAGLContext *context; + + /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ + GLuint viewRenderbuffer, viewFramebuffer; + + /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ + GLuint depthRenderbuffer; + +} +@property (nonatomic, readwrite, retain) QQWorld* world; +@property (nonatomic, readonly, assign, getter=isPanning) BOOL panning; -- (void) startAnimation; -- (void) stopAnimation; +- (void) drawView; @end diff --git a/src/physics/debug/QQPhysicsDebugView.mm b/src/physics/debug/QQPhysicsDebugView.mm index 6c48262..bd645ac 100644 --- a/src/physics/debug/QQPhysicsDebugView.mm +++ b/src/physics/debug/QQPhysicsDebugView.mm @@ -11,50 +11,18 @@ // A class extension to declare private methods -@interface QQPhysicsDebugView () { - -@private - QQWorld* _world; - BOOL _running; - - NSTimer* animationTimer; - NSTimeInterval animationInterval; - BOOL panning; - - // Position offset and scale - float sceneScale; - CGPoint positionOffset; - - CGPoint lastWorldTouch; - CGPoint lastScreenTouch; - - b2MouseJoint* mouseJoint; - b2Vec2 mouseWorld; - int32 stepCount; - - - /// OpenGL /// - - /* The pixel dimensions of the backbuffer */ - GLint backingWidth; - GLint backingHeight; - - EAGLContext *context; - - /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ - GLuint viewRenderbuffer, viewFramebuffer; - - /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ - GLuint depthRenderbuffer; - -} +@interface QQPhysicsDebugView () @property (nonatomic, retain) EAGLContext *context; -@property (nonatomic, assign) NSTimer *animationTimer; + +- (void) setup; - (BOOL) createFramebuffer; - (void) destroyFramebuffer; +- (void) prepContext; +- (void) flushContext; + @end @@ -63,11 +31,9 @@ @implementation QQPhysicsDebugView @synthesize world = _world; -@synthesize running = _running; +@synthesize panning = _panning; @synthesize context; -@synthesize animationTimer; -@synthesize animationInterval; // You must implement this method @@ -75,78 +41,58 @@ return [CAEAGLLayer class]; } +- (id) initWithFrame:(CGRect)aRect { + if ((self = [super initWithFrame:aRect])) { + [self setup]; + } + return self; +} //The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: -- (id)initWithCoder:(NSCoder*)coder { - +- (id) initWithCoder:(NSCoder*)coder { if ((self = [super initWithCoder:coder])) { - // Get the layer - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - - if (!context || ![EAGLContext setCurrentContext:context]) { - [self release]; - return nil; - } - - _running = NO; - animationInterval = 1.0 / 60.0; - sceneScale = 10.0f; - positionOffset = CGPointMake(0, 0); - lastWorldTouch = CGPointMake(0, 0); - - [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; - [[UIAccelerometer sharedAccelerometer] setDelegate:self]; + [self setup]; } - return self; } -- (void) dealloc { - [self stopAnimation]; +- (void) setup { + // Get the layer + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - if ([EAGLContext currentContext] == context) { - [EAGLContext setCurrentContext:nil]; + eaglLayer.opaque = NO; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, + kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, + nil]; + + context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + + if (!context || ![EAGLContext setCurrentContext:context]) { + [self release]; + return nil; } - [context release]; - [super dealloc]; + sceneScale = 10.0f; + positionOffset = CGPointMake(0,0); + lastWorldTouch = CGPointMake(0,0); + + [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)]; + [[UIAccelerometer sharedAccelerometer] setDelegate:self]; } - -/// Accessors /// - -- (void) setAnimationTimer:(NSTimer*)newTimer { - [animationTimer invalidate]; - animationTimer = newTimer; +- (void) dealloc { + if ([EAGLContext currentContext] == context) + [EAGLContext setCurrentContext:nil]; + [context release]; + [_world release]; + [super dealloc]; } -- (void) setAnimationInterval:(NSTimeInterval)interval { - animationInterval = interval; - if (animationTimer) { - [self stopAnimation]; - [self startAnimation]; - } -} /// Methods /// -- (void) startAnimation { - _running = YES; - self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; -} - -- (void) stopAnimation { - _running = NO; - self.animationTimer = nil; -} - - (CGPoint) screenSpaceToWorldSpace:(CGPoint) screenLocation { screenLocation.x -= 160; screenLocation.y -= 240; @@ -217,7 +163,14 @@ /// OpenGL /// -- (void) drawView { +- (void) layoutSubviews { + [EAGLContext setCurrentContext:context]; + [self destroyFramebuffer]; + [self createFramebuffer]; + [self drawView]; +} + +- (void) prepContext { [EAGLContext setCurrentContext:context]; glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); @@ -230,27 +183,25 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glTranslatef(positionOffset.x, positionOffset.y,0); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glTranslatef(positionOffset.x, positionOffset.y, 0); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnableClientState(GL_VERTEX_ARRAY); - - [self.world step]; - - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); - [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } +- (void) drawView { + [self prepContext]; + [self.world drawDebug]; + [self flushContext]; +} -- (void) layoutSubviews { - [EAGLContext setCurrentContext:context]; - [self destroyFramebuffer]; - [self createFramebuffer]; - [self drawView]; +- (void) flushContext { + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } diff --git a/src/ui/QQAppDelegate.h b/src/ui/QQAppDelegate.h index f868fe1..29dbd78 100644 --- a/src/ui/QQAppDelegate.h +++ b/src/ui/QQAppDelegate.h @@ -1,16 +1,19 @@ #import "Sparrow.h" #import "game/QQGame.h" +#import "physics/debug/QQPhysicsDebugView.h" @interface QQAppDelegate : NSObject { UIWindow* window; SPView* sparrowView; + QQPhysicsDebugView* _debugView; QQGame* _game; } @property (nonatomic, retain) IBOutlet UIWindow* window; @property (nonatomic, retain) IBOutlet SPView* sparrowView; +@property (nonatomic, retain) QQPhysicsDebugView* debugView; @property (nonatomic, retain) QQGame* game; @end \ No newline at end of file diff --git a/src/ui/QQAppDelegate.mm b/src/ui/QQAppDelegate.mm index 7eaeb17..3e161ef 100644 --- a/src/ui/QQAppDelegate.mm +++ b/src/ui/QQAppDelegate.mm @@ -13,6 +13,7 @@ @synthesize window; @synthesize sparrowView; +@synthesize debugView = _debugView; @synthesize game = _game; @@ -25,8 +26,10 @@ sparrowView.frameRate = 60.0f; // sparrowView.stage = [[[SPStage alloc] init] autorelease]; - _game = [[QQGame alloc] init]; + self.game = [[[QQGame alloc] init] autorelease]; sparrowView.stage = _game; + self.debugView = [[[QQPhysicsDebugView alloc] initWithFrame:sparrowView.frame] autorelease]; + [window addSubview:self.debugView]; [window makeKeyAndVisible]; [sparrowView start]; diff --git a/src/ui/iPad/en.lproj/MainWindow_iPad.xib b/src/ui/iPad/en.lproj/MainWindow_iPad.xib index f0d386c..50d6ea2 100644 --- a/src/ui/iPad/en.lproj/MainWindow_iPad.xib +++ b/src/ui/iPad/en.lproj/MainWindow_iPad.xib @@ -40,7 +40,6 @@ {{284, 501}, {200, 22}} - NO YES 7 @@ -58,7 +57,7 @@ 292 - {{0, 21}, {768, 1003}} + {768, 1003} @@ -83,9 +82,7 @@ NO NO - - 2 - + YES IBIPadFramework YES diff --git a/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib b/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib index 32443c1..a5af9d2 100644 --- a/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib +++ b/src/ui/iPhone/en.lproj/MainWindow_iPhone.xib @@ -86,7 +86,7 @@ NO NO - + YES IBCocoaTouchFramework YES -- 1.7.0.4