Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Use a consistent source code format in src/video/uikit
Browse files Browse the repository at this point in the history
For example:
* Opening bracket of a method/function on a new line at column 0
* space after "if", "while", etc
  • Loading branch information
keestux committed Sep 27, 2011
1 parent 307afa9 commit f98d6e7
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 135 deletions.
6 changes: 3 additions & 3 deletions src/video/uikit/SDL_uikitappdelegate.h
Expand Up @@ -22,11 +22,11 @@
#import <UIKit/UIKit.h>
#import "SDL_uikitopenglview.h"

@interface SDLUIKitDelegate:NSObject<UIApplicationDelegate> {
@interface SDLUIKitDelegate : NSObject<UIApplicationDelegate> {
}

+(SDLUIKitDelegate *)sharedAppDelegate;
+(NSString *)getAppDelegateClassName;
+ (SDLUIKitDelegate *)sharedAppDelegate;
+ (NSString *)getAppDelegateClassName;

@end

Expand Down
32 changes: 18 additions & 14 deletions src/video/uikit/SDL_uikitappdelegate.m
Expand Up @@ -37,15 +37,15 @@
static int forward_argc;
static char **forward_argv;

int main(int argc, char **argv) {

int main(int argc, char **argv)
{
int i;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

/* store arguments */
forward_argc = argc;
forward_argv = (char **)malloc((argc+1) * sizeof(char *));
for (i=0; i<argc; i++) {
for (i = 0; i < argc; i++) {
forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
strcpy(forward_argv[i], argv[i]);
}
Expand All @@ -58,7 +58,8 @@ int main(int argc, char **argv) {
return 0;
}

static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue) {
static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue, const char *newValue)
{
SDL_assert(SDL_strcmp(name, SDL_HINT_IDLE_TIMER_DISABLED) == 0);

BOOL disable = (*newValue != '0');
Expand All @@ -68,24 +69,27 @@ static void SDL_IdleTimerDisabledChanged(const char *name, const char *oldValue,
@implementation SDLUIKitDelegate

/* convenience method */
+(SDLUIKitDelegate *)sharedAppDelegate {
+ (SDLUIKitDelegate *)sharedAppDelegate
{
/* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
return (SDLUIKitDelegate *)[[UIApplication sharedApplication] delegate];
}

+(NSString *)getAppDelegateClassName {
+ (NSString *)getAppDelegateClassName
{
/* subclassing notice: when you subclass this appdelegate, make sure to add a category to override
this method and return the actual name of the delegate */
return @"SDLUIKitDelegate";
}

- (id)init {
- (id)init
{
self = [super init];
return self;
}

- (void)postFinishLaunch {

- (void)postFinishLaunch
{
/* register a callback for the idletimer hint */
SDL_SetHint(SDL_HINT_IDLE_TIMER_DISABLED, "0");
SDL_RegisterHintChangedCb(SDL_HINT_IDLE_TIMER_DISABLED, &SDL_IdleTimerDisabledChanged);
Expand All @@ -95,7 +99,7 @@ - (void)postFinishLaunch {

/* free the memory we used to hold copies of argc and argv */
int i;
for (i=0; i<forward_argc; i++) {
for (i = 0; i < forward_argc; i++) {
free(forward_argv[i]);
}
free(forward_argv);
Expand All @@ -104,8 +108,8 @@ - (void)postFinishLaunch {
exit(exit_status);
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/* Set working directory to resource path */
[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];

Expand All @@ -114,8 +118,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (void)applicationWillTerminate:(UIApplication *)application {

- (void)applicationWillTerminate:(UIApplication *)application
{
SDL_SendQuit();
/* hack to prevent automatic termination. See SDL_uikitevents.m for details */
longjmp(*(jump_env()), 1);
Expand Down
2 changes: 1 addition & 1 deletion src/video/uikit/SDL_uikitevents.m
Expand Up @@ -47,7 +47,7 @@ So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelega
SInt32 result;
do {
result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
} while(result == kCFRunLoopRunHandledSource);
} while (result == kCFRunLoopRunHandledSource);
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/video/uikit/SDL_uikitopengles.m
Expand Up @@ -47,7 +47,6 @@
*/
int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{

if (context) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
[data->view setCurrentContext];
Expand Down Expand Up @@ -78,10 +77,10 @@ int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)

void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
{
#ifdef SDL_POWER_UIKIT
#ifdef SDL_POWER_UIKIT
// Check once a frame to see if we should turn off the battery monitor.
SDL_UIKit_UpdateBatteryMonitoring();
#endif
#endif

SDL_WindowData *data = (SDL_WindowData *)window->driverdata;

Expand All @@ -106,13 +105,13 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
UIWindow *uiwindow = data->uiwindow;

/* construct our view, passing in SDL's OpenGL configuration data */
view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds] \
retainBacking: _this->gl_config.retained_backing \
rBits: _this->gl_config.red_size \
gBits: _this->gl_config.green_size \
bBits: _this->gl_config.blue_size \
aBits: _this->gl_config.alpha_size \
depthBits: _this->gl_config.depth_size \
view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds]
retainBacking: _this->gl_config.retained_backing
rBits: _this->gl_config.red_size
gBits: _this->gl_config.green_size
bBits: _this->gl_config.blue_size
aBits: _this->gl_config.alpha_size
depthBits: _this->gl_config.depth_size
majorVersion: _this->gl_config.major_version];

data->view = view;
Expand Down
12 changes: 6 additions & 6 deletions src/video/uikit/SDL_uikitopenglview.h
Expand Up @@ -54,12 +54,12 @@
- (void)setCurrentContext;

- (id)initWithFrame:(CGRect)frame
retainBacking:(BOOL)retained \
rBits:(int)rBits \
gBits:(int)gBits \
bBits:(int)bBits \
aBits:(int)aBits \
depthBits:(int)depthBits \
retainBacking:(BOOL)retained
rBits:(int)rBits
gBits:(int)gBits
bBits:(int)bBits
aBits:(int)aBits
depthBits:(int)depthBits
majorVersion:(int)majorVersion;

- (void)updateFrame;
Expand Down
41 changes: 24 additions & 17 deletions src/video/uikit/SDL_uikitopenglview.m
Expand Up @@ -35,20 +35,21 @@ @implementation SDL_uikitopenglview

@synthesize context;

+ (Class)layerClass {
+ (Class)layerClass
{
return [CAEAGLLayer class];
}

- (id)initWithFrame:(CGRect)frame \
retainBacking:(BOOL)retained \
rBits:(int)rBits \
gBits:(int)gBits \
bBits:(int)bBits \
aBits:(int)aBits \
depthBits:(int)depthBits \
majorVersion:(int)majorVersion \
- (id)initWithFrame:(CGRect)frame
retainBacking:(BOOL)retained
rBits:(int)rBits
gBits:(int)gBits
bBits:(int)bBits
aBits:(int)aBits
depthBits:(int)depthBits
majorVersion:(int)majorVersion
{
NSString *colorFormat=nil;
NSString *colorFormat = nil;
BOOL useDepthBuffer;

if (rBits == 8 && gBits == 8 && bBits == 8) {
Expand Down Expand Up @@ -116,7 +117,7 @@ - (id)initWithFrame:(CGRect)frame \
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
}

if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
return NO;
}
/* end create buffers */
Expand All @@ -131,7 +132,8 @@ - (id)initWithFrame:(CGRect)frame \
return self;
}

- (void)updateFrame {
- (void)updateFrame
{
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, 0);
Expand All @@ -156,22 +158,26 @@ - (void)updateFrame {
self.contentScaleFactor = [UIScreen mainScreen].scale;
}

- (void)setCurrentContext {
- (void)setCurrentContext
{
[EAGLContext setCurrentContext:context];
}


- (void)swapBuffers {
- (void)swapBuffers
{
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}


- (void)layoutSubviews {
- (void)layoutSubviews
{
[EAGLContext setCurrentContext:context];
}

- (void)destroyFramebuffer {
- (void)destroyFramebuffer
{
glDeleteFramebuffersOES(1, &viewFramebuffer);
viewFramebuffer = 0;
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
Expand All @@ -184,7 +190,8 @@ - (void)destroyFramebuffer {
}


- (void)dealloc {
- (void)dealloc
{
[self destroyFramebuffer];
if ([EAGLContext currentContext] == context) {
[EAGLContext setCurrentContext:nil];
Expand Down
2 changes: 1 addition & 1 deletion src/video/uikit/SDL_uikitvideo.m
Expand Up @@ -52,7 +52,7 @@ static int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display,
static int
UIKit_Available(void)
{
return (1);
return 1;
}

static void UIKit_DeleteDevice(SDL_VideoDevice * device)
Expand Down

0 comments on commit f98d6e7

Please sign in to comment.