Bläddra i källkod

Merge pull request #17 from blackberry-gaming/next

Next
Sean Paul Taylor 14 år sedan
förälder
incheckning
04282c3299

+ 14 - 14
gameplay/gameplay.xcodeproj/project.pbxproj

@@ -559,8 +559,8 @@
 		4234D9A314686C52003031B3 /* src */ = {
 		4234D9A314686C52003031B3 /* src */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
-				5B43D19714C35347008A5D9D /* GamePlay */,
-				5B43D19614C35344008A5D9D /* Platform */,
+				5B43D19714C35347008A5D9D /* gameplay */,
+				5B43D19614C35344008A5D9D /* platform */,
 			);
 			);
 			name = src;
 			name = src;
 			path = gameplay;
 			path = gameplay;
@@ -614,23 +614,23 @@
 			name = "Mac OS X";
 			name = "Mac OS X";
 			sourceTree = "<group>";
 			sourceTree = "<group>";
 		};
 		};
-		5B43D19614C35344008A5D9D /* Platform */ = {
+		5B43D19614C35344008A5D9D /* platform */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				42CD0DE0147D8FF50000361E /* gameplay-main-win32.cpp */,
 				42CD0DDE147D8FF50000361E /* gameplay-main-macos.mm */,
 				42CD0DDE147D8FF50000361E /* gameplay-main-macos.mm */,
 				5B04C5CB14BFD48500EB0071 /* gameplay-main-ios.mm */,
 				5B04C5CB14BFD48500EB0071 /* gameplay-main-ios.mm */,
 				42CD0DDF147D8FF50000361E /* gameplay-main-qnx.cpp */,
 				42CD0DDF147D8FF50000361E /* gameplay-main-qnx.cpp */,
-				42CD0DE0147D8FF50000361E /* gameplay-main-win32.cpp */,
 				42CD0E19147D8FF50000361E /* Platform.h */,
 				42CD0E19147D8FF50000361E /* Platform.h */,
-				42CD0E1A147D8FF50000361E /* PlatformMacOS.mm */,
-				42CD0E1B147D8FF50000361E /* PlatformQNX.cpp */,
 				42CD0E1C147D8FF50000361E /* PlatformWin32.cpp */,
 				42CD0E1C147D8FF50000361E /* PlatformWin32.cpp */,
+				42CD0E1A147D8FF50000361E /* PlatformMacOS.mm */,
 				5B04C5CC14BFD48500EB0071 /* PlatformiOS.mm */,
 				5B04C5CC14BFD48500EB0071 /* PlatformiOS.mm */,
+				42CD0E1B147D8FF50000361E /* PlatformQNX.cpp */,
 			);
 			);
-			name = Platform;
+			name = platform;
 			sourceTree = "<group>";
 			sourceTree = "<group>";
 		};
 		};
-		5B43D19714C35347008A5D9D /* GamePlay */ = {
+		5B43D19714C35347008A5D9D /* gameplay */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
 				42CD0DB1147D8FF50000361E /* Animation.cpp */,
 				42CD0DB1147D8FF50000361E /* Animation.cpp */,
@@ -786,7 +786,7 @@
 				42CD0E44147D8FF50000361E /* Viewport.cpp */,
 				42CD0E44147D8FF50000361E /* Viewport.cpp */,
 				42CD0E45147D8FF50000361E /* Viewport.h */,
 				42CD0E45147D8FF50000361E /* Viewport.h */,
 			);
 			);
