# HG changeset patch # User John Tsiombikas # Date 1340765697 -10800 # Node ID e1a27aa2495636a6458f85b4eca454f2157852b4 # Parent a7b96de14be845a32fba1351f88bab49199d5c8d fixed broken build diff -r a7b96de14be8 -r e1a27aa24956 include/sgl.h --- a/include/sgl.h Wed Jun 27 05:16:25 2012 +0300 +++ b/include/sgl.h Wed Jun 27 05:54:57 2012 +0300 @@ -15,31 +15,50 @@ /* Create callback is called just after a window and its OpenGL context is created */ typedef void (*sgl_create_callback_t)(int window); + /* Close callback is called before the window and its OpenGL context is destroyed */ typedef void (*sgl_close_callback_t)(int window); + /* The display callback is called whenever the window needs repainting. This is * the only place you should perform drawing. */ typedef void (*sgl_display_callback_t)(void); + /* Reshape is called whenever the window size changes, and at least once for * each newly created window, just after the call to the create callback. */ typedef void (*sgl_reshape_callback_t)(int width, int height); + /* The keyboard callback is called whenever a key is pressed or released */ typedef void (*sgl_keyboard_callback_t)(int key, int pressed); + /* The mouse callback is called whenever a mouse button is pressed or released * over the window. The first argument is the touch id for multitouch devices. * For regular mouse events it is always 0. */ typedef void (*sgl_mouse_callback_t)(int id, int button, int pressed, int x, int y); + /* The motion callback is called when the user drags the mouse around with any * mouse buttons held down. The first argument is the touch id for multitouch * devices. */ typedef void (*sgl_motion_callback_t)(int id, int x, int y); + /* Passive gets called whenever the mouse is moved without any button being * held. The first argument is the touch id for multitouch devices. * * Avoid setting this callback unless absolutely necessary, because it will * generate a huge volume of events whenever the mouse moves over the window. */ typedef void (*sgl_passive_callback_t)(int id, int x, int y); + +/* The space control callback gets called when we receive input from spatial + * controllers such as spaceballs, accelerometers, and gyroscopes + */ +typedef void (*sgl_space_callback_t)(int x, int y, int z, int rx, int ry, int rz); + +/* The button callback gets called whenever we have button presses/releases + * from special hardware buttons such as the home button on mobile devices, + * buttons on spaceballs, etc. + */ +typedef void (*sgl_button_callback_t)(int bn, int pressed); + /* Setting the idle callback will change the behaviour of the library. Instead * of blocking, to wait for events from the window system, it will poll for * events and after processing them will call this idle callback. @@ -59,6 +78,8 @@ SGL_MOUSE, SGL_MOTION, SGL_PASSIVE, + SGL_SPACE, + SGL_BUTTON, SGL_IDLE, SGL_NUM_CALLBACKS @@ -117,6 +138,8 @@ void sgl_mouse_callback(sgl_mouse_callback_t func); void sgl_motion_callback(sgl_motion_callback_t func); void sgl_passive_callback(sgl_passive_callback_t func); +void sgl_space_callback(sgl_space_callback_t func); +void sgl_button_callback(sgl_button_callback_t func); void sgl_idle_callback(sgl_idle_callback_t func); #endif /* SGL_H_ */ diff -r a7b96de14be8 -r e1a27aa24956 src/ios_init.h --- a/src/ios_init.h Wed Jun 27 05:16:25 2012 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#import - -@interface sgl : NSObject -// XXX no need for init yet... -@end - - -void sgl_modules_init(void); \ No newline at end of file diff -r a7b96de14be8 -r e1a27aa24956 src/ios_init.m --- a/src/ios_init.m Wed Jun 27 05:16:25 2012 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -#import "ios_init.h" - -@implementation sgl - -- (id)init -{ - self = [super init]; - if(self) { - // Initialization code here. - } - - return self; -} - -@end - -void sgl_register_uikit(void); - -void sgl_modules_init(void) -{ - sgl_register_uikit(); -} \ No newline at end of file diff -r a7b96de14be8 -r e1a27aa24956 src/wsys_ios.m --- a/src/wsys_ios.m Wed Jun 27 05:16:25 2012 +0300 +++ b/src/wsys_ios.m Wed Jun 27 05:54:57 2012 +0300 @@ -1,3 +1,10 @@ +/* SimplyGL window system module for iOS */ +/* mac-framework: -framework UIKit */ + +#include "config.h" + +#ifdef USE_WSYS_MODULE_IOS + #include #import #import @@ -34,6 +41,55 @@ +static int init(void); +static void shutdown(void); + +/* video mode switching */ +static int set_vidmode(int xsz, int ysz); +static int get_vidmode(int *xsz, int *ysz); + +/* create/destroy windows */ +static int create_window(int xsz, int ysz, unsigned int flags); +static void close_window(int wid); + +/* window management */ +static int set_active(int wid); +static int set_title(const char *str); +static void redisplay(void); +static void swap_buffers(void); + +static int get_modifiers(void); + +/* event handling and friends */ +static void set_event(int idx, int enable); +static int process_events(void); + + +static struct wsys_module ws = { + "ios", 0, + init, + shutdown, + set_vidmode, + get_vidmode, + create_window, + close_window, + set_active, + set_title, + redisplay, + swap_buffers, + get_modifiers, + set_event, + process_events, + 0 +}; + + +void sgl_register_ios(void) +{ + sgl_register_module(&ws); +} + + @implementation SGLView @synthesize active; @@ -44,14 +100,14 @@ return [CAEAGLLayer class]; } -//The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: +/*The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: */ -(id)initWithCoder: (NSCoder*)coder { if((self = [super initWithCoder: coder])) { - // Get the layer + /* Get the layer */ CAEAGLLayer *layer = (CAEAGLLayer*)self.layer; - //self.contentScaleFactor = 2.0; + /*self.contentScaleFactor = 2.0; */ layer.opaque = TRUE; layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: @@ -66,7 +122,7 @@ return nil; } - // initialize fbos etc... + /* initialize fbos etc... */ glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); @@ -85,17 +141,17 @@ disp_link = nil; anim_timer = nil; - // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer - // class is used as fallback when it isn't available. + /* A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer */ + /* class is used as fallback when it isn't available. */ NSString *req_ver = @"3.1"; NSString *cur_ver = [[UIDevice currentDevice] systemVersion]; if([cur_ver compare: req_ver options: NSNumericSearch] != NSOrderedAscending) { use_disp_link = TRUE; } - //self.multipleTouchEnabled = 1; + /*self.multipleTouchEnabled = 1; */ - // TODO call user init ? + /* TODO call user init ? */ } return self; @@ -103,14 +159,14 @@ -(void)drawView: (id)sender { - // TODO call display + /* TODO call display */ } -(void)layoutSubviews { - // TODO call reshape - // XXX originally call to renderer resizeFromLayer - // XXX originally call to [self drawView: nil] + /* TODO call reshape */ + /* XXX originally call to renderer resizeFromLayer */ + /* XXX originally call to [self drawView: nil] */ } -(void)setAnimationFrameInterval: (NSInteger)interval @@ -139,9 +195,10 @@ { if(!active) { if(use_disp_link) { - // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed - // if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will - // not be called in system versions earlier than 3.1. + /* CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed + * if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will + * not be called in system versions earlier than 3.1. + */ disp_link = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget: self selector: @selector(drawView:)]; @@ -174,7 +231,7 @@ -(void)dealloc { - // XXX originally [renderer release]; + /* XXX originally [renderer release]; */ [super dealloc]; } @end @@ -212,3 +269,106 @@ [super dealloc]; } @end + + + +static int init(void) +{ + return -1; +} + +static void shutdown(void) +{ +} + +/* video mode switching */ +static int set_vidmode(int xsz, int ysz) +{ + return -1; +} + +static int get_vidmode(int *xsz, int *ysz) +{ + return -1; +} + +/* create/destroy windows */ +static int create_window(int xsz, int ysz, unsigned int flags) +{ + return -1; +} + +static void close_window(int wid) +{ +} + +/* window management */ +static int set_active(int wid) +{ + return -1; +} + +static int set_title(const char *str) +{ + return -1; +} + +static void redisplay(void) +{ +} + +static void swap_buffers(void) +{ +} + +static int get_modifiers(void) +{ + return 0; +} + +/* event handling and friends */ +static void set_event(int idx, int enable) +{ +} + +static int process_events(void) +{ + return -1; +} + + + + + +/* only compile the following if we're building in xcode and we + * don't have generated modules.c file + */ +#ifdef XCODE_BUILD +@interface sgl : NSObject +/* XXX no need for init yet... */ +@end + +@implementation sgl + +- (id)init +{ + self = [super init]; + if(self) { + /* XXX Initialization code here. */ + } + return self; +} + +@end + +void sgl_modules_init(void) +{ + sgl_register_uikit(); +} + +#endif /* XCODE_BUILD */ + + +#else +int sgl_wsys_ios_silence_the_fucking_empty_file_warnings; +#endif /* USE_WSYS_MODULE_IOS */