sgl
changeset 39:e1a27aa24956
fixed broken build
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Wed, 27 Jun 2012 05:54:57 +0300 |
parents | a7b96de14be8 |
children | f7de32814f34 |
files | include/sgl.h src/ios_init.h src/ios_init.m src/wsys_ios.m |
diffstat | 4 files changed, 199 insertions(+), 46 deletions(-) [+] |
line diff
1.1 --- a/include/sgl.h Wed Jun 27 05:16:25 2012 +0300 1.2 +++ b/include/sgl.h Wed Jun 27 05:54:57 2012 +0300 1.3 @@ -15,31 +15,50 @@ 1.4 1.5 /* Create callback is called just after a window and its OpenGL context is created */ 1.6 typedef void (*sgl_create_callback_t)(int window); 1.7 + 1.8 /* Close callback is called before the window and its OpenGL context is destroyed */ 1.9 typedef void (*sgl_close_callback_t)(int window); 1.10 + 1.11 /* The display callback is called whenever the window needs repainting. This is 1.12 * the only place you should perform drawing. 1.13 */ 1.14 typedef void (*sgl_display_callback_t)(void); 1.15 + 1.16 /* Reshape is called whenever the window size changes, and at least once for 1.17 * each newly created window, just after the call to the create callback. */ 1.18 typedef void (*sgl_reshape_callback_t)(int width, int height); 1.19 + 1.20 /* The keyboard callback is called whenever a key is pressed or released */ 1.21 typedef void (*sgl_keyboard_callback_t)(int key, int pressed); 1.22 + 1.23 /* The mouse callback is called whenever a mouse button is pressed or released 1.24 * over the window. The first argument is the touch id for multitouch devices. 1.25 * For regular mouse events it is always 0. */ 1.26 typedef void (*sgl_mouse_callback_t)(int id, int button, int pressed, int x, int y); 1.27 + 1.28 /* The motion callback is called when the user drags the mouse around with any 1.29 * mouse buttons held down. The first argument is the touch id for multitouch 1.30 * devices. */ 1.31 typedef void (*sgl_motion_callback_t)(int id, int x, int y); 1.32 + 1.33 /* Passive gets called whenever the mouse is moved without any button being 1.34 * held. The first argument is the touch id for multitouch devices. 1.35 * 1.36 * Avoid setting this callback unless absolutely necessary, because it will 1.37 * generate a huge volume of events whenever the mouse moves over the window. */ 1.38 typedef void (*sgl_passive_callback_t)(int id, int x, int y); 1.39 + 1.40 +/* The space control callback gets called when we receive input from spatial 1.41 + * controllers such as spaceballs, accelerometers, and gyroscopes 1.42 + */ 1.43 +typedef void (*sgl_space_callback_t)(int x, int y, int z, int rx, int ry, int rz); 1.44 + 1.45 +/* The button callback gets called whenever we have button presses/releases 1.46 + * from special hardware buttons such as the home button on mobile devices, 1.47 + * buttons on spaceballs, etc. 1.48 + */ 1.49 +typedef void (*sgl_button_callback_t)(int bn, int pressed); 1.50 + 1.51 /* Setting the idle callback will change the behaviour of the library. Instead 1.52 * of blocking, to wait for events from the window system, it will poll for 1.53 * events and after processing them will call this idle callback. 1.54 @@ -59,6 +78,8 @@ 1.55 SGL_MOUSE, 1.56 SGL_MOTION, 1.57 SGL_PASSIVE, 1.58 + SGL_SPACE, 1.59 + SGL_BUTTON, 1.60 SGL_IDLE, 1.61 1.62 SGL_NUM_CALLBACKS 1.63 @@ -117,6 +138,8 @@ 1.64 void sgl_mouse_callback(sgl_mouse_callback_t func); 1.65 void sgl_motion_callback(sgl_motion_callback_t func); 1.66 void sgl_passive_callback(sgl_passive_callback_t func); 1.67 +void sgl_space_callback(sgl_space_callback_t func); 1.68 +void sgl_button_callback(sgl_button_callback_t func); 1.69 void sgl_idle_callback(sgl_idle_callback_t func); 1.70 1.71 #endif /* SGL_H_ */
2.1 --- a/src/ios_init.h Wed Jun 27 05:16:25 2012 +0300 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,8 +0,0 @@ 2.4 -#import <Foundation/Foundation.h> 2.5 - 2.6 -@interface sgl : NSObject 2.7 -// XXX no need for init yet... 2.8 -@end 2.9 - 2.10 - 2.11 -void sgl_modules_init(void); 2.12 \ No newline at end of file
3.1 --- a/src/ios_init.m Wed Jun 27 05:16:25 2012 +0300 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,22 +0,0 @@ 3.4 -#import "ios_init.h" 3.5 - 3.6 -@implementation sgl 3.7 - 3.8 -- (id)init 3.9 -{ 3.10 - self = [super init]; 3.11 - if(self) { 3.12 - // Initialization code here. 3.13 - } 3.14 - 3.15 - return self; 3.16 -} 3.17 - 3.18 -@end 3.19 - 3.20 -void sgl_register_uikit(void); 3.21 - 3.22 -void sgl_modules_init(void) 3.23 -{ 3.24 - sgl_register_uikit(); 3.25 -} 3.26 \ No newline at end of file
4.1 --- a/src/wsys_ios.m Wed Jun 27 05:16:25 2012 +0300 4.2 +++ b/src/wsys_ios.m Wed Jun 27 05:54:57 2012 +0300 4.3 @@ -1,3 +1,10 @@ 4.4 +/* SimplyGL window system module for iOS */ 4.5 +/* mac-framework: -framework UIKit */ 4.6 + 4.7 +#include "config.h" 4.8 + 4.9 +#ifdef USE_WSYS_MODULE_IOS 4.10 + 4.11 #include <assert.h> 4.12 #import <UIKit/UIKit.h> 4.13 #import <QuartzCore/QuartzCore.h> 4.14 @@ -34,6 +41,55 @@ 4.15 4.16 4.17 4.18 +static int init(void); 4.19 +static void shutdown(void); 4.20 + 4.21 +/* video mode switching */ 4.22 +static int set_vidmode(int xsz, int ysz); 4.23 +static int get_vidmode(int *xsz, int *ysz); 4.24 + 4.25 +/* create/destroy windows */ 4.26 +static int create_window(int xsz, int ysz, unsigned int flags); 4.27 +static void close_window(int wid); 4.28 + 4.29 +/* window management */ 4.30 +static int set_active(int wid); 4.31 +static int set_title(const char *str); 4.32 +static void redisplay(void); 4.33 +static void swap_buffers(void); 4.34 + 4.35 +static int get_modifiers(void); 4.36 + 4.37 +/* event handling and friends */ 4.38 +static void set_event(int idx, int enable); 4.39 +static int process_events(void); 4.40 + 4.41 + 4.42 +static struct wsys_module ws = { 4.43 + "ios", 0, 4.44 + init, 4.45 + shutdown, 4.46 + set_vidmode, 4.47 + get_vidmode, 4.48 + create_window, 4.49 + close_window, 4.50 + set_active, 4.51 + set_title, 4.52 + redisplay, 4.53 + swap_buffers, 4.54 + get_modifiers, 4.55 + set_event, 4.56 + process_events, 4.57 + 0 4.58 +}; 4.59 + 4.60 + 4.61 +void sgl_register_ios(void) 4.62 +{ 4.63 + sgl_register_module(&ws); 4.64 +} 4.65 + 4.66 + 4.67 @implementation SGLView 4.68 4.69 @synthesize active; 4.70 @@ -44,14 +100,14 @@ 4.71 return [CAEAGLLayer class]; 4.72 } 4.73 4.74 -//The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: 4.75 +/*The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: */ 4.76 -(id)initWithCoder: (NSCoder*)coder 4.77 { 4.78 if((self = [super initWithCoder: coder])) { 4.79 - // Get the layer 4.80 + /* Get the layer */ 4.81 CAEAGLLayer *layer = (CAEAGLLayer*)self.layer; 4.82 4.83 - //self.contentScaleFactor = 2.0; 4.84 + /*self.contentScaleFactor = 2.0; */ 4.85 4.86 layer.opaque = TRUE; 4.87 layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: 4.88 @@ -66,7 +122,7 @@ 4.89 return nil; 4.90 } 4.91 4.92 - // initialize fbos etc... 4.93 + /* initialize fbos etc... */ 4.94 glGenFramebuffers(1, &fbo); 4.95 glBindFramebuffer(GL_FRAMEBUFFER, fbo); 4.96 4.97 @@ -85,17 +141,17 @@ 4.98 disp_link = nil; 4.99 anim_timer = nil; 4.100 4.101 - // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer 4.102 - // class is used as fallback when it isn't available. 4.103 + /* A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer */ 4.104 + /* class is used as fallback when it isn't available. */ 4.105 NSString *req_ver = @"3.1"; 4.106 NSString *cur_ver = [[UIDevice currentDevice] systemVersion]; 4.107 if([cur_ver compare: req_ver options: NSNumericSearch] != NSOrderedAscending) { 4.108 use_disp_link = TRUE; 4.109 } 4.110 4.111 - //self.multipleTouchEnabled = 1; 4.112 + /*self.multipleTouchEnabled = 1; */ 4.113 4.114 - // TODO call user init ? 4.115 + /* TODO call user init ? */ 4.116 } 4.117 4.118 return self; 4.119 @@ -103,14 +159,14 @@ 4.120 4.121 -(void)drawView: (id)sender 4.122 { 4.123 - // TODO call display 4.124 + /* TODO call display */ 4.125 } 4.126 4.127 -(void)layoutSubviews 4.128 { 4.129 - // TODO call reshape 4.130 - // XXX originally call to renderer resizeFromLayer 4.131 - // XXX originally call to [self drawView: nil] 4.132 + /* TODO call reshape */ 4.133 + /* XXX originally call to renderer resizeFromLayer */ 4.134 + /* XXX originally call to [self drawView: nil] */ 4.135 } 4.136 4.137 -(void)setAnimationFrameInterval: (NSInteger)interval 4.138 @@ -139,9 +195,10 @@ 4.139 { 4.140 if(!active) { 4.141 if(use_disp_link) { 4.142 - // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed 4.143 - // if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will 4.144 - // not be called in system versions earlier than 3.1. 4.145 + /* CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed 4.146 + * if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will 4.147 + * not be called in system versions earlier than 3.1. 4.148 + */ 4.149 4.150 disp_link = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget: self 4.151 selector: @selector(drawView:)]; 4.152 @@ -174,7 +231,7 @@ 4.153 4.154 -(void)dealloc 4.155 { 4.156 - // XXX originally [renderer release]; 4.157 + /* XXX originally [renderer release]; */ 4.158 [super dealloc]; 4.159 } 4.160 @end 4.161 @@ -212,3 +269,106 @@ 4.162 [super dealloc]; 4.163 } 4.164 @end 4.165 + 4.166 + 4.167 + 4.168 +static int init(void) 4.169 +{ 4.170 + return -1; 4.171 +} 4.172 + 4.173 +static void shutdown(void) 4.174 +{ 4.175 +} 4.176 + 4.177 +/* video mode switching */ 4.178 +static int set_vidmode(int xsz, int ysz) 4.179 +{ 4.180 + return -1; 4.181 +} 4.182 + 4.183 +static int get_vidmode(int *xsz, int *ysz) 4.184 +{ 4.185 + return -1; 4.186 +} 4.187 + 4.188 +/* create/destroy windows */ 4.189 +static int create_window(int xsz, int ysz, unsigned int flags) 4.190 +{ 4.191 + return -1; 4.192 +} 4.193 + 4.194 +static void close_window(int wid) 4.195 +{ 4.196 +} 4.197 + 4.198 +/* window management */ 4.199 +static int set_active(int wid) 4.200 +{ 4.201 + return -1; 4.202 +} 4.203 + 4.204 +static int set_title(const char *str) 4.205 +{ 4.206 + return -1; 4.207 +} 4.208 + 4.209 +static void redisplay(void) 4.210 +{ 4.211 +} 4.212 + 4.213 +static void swap_buffers(void) 4.214 +{ 4.215 +} 4.216 + 4.217 +static int get_modifiers(void) 4.218 +{ 4.219 + return 0; 4.220 +} 4.221 + 4.222 +/* event handling and friends */ 4.223 +static void set_event(int idx, int enable) 4.224 +{ 4.225 +} 4.226 + 4.227 +static int process_events(void) 4.228 +{ 4.229 + return -1; 4.230 +} 4.231 + 4.232 + 4.233 + 4.234 + 4.235 + 4.236 +/* only compile the following if we're building in xcode and we 4.237 + * don't have generated modules.c file 4.238 + */ 4.239 +#ifdef XCODE_BUILD 4.240 +@interface sgl : NSObject 4.241 +/* XXX no need for init yet... */ 4.242 +@end 4.243 + 4.244 +@implementation sgl 4.245 + 4.246 +- (id)init 4.247 +{ 4.248 + self = [super init]; 4.249 + if(self) { 4.250 + /* XXX Initialization code here. */ 4.251 + } 4.252 + return self; 4.253 +} 4.254 + 4.255 +@end 4.256 + 4.257 +void sgl_modules_init(void) 4.258 +{ 4.259 + sgl_register_uikit(); 4.260 +} 4.261 + 4.262 +#endif /* XCODE_BUILD */ 4.263 + 4.264 + 4.265 +#else 4.266 +int sgl_wsys_ios_silence_the_fucking_empty_file_warnings; 4.267 +#endif /* USE_WSYS_MODULE_IOS */