-			name = GamePlay;
+			name = gameplay;
 			sourceTree = "<group>";
 			sourceTree = "<group>";
 		};
 		};
 		5B5ADCE014C22DBE00AC6109 /* iOS */ = {
 		5B5ADCE014C22DBE00AC6109 /* iOS */ = {
@@ -971,9 +971,9 @@
 /* End PBXHeadersBuildPhase section */
 /* End PBXHeadersBuildPhase section */
 
 
 /* Begin PBXNativeTarget section */
 /* Begin PBXNativeTarget section */
-		4234D99914686C52003031B3 /* gameplay-macosx */ = {
+		4234D99914686C52003031B3 /* gameplay-macos */ = {
 			isa = PBXNativeTarget;
 			isa = PBXNativeTarget;
-			buildConfigurationList = 4234D9AB14686C52003031B3 /* Build configuration list for PBXNativeTarget "gameplay-macosx" */;
+			buildConfigurationList = 4234D9AB14686C52003031B3 /* Build configuration list for PBXNativeTarget "gameplay-macos" */;
 			buildPhases = (
 			buildPhases = (
 				4234D99614686C52003031B3 /* Sources */,
 				4234D99614686C52003031B3 /* Sources */,
 				4234D99714686C52003031B3 /* Frameworks */,
 				4234D99714686C52003031B3 /* Frameworks */,
@@ -983,7 +983,7 @@
 			);
 			);
 			dependencies = (
 			dependencies = (
 			);
 			);
-			name = "gameplay-macosx";
+			name = "gameplay-macos";
 			productName = gameplay;
 			productName = gameplay;
 			productReference = 4234D99A14686C52003031B3 /* libgameplay.a */;
 			productReference = 4234D99A14686C52003031B3 /* libgameplay.a */;
 			productType = "com.apple.product-type.library.static";
 			productType = "com.apple.product-type.library.static";
@@ -1025,7 +1025,7 @@
 			projectDirPath = "";
 			projectDirPath = "";
 			projectRoot = "";
 			projectRoot = "";
 			targets = (
 			targets = (
-				4234D99914686C52003031B3 /* gameplay-macosx */,
+				4234D99914686C52003031B3 /* gameplay-macos */,
 				5B04C52B14BFCFE100EB0071 /* gameplay-ios */,
 				5B04C52B14BFCFE100EB0071 /* gameplay-ios */,
 			);
 			);
 		};
 		};
@@ -1389,7 +1389,7 @@
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 			defaultConfigurationName = Release;
 		};
 		};
-		4234D9AB14686C52003031B3 /* Build configuration list for PBXNativeTarget "gameplay-macosx" */ = {
+		4234D9AB14686C52003031B3 /* Build configuration list for PBXNativeTarget "gameplay-macos" */ = {
 			isa = XCConfigurationList;
 			isa = XCConfigurationList;
 			buildConfigurations = (
 			buildConfigurations = (
 				4234D9A914686C52003031B3 /* Debug */,
 				4234D9A914686C52003031B3 /* Debug */,

+ 13 - 18
gameplay/src/Base.h

@@ -136,15 +136,12 @@ extern void printError(const char* format, ...);
 #endif
 #endif
 #include <vorbis/vorbisfile.h>
 #include <vorbis/vorbisfile.h>
 
 
-// Screen/Window
-#define WINDOW_WIDTH        1024
-#define WINDOW_HEIGHT       600
-#define WINDOW_VSYNC        1
-#define WINDOW_FULLSCREEN   0
-
 // Image
 // Image
 #include <png.h>
 #include <png.h>
 
 
+#define WINDOW_VSYNC        1
+#define WINDOW_FULLSCREEN   0
+
 // Graphics (OpenGL)
 // Graphics (OpenGL)
 #ifdef __QNX__
 #ifdef __QNX__
     #include <EGL/egl.h>
     #include <EGL/egl.h>
@@ -155,22 +152,16 @@ extern void printError(const char* format, ...);
     extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays;
     extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays;
     extern PFNGLISVERTEXARRAYOESPROC glIsVertexArray;
     extern PFNGLISVERTEXARRAYOESPROC glIsVertexArray;
     #define glClearDepth glClearDepthf
     #define glClearDepth glClearDepthf
-   #define OPENGL_ES
+    #define OPENGL_ES
+    #define WINDOW_WIDTH    1024
+    #define WINDOW_HEIGHT   600
 #elif WIN32
 #elif WIN32
     #define WIN32_LEAN_AND_MEAN
     #define WIN32_LEAN_AND_MEAN
     #include <GL/glew.h>
     #include <GL/glew.h>
+    #define WINDOW_WIDTH    1024
+    #define WINDOW_HEIGHT   600
 #elif __APPLE__
 #elif __APPLE__
     #include "TargetConditionals.h"
     #include "TargetConditionals.h"
-    // NOTE: Alternative
-    // #ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
-    // ...
-    // #elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
-    // ...
-    // #endif
-    // NOTE: TARGET_OS_MAC is defined in iOS libs, therefore the 
-    // below order matters, the above does not not
-    // see: http://developer.apple.com/library/mac/#documentation/developertools/conceptual/cross_development/Using/using.html
-
     #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
     #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
         #include <OpenGLES/ES2/gl.h>
         #include <OpenGLES/ES2/gl.h>
         #include <OpenGLES/ES2/glext.h>
         #include <OpenGLES/ES2/glext.h>
@@ -179,7 +170,9 @@ extern void printError(const char* format, ...);
         #define glGenVertexArrays glGenVertexArraysOES
         #define glGenVertexArrays glGenVertexArraysOES
         #define glIsVertexArray glIsVertexArrayOES
         #define glIsVertexArray glIsVertexArrayOES
         #define glClearDepth glClearDepthf
         #define glClearDepth glClearDepthf
-        #define OPENGL_ES 1
+        #define OPENGL_ES
+        #define WINDOW_WIDTH    480
+        #define WINDOW_HEIGHT   360
     #elif TARGET_OS_MAC
     #elif TARGET_OS_MAC
         #include <OpenGL/gl.h>
         #include <OpenGL/gl.h>
         #include <OpenGL/glext.h>
         #include <OpenGL/glext.h>
@@ -187,6 +180,8 @@ extern void printError(const char* format, ...);
         #define glDeleteVertexArrays glDeleteVertexArraysAPPLE
         #define glDeleteVertexArrays glDeleteVertexArraysAPPLE
         #define glGenVertexArrays glGenVertexArraysAPPLE
         #define glGenVertexArrays glGenVertexArraysAPPLE
         #define glIsVertexArray glIsVertexArrayAPPLE
         #define glIsVertexArray glIsVertexArrayAPPLE
+        #define WINDOW_WIDTH    960
+        #define WINDOW_HEIGHT   640
     #else
     #else
         #error "Unsupported Apple Device"
         #error "Unsupported Apple Device"
     #endif
     #endif

+ 0 - 1
gameplay/src/PlatformMacOS.mm

@@ -65,7 +65,6 @@ static View* __view = NULL;
     [[NSApplication sharedApplication] terminate:self];
     [[NSApplication sharedApplication] terminate:self];
 }
 }
 
 
-
 - (CVReturn) getFrameForTime:(const CVTimeStamp*)outputTime
 - (CVReturn) getFrameForTime:(const CVTimeStamp*)outputTime
 {
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

+ 99 - 74
gameplay/src/PlatformiOS.mm

@@ -46,33 +46,38 @@ long getMachTimeInMilliseconds()
     return (long)((mach_absolute_time() * s_timebase_info.numer) / (kOneMillion * s_timebase_info.denom));
     return (long)((mach_absolute_time() * s_timebase_info.numer) / (kOneMillion * s_timebase_info.denom));
 }
 }
 
 
-@interface GameplayView : UIView 
+
+@interface View : UIView 
 {
 {
     EAGLContext* context;	
     EAGLContext* context;	
-    CADisplayLink *displayLink;
-    
-	GLuint defaultFramebuffer, colorRenderbuffer, depthRenderbuffer;
-    GLint framebufferWidth, framebufferHeight;
-    BOOL useDepthBuffer;
-    
+    CADisplayLink* displayLink;
+	GLuint defaultFramebuffer;
+    GLuint colorRenderbuffer;
+    GLuint depthRenderbuffer;
+    GLint framebufferWidth;
+    GLint framebufferHeight;    
     NSInteger swapInterval;
     NSInteger swapInterval;
     BOOL updating;
     BOOL updating;
     Game* _game;
     Game* _game;
 }
 }
+
 @property (readonly, nonatomic, getter=isUpdating) BOOL updating;
 @property (readonly, nonatomic, getter=isUpdating) BOOL updating;
+@property (readonly, nonatomic, getter=getContext) EAGLContext* context;
 
 
 - (void)startUpdating;
 - (void)startUpdating;
 - (void)stopUpdating;
 - (void)stopUpdating;
 - (void)update:(id)sender;
 - (void)update:(id)sender;
-
 - (void)createFramebuffer;
 - (void)createFramebuffer;
 - (void)deleteFramebuffer;
 - (void)deleteFramebuffer;
 
 
 @end
 @end
 
 
-@implementation GameplayView
+static View* __view = NULL;
+
+@implementation View
 
 
 @synthesize updating;
 @synthesize updating;
+@synthesize context;
 
 
 + (Class) layerClass
 + (Class) layerClass
 {
 {
@@ -81,6 +86,7 @@ long getMachTimeInMilliseconds()
 
 
 - (id) initWithFrame:(CGRect)frame
 - (id) initWithFrame:(CGRect)frame
 {
 {
+    __view = self;
     if ((self = [super initWithFrame:frame]))
     if ((self = [super initWithFrame:frame]))
 	{
 	{
         // Do a sanity check
         // Do a sanity check
@@ -105,8 +111,7 @@ long getMachTimeInMilliseconds()
         layer.opaque = TRUE;
         layer.opaque = TRUE;
         layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
         layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, 
                                    [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, 
-                                    kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, 
-                                    nil];
+                                    kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
 		context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
 		context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
         if (!context || ![EAGLContext setCurrentContext:context])
         if (!context || ![EAGLContext setCurrentContext:context])
 		{
 		{
@@ -119,21 +124,20 @@ long getMachTimeInMilliseconds()
         defaultFramebuffer = 0;
         defaultFramebuffer = 0;
         colorRenderbuffer = 0;
         colorRenderbuffer = 0;
         depthRenderbuffer = 0;
         depthRenderbuffer = 0;
-        useDepthBuffer = TRUE;
-        
+        framebufferWidth = 0;
+        framebufferHeight = 0;
 		swapInterval = 1;        
 		swapInterval = 1;        
         updating = FALSE;
         updating = FALSE;
         
         
         [self createFramebuffer];
         [self createFramebuffer];
         
         
-        // GamePlay Setup
         // Set the resource path and initalize the game
         // Set the resource path and initalize the game
         NSString* bundlePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/"];
         NSString* bundlePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/"];
         FileSystem::setResourcePath([bundlePath fileSystemRepresentation]); 
         FileSystem::setResourcePath([bundlePath fileSystemRepresentation]); 
         
         
         _game = Game::getInstance();
         _game = Game::getInstance();
         __timeStart = getMachTimeInMilliseconds();
         __timeStart = getMachTimeInMilliseconds();
-        _game->run(framebufferWidth, framebufferHeight);
+        _game->run(WINDOW_WIDTH, WINDOW_HEIGHT);    // TODO: Handle based on current orientation
     }
     }
     return self;
     return self;
 }
 }
@@ -149,45 +153,39 @@ long getMachTimeInMilliseconds()
     [super dealloc];
     [super dealloc];
 }
 }
 
 
-// iOS Requires all content go to a rendering buffer
-// then it is swapped into the windows rendering surface
 - (void)createFramebuffer
 - (void)createFramebuffer
 {
 {
+    // iOS Requires all content go to a rendering buffer then it is swapped into the windows rendering surface
     assert(defaultFramebuffer == 0);
     assert(defaultFramebuffer == 0);
     //NSLog(@"EAGLView: creating Framebuffer");
     //NSLog(@"EAGLView: creating Framebuffer");
     
     
     // Create the default frame buffer, and render buffer
     // Create the default frame buffer, and render buffer
     glGenFramebuffers(1, &defaultFramebuffer);
     glGenFramebuffers(1, &defaultFramebuffer);
-    glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);    
     glGenRenderbuffers(1, &colorRenderbuffer);
     glGenRenderbuffers(1, &colorRenderbuffer);
+    glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);    
     glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
     glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
     
     
     // request storage, width, and height of the view that we will render in
     // request storage, width, and height of the view that we will render in
     [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
     [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
+    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
     glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &framebufferWidth);
     glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &framebufferWidth);
     glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &framebufferHeight);
     glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &framebufferHeight);
-    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
-
-    // Optionally use depth buffer
-    // If desired, create the depth buffer, and request storage for the depth buffer
-    // Then attach to the frame buffer
-    if(useDepthBuffer)
-    {
-        glGenRenderbuffers(1, &depthRenderbuffer);
-        glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
-        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, framebufferWidth, framebufferHeight);
-        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
-    }
-
+    
+    glGenRenderbuffers(1, &depthRenderbuffer);
+    glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
+    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24_OES, framebufferWidth, framebufferHeight);
+    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer);
+    
     // Sanity check, ensure that the framebuffer is valid
     // Sanity check, ensure that the framebuffer is valid
     if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
     if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
         NSLog(@"ERROR: Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
         NSLog(@"ERROR: Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
 }
 }
 
 
-//deleting the framebuffer and all the buffers it contains
 - (void)deleteFramebuffer
 - (void)deleteFramebuffer
 {
 {
-    if (context) {
+    // Deleting the framebuffer and all the buffers it contains
+    if (context) 
+    {
         [EAGLContext setCurrentContext:context];        
         [EAGLContext setCurrentContext:context];        
         if (defaultFramebuffer) 
         if (defaultFramebuffer) 
         {
         {
@@ -219,7 +217,9 @@ long getMachTimeInMilliseconds()
 		}
 		}
 	}
 	}
 }
 }
-- (int)swapInterval {
+
+- (int)swapInterval 
+{
     return swapInterval;
     return swapInterval;
 }
 }
 
 
@@ -251,6 +251,7 @@ long getMachTimeInMilliseconds()
         [EAGLContext setCurrentContext:context];
         [EAGLContext setCurrentContext:context];
         if (!defaultFramebuffer)
         if (!defaultFramebuffer)
             [self createFramebuffer];
             [self createFramebuffer];
+        
         glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
         glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
         glViewport(0, 0, framebufferWidth, framebufferHeight);
         glViewport(0, 0, framebufferWidth, framebufferHeight);
 
 
@@ -265,46 +266,58 @@ long getMachTimeInMilliseconds()
 - (void) layoutSubviews
 - (void) layoutSubviews
 {
 {
     [self deleteFramebuffer];
     [self deleteFramebuffer];
-	//_game->resize() //(CAEAGLLayer*)self.layer];
 }
 }
 
 
-
-- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
+- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event 
+{
     unsigned int uniqueTouch = 0;
     unsigned int uniqueTouch = 0;
-    for(UITouch *t in touches) {
-        CGPoint touchLoc = [t locationInView:nil];
-        Game::getInstance()->touchEvent(Touch::TOUCH_PRESS, touchLoc.x, touchLoc.y, uniqueTouch);
-    }
-}
-- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
-    unsigned 
-    int uniqueTouch = 0;
-    for(UITouch *t in touches) {
+    for(UITouch *t in touches) 
+    {
         CGPoint touchLoc = [t locationInView:nil];
         CGPoint touchLoc = [t locationInView:nil];
-        Game::getInstance()->touchEvent(Touch::TOUCH_MOVE, touchLoc.x, touchLoc.y, uniqueTouch);
+        // TODO: Handle this based on orientation
+        Game::getInstance()->touchEvent(Touch::TOUCH_PRESS, touchLoc.y,  WINDOW_WIDTH - touchLoc.x, uniqueTouch);
     }
     }
 }
 }
-- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
+
+- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent *)event 
+{
     unsigned int uniqueTouch = 0;
     unsigned int uniqueTouch = 0;
-    for(UITouch *t in touches) {
+    for(UITouch* t in touches) 
+    {
         CGPoint touchLoc = [t locationInView:nil];
         CGPoint touchLoc = [t locationInView:nil];
-        Game::getInstance()->touchEvent(Touch::TOUCH_RELEASE, touchLoc.x, touchLoc.y, uniqueTouch);
+        // TODO: Handle this based on orientation
+        Game::getInstance()->touchEvent(Touch::TOUCH_RELEASE, touchLoc.y, WINDOW_WIDTH - touchLoc.x, uniqueTouch);
     }
     }
 }
 }
-- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
+
+- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event 
+{
     // No equivalent for this in GamePlay -- treat as touch end
     // No equivalent for this in GamePlay -- treat as touch end
     [self touchesEnded:touches withEvent:event];
     [self touchesEnded:touches withEvent:event];
 }
 }
 
 
+- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event 
+{
+    unsigned 
+    int uniqueTouch = 0;
+    for(UITouch* t in touches) 
+    {
+        CGPoint touchLoc = [t locationInView:nil];
+        // TODO: Handle this based on orientation
+        Game::getInstance()->touchEvent(Touch::TOUCH_MOVE, touchLoc.y,  WINDOW_WIDTH - touchLoc.x, uniqueTouch);
+    }
+}
+
 @end
 @end
 
 
 
 
-@interface GameplayViewController : UIViewController
+@interface ViewController : UIViewController
 - (void)startUpdating;
 - (void)startUpdating;
 - (void)stopUpdating;
 - (void)stopUpdating;
 @end
 @end
 
 
-@implementation GameplayViewController 
+
+@implementation ViewController 
 
 
 - (id)init 
 - (id)init 
 {
 {
@@ -313,6 +326,7 @@ long getMachTimeInMilliseconds()
     }
     }
     return self;
     return self;
 }
 }
+
 - (void)dealloc 
 - (void)dealloc 
 {
 {
     __rootView = nil;
     __rootView = nil;
@@ -328,55 +342,66 @@ long getMachTimeInMilliseconds()
 #pragma mark - View lifecycle
 #pragma mark - View lifecycle
 - (void)loadView
 - (void)loadView
 {
 {
-    self.view = [[[GameplayView alloc] init] autorelease];
-    if(__rootView == nil) {
+    self.view = [[[View alloc] init] autorelease];
+    if(__rootView == nil) 
+    {
         __rootView = self.view;
         __rootView = self.view;
     }
     }
 }
 }
 
 
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 {
 {
-    // Return YES for supported orientations
-    // Currently support landscape only?
+    // Return YES for supported orientation, currently support landscape only?
     return UIInterfaceOrientationIsLandscape(interfaceOrientation);
     return UIInterfaceOrientationIsLandscape(interfaceOrientation);
 }
 }
 
 
-- (void)startUpdating {
-    [(GameplayView*)self.view startUpdating];
+- (void)startUpdating 
+{
+    [(View*)self.view startUpdating];
 }
 }
-- (void)stopUpdating {
-    [(GameplayView*)self.view stopUpdating];
 
 
+- (void)stopUpdating 
+{
+    [(View*)self.view stopUpdating];
 }
 }
 
 
 @end
 @end
 
 
 
 
-@interface AppDelegate : UIApplication <UIApplicationDelegate> 
+@interface AppDelegate : UIApplication <UIApplicationDelegate, UIAccelerometerDelegate>
 {
 {
     UIWindow* window;
     UIWindow* window;
-    GameplayViewController* viewController;
+    ViewController* viewController;
 }
 }
 @end
 @end
 
 
+
 @implementation AppDelegate
 @implementation AppDelegate
 
 
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
 {
 {
+    [UIApplication sharedApplication].statusBarHidden = YES;
+    UIAccelerometer*  accelerometer = [UIAccelerometer sharedAccelerometer];
+    accelerometer.updateInterval = 1 / 40.0;    // 40Hz
+    accelerometer.delegate = self;
+    
     window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
     window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
-    viewController = [[GameplayViewController alloc] init];
+    viewController = [[ViewController alloc] init];
     [window setRootViewController:viewController];
     [window setRootViewController:viewController];
     [window makeKeyAndVisible];
     [window makeKeyAndVisible];
-    
-    // Hide the status bar 
-    // Possilibitlies for hiding include:
-    // * UIStatusBarAnimationNone
-    // * UIStatusBarAnimationFade
-    // * UIStatusBarAnimationSlide
-    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
     return YES;
     return YES;
 }
 }
 
 
+- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
+{
+    UIAccelerationValue x, y, z;
+    x = acceleration.x;
+    y = acceleration.y;
+    z = acceleration.z;
+    
+    // Do something with the values.
+}
+
 - (void)applicationWillResignActive:(UIApplication*)application
 - (void)applicationWillResignActive:(UIApplication*)application
 {    
 {    
 	[viewController stopUpdating];
 	[viewController stopUpdating];
@@ -415,7 +440,6 @@ long getMachTimeInMilliseconds()
 
 
 namespace gameplay
 namespace gameplay
 {
 {
-    
     extern void printError(const char* format, ...)
     extern void printError(const char* format, ...)
     {
     {
         va_list argptr;
         va_list argptr;
@@ -498,7 +522,8 @@ namespace gameplay
     
     
     void Platform::swapBuffers()
     void Platform::swapBuffers()
     {
     {
-        
+        if (__view)
+            [[__view getContext] presentRenderbuffer:GL_RENDERBUFFER];
     }
     }
     
     
 }
 }