├── .gitignore ├── Info.plist ├── Makefile ├── app ├── EAGLView.h ├── EAGLView.m ├── main.m ├── tosserAppDelegate.h ├── tosserAppDelegate.m └── window.xib ├── bin └── compile-mesh.scm ├── lib ├── apps │ ├── app1.scm │ ├── app2.scm │ ├── app3.scm │ ├── app4.scm │ ├── app5.scm │ └── app6.scm ├── config.scm ├── events#.scm ├── events.scm ├── ffi │ ├── al#.scm │ ├── al.m │ ├── al.scm │ ├── arrays#.scm │ ├── arrays.scm │ ├── ffi#.scm │ ├── ffi.scm │ ├── freeimage.scm │ ├── gl-util.scm │ ├── gl.scm │ ├── image.scm │ ├── iphone#.scm │ ├── iphone.scm │ ├── osx#.scm │ ├── osx.scm │ └── types.scm ├── init.scm ├── intersection.scm ├── obj-loader.scm ├── obj-loader2.scm ├── physics.scm ├── resource.scm ├── scene.scm ├── test.scm ├── texture.scm ├── util-3d.scm ├── util │ ├── remote-debugger │ │ ├── README │ │ ├── debuggee.scm │ │ ├── debugger.scm │ │ ├── grime │ │ ├── grime-client │ │ ├── grime.el │ │ ├── pump.scm │ │ └── rdi.scm │ ├── sort.scm │ ├── srfi-1.scm │ ├── srfi-13.scm │ ├── srfi-14.scm │ ├── srfi-2.scm │ └── tests.scm └── vectors.scm ├── resources ├── .DS_Store ├── box.obj ├── collision.obj ├── collision.obj.gso ├── gradient.png ├── ico.obj ├── ico.obj.gso ├── jlongster.obj ├── jlongster.obj.gso ├── logo.3ds ├── logo.blend ├── logo.blend1 ├── logo.obj ├── logo.obj.gso ├── logo.raw ├── mass.blend ├── mass.mtl ├── mass.obj ├── mass.obj.gso ├── medium.obj ├── sphere.obj └── sphere.obj.gso ├── test.c ├── test.scm ├── tosser.xcodeproj ├── james.mode1v3 ├── james.pbxuser └── project.pbxproj └── tosser_Prefix.pch /.gitignore: -------------------------------------------------------------------------------- 1 | .#* 2 | *.o1 3 | gl*.c 4 | init*.c 5 | build 6 | tosser.app 7 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSEnvironment 6 | 7 | GAMBCOPT 8 | dQ- 9 | 10 | CFBundleDevelopmentRegion 11 | en 12 | CFBundleDisplayName 13 | tosser 14 | CFBundleExecutable 15 | tosser 16 | CFBundleIconFile 17 | 18 | CFBundleIdentifier 19 | com.fluidapps.tosser2 20 | CFBundleInfoDictionaryVersion 21 | 6.0 22 | CFBundleName 23 | tosser 24 | CFBundlePackageType 25 | APPL 26 | CFBundleSignature 27 | ???? 28 | CFBundleVersion 29 | 1.0 30 | LSRequiresIPhoneOS 31 | 32 | NSMainNibFile 33 | window 34 | 35 | 36 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | #### Settings 3 | 4 | ### It's ok to always use "gsc" from the iPhoneSimulator build since, 5 | ### at this point in time, we are never using it to generate compiled 6 | ### code for the iPhone OS. We use it when targeting the iPhone OS 7 | ### only to generate C code. (Obviously, we can't run "gsc" from the 8 | ### iPhoneOS build since it's build for ARM.) 9 | 10 | gsc=/usr/local/Gambit-C/iPhoneSimulator-3.1.2/bin/gsc 11 | 12 | #### Main 13 | 14 | all: lib/init_.c config 15 | 16 | lib/init_.c: lib/init.scm lib/ffi/gl.scm lib/util/srfi-1.scm lib/apps/* 17 | cd lib && $(gsc) -link init.scm 18 | 19 | config: 20 | echo '(define root "$(CURDIR)")' > lib/config.scm 21 | 22 | 23 | #### UNUSED 24 | ### The following sections are UNUSED unless you want to play around 25 | ### with more advanced ways of compilation and deployment. 26 | 27 | #### Loadable modules 28 | ### These are here if you change the "include" statements in 29 | ### lib/init.scm to "load" statements 30 | 31 | lib/ffi/gl.o1: lib/ffi/gl.scm 32 | rm -rf lib/ffi/gl.o1 33 | cd lib/ffi && $(gsc) -debug gl.scm 34 | 35 | lib/util/srfi-1.o1: lib/util/srfi-1.scm 36 | rm -rf lib/util/srfi-1.o1 37 | cd lib/util && $(gsc) -debug srfi-1.scm 38 | 39 | lib/graphics.o1: lib/graphics.scm 40 | rm -rf lib/graphics.o1 41 | cd lib && $(gsc) graphics.scm 42 | 43 | #### Making tosser.app 44 | ### These are here for manual compilation and deployment of the app 45 | 46 | app_name=tosser.app 47 | exe_name=tosser 48 | uuid=6105AA5B-02C7-4250-9D68-4789C9EE0ECF 49 | deploy_path=~/Library/'Application Support/iPhone Simulator'/User/Applications/$(uuid) 50 | 51 | gcc=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 52 | sdk=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk 53 | # gcc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 54 | # sdk=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk 55 | 56 | tosser.app: Info.plist app/main.m app/EAGLView.m lib/init_.c config 57 | mkdir -p $(app_name) 58 | cp Info.plist $(app_name) 59 | ibtool --errors --warnings --notices \ 60 | --output-format human-readable-text \ 61 | --compile $(app_name)/window.nib \ 62 | app/window.xib 63 | 64 | $(gcc) -x objective-c -arch i386 -isysroot $(sdk) \ 65 | -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000 \ 66 | -mmacosx-version-min=10.5 \ 67 | -framework Foundation -framework UIKit \ 68 | -framework OpenGLES -framework QuartzCore \ 69 | -framework CoreGraphics \ 70 | -framework OpenAL -framework AudioToolbox \ 71 | -fvisibility=hidden -I/usr/local/include -D___LIBRARY -lgambc \ 72 | -I/usr/local/Gambit-C/iPhoneSimulator3.1/include \ 73 | -L/usr/local/Gambit-C/iPhoneSimulator3.1/lib \ 74 | app/EAGLView.m app/tosserAppDelegate.m app/main.m \ 75 | lib/init*.c \ 76 | -o $(app_name)/$(exe_name) 77 | 78 | cp -r resources/* $(app_name) 79 | 80 | deploy: tosser.app 81 | rm -fr $(deploy_path)/$(app_name) 82 | cp -r $(app_name) $(deploy_path) 83 | -------------------------------------------------------------------------------- /app/EAGLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // EAGLView.h 3 | // gambit-iphone 4 | // 5 | // Created by James on 4/22/09. 6 | // Copyright Coptix, Inc 2009. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | /* 16 | This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. 17 | The view content is basically an EAGL surface you render your OpenGL scene into. 18 | Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. 19 | */ 20 | @interface EAGLView : UIView { 21 | 22 | @private 23 | /* The pixel dimensions of the backbuffer */ 24 | GLint backingWidth; 25 | GLint backingHeight; 26 | 27 | EAGLContext *context; 28 | 29 | /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ 30 | GLuint viewRenderbuffer, viewFramebuffer; 31 | 32 | /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ 33 | GLuint depthRenderbuffer; 34 | 35 | NSTimer *animationTimer; 36 | NSTimeInterval animationInterval; 37 | 38 | IBOutlet UILabel *label; 39 | } 40 | 41 | @property NSTimeInterval animationInterval; 42 | @property (nonatomic, retain) UILabel *label; 43 | 44 | - (void)startAnimation; 45 | - (void)stopAnimation; 46 | - (void)drawView; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /app/EAGLView.m: -------------------------------------------------------------------------------- 1 | // 2 | // EAGLView.m 3 | // gambit-iphone 4 | // 5 | // Created by James on 4/22/09. 6 | // Copyright Coptix, Inc 2009. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #import "EAGLView.h" 13 | 14 | #define USE_DEPTH_BUFFER 1 15 | 16 | #if __cplusplus 17 | extern "C" { 18 | #endif 19 | void register_view(UIView*); 20 | void init(); 21 | void render(); 22 | char* get_title(); 23 | void did_accelerate(UIAccelerometer*, UIAcceleration*); 24 | void touches_began(NSSet*, UIEvent*); 25 | void touches_moved(NSSet*, UIEvent*); 26 | void touches_ended(NSSet*, UIEvent*); 27 | void touches_cancelled(NSSet*, UIEvent*); 28 | #if __cplusplus 29 | } 30 | #endif 31 | 32 | 33 | // A class extension to declare private methods 34 | @interface EAGLView () 35 | 36 | @property (nonatomic, retain) EAGLContext *context; 37 | @property (nonatomic, assign) NSTimer *animationTimer; 38 | 39 | - (BOOL) createFramebuffer; 40 | - (void) destroyFramebuffer; 41 | - (void) initAccelerometer; 42 | 43 | @end 44 | 45 | 46 | @implementation EAGLView 47 | 48 | @synthesize context; 49 | @synthesize animationTimer; 50 | @synthesize animationInterval; 51 | @synthesize label; 52 | 53 | 54 | // You must implement this 55 | + (Class)layerClass { 56 | return [CAEAGLLayer class]; 57 | } 58 | 59 | //The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: 60 | - (id)initWithCoder:(NSCoder*)coder { 61 | if ((self = [super initWithCoder:coder])) { 62 | // Get the layer 63 | CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; 64 | 65 | eaglLayer.opaque = YES; 66 | eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: 67 | [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; 68 | 69 | context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; 70 | 71 | if (!context || ![EAGLContext setCurrentContext:context]) { 72 | [self release]; 73 | return nil; 74 | } 75 | 76 | animationInterval = 1.0 / 60.0; 77 | 78 | register_view(self); 79 | init(); 80 | [self initAccelerometer]; 81 | } 82 | return self; 83 | } 84 | 85 | //// Accelerometer 86 | 87 | - (void)initAccelerometer { 88 | UIAccelerometer* theAccelerometer = [UIAccelerometer sharedAccelerometer]; 89 | theAccelerometer.updateInterval = 1/50.0; 90 | theAccelerometer.delegate = self; 91 | } 92 | 93 | - (void)accelerometer:(UIAccelerometer *)accelerometer 94 | didAccelerate:(UIAcceleration *)acceleration { 95 | did_accelerate(accelerometer, acceleration); 96 | } 97 | 98 | 99 | //// Touches 100 | 101 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 102 | touches_began(touches, event); 103 | } 104 | 105 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 106 | touches_moved(touches, event); 107 | } 108 | 109 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 110 | touches_ended(touches, event); 111 | } 112 | 113 | - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { 114 | touches_cancelled(touches, event); 115 | } 116 | 117 | //// Rendering 118 | 119 | - (void)drawView { 120 | NSString *labelText = [[NSString alloc] initWithCString:(char*)get_title() 121 | encoding: NSASCIIStringEncoding]; 122 | [self.label setText:labelText]; 123 | 124 | [EAGLContext setCurrentContext:context]; 125 | 126 | glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); 127 | glViewport(0, 0, backingWidth, backingHeight); 128 | 129 | render(); 130 | 131 | glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); 132 | [context presentRenderbuffer:GL_RENDERBUFFER_OES]; 133 | } 134 | 135 | - (void)layoutSubviews { 136 | [EAGLContext setCurrentContext:context]; 137 | [self destroyFramebuffer]; 138 | [self createFramebuffer]; 139 | [self drawView]; 140 | } 141 | 142 | - (BOOL)createFramebuffer { 143 | glGenFramebuffersOES(1, &viewFramebuffer); 144 | glGenRenderbuffersOES(1, &viewRenderbuffer); 145 | 146 | glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); 147 | glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); 148 | [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; 149 | glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); 150 | 151 | glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); 152 | glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); 153 | 154 | if(USE_DEPTH_BUFFER) { 155 | glGenRenderbuffersOES(1, &depthRenderbuffer); 156 | glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); 157 | glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); 158 | glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); 159 | } 160 | 161 | glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); 162 | 163 | if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { 164 | NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); 165 | return NO; 166 | } 167 | 168 | return YES; 169 | } 170 | 171 | 172 | - (void)destroyFramebuffer { 173 | 174 | glDeleteFramebuffersOES(1, &viewFramebuffer); 175 | viewFramebuffer = 0; 176 | glDeleteRenderbuffersOES(1, &viewRenderbuffer); 177 | viewRenderbuffer = 0; 178 | 179 | if(depthRenderbuffer) { 180 | glDeleteRenderbuffersOES(1, &depthRenderbuffer); 181 | depthRenderbuffer = 0; 182 | } 183 | } 184 | 185 | 186 | - (void)startAnimation { 187 | self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; 188 | } 189 | 190 | 191 | - (void)stopAnimation { 192 | self.animationTimer = nil; 193 | } 194 | 195 | 196 | - (void)setAnimationTimer:(NSTimer *)newTimer { 197 | [animationTimer invalidate]; 198 | animationTimer = newTimer; 199 | } 200 | 201 | 202 | - (void)setAnimationInterval:(NSTimeInterval)interval { 203 | 204 | animationInterval = interval; 205 | if (animationTimer) { 206 | [self stopAnimation]; 207 | [self startAnimation]; 208 | } 209 | } 210 | 211 | 212 | - (void)dealloc { 213 | 214 | [self stopAnimation]; 215 | 216 | if ([EAGLContext currentContext] == context) { 217 | [EAGLContext setCurrentContext:nil]; 218 | } 219 | 220 | [context release]; 221 | [super dealloc]; 222 | } 223 | 224 | @end 225 | -------------------------------------------------------------------------------- /app/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // gambit-iphone 4 | // 5 | // Created by James on 4/22/09. 6 | // Copyright Coptix, Inc 2009. All rights reserved. 7 | // 8 | 9 | #define ___VERSION 405002 10 | 11 | #import 12 | #include "gambit.h" 13 | #include "stdlib.h" 14 | 15 | #define LINKER ____20_init__ 16 | 17 | ___BEGIN_C_LINKAGE 18 | extern ___mod_or_lnk LINKER (___global_state_struct*); 19 | ___END_C_LINKAGE 20 | 21 | ___setup_params_struct setup_params; 22 | 23 | int main(int argc, char *argv[]) { 24 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 25 | 26 | // Taken from gambit, lib/main.c. 27 | int debug_settings = ___DEBUG_SETTINGS_INITIAL; 28 | 29 | // -:d- (force repl io to be stdin/stdout since terminal isn't 30 | // -attached) 31 | debug_settings = 32 | (debug_settings 33 | & ~___DEBUG_SETTINGS_REPL_MASK) 34 | | (___DEBUG_SETTINGS_REPL_STDIO 35 | << ___DEBUG_SETTINGS_REPL_SHIFT); 36 | // -:da 37 | debug_settings = 38 | (debug_settings 39 | & ~___DEBUG_SETTINGS_UNCAUGHT_MASK) 40 | | (___DEBUG_SETTINGS_UNCAUGHT_ALL 41 | << ___DEBUG_SETTINGS_UNCAUGHT_SHIFT); 42 | // -:dr 43 | debug_settings = 44 | (debug_settings 45 | & ~___DEBUG_SETTINGS_ERROR_MASK) 46 | | (___DEBUG_SETTINGS_ERROR_REPL 47 | << ___DEBUG_SETTINGS_ERROR_SHIFT); 48 | // -:d2 49 | // debug_settings = 50 | // (debug_settings & ~___DEBUG_SETTINGS_LEVEL_MASK) 51 | // | (2 << ___DEBUG_SETTINGS_LEVEL_SHIFT); 52 | 53 | ___setup_params_reset (&setup_params); 54 | setup_params.version = ___VERSION; 55 | setup_params.linker = LINKER; 56 | setup_params.debug_settings = debug_settings; 57 | 58 | ___setup(&setup_params); 59 | 60 | int retVal = UIApplicationMain(argc, argv, nil, nil); 61 | 62 | ___cleanup(); 63 | [pool release]; 64 | return retVal; 65 | } 66 | -------------------------------------------------------------------------------- /app/tosserAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // tosserAppDelegate.h 3 | // tosser 4 | // 5 | // Created by James on 6/2/09. 6 | // Copyright Coptix, Inc 2009. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class EAGLView; 12 | 13 | @interface tosserAppDelegate : NSObject { 14 | IBOutlet UIWindow *window; 15 | IBOutlet EAGLView *glView; 16 | } 17 | 18 | @property (nonatomic, retain) UIWindow *window; 19 | @property (nonatomic, retain) EAGLView *glView; 20 | 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /app/tosserAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // tosserAppDelegate.m 3 | // tosser 4 | // 5 | // Created by James on 6/2/09. 6 | // Copyright Coptix, Inc 2009. All rights reserved. 7 | // 8 | 9 | #import "tosserAppDelegate.h" 10 | #import "EAGLView.h" 11 | 12 | @implementation tosserAppDelegate 13 | 14 | @synthesize window; 15 | @synthesize glView; 16 | 17 | - (void)applicationDidFinishLaunching:(UIApplication *)application { 18 | 19 | glView.animationInterval = 1.0 / 60.0; 20 | [glView startAnimation]; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | glView.animationInterval = 1.0 / 5.0; 26 | } 27 | 28 | 29 | - (void)applicationDidBecomeActive:(UIApplication *)application { 30 | glView.animationInterval = 1.0 / 60.0; 31 | } 32 | 33 | - (void)dealloc { 34 | [window release]; 35 | [glView release]; 36 | [super dealloc]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /app/window.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 512 5 | 10B504 6 | 732 7 | 1038.2 8 | 437.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 62 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | 35 | 36 | IBFirstResponder 37 | 38 | 39 | 40 | 41 | 1316 42 | 43 | YES 44 | 45 | 46 | 1298 47 | 48 | YES 49 | 50 | 51 | 1316 52 | {{20, 412}, {280, 68}} 53 | 54 | NO 55 | YES 56 | NO 57 | Label 58 | 59 | 1 60 | MSAxIDEAA 61 | 62 | 63 | 1 64 | 10 65 | 5 66 | 1 67 | 68 | 69 | {320, 480} 70 | 71 | 72 | 3 73 | MQA 74 | 75 | 2 76 | 77 | 78 | NO 79 | YES 80 | 81 | 82 | 83 | {320, 480} 84 | 85 | 86 | NO 87 | YES 88 | 89 | 90 | 91 | 92 | YES 93 | 94 | 95 | delegate 96 | 97 | 98 | 99 | 4 100 | 101 | 102 | 103 | window 104 | 105 | 106 | 107 | 5 108 | 109 | 110 | 111 | glView 112 | 113 | 114 | 115 | 9 116 | 117 | 118 | 119 | label 120 | 121 | 122 | 123 | 12 124 | 125 | 126 | 127 | 128 | YES 129 | 130 | 0 131 | 132 | 133 | 134 | 135 | 136 | 2 137 | 138 | 139 | YES 140 | 141 | 142 | 143 | 144 | 145 | -1 146 | 147 | 148 | File's Owner 149 | 150 | 151 | 3 152 | 153 | 154 | 155 | 156 | 8 157 | 158 | 159 | YES 160 | 161 | 162 | 163 | 164 | 165 | -2 166 | 167 | 168 | 169 | 170 | 10 171 | 172 | 173 | 174 | 175 | 176 | 177 | YES 178 | 179 | YES 180 | -1.CustomClassName 181 | -2.CustomClassName 182 | 10.IBPluginDependency 183 | 2.IBAttributePlaceholdersKey 184 | 2.IBEditorWindowLastContentRect 185 | 2.IBPluginDependency 186 | 3.CustomClassName 187 | 3.IBPluginDependency 188 | 8.CustomClassName 189 | 8.IBPluginDependency 190 | 191 | 192 | YES 193 | UIApplication 194 | UIResponder 195 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 196 | 197 | YES 198 | 199 | 200 | YES 201 | 202 | 203 | {{471, 319}, {320, 480}} 204 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 205 | tosserAppDelegate 206 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 207 | EAGLView 208 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 209 | 210 | 211 | 212 | YES 213 | 214 | 215 | YES 216 | 217 | 218 | 219 | 220 | YES 221 | 222 | 223 | YES 224 | 225 | 226 | 227 | 12 228 | 229 | 230 | 231 | YES 232 | 233 | EAGLView 234 | UIView 235 | 236 | label 237 | UILabel 238 | 239 | 240 | IBProjectSource 241 | app/EAGLView.h 242 | 243 | 244 | 245 | tosserAppDelegate 246 | NSObject 247 | 248 | YES 249 | 250 | YES 251 | glView 252 | window 253 | 254 | 255 | YES 256 | EAGLView 257 | UIWindow 258 | 259 | 260 | 261 | IBProjectSource 262 | app/tosserAppDelegate.h 263 | 264 | 265 | 266 | 267 | 0 268 | 269 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 270 | 271 | 272 | 273 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 274 | 275 | 276 | YES 277 | ../tosser.xcodeproj 278 | 3 279 | 3.1 280 | 281 | 282 | -------------------------------------------------------------------------------- /bin/compile-mesh.scm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gsi-script 2 | 3 | (include "../lib/util/srfi-1.scm") 4 | (include "../lib/vectors.scm") 5 | (include "../lib/obj-loader2.scm") 6 | 7 | (define (main filename) 8 | (compress (string-append filename ".obj.gso") (obj-load filename #f #t))) 9 | -------------------------------------------------------------------------------- /lib/apps/app1.scm: -------------------------------------------------------------------------------- 1 | ;;;; "app1" 2 | ;;; shows some dancing 2d boxes 3 | 4 | ;;;; config 5 | 6 | (define vertices 7 | (vector->GLfloat* (vector -.05 -.05 8 | .05 -.05 9 | -.05 .05 10 | .05 .05))) 11 | 12 | ;; You can use this to play around with per-vertex colors, 13 | ;; works fine if you uncomment the code in SELECT-BOX 14 | ;; (define colors 15 | ;; (vector->GLubyte* (vector 255 255 0 255 16 | ;; 0 255 255 255 17 | ;; 0 0 0 0 18 | ;; 255 0 255 255))) 19 | 20 | (define num-boxes 100) 21 | (define zoom-level 5) 22 | (define rotate-speed 2) 23 | 24 | ;;;; rendering 25 | 26 | (define (select-box) 27 | (glVertexPointer 2 GL_FLOAT 0 vertices) 28 | (glEnableClientState GL_VERTEX_ARRAY) 29 | 30 | ;; The folowing works too, but you have to uncomment the statement 31 | ;; which defines `colors' at the top of this file 32 | ;; (glColorPointer 4 GL_UNSIGNED_BYTE 0 colors) 33 | ;; (glEnableClientState GL_COLOR_ARRAY) 34 | ) 35 | 36 | (define (draw-box n) 37 | (define (ratio n #!optional mult) 38 | (let ((r (/ n num-boxes))) 39 | (exact->inexact (if mult (* r mult) r)))) 40 | 41 | (define (screen-space f) 42 | (+ (/ f 2.) .75)) 43 | 44 | (glLoadIdentity) 45 | (glColor4f .2 (ratio n) .5 1.) 46 | (glTranslatef (ratio n) 47 | (screen-space 48 | (sin (+ (real-time) 49 | (/ n zoom-level)))) 50 | .0) 51 | (glRotatef (* (real-time) 52 | (* rotate-speed 100.)) 53 | 0. 0. 1.) 54 | (glDrawArrays GL_TRIANGLE_STRIP 0 4)) 55 | 56 | (define (init) 57 | ;; glMatrixMode(GL_PROJECTION); 58 | ;; glLoadIdentity(); 59 | ;; glOrthof(0.0f, 1.0f, 1.5f, 0.0f, -1.0f, 1.0f); 60 | ;; glMatrixMode(GL_MODELVIEW); 61 | (void)) 62 | 63 | (define (render) 64 | (select-box) 65 | (unfold (lambda (i) (>= i num-boxes)) 66 | (lambda (i) (draw-box i)) 67 | (lambda (i) (+ i 1)) 68 | 0)) 69 | 70 | (define (get-title) 71 | "Hello, World. - Gambit Scheme") 72 | -------------------------------------------------------------------------------- /lib/apps/app2.scm: -------------------------------------------------------------------------------- 1 | 2 | ;;;; settings 3 | 4 | (define AGE_OF_DEATH 1.) ; in seconds 5 | 6 | ;;;; events 7 | 8 | (define-event-handler (touches-began touches event) 9 | (for-each (lambda (touch) 10 | (let ((loc (UITouch-location touch))) 11 | (add-point (car loc) (cdr loc)))) 12 | touches)) 13 | 14 | (define-event-handler (touches-moved touches event) 15 | (for-each (lambda (touch) 16 | (let ((loc (UITouch-location touch))) 17 | (add-point (car loc) (cdr loc)))) 18 | touches)) 19 | 20 | (define-event-handler (did-accelerate device accel) 21 | ;; (add-point (+ (/ (UIAcceleration-x accel) 2.) .5) 22 | ;; (+ (/ (UIAcceleration-y accel) 2.) .5)) 23 | 24 | (define (shift n weight) 25 | (+ n (* weight 70))) 26 | 27 | (add-point (shift 150 (UIAcceleration-x accel)) 28 | (shift 100 (- (UIAcceleration-y accel))) 29 | '(.8 .5 .2))) 30 | 31 | ;;;; util 32 | 33 | (define (display?) 34 | (let* ((time (real-time)) 35 | (rounded (floor time))) 36 | (< (- time rounded) .05))) 37 | 38 | (define %%screen-width #f) 39 | (define %%screen-height #f) 40 | 41 | (define (select-view) 42 | ;; This part of the ffi crashes right now 43 | ;; (let* ((bounds (UIView-bounds (current-view))) 44 | ;; (size (CGRect-size bounds))) 45 | ;; (set! %%screen-width (CGSize-width size)) 46 | ;; (set! %%screen-height (CGSize-height size))) 47 | (set! %%screen-width (UIView-width (current-view))) 48 | (set! %%screen-height (UIView-height (current-view)))) 49 | 50 | (define (view-space-x n) 51 | (exact->inexact (/ n %%screen-width))) 52 | 53 | (define (view-space-y n) 54 | (exact->inexact (/ n %%screen-height))) 55 | 56 | ;;;; app 57 | 58 | (define-type point 59 | x y 60 | color 61 | birthtime) 62 | 63 | (define points '()) 64 | 65 | (define (add-point x y #!optional color) 66 | (set! points (cons (make-point x y 67 | (or color '(.2 .8 .5)) 68 | (real-time)) 69 | points))) 70 | 71 | (define (point-render point) 72 | (glLoadIdentity) 73 | (let ((color (point-color point))) 74 | (glColor4f 75 | (car color) 76 | (cadr color) 77 | (caddr color) 78 | (- 1. 79 | (/ (point-age point) AGE_OF_DEATH)))) 80 | (glTranslatef (view-space-x (point-x point)) 81 | (view-space-y (point-y point)) 82 | 0.) 83 | (glDrawArrays GL_TRIANGLE_STRIP 0 4)) 84 | 85 | (define (point-age point) 86 | (- (real-time) (point-birthtime point))) 87 | 88 | (define (point-dead? point) 89 | (> (point-age point) AGE_OF_DEATH)) 90 | 91 | (define vertices 92 | (vector->GLfloat* (vector -.05 -.0375 93 | .05 -.0375 94 | -.05 .0375 95 | .05 .0375))) 96 | 97 | (define (select-geometry) 98 | (glVertexPointer 2 GL_FLOAT 0 vertices) 99 | (glEnableClientState GL_VERTEX_ARRAY)) 100 | 101 | (define (init) 102 | (glMatrixMode GL_PROJECTION) 103 | (glLoadIdentity) 104 | (ortho 0.0 1.0 1.0 0.0 -1.0 1.0) 105 | (glMatrixMode GL_MODELVIEW) 106 | (glLoadIdentity) 107 | 108 | (glEnable GL_BLEND) 109 | (glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA)) 110 | 111 | (define (render) 112 | (glClearColor 0. 0. 1. 1.) 113 | (glClear (bitwise-ior GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) 114 | 115 | (select-view) 116 | (select-geometry) 117 | 118 | (set! points 119 | (fold-right 120 | (lambda (point acc) 121 | (point-render point) 122 | (if (point-dead? point) 123 | acc 124 | (cons point acc))) 125 | '() 126 | points)) 127 | (##gc)) 128 | 129 | (define (get-title) 130 | (number->string (real-time))) 131 | -------------------------------------------------------------------------------- /lib/apps/app3.scm: -------------------------------------------------------------------------------- 1 | ;;;; "app3" 2 | ;;; renders a 3d box, which may bounce around some 3 | 4 | (declare (block) 5 | (standard-bindings) 6 | (extended-bindings)) 7 | 8 | (include "events#.scm") 9 | (include "obj-loader2.scm") 10 | (include "scene.scm") 11 | (include "physics.scm") 12 | 13 | ;;;;; settings 14 | 15 | (define %%settings (make-table)) 16 | 17 | (define (get-config name #!optional default) 18 | (table-ref %%settings name default)) 19 | 20 | (define (set-config name val) 21 | (table-set! %%settings name val)) 22 | 23 | ;;;;; masses 24 | 25 | (define-type mass 26 | constructor: really-make-mass 27 | mass 28 | position 29 | scene-object) 30 | 31 | (define (make-mass mass pos) 32 | (really-make-mass mass pos #f)) 33 | 34 | (define masses '()) 35 | 36 | (define (add-mass mass) 37 | (set! masses (cons mass masses)) 38 | (let ((obj (make-scene-object mass-mesh 39 | (make-vec3d 1. 1. 1.) 40 | (mass-position mass) 41 | (make-vec4d 0.5 0.5 0. (* (random-real) 360.)) 42 | 1.5))) 43 | (mass-scene-object-set! mass obj) 44 | (scene-list-add obj))) 45 | 46 | (define (mass-apply-gravity) 47 | (for-each 48 | (lambda (mass) 49 | (for-each 50 | (lambda (el) 51 | (if (and (scene-object-velocity el) 52 | (scene-object-radius el)) 53 | (let* ((v (vec3d-sub (mass-position mass) 54 | (scene-object-position el))) 55 | (d (- (vec3d-length v) 56 | (scene-object-radius el) 57 | (scene-object-radius (mass-scene-object mass)))) 58 | (F (* 6.67428e-11 (/ (* (mass-mass mass) OBJECT_MASS) 59 | (* d d)))) 60 | (accel (vec3d-scalar-mul 61 | (vec3d-unit v) 62 | (/ F OBJECT_MASS)))) 63 | (scene-object-velocity-set! 64 | el 65 | (vec3d-add (scene-object-velocity el) 66 | accel))))) 67 | scene-list)) 68 | masses)) 69 | 70 | (define (mass-lighting) 71 | (let loop ((i 0)) 72 | (if (< i 9) 73 | (begin 74 | (glDisable (+ GL_LIGHT0 i)) 75 | (loop (+ i 1))))) 76 | 77 | (let loop ((tail masses) 78 | (i 0)) 79 | (if (and (not (null? tail)) 80 | (< i 9)) 81 | (let ((pos (mass-position (car tail))) 82 | (light (+ GL_LIGHT0 i))) 83 | (glEnable light) 84 | (glLightf light GL_CONSTANT_ATTENUATION .5) 85 | (glLightfv light GL_AMBIENT (vector->GLfloat* (vector .05 .05 .05 1.))) 86 | (glLightfv light GL_POSITION 87 | (vector->GLfloat* (vector (vec3d-x pos) 88 | (vec3d-y pos) 89 | (vec3d-z pos) 90 | 1.))) 91 | (glLightfv light GL_DIFFUSE (vector->GLfloat* (vector 1. 1. 1. 1.))) 92 | (loop (cdr tail) (+ i 1)))))) 93 | 94 | (define OBJECT_MASS 1000.) 95 | 96 | ;;;;; throwing 97 | 98 | (define mass-mesh (obj-load (resource "resources/mass") #t)) 99 | (define sphere-mesh (obj-load (resource "resources/sphere") #t)) 100 | (define collision-mesh (obj-load (resource "resources/collision") #t)) 101 | 102 | (define (spread-number fl) 103 | (- (* fl 2.) 1.)) 104 | 105 | (define (throw pos vel) 106 | (define (random-color) 107 | (random-real)) 108 | 109 | (let ((then (real-time))) 110 | (scene-list-add 111 | (make-scene-object sphere-mesh 112 | (make-vec3d (random-color) 113 | (random-color) 114 | (random-color)) 115 | pos 116 | ;; (make-vec4d 0. 1. 0. -90.) 117 | #f 118 | 1.5 119 | vel 120 | #f)))) 121 | 122 | ;;;;; collisions 123 | 124 | (define collision-reference (make-table)) 125 | 126 | (define (reset-table!) 127 | (set! collision-reference (make-table))) 128 | 129 | (define (obj-collided? obj1 obj2) 130 | ;; sphere collision 131 | (let ((diff (vec3d-sub (scene-object-position obj1) 132 | (scene-object-position obj2))) 133 | (r1 (scene-object-radius obj1)) 134 | (r2 (scene-object-radius obj2))) 135 | (and r1 r2 136 | (< (vec3d-length diff) (+ r1 r2 -1.))))) 137 | 138 | ;; (define (detect-collisions) 139 | ;; (reset-table!) 140 | ;; (fold 141 | ;; (lambda (obj1 acc) 142 | ;; (or acc 143 | ;; (fold 144 | ;; (lambda (obj2 acc) 145 | ;; (or acc 146 | ;; (and (not (table-ref collision-reference (list obj1 obj2) #f)) 147 | ;; (not (eq? obj1 obj2)) 148 | ;; (obj-collided? obj1 obj2)))) 149 | ;; #f 150 | ;; scene-list))) 151 | ;; #f 152 | ;; scene-list)) 153 | 154 | (define (detect-collisions) 155 | (fold 156 | (lambda (mass acc) 157 | (let ((obj1 (mass-scene-object mass))) 158 | (or acc 159 | (fold 160 | (lambda (obj2 acc) 161 | (or acc 162 | (and (not (eq? obj1 obj2)) 163 | (obj-collided? obj1 obj2)))) 164 | #f 165 | scene-list)))) 166 | #f 167 | masses)) 168 | 169 | ;;;;; controls 170 | 171 | (define (screen-to-space x y) 172 | (let* ((width (UIView-width (current-view))) 173 | (height (UIView-height (current-view))) 174 | (pers (current-perspective)) 175 | (x-width (- (perspective-xmax pers) 176 | (perspective-xmin pers))) 177 | (y-width (- (perspective-ymax pers) 178 | (perspective-ymin pers)))) 179 | (vec3d-unit 180 | (make-vec3d 181 | (- (perspective-xmax pers) 182 | (* (/ x width) x-width)) 183 | (- (perspective-ymax pers) 184 | (* (/ y height) y-width)) 185 | (perspective-znear pers))))) 186 | 187 | (define %%touch-times (make-table)) 188 | 189 | (define (touch-record-time touch) 190 | (table-set! %%touch-times touch (real-time))) 191 | 192 | (define (touch-pop-life-time touch) 193 | (let ((v (table-ref %%touch-times touch))) 194 | (table-set! %%touch-times touch) 195 | (- (real-time) v))) 196 | 197 | (define-event-handler (touches-began touches event) 198 | (let ((now (real-time))) 199 | (for-each (lambda (touch) 200 | (touch-record-time touch)) 201 | touches))) 202 | 203 | (define-event-handler (touches-ended touches event) 204 | (for-each (lambda (touch) 205 | (if (not collided) 206 | (let ((loc (UITouch-location touch)) 207 | (power (touch-pop-life-time touch))) 208 | (user-toss-ball (screen-to-space (car loc) (cdr loc)) 209 | power)))) 210 | touches)) 211 | 212 | (define (user-toss-ball dir power) 213 | (throw (vec3d-scalar-mul dir (get-config "touch-depth")) 214 | (vec3d-scalar-mul 215 | (vec3d-unit 216 | (vec3d-component-mul dir (get-config "touch-dir"))) 217 | (user-force power)))) 218 | 219 | (define (user-force power) 220 | (let ((power (max 0. (min 1. power))) 221 | (f (get-config "touch-force"))) 222 | (- f (* power power f)))) 223 | 224 | ;;;;; app 225 | 226 | (define collided #f) 227 | 228 | (define reset-camera glLoadIdentity) 229 | 230 | (define (init) 231 | (random-source-randomize! default-random-source) 232 | 233 | ;; opengl 234 | (let* ((fov 40.) 235 | (aspect (/ (UIView-width (current-view)) 236 | (UIView-height (current-view))))) 237 | (glMatrixMode GL_PROJECTION) 238 | (glLoadIdentity) 239 | (perspective fov aspect 1. 1000.) 240 | (lookat (make-vec3d 0. 0. 0.) 241 | (make-vec3d 0. 0. 1.) 242 | (make-vec3d 0. 1. 0.)) 243 | (glMatrixMode GL_MODELVIEW) 244 | (glLoadIdentity)) 245 | 246 | (glEnable GL_DEPTH_TEST) 247 | (glDisable GL_CULL_FACE) 248 | (glShadeModel GL_SMOOTH) 249 | 250 | (glEnable GL_RESCALE_NORMAL) 251 | (glEnable GL_LIGHTING) 252 | (glEnable GL_LIGHT0) 253 | (glLightf GL_LIGHT0 GL_CONSTANT_ATTENUATION .6) 254 | (glLightfv GL_LIGHT0 GL_AMBIENT (vector->GLfloat* (vector .15 .15 .15 1.))) 255 | (glLightfv GL_LIGHT0 GL_POSITION (vector->GLfloat* (vector 25. 25. 0. 1.))) 256 | (glLightfv GL_LIGHT0 GL_DIFFUSE (vector->GLfloat* (vector 1. 1. 1. 1.))) 257 | 258 | (glFogx GL_FOG_MODE GL_EXP2) 259 | (glFogfv GL_FOG_COLOR (vector->GLfloat* (vector 0. 0. 0. 1.))) 260 | (glFogf GL_FOG_DENSITY .01) 261 | (glFogf GL_FOG_START 1.) 262 | (glFogf GL_FOG_END 1000.) 263 | (glEnable GL_FOG) 264 | 265 | (current-level) 266 | 267 | (set! GRAVITY (make-vec3d 0. 0. 0.))) 268 | 269 | (define (level1) 270 | (set-config "touch-force" 19.) 271 | (set-config "touch-dir" (make-vec3d 15. 15. 5.)) 272 | (set-config "touch-depth" 10.) 273 | (add-mass (make-mass 5.3736e11 (make-vec3d 0. 0. 25.)))) 274 | 275 | (define (level2) 276 | (set-config "touch-force" 25.) 277 | (set-config "touch-dir" (make-vec3d 15. 15. 5.)) 278 | 279 | ;(add-mass (make-mass 4.9736e11 (make-vec3d -10. 10. 35.))) 280 | (add-mass (make-mass 5.3736e13 (make-vec3d 7. -10. 45.))) 281 | ;(add-mass (make-mass 1.3736e11 (make-vec3d -3. -7. 35.))) 282 | (add-mass (make-mass 1.3736e11 (make-vec3d 3. 10. 45.)))) 283 | 284 | (define (reset-and-add mass) 285 | (reset) 286 | (add-mass mass)) 287 | 288 | (define current-level level1) 289 | 290 | (define (reset #!optional make-level) 291 | (set! scene-list '()) 292 | (set! masses '()) 293 | (set! collided #f) 294 | (if make-level 295 | (current-level))) 296 | 297 | (define (run) 298 | (if (and (not collided) 299 | (detect-collisions)) 300 | (let ((now (real-time))) 301 | (set! collided (real-time)) 302 | (scene-list-add 303 | (make-scene-object 304 | collision-mesh 305 | (make-vec3d .8 .5 .2) 306 | (make-vec3d 0. 0. 6.) 307 | (make-vec4d 0. 1. 0. 180.) 308 | #f 309 | (make-vec3d 0. 0. 0.) 310 | (make-vec3d 0. 0. 0.) 311 | (lambda (el) 312 | (if (> (real-time) (+ now 1.)) 313 | (begin 314 | (scene-object-velocity-set! el #f) 315 | (scene-object-acceleration-set! el #f)))))))) 316 | 317 | (if (and collided 318 | (> (real-time) (+ collided 2.))) 319 | (begin 320 | ;; (set! current-level (if (eq? current-level level1) 321 | ;; level2 322 | ;; level1)) 323 | (reset #t))) 324 | 325 | (mass-apply-gravity) 326 | (scene-list-update update-physics)) 327 | 328 | (define (render) 329 | (glClearColor 0. 0. 0. 1.) 330 | (glClear (bitwise-ior GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) 331 | (run) 332 | ;(mass-lighting) 333 | (run-render-queue (scene-list->render-queue)) 334 | (##gc)) 335 | 336 | (define (get-title) 337 | "") 338 | -------------------------------------------------------------------------------- /lib/apps/app4.scm: -------------------------------------------------------------------------------- 1 | 2 | (include "obj-loader2.scm") 3 | 4 | (define mesh #f) 5 | 6 | (define (init) 7 | (let* ((fov 40.) 8 | (aspect (/ (UIView-width (current-view)) 9 | (UIView-height (current-view)))) 10 | (half-fov-y (/ fov aspect 2))) 11 | (glMatrixMode GL_PROJECTION) 12 | (glLoadIdentity) 13 | (perspective fov aspect 1. 1000.) 14 | (lookat (make-vec3d 0. 0. 0.) 15 | ;; (make-vec3d 0. (sin half-fov-y) (cos half-fov-y)) 16 | (make-vec3d 0. 0. 1.) 17 | (make-vec3d 0. 1. 0.)) 18 | (glMatrixMode GL_MODELVIEW) 19 | (glLoadIdentity)) 20 | 21 | (glEnable GL_DEPTH_TEST) 22 | (glDisable GL_CULL_FACE) 23 | (glShadeModel GL_SMOOTH) 24 | 25 | (glEnable GL_LIGHTING) 26 | (glEnable GL_LIGHT0) 27 | (glLightfv GL_LIGHT0 GL_POSITION (vector->GLfloat* (vector 0. 3. 0. 1.))) 28 | (glLightfv GL_LIGHT0 GL_DIFFUSE (vector->GLfloat* (vector 1. 1. 1. 1.))) 29 | 30 | (let ((now (real-time))) 31 | (set! mesh (obj-load (resource "resources/logo.obj") #f)) 32 | (pp (- (real-time) now)))) 33 | 34 | (define rot 0.) 35 | (define (render) 36 | (glClearColor 0. 0. 0. 1.) 37 | (glClear (bitwise-ior GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) 38 | 39 | (glVertexPointer 3 GL_FLOAT 0 (obj-vertices mesh)) 40 | (glEnableClientState GL_VERTEX_ARRAY) 41 | (glNormalPointer GL_FLOAT 0 (->void* (obj-normals mesh))) 42 | (glEnableClientState GL_NORMAL_ARRAY) 43 | 44 | (glLoadIdentity) 45 | (glTranslatef 0. 0. 3.) 46 | (glRotatef rot 0.3 1. 0.) 47 | (glRotatef 90. 0. 0. 1.) 48 | (set! rot (+ rot .2)) 49 | 50 | (glMaterialfv GL_FRONT_AND_BACK 51 | GL_DIFFUSE 52 | (vector->GLfloat* 53 | (vector .8 .4 .1))) 54 | 55 | (glDrawElements GL_TRIANGLES 56 | (obj-num-indices mesh) 57 | GL_UNSIGNED_SHORT 58 | (->void* (obj-indices mesh)))) 59 | 60 | (define (get-title) 61 | "") 62 | -------------------------------------------------------------------------------- /lib/apps/app5.scm: -------------------------------------------------------------------------------- 1 | ;;;; "app5" 2 | ;;; Balls thrown up and pulled down by gravity (determined from 3 | ;;; accelerometer) 4 | 5 | (include "../events#.scm") 6 | (include "../obj-loader2.scm") 7 | (include "../scene.scm") 8 | (include "../physics.scm") 9 | 10 | ;;; resources 11 | 12 | (define sphere-mesh #f) 13 | 14 | ;;; throwing 15 | 16 | (define (spread-number fl) 17 | (- (* fl 2.) 1.)) 18 | 19 | (define (get-random-throw) 20 | (+ (real-time) (/ (random-real) 9.))) 21 | 22 | (define next-throw (get-random-throw)) 23 | 24 | (define (possibly-throw) 25 | (if (> (real-time) next-throw) 26 | (begin 27 | (throw (make-vec3d (* (spread-number (random-real)) 5.) 28 | 0. 29 | (+ (* (random-real) 35.) 10.)) 30 | (make-vec3d 0. (+ (random-real) 5.) 0.)) 31 | (set! next-throw (get-random-throw))))) 32 | 33 | (define (throw pos vel) 34 | (define (random-color) 35 | (random-real)) 36 | 37 | (let ((then (real-time))) 38 | (scene-list-add 39 | (make-scene-object sphere-mesh 40 | (make-vec3d (random-color) 41 | (random-color) 42 | (random-color)) 43 | pos 44 | ;; (make-vec4d 0. 1. 0. -90.) 45 | #f 46 | 1.5 47 | vel 48 | #f 49 | (lambda (el) 50 | (> 3. (- (real-time) then))) 51 | )))) 52 | 53 | ;;; controls 54 | 55 | (define CAMERA 0.) 56 | 57 | (define (reset-camera) 58 | (glLoadIdentity) 59 | (glRotatef (* (/ CAMERA PI) 180) 0. 0. 1.)) 60 | 61 | (define-event-handler (did-accelerate device accel) 62 | (let ((v (vec3d-unit (make-vec3d (UIAcceleration-x accel) 63 | (UIAcceleration-y accel) 64 | 0.)))) 65 | (set! CAMERA (atan (- (vec3d-x v)) (- (vec3d-y v)))))) 66 | 67 | 68 | ;;; app 69 | 70 | (define (init) 71 | (random-source-randomize! default-random-source) 72 | 73 | (set! sphere-mesh (obj-load (local-resource "resources/sphere") #t)) 74 | 75 | ;; opengl 76 | (let* ((fov 40.) 77 | (aspect (/ (UIView-width (current-view)) 78 | (UIView-height (current-view))))) 79 | (glMatrixMode GL_PROJECTION) 80 | (glLoadIdentity) 81 | (perspective fov aspect 1. 1000.) 82 | (lookat (make-vec3d 0. 0. 0.) 83 | (make-vec3d 0. 0. 1.) 84 | (make-vec3d 0. 1. 0.)) 85 | (glMatrixMode GL_MODELVIEW) 86 | (glLoadIdentity)) 87 | 88 | (glEnable GL_DEPTH_TEST) 89 | (glDisable GL_CULL_FACE) 90 | (glShadeModel GL_SMOOTH) 91 | 92 | (glEnable GL_RESCALE_NORMAL) 93 | (glEnable GL_LIGHTING) 94 | (glEnable GL_LIGHT0) 95 | (glLightf GL_LIGHT0 GL_CONSTANT_ATTENUATION .6) 96 | (glLightfv GL_LIGHT0 GL_AMBIENT (vector->float-array (vector .15 .15 .15 1.))) 97 | (glLightfv GL_LIGHT0 GL_POSITION (vector->float-array (vector 25. 25. 0. 1.))) 98 | (glLightfv GL_LIGHT0 GL_DIFFUSE (vector->float-array (vector 1. 1. 1. 1.))) 99 | 100 | (glFogx GL_FOG_MODE GL_EXP2) 101 | (glFogfv GL_FOG_COLOR (vector->float-array (vector 0. 0. 0. 1.))) 102 | (glFogf GL_FOG_DENSITY .01) 103 | (glFogf GL_FOG_START 1.) 104 | (glFogf GL_FOG_END 1000.) 105 | (glEnable GL_FOG)) 106 | 107 | (define (run) 108 | (possibly-throw) 109 | (scene-list-update update-physics)) 110 | 111 | (define (render) 112 | (glClearColor 0. 0. 0. 1.) 113 | (glClear (bitwise-ior GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) 114 | (run) 115 | (run-render-queue (scene-list->render-queue)) 116 | (##gc)) 117 | 118 | (define (get-title) 119 | "") 120 | -------------------------------------------------------------------------------- /lib/apps/app6.scm: -------------------------------------------------------------------------------- 1 | ;;;; "app6" 2 | ;;; dynamic world 3 | 4 | (include "../events#.scm") 5 | (include "../obj-loader2.scm") 6 | (include "../scene.scm") 7 | (include "../physics.scm") 8 | 9 | ;;; resources 10 | 11 | (define sphere-mesh (obj-load (resource "resources/sphere") #t)) 12 | (define jlongster-mesh (obj-load (resource "resources/jlongster") #t)) 13 | 14 | (define line (vector->GLfloat* (vector 0. 0. 0. 15 | 1. 0. 0.))) 16 | 17 | (define grid-size 100.) 18 | 19 | (define (render-grid) 20 | (define (draw) 21 | (glScalef grid-size 0. 0.) 22 | (glDrawArrays GL_LINES 0 2)) 23 | 24 | (define offset (/ grid-size 2.)) 25 | 26 | (define (render-lines) 27 | (unfold (lambda (i) (> i grid-size)) 28 | (lambda (i) 29 | (reset-camera) 30 | ;;(glRotatef 45. 1. 0. 0.) 31 | (glTranslatef (- offset) -5. (- (exact->inexact i) offset)) 32 | (draw)) 33 | (lambda (i) (+ i 1)) 34 | 0) 35 | 36 | (unfold (lambda (i) (> i grid-size)) 37 | (lambda (i) 38 | (reset-camera) 39 | ;;(glRotatef 45. 0. 0. 0.) 40 | (glTranslatef (- (exact->inexact i) offset) -5. (- offset)) 41 | (glRotatef -90. 0. 1. 0.) 42 | (draw)) 43 | (lambda (i) (+ i 1)) 44 | 0)) 45 | 46 | (glDisable GL_LIGHTING) 47 | (glVertexPointer 3 GL_FLOAT 0 line) 48 | (glEnableClientState GL_VERTEX_ARRAY) 49 | (glColor4f 0. 1. 0. 1.) 50 | (render-lines) 51 | (glEnable GL_LIGHTING)) 52 | 53 | ;;; controls 54 | 55 | (define yaw 0.) 56 | (define pitch 0.) 57 | 58 | (define (reset-camera) 59 | (glLoadIdentity) 60 | (glRotatef (- (exact->inexact yaw)) 1. 0. 0.) 61 | (glRotatef (exact->inexact pitch) 0. 1. 0.)) 62 | 63 | (define %%touch-coords (make-table)) 64 | 65 | (define (record-touch touch) 66 | (table-set! %%touch-coords touch (UITouch-location touch))) 67 | 68 | (define (update-touch/get-movement touch) 69 | (let* ((old-loc (table-ref %%touch-coords touch)) 70 | (loc (UITouch-location touch)) 71 | (x (- (car old-loc) (car loc))) 72 | (y (- (cdr old-loc) (cdr loc)))) 73 | (record-touch touch) 74 | (cons x y))) 75 | 76 | (define (remove-touch touch) 77 | (table-set! %%touch-coords touch)) 78 | 79 | (define-event-handler (touches-began touches event) 80 | (for-each record-touch touches)) 81 | 82 | (define-event-handler (touches-moved touches event) 83 | (let* ((touch (car touches)) 84 | (dist (update-touch/get-movement touch))) 85 | (set! yaw (+ yaw (* (cdr dist) .2))) 86 | (set! pitch (+ pitch (* (car dist) .2))))) 87 | 88 | (define-event-handler (touches-ended touches event) 89 | (for-each remove-touch touches)) 90 | 91 | ;;; threading test 92 | 93 | (define num-error-threads 20) 94 | 95 | (define (make-error-threads) 96 | (map thread-start! 97 | (unfold (lambda (i) (> i num-error-threads)) 98 | (lambda (i) (error-thread i)) 99 | (lambda (i) (+ i 1)) 100 | 0))) 101 | 102 | (define (error-thread i) 103 | (make-thread 104 | (lambda () 105 | (thread-sleep! i) 106 | (myerror i)))) 107 | 108 | ;;; app 109 | 110 | (define (init) 111 | (random-source-randomize! default-random-source) 112 | 113 | ;; opengl 114 | (let* ((fov 40.) 115 | (aspect (/ (UIView-width (current-view)) 116 | (UIView-height (current-view))))) 117 | (glMatrixMode GL_PROJECTION) 118 | (glLoadIdentity) 119 | (perspective fov aspect 1. 1000.) 120 | (lookat (make-vec3d 0. 0. 0.) 121 | (make-vec3d 0. 0. 1.) 122 | (make-vec3d 0. 1. 0.)) 123 | (glMatrixMode GL_MODELVIEW) 124 | (glLoadIdentity)) 125 | 126 | (glEnable GL_DEPTH_TEST) 127 | (glDisable GL_CULL_FACE) 128 | (glShadeModel GL_SMOOTH) 129 | 130 | (glEnable GL_RESCALE_NORMAL) 131 | (glEnable GL_LIGHTING) 132 | (glEnable GL_LIGHT0) 133 | (glLightf GL_LIGHT0 GL_LINEAR_ATTENUATION .01) 134 | (glLightfv GL_LIGHT0 GL_AMBIENT (vector->GLfloat* (vector .07 .07 .07 1.))) 135 | (glLightfv GL_LIGHT0 GL_POSITION (vector->GLfloat* (vector 5. 5. 2. 1.))) 136 | (glLightfv GL_LIGHT0 GL_DIFFUSE (vector->GLfloat* (vector 1. 1. 1. 1.))) 137 | 138 | (glFogx GL_FOG_MODE GL_EXP2) 139 | (glFogfv GL_FOG_COLOR (vector->GLfloat* (vector 0. 0. 0. 1.))) 140 | (glFogf GL_FOG_DENSITY .01) 141 | (glFogf GL_FOG_START 1.) 142 | (glFogf GL_FOG_END 1000.) 143 | (glEnable GL_FOG) 144 | 145 | (set! pitch -45.)) 146 | 147 | (define (make-scene) 148 | (scene-list-clear) 149 | 150 | (scene-list-add 151 | (make-scene-object 152 | sphere-mesh 153 | (make-vec3d 0. 0. 1.) 154 | (make-vec3d 20. 0. 15.))) 155 | 156 | (scene-list-add 157 | (make-scene-object 158 | jlongster-mesh 159 | (make-vec3d 0. 2. 8.) 160 | (make-vec3d 20. -5. 20.) 161 | (make-vec4d 0. 1. 0. 200.) 162 | 3.3))) 163 | 164 | (define (run) 165 | (scene-list-update update-physics)) 166 | 167 | (define (render) 168 | (glClearColor .0 .0 .0 1.) 169 | (glClear (bitwise-ior GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) 170 | (run) 171 | (render-grid) 172 | (run-render-queue (scene-list->render-queue)) 173 | (##gc)) 174 | 175 | (define (get-title) 176 | "") 177 | 178 | ;;;; scratch 179 | 180 | ;;(define cow-mesh (obj-load (resource "resources/cow"))) 181 | 182 | ;; (scene-list-add 183 | ;; (make-scene-object 184 | ;; cow-mesh 185 | ;; (make-vec3d 0. 2. 8.) 186 | ;; (make-vec3d 20. -5. 20.) 187 | ;; (make-vec4d 0. 1. 0. 230.) 188 | ;; 10. 189 | ;; (make-vec3d -10. 20. -10.))) 190 | -------------------------------------------------------------------------------- /lib/config.scm: -------------------------------------------------------------------------------- 1 | (define root "/Users/james/projects/scheme/gambit-iphone-example") 2 | -------------------------------------------------------------------------------- /lib/events#.scm: -------------------------------------------------------------------------------- 1 | 2 | (define-macro (define-event-handler sig . body) 3 | (let ((name (car sig)) 4 | (args (cdr sig))) 5 | `(install-event-handler 6 | ',name 7 | (lambda ,args ,@body)))) 8 | -------------------------------------------------------------------------------- /lib/events.scm: -------------------------------------------------------------------------------- 1 | ;;;; Events 2 | 3 | (declare (block) 4 | (standard-bindings) 5 | (extended-bindings)) 6 | 7 | (define %%handlers (make-table)) 8 | 9 | (define (install-event-handler name handler) 10 | (table-set! 11 | %%handlers 12 | name 13 | (cons handler (table-ref %%handlers name '())))) 14 | 15 | (define (run-event-handlers name . args) 16 | (for-each (lambda (handler) 17 | (apply handler args)) 18 | (table-ref %%handlers name '()))) 19 | 20 | ;;;; Usage 21 | 22 | ;;; (install-event-handler 'event-name (lambda (event) ...)) 23 | ;;; (define-event-handler (event-name event) ...) 24 | ;;; (run-event-handlers 'event-name) 25 | -------------------------------------------------------------------------------- /lib/ffi/al#.scm: -------------------------------------------------------------------------------- 1 | 2 | (c-define-type AudioData (struct "AudioData")) 3 | (c-define-type AudioSource (struct "AudioSource")) 4 | -------------------------------------------------------------------------------- /lib/ffi/al.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: MyOpenALSupport.c 4 | Abstract: OpenAL-related support functions 5 | Version: 1.3 6 | 7 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 8 | Inc. ("Apple") in consideration of your agreement to the following 9 | terms, and your use, installation, modification or redistribution of 10 | this Apple software constitutes acceptance of these terms. If you do 11 | not agree with these terms, please do not use, install, modify or 12 | redistribute this Apple software. 13 | 14 | In consideration of your agreement to abide by the following terms, and 15 | subject to these terms, Apple grants you a personal, non-exclusive 16 | license, under Apple's copyrights in this original Apple software (the 17 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 18 | Software, with or without modifications, in source and/or binary forms; 19 | provided that if you redistribute the Apple Software in its entirety and 20 | without modifications, you must retain this notice and the following 21 | text and disclaimers in all such redistributions of the Apple Software. 22 | Neither the name, trademarks, service marks or logos of Apple Inc. may 23 | be used to endorse or promote products derived from the Apple Software 24 | without specific prior written permission from Apple. Except as 25 | expressly stated in this notice, no other rights or licenses, express or 26 | implied, are granted by Apple herein, including but not limited to any 27 | patent rights that may be infringed by your derivative works or by other 28 | works in which the Apple Software may be incorporated. 29 | 30 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 31 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 32 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 33 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 34 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 35 | 36 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 37 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 38 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 40 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 41 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 42 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 43 | POSSIBILITY OF SUCH DAMAGE. 44 | 45 | Copyright (C) 2008 Apple Inc. All Rights Reserved. 46 | 47 | */ 48 | 49 | #import 50 | #import 51 | #import 52 | #import 53 | 54 | struct AudioData { 55 | void* data; 56 | int size; 57 | int format; 58 | int sampleRate; 59 | }; 60 | 61 | typedef struct AudioData AudioData; 62 | typedef ALvoid AL_APIENTRY (*alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq); 63 | 64 | ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq) { 65 | static alBufferDataStaticProcPtr proc = NULL; 66 | 67 | if (proc == NULL) { 68 | proc = (alBufferDataStaticProcPtr) alcGetProcAddress(NULL, (const ALCchar*) "alBufferDataStatic"); 69 | } 70 | 71 | if (proc) proc(bid, format, data, size, freq); 72 | } 73 | 74 | AudioData load_audio(char *inFile) { 75 | CFStringRef name = CFStringCreateWithCString(NULL, inFile, kCFStringEncodingUTF8); 76 | CFURLRef inFileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), name, NULL, NULL); 77 | CFRelease(name); 78 | 79 | OSStatus err = noErr; 80 | SInt64 theFileLengthInFrames = 0; 81 | AudioStreamBasicDescription theFileFormat; 82 | UInt32 thePropertySize = sizeof(theFileFormat); 83 | ExtAudioFileRef extRef = NULL; 84 | void* theData = NULL; 85 | AudioStreamBasicDescription theOutputFormat; 86 | AudioData result; 87 | 88 | // Open a file with ExtAudioFileOpen() 89 | err = ExtAudioFileOpenURL(inFileURL, &extRef); 90 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileOpenURL FAILED, Error = %ld\n", (long int)err); goto Exit; } 91 | 92 | // Get the audio data format 93 | err = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileDataFormat, &thePropertySize, &theFileFormat); 94 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileDataFormat) FAILED, Error = %ld\n", (long int)err); goto Exit; } 95 | if (theFileFormat.mChannelsPerFrame > 2) { printf("MyGetOpenALAudioData - Unsupported Format, channel count is greater than stereo\n"); goto Exit;} 96 | 97 | // Set the client format to 16 bit signed integer (native-endian) data 98 | // Maintain the channel count and sample rate of the original source format 99 | theOutputFormat.mSampleRate = theFileFormat.mSampleRate; 100 | theOutputFormat.mChannelsPerFrame = theFileFormat.mChannelsPerFrame; 101 | 102 | theOutputFormat.mFormatID = kAudioFormatLinearPCM; 103 | theOutputFormat.mBytesPerPacket = 2 * theOutputFormat.mChannelsPerFrame; 104 | theOutputFormat.mFramesPerPacket = 1; 105 | theOutputFormat.mBytesPerFrame = 2 * theOutputFormat.mChannelsPerFrame; 106 | theOutputFormat.mBitsPerChannel = 16; 107 | theOutputFormat.mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger; 108 | 109 | // Set the desired client (output) data format 110 | err = ExtAudioFileSetProperty(extRef, kExtAudioFileProperty_ClientDataFormat, sizeof(theOutputFormat), &theOutputFormat); 111 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileSetProperty(kExtAudioFileProperty_ClientDataFormat) FAILED, Error = %ld\n", (long int)err); goto Exit; } 112 | 113 | // Get the total frame count 114 | thePropertySize = sizeof(theFileLengthInFrames); 115 | err = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileLengthFrames, &thePropertySize, &theFileLengthInFrames); 116 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileLengthFrames) FAILED, Error = %ld\n", (long int)err); goto Exit; } 117 | 118 | // Read all the data into memory 119 | UInt32 dataSize = theFileLengthInFrames * theOutputFormat.mBytesPerFrame;; 120 | theData = malloc(dataSize); 121 | if (theData) 122 | { 123 | AudioBufferList theDataBuffer; 124 | theDataBuffer.mNumberBuffers = 1; 125 | theDataBuffer.mBuffers[0].mDataByteSize = dataSize; 126 | theDataBuffer.mBuffers[0].mNumberChannels = theOutputFormat.mChannelsPerFrame; 127 | theDataBuffer.mBuffers[0].mData = theData; 128 | 129 | // Read the data into an AudioBufferList 130 | err = ExtAudioFileRead(extRef, (UInt32*)&theFileLengthInFrames, &theDataBuffer); 131 | if(err == noErr) { 132 | // success 133 | result.size = (ALsizei)dataSize; 134 | result.format = (theOutputFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; 135 | result.sampleRate = (ALsizei)theOutputFormat.mSampleRate; 136 | } 137 | else { 138 | // failure 139 | free(theData); 140 | theData = NULL; // make sure to return NULL 141 | printf("MyGetOpenALAudioData: ExtAudioFileRead FAILED, Error = %ld\n", (long int)err); goto Exit; 142 | } 143 | } 144 | 145 | Exit: 146 | // Dispose the ExtAudioFileRef, it is no longer needed 147 | if (extRef) ExtAudioFileDispose(extRef); 148 | result.data = theData; 149 | return result; 150 | } 151 | -------------------------------------------------------------------------------- /lib/ffi/al.scm: -------------------------------------------------------------------------------- 1 | ;;;; OpenAL interface 2 | ;;; OK, don't harass me here. This is awful, and I know it. Sound is a 3 | ;;; whole task which I wasn't prepared for. This barely gets me up and 4 | ;;; running. 5 | 6 | (include "al#.scm") 7 | 8 | (c-declare #< 11 | #import 12 | #import 13 | #import 14 | 15 | struct AudioData { 16 | void* data; 17 | int size; 18 | int format; 19 | int sampleRate; 20 | }; 21 | 22 | typedef struct AudioData AudioData; 23 | 24 | typedef ALvoid AL_APIENTRY (*alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq); 25 | AudioData load_audio_data(char *inFile); 26 | 27 | ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq) { 28 | static alBufferDataStaticProcPtr proc = NULL; 29 | 30 | if (proc == NULL) { 31 | proc = (alBufferDataStaticProcPtr) alcGetProcAddress(NULL, (const ALCchar*) "alBufferDataStatic"); 32 | } 33 | 34 | if (proc) proc(bid, format, data, size, freq); 35 | } 36 | 37 | ALCdevice *device; 38 | ALCcontext *context; 39 | 40 | void init_audio() { 41 | device = alcOpenDevice(NULL); 42 | if(device) { 43 | context = alcCreateContext(device, NULL); 44 | alcMakeContextCurrent(context); 45 | } 46 | } 47 | 48 | void shutdown_audio() { 49 | alcDestroyContext(context); 50 | alcCloseDevice(device); 51 | } 52 | 53 | GLuint load_audio(char *file) { 54 | AudioData data_desc; 55 | data_desc = load_audio_data(file); 56 | 57 | if(!data_desc.data) { 58 | return 0; 59 | } 60 | 61 | ALuint bufferId; 62 | alGenBuffers(1, &bufferId); 63 | alBufferData(bufferId, 64 | data_desc.format, 65 | data_desc.data, 66 | data_desc.size, 67 | data_desc.sampleRate); 68 | free(data_desc.data); 69 | return bufferId; 70 | } 71 | 72 | GLuint make_audio_source(GLuint bufferId) { 73 | GLuint sourceId; 74 | alGenSources(1, &sourceId); 75 | alSourcei(sourceId, AL_BUFFER, bufferId); 76 | alSourcef(sourceId, AL_PITCH, 1.0f); 77 | alSourcef(sourceId, AL_GAIN, 1.0f); 78 | 79 | NSLog(@"PITCH: %d, GAIN: %d", AL_PITCH, AL_GAIN); 80 | 81 | return sourceId; 82 | } 83 | 84 | void free_audio_source(GLuint sourceId) { 85 | alDeleteSources(1, &sourceId); 86 | } 87 | 88 | void free_audio_buffer(GLuint bufferId) { 89 | alDeleteBuffers(1, &bufferId); 90 | } 91 | 92 | void play_audio(GLuint sourceId) { 93 | alSourcePlay(sourceId); 94 | } 95 | 96 | void stop_audio(GLuint sourceId) { 97 | alSourceStop(sourceId); 98 | } 99 | 100 | void rewind_audio(GLuint sourceId) { 101 | alSourceRewind(sourceId); 102 | } 103 | 104 | int is_audio_playing(GLuint sourceId) { 105 | ALenum state; 106 | alGetSourcei(sourceId, AL_SOURCE_STATE, &state); 107 | return state == AL_PLAYING; 108 | } 109 | 110 | AudioData load_audio_data(char *inFile) { 111 | CFStringRef name = CFStringCreateWithCString(NULL, inFile, kCFStringEncodingUTF8); 112 | CFURLRef inFileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), name, NULL, NULL); 113 | CFRelease(name); 114 | 115 | OSStatus err = noErr; 116 | SInt64 theFileLengthInFrames = 0; 117 | AudioStreamBasicDescription theFileFormat; 118 | UInt32 thePropertySize = sizeof(theFileFormat); 119 | ExtAudioFileRef extRef = NULL; 120 | void* theData = NULL; 121 | AudioStreamBasicDescription theOutputFormat; 122 | AudioData result; 123 | 124 | // Open a file with ExtAudioFileOpen() 125 | err = ExtAudioFileOpenURL(inFileURL, &extRef); 126 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileOpenURL FAILED, Error = %ld\n", (long int)err); goto Exit; } 127 | 128 | // Get the audio data format 129 | err = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileDataFormat, &thePropertySize, &theFileFormat); 130 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileDataFormat) FAILED, Error = %ld\n", (long int)err); goto Exit; } 131 | if (theFileFormat.mChannelsPerFrame > 2) { printf("MyGetOpenALAudioData - Unsupported Format, channel count is greater than stereo\n"); goto Exit;} 132 | 133 | // Set the client format to 16 bit signed integer (native-endian) data 134 | // Maintain the channel count and sample rate of the original source format 135 | theOutputFormat.mSampleRate = theFileFormat.mSampleRate; 136 | theOutputFormat.mChannelsPerFrame = theFileFormat.mChannelsPerFrame; 137 | 138 | theOutputFormat.mFormatID = kAudioFormatLinearPCM; 139 | theOutputFormat.mBytesPerPacket = 2 * theOutputFormat.mChannelsPerFrame; 140 | theOutputFormat.mFramesPerPacket = 1; 141 | theOutputFormat.mBytesPerFrame = 2 * theOutputFormat.mChannelsPerFrame; 142 | theOutputFormat.mBitsPerChannel = 16; 143 | theOutputFormat.mFormatFlags = kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger; 144 | 145 | // Set the desired client (output) data format 146 | err = ExtAudioFileSetProperty(extRef, kExtAudioFileProperty_ClientDataFormat, sizeof(theOutputFormat), &theOutputFormat); 147 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileSetProperty(kExtAudioFileProperty_ClientDataFormat) FAILED, Error = %ld\n", (long int)err); goto Exit; } 148 | 149 | // Get the total frame count 150 | thePropertySize = sizeof(theFileLengthInFrames); 151 | err = ExtAudioFileGetProperty(extRef, kExtAudioFileProperty_FileLengthFrames, &thePropertySize, &theFileLengthInFrames); 152 | if(err) { printf("MyGetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileLengthFrames) FAILED, Error = %ld\n", (long int)err); goto Exit; } 153 | 154 | // Read all the data into memory 155 | UInt32 dataSize = theFileLengthInFrames * theOutputFormat.mBytesPerFrame;; 156 | theData = malloc(dataSize); 157 | if (theData) 158 | { 159 | AudioBufferList theDataBuffer; 160 | theDataBuffer.mNumberBuffers = 1; 161 | theDataBuffer.mBuffers[0].mDataByteSize = dataSize; 162 | theDataBuffer.mBuffers[0].mNumberChannels = theOutputFormat.mChannelsPerFrame; 163 | theDataBuffer.mBuffers[0].mData = theData; 164 | 165 | // Read the data into an AudioBufferList 166 | err = ExtAudioFileRead(extRef, (UInt32*)&theFileLengthInFrames, &theDataBuffer); 167 | if(err == noErr) { 168 | // success 169 | result.size = (ALsizei)dataSize; 170 | result.format = (theOutputFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16; 171 | result.sampleRate = (ALsizei)theOutputFormat.mSampleRate; 172 | } 173 | else { 174 | // failure 175 | free(theData); 176 | theData = NULL; // make sure to return NULL 177 | printf("MyGetOpenALAudioData: ExtAudioFileRead FAILED, Error = %ld\n", (long int)err); goto Exit; 178 | } 179 | } 180 | 181 | Exit: 182 | // Dispose the ExtAudioFileRef, it is no longer needed 183 | if (extRef) ExtAudioFileDispose(extRef); 184 | result.data = theData; 185 | return result; 186 | } 187 | 188 | end-c-code 189 | ) 190 | 191 | (define AL_PITCH 4099) 192 | (define AL_GAIN 4106) 193 | 194 | (define init-audio 195 | (c-lambda () void "init_audio")) 196 | 197 | (define shutdown-audio 198 | (c-lambda () void "shutdown_audio")) 199 | 200 | (define load-audio 201 | (c-lambda (char-string) GLuint "load_audio")) 202 | 203 | (define make-audio-source 204 | (c-lambda (unsigned-int) GLuint "make_audio_source")) 205 | 206 | (define free-audio-buffer 207 | (c-lambda (unsigned-int) void "free_audio_buffer")) 208 | 209 | (define free-audio-source 210 | (c-lambda (unsigned-int) void "free_audio_source")) 211 | 212 | (define play-audio 213 | (c-lambda (unsigned-int) void "play_audio")) 214 | 215 | (define stop-audio 216 | (c-lambda (unsigned-int) void "stop_audio")) 217 | 218 | (define rewind-audio 219 | (c-lambda (unsigned-int) void "rewind_audio")) 220 | 221 | (define is-audio-playing 222 | (c-lambda (unsigned-int) bool "is_audio_playing")) 223 | 224 | (define alSourcei 225 | (c-lambda (unsigned-int int int) void "alSourcei")) 226 | 227 | (define alSourcef 228 | (c-lambda (unsigned-int int float) void "alSourcef")) 229 | 230 | ;;; AudioData structure 231 | 232 | ;; (define AudioData-data 233 | ;; (c-lambda (AudioData) void-array "___result_voidstar = ___arg1.data;")) 234 | 235 | ;; (define AudioData-size 236 | ;; (c-lambda (AudioData) int "___result = ___arg1.size;")) 237 | 238 | ;; (define AudioData-format 239 | ;; (c-lambda (AudioData) int "___result = ___arg1.format;")) 240 | 241 | ;; (define AudioData-sample-rate 242 | ;; (c-lambda (AudioData) int "___result = ___arg1.sampleRate;")) 243 | -------------------------------------------------------------------------------- /lib/ffi/arrays#.scm: -------------------------------------------------------------------------------- 1 | 2 | (c-define-type unsigned-int8-array (pointer unsigned-int8)) 3 | (c-define-type unsigned-int16-array (pointer unsigned-int8)) 4 | (c-define-type unsigned-int-array (pointer unsigned-int)) 5 | (c-define-type float-array (pointer float)) 6 | (c-define-type void-array (pointer void)) 7 | -------------------------------------------------------------------------------- /lib/ffi/arrays.scm: -------------------------------------------------------------------------------- 1 | 2 | (include "arrays#.scm") 3 | (include "ffi#.scm") 4 | (include "../util/tests.scm") 5 | 6 | ;;; util 7 | 8 | (define NULL 9 | ((c-lambda () (pointer void #f) "___result_voidstar=0;"))) 10 | 11 | (define free 12 | (c-lambda ((pointer void #f)) void "free((void*)___arg1);")) 13 | 14 | (define ->void-array 15 | (c-lambda ((pointer void #f)) (pointer void #f) 16 | "___result_voidstar = (void*)___arg1;")) 17 | 18 | ;;; unsigned-int8-array 19 | 20 | (define make-unsigned-int8-array 21 | (c-lambda (int) unsigned-int8-array 22 | "___result_voidstar = malloc(___arg1*sizeof(unsigned char));")) 23 | 24 | (define unsigned-int8-array-ref 25 | (c-lambda (unsigned-int8-array int) unsigned-int8 26 | "___result = ((unsigned char*)___arg1)[___arg2];")) 27 | 28 | (define unsigned-int8-array-set! 29 | (c-lambda (unsigned-int8-array int unsigned-int8) void 30 | "((unsigned char*)___arg1)[___arg2] = ___arg3;")) 31 | 32 | (define (vector->unsigned-int8-array vec) 33 | (let* ((length (vector-length vec)) 34 | (buf (make-unsigned-int8-array length))) 35 | (let loop ((i 0)) 36 | (if (< i length) 37 | (begin 38 | (unsigned-int8-array-set! buf i (vector-ref vec i)) 39 | (loop (+ i 1))) 40 | buf)))) 41 | 42 | ;;; unsigned-int16-array 43 | 44 | (define make-unsigned-int16-array 45 | (c-lambda (int) unsigned-int16-array 46 | "___result_voidstar = malloc(___arg1*sizeof(unsigned short));")) 47 | 48 | (define unsigned-int16-array-ref 49 | (c-lambda (unsigned-int16-array int) unsigned-int16 50 | "___result = ((unsigned short*)___arg1)[___arg2];")) 51 | 52 | (define unsigned-int16-array-set! 53 | (c-lambda (unsigned-int16-array int unsigned-int16) void 54 | "((unsigned short*)___arg1)[___arg2] = ___arg3;")) 55 | 56 | (define (vector->unsigned-int16-array vec) 57 | (let* ((length (vector-length vec)) 58 | (buf (make-unsigned-int16-array length))) 59 | (let loop ((i 0)) 60 | (if (< i length) 61 | (begin 62 | (unsigned-int16-array-set! buf i (vector-ref vec i)) 63 | (loop (+ i 1))) 64 | buf)))) 65 | 66 | ;;; unsigned-int array 67 | 68 | (define make-unsigned-int-array 69 | (c-lambda (int) unsigned-int-array 70 | "___result_voidstar = malloc(___arg1*sizeof(unsigned int));")) 71 | 72 | (define unsigned-int-array-ref 73 | (c-lambda (unsigned-int-array int) unsigned-int 74 | "___result = ((unsigned int*)___arg1)[___arg2];")) 75 | 76 | (define unsigned-int-array-set! 77 | (c-lambda (unsigned-int-array int unsigned-int) void 78 | "((unsigned int*)___arg1)[___arg2] = ___arg3;")) 79 | 80 | (define (vector->unsigned-int-array vec) 81 | (let* ((length (vector-length vec)) 82 | (buf (make-unsigned-int-array length))) 83 | (let loop ((i 0)) 84 | (if (< i length) 85 | (begin 86 | (unsigned-int-array-set! buf i (vector-ref vec i)) 87 | (loop (+ i 1))) 88 | buf)))) 89 | 90 | (with-alloc (buf (make-unsigned-int-array 5)) 91 | (unsigned-int-array-set! buf 0 70000) 92 | (unsigned-int-array-set! buf 1 80000) 93 | (assert-equal (unsigned-int-array-ref buf 0) 70000) 94 | (assert-equal (unsigned-int-array-ref buf 1) 80000)) 95 | 96 | (with-alloc (buf (vector->unsigned-int-array (vector 1000000 2000000))) 97 | (assert-equal (unsigned-int-array-ref buf 0) 1000000) 98 | (assert-equal (unsigned-int-array-ref buf 1) 2000000)) 99 | 100 | ;;; float 101 | 102 | (define make-float-array 103 | (c-lambda (int) float-array 104 | "___result_voidstar = malloc(___arg1*sizeof(float));")) 105 | 106 | (define float-array-ref 107 | (c-lambda (float-array int) float 108 | "___result = ((float*)___arg1)[___arg2];")) 109 | 110 | (define float-array-set! 111 | (c-lambda (float-array int float) void 112 | "((float*)___arg1)[___arg2] = ___arg3;")) 113 | 114 | (define (vector->float-array vec) 115 | (let* ((length (vector-length vec)) 116 | (buf (make-float-array length))) 117 | (let loop ((i 0)) 118 | (if (< i length) 119 | (begin 120 | (float-array-set! buf i (vector-ref vec i)) 121 | (loop (+ i 1))) 122 | buf)))) 123 | 124 | (with-alloc (buf (make-float-array 5)) 125 | (float-array-set! buf 0 1.) 126 | (float-array-set! buf 1 5.) 127 | (assert-equal (float-array-ref buf 0) 1.) 128 | (assert-equal (float-array-ref buf 1) 5.)) 129 | 130 | (with-alloc (buf (vector->float-array (vector 1. 2. 3.))) 131 | (assert-equal (float-array-ref buf 0) 1.) 132 | (assert-equal (float-array-ref buf 1) 2.) 133 | (assert-equal (float-array-ref buf 2) 3.)) 134 | 135 | ;; (define-macro (implement-c-array name scheme-type c-type) 136 | ;; (define make-symbol 137 | ;; (lambda args 138 | ;; (string->symbol 139 | ;; (apply string-append (map (lambda (el) 140 | ;; (if (symbol? el) 141 | ;; (symbol->string el) 142 | ;; el)) 143 | ;; args))))) 144 | 145 | ;; `(begin 146 | ;; (define ,(make-symbol "make-" name "-array") 147 | ;; (c-lambda (,scheme-type) )))) 148 | -------------------------------------------------------------------------------- /lib/ffi/ffi#.scm: -------------------------------------------------------------------------------- 1 | 2 | (define-macro (with-alloc expr . rest) 3 | `(let (,expr) 4 | (let ((ret (begin ,@rest))) 5 | (free ,(car expr)) 6 | ret))) 7 | -------------------------------------------------------------------------------- /lib/ffi/ffi.scm: -------------------------------------------------------------------------------- 1 | 2 | (include "arrays.scm") 3 | -------------------------------------------------------------------------------- /lib/ffi/freeimage.scm: -------------------------------------------------------------------------------- 1 | (c-declare "#include \"FreeImage.h\"") 2 | (c-declare "#include \"stdlib.h\"") 3 | 4 | (c-define-type FIBITMAP "FIBITMAP") 5 | (c-define-type FIBITMAP* (pointer FIBITMAP)) 6 | 7 | (define freeimage-initialize 8 | (c-lambda (bool) void "FreeImage_Initialise")) 9 | 10 | (define freeimage-deinitialize 11 | (c-lambda () void "FreeImage_DeInitialise")) 12 | 13 | (define freeimage-load 14 | (c-lambda (char-string) FIBITMAP* #<float-array 43 | (vector (vec3d-x x) (vec3d-y x) (vec3d-z x) 0. 44 | (vec3d-x y) (vec3d-y y) (vec3d-z y) 0. 45 | (- (vec3d-x z)) (- (vec3d-y z)) (- (vec3d-z z)) 0. 46 | 0. 0. 0. 1.)))) 47 | -------------------------------------------------------------------------------- /lib/ffi/image.scm: -------------------------------------------------------------------------------- 1 | 2 | (c-declare #<") 6 | 7 | (include "iphone#.scm") 8 | 9 | ;;;; UIView 10 | 11 | (define current-view (make-parameter #f)) 12 | 13 | (c-define (register-view view) (UIView*) void "register_view" "" 14 | (current-view view)) 15 | 16 | (define UIView-bounds 17 | (c-lambda (UIView*) CGRect #<list touches) 69 | event)) 70 | 71 | (c-define (touches-moved touches event) 72 | (NSSet* UIEvent) void "touches_moved" "" 73 | (run-event-handlers 'touches-moved 74 | (NSSet->list touches) 75 | event)) 76 | 77 | (c-define (touches-ended touches event) 78 | (NSSet* UIEvent) void "touches_ended" "" 79 | (run-event-handlers 'touches-ended 80 | (NSSet->list touches) 81 | event)) 82 | 83 | (c-define (touches-cancelled touches event) 84 | (NSSet* UIEvent) void "touches_cancelled" "" 85 | (run-event-handlers 'touches-cancelled 86 | (NSSet->list touches) 87 | event)) 88 | 89 | ;;;; UIAcceleration & Accelerometer events 90 | 91 | (define UIAcceleration-x 92 | (c-lambda (UIAcceleration*) UIAccelerationValue 93 | "___result = ___arg1.x;")) 94 | 95 | (define UIAcceleration-y 96 | (c-lambda (UIAcceleration*) UIAccelerationValue 97 | "___result = ___arg1.y;")) 98 | 99 | (define UIAcceleration-z 100 | (c-lambda (UIAcceleration*) UIAccelerationValue 101 | "___result = ___arg1.z;")) 102 | 103 | (define UIAcceleration-timestamp 104 | (c-lambda (UIAcceleration*) NSTimeInterval 105 | "___result = ___arg1.timestamp;")) 106 | 107 | (c-define (did-accelerate accelerometer acceleration) 108 | (UIAccelerometer* UIAcceleration*) void "did_accelerate" "" 109 | (run-event-handlers 'did-accelerate 110 | accelerometer 111 | acceleration)) 112 | 113 | ;;;; Usage 114 | 115 | ;;; (define-event-handler (touches-began touches event) 116 | ;;; (for-each (lambda (touch) 117 | ;;; (pp "tap count: ") 118 | ;;; (pp (UITouch-tap-count touch)) 119 | ;;; (pp "location: ") 120 | ;;; (pp (UITouch-location touch)) 121 | ;;; touches)) 122 | 123 | ;;; (define-event-handler (did-accelerate device accel) 124 | ;;; (pp (UIAcceleration-x accel)) 125 | ;;; (pp (UIAcceleration-y accel)) 126 | ;;; (pp (UIAcceleration-z accel))) 127 | -------------------------------------------------------------------------------- /lib/ffi/osx#.scm: -------------------------------------------------------------------------------- 1 | ;;;; "osx ffi types" 2 | ;;; Defines c types for the osx ffi. 3 | 4 | ;;;; Cocoa 5 | 6 | (c-define-type id (pointer (struct "objc_object") #f)) 7 | (c-define-type NSTimeInterval double) 8 | (c-define-type NSArray "NSArray") 9 | (c-define-type NSArray* (pointer NSArray)) 10 | (c-define-type NSSet "NSSet") 11 | (c-define-type NSSet* (pointer NSSet)) 12 | (c-define-type NSString "NSString") 13 | (c-define-type NSString* (pointer "NSString")) 14 | (c-define-type NSBundle "NSBundle") 15 | (c-define-type NSBundle* (pointer NSBundle)) 16 | (c-define-type NSImage "NSImage") 17 | (c-define-type NSImage* (pointer NSImage)) 18 | 19 | ;;;; Quartz 20 | 21 | (c-define-type CGFloat float) 22 | (c-define-type CGPoint "CGPoint") 23 | (c-define-type CGPoint* (pointer CGPoint)) 24 | (c-define-type CGSize "CGSize") 25 | (c-define-type CGSize* (pointer CGSize)) 26 | (c-define-type CGRect "CGRect") 27 | (c-define-type CGRect* (pointer CGRect)) 28 | (c-define-type CGImageRef "CGImageRef") 29 | 30 | -------------------------------------------------------------------------------- /lib/ffi/osx.scm: -------------------------------------------------------------------------------- 1 | ;;;; "osx ffis" 2 | ;;; Implements datatypes and procedures for interacting with OS X 3 | ;;; APIs. 4 | 5 | (c-declare "#import ") 6 | 7 | (include "osx#.scm") 8 | 9 | ;;; NSArray 10 | 11 | (define (NSArray->list arr) 12 | (let ((len (NSArray-length arr))) 13 | (unfold (lambda (i) (>= i len)) 14 | (lambda (i) (NSArray-ref arr i)) 15 | (lambda (i) (+ i 1)) 16 | 0))) 17 | 18 | (define NSArray-length 19 | (c-lambda (NSArray*) int "___result = [___arg1 count];")) 20 | 21 | (define NSArray-ref 22 | (c-lambda (NSArray* int) id #<NSArray 32 | (c-lambda (NSSet*) NSArray* "___result_voidstar = [___arg1 allObjects];")) 33 | 34 | (define (NSSet->list set) 35 | (NSArray->list (NSSet->NSArray set))) 36 | 37 | ;;; NSString 38 | 39 | (define make-NSString 40 | (c-lambda (char-string) NSString* 41 | "___result = [[NSString alloc] initWithCString:___arg1 encoding:NSASCIIStringEncoding];")) 42 | 43 | (define NSString-get-ascii-c-string 44 | (c-lambda (NSString*) char-string #<= i (vector-length numbers)) 19 | #t 20 | (let ((n1 (vector-ref numbers i)) 21 | (n2 (vector-ref numbers (+ i 1))) 22 | (orig-n (vector-ref numbers (+ i 2))) 23 | (ray-n (vector-ref numbers (+ i 3)))) 24 | (if (and (eq? ray-n 0.) 25 | (or (< orig-n n1) 26 | (> orig-n n2))) 27 | #f 28 | (let ((t1 (/ (- n1 orig-n) ray-n)) 29 | (t2 (/ (- n2 orig-n) ray-n))) 30 | (let ((t1 (min t1 t2)) 31 | (t2 (max t1 t2))) 32 | (if (or (not tnear) 33 | (> t1 tnear)) 34 | (set! tnear t1)) 35 | (if (or (not tfar) 36 | (< t2 tfar)) 37 | (set! tfar t2)) 38 | (if (or (> tnear tfar) 39 | (< tfar 0)) 40 | #f 41 | (loop (+ i 4))))))))))) 42 | 43 | 44 | 45 | ;; (ray-box-intersection 46 | ;; 5. 5. 5. 47 | ;; 10. 10. 10. 48 | ;; 0. 0. 0. 49 | ;; 1. 1. 1. 50 | ;; ) => #t 51 | 52 | ;; (ray-box-intersection 53 | ;; 5. 5. 5. 54 | ;; 10. 10. 10. 55 | ;; 0. 0. 0. 56 | ;; 10. 5. 10. 57 | ;; ) => #t 58 | 59 | ;; (ray-box-intersection 60 | ;; 5. 5. 5. 61 | ;; 10. 10. 10. 62 | ;; 0. 0. 0. 63 | ;; 10. 4.99 10. 64 | ;; ) => #f 65 | 66 | ;; (ray-box-intersection 67 | ;; -5. -10. -10. 68 | ;; 5. 10. 10. 69 | ;; 0. 0. 0. 70 | ;; -1. 1. 1. 71 | ;; ) => #t 72 | 73 | ;; (ray-box-intersection 74 | ;; -5. 2. 5. 75 | ;; 5. 10. 10. 76 | ;; 0. 0. 0. 77 | ;; -5. 2. 5. 78 | ;; ) => #f 79 | 80 | ;; (ray-box-intersection 81 | ;; -5. 2. 5. 82 | ;; 5. 10. 10. 83 | ;; 0. 0. 0. 84 | ;; -5. 2. 4.999 85 | ;; ) => #f 86 | -------------------------------------------------------------------------------- /lib/obj-loader.scm: -------------------------------------------------------------------------------- 1 | 2 | (declare (block) 3 | (standard-bindings) 4 | (extended-bindings)) 5 | 6 | ;; ---------------------------------------- 7 | ;; vertices & triangles 8 | ;; ---------------------------------------- 9 | (define-type vector3d 10 | id: 863A066E-B9D4-493E-8E6E-AF72A7208C88 11 | x y z) 12 | 13 | (define-type triangle 14 | id: E82033E8-B6F3-4ECD-8162-ED8DDC6079D6 15 | v1 v2 v3) 16 | 17 | (define-type obj-data 18 | id: 5582EB25-5587-49F7-93E2-FA13DC2CD207 19 | constructor: really-make-obj-data 20 | vertices 21 | vertices-finalized 22 | triangles 23 | triangles-finalized) 24 | 25 | (define (make-obj-data) 26 | (really-make-obj-data '() #f '() #f)) 27 | 28 | (define (push-vertex mesh vx) 29 | (obj-data-vertices-set! 30 | mesh 31 | (cons vx (obj-data-vertices mesh)))) 32 | 33 | (define (push-triangle mesh triangle) 34 | (obj-data-triangles-set! 35 | mesh 36 | (cons triangle (obj-data-triangles mesh)))) 37 | 38 | (define (push-face mesh face) 39 | (define (get-vertex i) 40 | (vector-ref (obj-data-vertices mesh) 41 | (- (vector-ref face i) 1))) 42 | 43 | (finalize-vertices mesh) 44 | (push-triangle mesh 45 | (make-triangle (get-vertex 0) 46 | (get-vertex 1) 47 | (get-vertex 2))) 48 | (if (= (vector-length face) 4) 49 | (push-triangle 50 | mesh 51 | (make-triangle (get-vertex 0) 52 | (get-vertex 2) 53 | (get-vertex 3))))) 54 | 55 | (define (finalize-vertices mesh) 56 | (if (not (obj-data-vertices-finalized mesh)) 57 | (begin 58 | (obj-data-vertices-set! 59 | mesh 60 | (list->vector (reverse (obj-data-vertices mesh)))) 61 | (obj-data-vertices-finalized-set! mesh #t)))) 62 | 63 | (define (finalize-triangles mesh) 64 | (if (not (obj-data-triangles-finalized mesh)) 65 | (begin 66 | (obj-data-triangles-set! 67 | mesh 68 | (reverse (obj-data-triangles mesh))) 69 | (obj-data-triangles-finalized-set! mesh #t)))) 70 | 71 | ;; ---------------------------------------- 72 | ;; obj file parsing 73 | ;; ---------------------------------------- 74 | (define (maybe-cdr lst) 75 | (if lst (cdr lst) lst)) 76 | 77 | (define (read-next-declaration) 78 | (if (eq? (peek-char) #\#) 79 | #f 80 | (let ((token (read (current-input-port)))) 81 | (maybe-cdr (assq token 82 | '((v . vertex) 83 | (f . face) 84 | (usemtl . usemtl))))))) 85 | 86 | (define (read-next-vertex mesh) 87 | (let ((x (exact->inexact (read))) 88 | (y (exact->inexact (read))) 89 | (z (exact->inexact (read)))) 90 | (push-vertex mesh (make-vector3d x y z)))) 91 | 92 | (define (read-next-face mesh) 93 | (define (read-all-vertices) 94 | (let loop ((acc '())) 95 | (if (eq? (peek-char) #\newline) 96 | (reverse acc) 97 | (loop (cons (read) acc))))) 98 | 99 | (let* ((vertices (list->vector (read-all-vertices))) 100 | (num (vector-length vertices))) 101 | (if (and (not (= num 3)) 102 | (not (= num 4))) 103 | (raise "Invalid number of vertices for this face")) 104 | (push-face mesh vertices))) 105 | 106 | (define (read-next-line mesh) 107 | (let ((type (read-next-declaration))) 108 | (case type 109 | ((vertex) (read-next-vertex mesh)) 110 | ((face) (read-next-face mesh)) 111 | ((mtlswitch) (read-next-mtlswitch mesh)))) 112 | (let ((next (peek-char))) 113 | (if (eq? next #!eof) 114 | #f 115 | (begin 116 | (if (not (eq? next #\newline)) 117 | (read-line)) 118 | #t)))) 119 | 120 | (define (obj-file-loop) 121 | (let ((mesh (make-obj-data))) 122 | (let loop () 123 | (if (read-next-line mesh) 124 | (loop) 125 | (begin 126 | (finalize-triangles mesh) 127 | mesh))))) 128 | 129 | (define (obj-load file) 130 | (with-input-from-file file 131 | (lambda () 132 | (obj-file-loop)))) 133 | -------------------------------------------------------------------------------- /lib/obj-loader2.scm: -------------------------------------------------------------------------------- 1 | 2 | (declare (block) 3 | (standard-bindings) 4 | (extended-bindings)) 5 | 6 | ;;;; util 7 | 8 | (define (read-map #!optional f) 9 | (unfold (lambda (x) (eof-object? x)) 10 | (lambda (x) (if f (f x) x)) 11 | (lambda (x) (read)) 12 | (read))) 13 | 14 | (define (enforce-length name len lst) 15 | (if (eq? (length lst) len) 16 | lst 17 | (error name "assert-length failed"))) 18 | 19 | ;;;; materials 20 | 21 | (define-type material 22 | id: 7A56AB3B-C6D4-4C8C-9BB8-9845CFE1CF07 23 | constructor: really-make-material 24 | ambient 25 | diffuse 26 | specular) 27 | 28 | (define (make-material) 29 | (really-make-material #f #f #f)) 30 | 31 | (define (mtl-parse-ambient) 32 | (apply make-vec3d 33 | (enforce-length "ambient" 3 (read-map exact->inexact)))) 34 | 35 | (define (mtl-parse-diffuse) 36 | (apply make-vec3d 37 | (enforce-length "diffuse" 3 (read-map exact->inexact)))) 38 | 39 | (define (mtl-parse-specular) 40 | (apply make-vec3d 41 | (enforce-length "specular" 3 (read-map exact->inexact)))) 42 | 43 | (define (mtl-parse-line mtls mtl-name line) 44 | (with-input-from-string line 45 | (lambda () 46 | (let* ((type (read)) 47 | (name mtl-name) 48 | (mtl (table-ref mtls name #f))) 49 | (case type 50 | ((newmtl) 51 | (let ((new-name (read))) 52 | (table-set! mtls new-name (make-material)) 53 | (set! name new-name))) 54 | ((Ka) (material-ambient-set! mtl (mtl-parse-ambient))) 55 | ((Kd) (material-diffuse-set! mtl (mtl-parse-diffuse))) 56 | ((Ks) (material-specular-set! mtl (mtl-parse-specular)))) 57 | name)))) 58 | 59 | (define (mtl-load file) 60 | (let ((file (string-append file ".mtl"))) 61 | (if (file-exists? file) 62 | (with-input-from-file file 63 | (lambda () 64 | (let ((mtls (make-table))) 65 | (let loop ((current-mat #f)) 66 | (let ((line (read-line))) 67 | (if (not (eof-object? line)) 68 | (begin 69 | (loop (mtl-parse-line mtls 70 | current-mat 71 | line)))))) 72 | mtls))) 73 | (make-table)))) 74 | 75 | ;;;; objects 76 | 77 | (define-type bounding-box 78 | id: 5F2D3F2A-BCE3-40B0-992C-F665CBA4B68F 79 | constructor: really-make-bounding-box 80 | min-x 81 | max-x 82 | min-y 83 | max-y 84 | min-z 85 | max-z) 86 | 87 | (define-type obj-chunk 88 | id: 9B813D93-5965-432C-AF69-31955C9D9506 89 | constructor: really-make-obj-chunk 90 | num-indices 91 | indices 92 | mat) 93 | 94 | (define-type obj 95 | id: 8E600AD2-9106-405C-82DF-0D700BE0E5D9 96 | constructor: really-make-obj 97 | num-vertices 98 | vertices 99 | normals 100 | chunks 101 | bounding-box) 102 | 103 | (define (make-bounding-box) 104 | (really-make-bounding-box 0. 0. 0. 0. 0. 0.)) 105 | 106 | (define (make-chunk mat) 107 | (really-make-obj-chunk #f '() mat)) 108 | 109 | (define (make-obj) 110 | (really-make-obj #f '() '() '() (make-bounding-box))) 111 | 112 | (define (obj-parse-vertex) 113 | (enforce-length "vertex" 3 (read-map exact->inexact))) 114 | 115 | (define (obj-parse-normal) 116 | (let ((v (vec3d-unit 117 | (apply make-vec3d 118 | (enforce-length "normal" 3 119 | (read-map exact->inexact)))))) 120 | (list (vec3d-x v) (vec3d-y v) (vec3d-z v)))) 121 | 122 | (define (obj-parse-face) 123 | (enforce-length "face" 3 (read-map (lambda (n) (- n 1))))) 124 | 125 | (define (update-bounding-box obj x y z) 126 | (let ((box (obj-bounding-box obj))) 127 | (if (< x (bounding-box-min-x box)) 128 | (bounding-box-min-x-set! box x) 129 | (if (> x (bounding-box-max-x box)) 130 | (bounding-box-max-x-set! box x))) 131 | 132 | (if (< y (bounding-box-min-y box)) 133 | (bounding-box-min-y-set! box y) 134 | (if (> y (bounding-box-max-y box)) 135 | (bounding-box-max-y-set! box y))) 136 | 137 | (if (< z (bounding-box-min-z box)) 138 | (bounding-box-min-z-set! box z) 139 | (if (> z (bounding-box-max-x box)) 140 | (bounding-box-max-z-set! box z))))) 141 | 142 | (define (obj-parse-line obj chunk mtls line) 143 | (define (appendd lst lst2) 144 | (append (reverse lst) lst2)) 145 | 146 | (with-input-from-string line 147 | (lambda () 148 | (let ((type (read))) 149 | (case type 150 | ((v) 151 | (let ((v (obj-parse-vertex))) 152 | (apply update-bounding-box (cons obj v)) 153 | (obj-vertices-set! 154 | obj 155 | (appendd v (obj-vertices obj))))) 156 | ((vn) 157 | (obj-normals-set! 158 | obj 159 | (appendd (obj-parse-normal) 160 | (obj-normals obj)))) 161 | ((f) 162 | (obj-chunk-indices-set! 163 | chunk 164 | (appendd (obj-parse-face) 165 | (obj-chunk-indices chunk)))) 166 | ((usemtl) 167 | (let ((name (read))) 168 | (table-ref mtls name #f)))))))) 169 | 170 | (define (flip-and-vectorize data) 171 | (list->vector (reverse data))) 172 | 173 | (define (obj-finalize obj avoid-c-vectors?) 174 | (if (not avoid-c-vectors?) 175 | (begin 176 | (obj-num-vertices-set! obj (length (obj-vertices obj))) 177 | (obj-vertices-set! obj (flip-and-vectorize (obj-vertices obj))) 178 | (obj-normals-set! obj (flip-and-vectorize (obj-normals obj))) 179 | (obj-vertices-set! obj 180 | (vector->float-array (obj-vertices obj))) 181 | (obj-normals-set! obj 182 | (vector->float-array (obj-normals obj)))))) 183 | 184 | (define (obj-chunk-finalize chunk avoid-c-vectors?) 185 | (if (not avoid-c-vectors?) 186 | (begin 187 | (obj-chunk-num-indices-set! chunk (length (obj-chunk-indices chunk))) 188 | (obj-chunk-indices-set! chunk (flip-and-vectorize 189 | (obj-chunk-indices chunk))) 190 | (obj-chunk-indices-set! chunk 191 | (vector->unsigned-int16-array (obj-chunk-indices chunk)))))) 192 | 193 | (define (obj-load file #!optional compressed? avoid-c-vectors?) 194 | (if compressed? 195 | (let ((mesh (decompress (string-append file ".obj.gso")))) 196 | (for-each (lambda (el) 197 | (obj-chunk-finalize el avoid-c-vectors?)) 198 | (obj-chunks mesh)) 199 | (obj-finalize mesh avoid-c-vectors?) 200 | mesh) 201 | (with-input-from-file (string-append file ".obj") 202 | (lambda () 203 | (let ((mesh (make-obj)) 204 | (mtls (mtl-load file))) 205 | (let loop ((acc '()) 206 | (chunk (make-chunk #f))) 207 | (let ((line (read-line))) 208 | (if (not (eof-object? line)) 209 | (let ((res (obj-parse-line mesh chunk mtls line))) 210 | (if (material? res) 211 | (begin 212 | (obj-chunk-finalize chunk avoid-c-vectors?) 213 | (loop (cons chunk acc) 214 | (make-chunk res))) 215 | (loop acc chunk))) 216 | (begin 217 | (obj-chunk-finalize chunk avoid-c-vectors?) 218 | (obj-chunks-set! mesh (cons chunk acc)))))) 219 | (obj-finalize mesh avoid-c-vectors?) 220 | mesh))))) 221 | 222 | ;;;; compressor 223 | 224 | (define (compress filename mesh) 225 | (with-output-to-file filename 226 | (lambda () 227 | (let* ((v (object->u8vector mesh)) 228 | (len (u8vector-length v)) 229 | (len-u8 (object->u8vector len)) 230 | (boot (u8vector-length len-u8))) 231 | (write-u8 boot) 232 | (write-subu8vector len-u8 0 boot) 233 | (write-subu8vector v 0 (u8vector-length v)))))) 234 | 235 | (define (decompress filename) 236 | (with-input-from-file filename 237 | (lambda () 238 | (let* ((boot (read-u8)) 239 | (len-u8 (make-u8vector boot))) 240 | (read-subu8vector len-u8 0 boot) 241 | (let* ((len (u8vector->object len-u8)) 242 | (v (make-u8vector len))) 243 | (read-subu8vector v 0 len) 244 | (u8vector->object v)))))) 245 | -------------------------------------------------------------------------------- /lib/physics.scm: -------------------------------------------------------------------------------- 1 | ;;;; "phyics" 2 | ;;; Basic physics system involving velocity & acceleration 3 | 4 | (declare (block) 5 | (standard-bindings) 6 | (extended-bindings)) 7 | 8 | (define GRAVITY (make-vec3d 0. -25. 0.)) 9 | 10 | (define (update-physics obj) 11 | (let* ((now (real-time)) 12 | (last (or (scene-object-%%last-update obj) now)) 13 | (change (- now last))) 14 | (apply-acceleration obj change) 15 | (apply-velocity obj change) 16 | (scene-object-%%last-update-set! obj now))) 17 | 18 | (define (apply-acceleration obj change) 19 | (let ((velocity (scene-object-velocity obj))) 20 | (if velocity 21 | (let* ((acceleration (global-acceleration obj)) 22 | (change (vec3d-scalar-mul acceleration change))) 23 | (scene-object-velocity-set! 24 | obj 25 | (vec3d-add (scene-object-velocity obj) 26 | change)))))) 27 | 28 | (define (apply-velocity obj change) 29 | (let ((velocity (scene-object-velocity obj))) 30 | (if velocity 31 | (let ((change (vec3d-scalar-mul velocity change))) 32 | (scene-object-position-set! 33 | obj 34 | (vec3d-add (scene-object-position obj) 35 | change)))))) 36 | 37 | (define (global-acceleration obj) 38 | ;; apply gravity 39 | (let ((accel (scene-object-acceleration obj))) 40 | (if accel 41 | (vec3d-add accel GRAVITY) 42 | GRAVITY))) 43 | 44 | (define (kick v) 45 | (for-each (lambda (el) 46 | (if (scene-object-velocity el) 47 | (scene-object-velocity-set! 48 | el 49 | (vec3d-add v (scene-object-velocity el))))) 50 | scene-list)) 51 | -------------------------------------------------------------------------------- /lib/resource.scm: -------------------------------------------------------------------------------- 1 | ;;;; "resources" 2 | ;;; This file implements two ways of finding resources: one calls into 3 | ;;; Cocoa to find the resource path of the current bundle, and the 4 | ;;; other depends on "config.scm" to define a variable named "root". 5 | ;;; 6 | ;;; The former seems more scalable, but it requires up to deploy all of 7 | ;;; our resources like Xcode, which is annoying, so we choose the 8 | ;;; latter. 9 | 10 | (define (resource path) 11 | (let ((base (NSBundle-resource-path (NSBundle-main-bundle)))) 12 | (string-append base "/" path))) 13 | 14 | (include "config.scm") 15 | 16 | (define (local-resource path) 17 | (string-append root "/" path)) 18 | -------------------------------------------------------------------------------- /lib/scene.scm: -------------------------------------------------------------------------------- 1 | ;;;; "scene" 2 | ;;; Functionality for organizing data in a scene in a heirarchal 3 | ;;; order and rendering it 4 | 5 | ;; (define-class Scene-Object Object 6 | ;; (mesh 7 | ;; (= color :maybe-uninitialized) 8 | ;; (= position :initializer (lambda () (make-vec3d 0. 0. 0.))) 9 | ;; (= rotation :initializer (lambda () (make-vec4d 0. 0. 0. 0.))) 10 | ;; (= scale :initializer (lambda () (make-vec3d 1. 1. 1.))))) 11 | 12 | ;; (define-class Physics-Object Scene-Object 13 | ;; (= velocity :initialize (lambda () (make-vec3d 0. 0. 0.))) 14 | ;; (= acceleration :initialize (lambda () (make-vec3d 0. 0. 0.))) 15 | ;; (= updater :initialize ) 16 | ;; (= %%last-update :initializer (lambda () #f))) 17 | 18 | (declare (block) 19 | (standard-bindings) 20 | (extended-bindings)) 21 | 22 | (define-type scene-object 23 | constructor: really-make-scene-object 24 | mesh 25 | color 26 | position 27 | rotation 28 | radius 29 | velocity 30 | acceleration 31 | callback 32 | %%last-update 33 | data 34 | voice-source 35 | thud-source) 36 | 37 | (define (make-scene-object mesh color pos #!optional rot scale vel accel update data) 38 | (really-make-scene-object mesh color pos rot scale vel accel 39 | (or update (lambda (el) #t)) 40 | #f 41 | data 42 | #f 43 | #f)) 44 | 45 | (define scene-list '()) 46 | 47 | (define (scene-list-clear) 48 | (set! scene-list '())) 49 | 50 | (define (scene-list-add obj) 51 | (set! scene-list (cons obj scene-list))) 52 | 53 | (define (scene-list-update #!optional update-fn) 54 | (set! scene-list 55 | (fold (lambda (el acc) 56 | (if ((scene-object-callback el) el) 57 | (begin 58 | ((or update-fn values) el) 59 | (cons el acc)) 60 | acc)) 61 | '() 62 | scene-list))) 63 | 64 | (define (scene-list->render-queue) 65 | (map (lambda (el) 66 | (lambda () 67 | (let ((mesh (scene-object-mesh el)) 68 | (color (scene-object-color el)) 69 | (pos (scene-object-position el)) 70 | (rot (scene-object-rotation el)) 71 | (vel (scene-object-velocity el)) 72 | (radius (scene-object-radius el))) 73 | 74 | (glVertexPointer 3 GL_FLOAT 0 (obj-vertices mesh)) 75 | (glEnableClientState GL_VERTEX_ARRAY) 76 | (glNormalPointer GL_FLOAT 0 (->void-array (obj-normals mesh))) 77 | (glEnableClientState GL_NORMAL_ARRAY) 78 | 79 | (reset-camera) 80 | 81 | (if color 82 | (begin 83 | (glMaterialfv GL_FRONT_AND_BACK 84 | GL_DIFFUSE 85 | (vector->float-array 86 | (vector 87 | (vec3d-x color) 88 | (vec3d-y color) 89 | (vec3d-z color) 90 | 1.))) 91 | (glColor4f (vec3d-x color) 92 | (vec3d-y color) 93 | (vec3d-z color) 94 | 1.))) 95 | 96 | (if pos 97 | (glTranslatef (vec3d-x pos) (vec3d-y pos) (vec3d-z pos))) 98 | 99 | (if rot 100 | (glRotatef (vec4d-w rot) 101 | (vec4d-x rot) 102 | (vec4d-y rot) 103 | (vec4d-z rot))) 104 | 105 | (if radius 106 | (glScalef radius radius radius)) 107 | 108 | (for-each (lambda (chunk) 109 | (if (obj-chunk-mat chunk) 110 | (let* ((mat (obj-chunk-mat chunk)) 111 | (d (material-diffuse mat))) 112 | (glMaterialfv GL_FRONT_AND_BACK 113 | GL_DIFFUSE 114 | (vector->float-array 115 | (vector 116 | (vec3d-x d) (vec3d-y d) (vec3d-z d) 117 | 1.))) 118 | (glColor4f (vec3d-x d) 119 | (vec3d-y d) 120 | (vec3d-z d) 121 | 1.))) 122 | (if (not (null? (obj-chunk-indices chunk))) 123 | (glDrawElements GL_TRIANGLES 124 | (obj-chunk-num-indices chunk) 125 | GL_UNSIGNED_SHORT 126 | (->void-array (obj-chunk-indices chunk))))) 127 | (obj-chunks mesh)) 128 | 129 | (glDisableClientState GL_NORMAL_ARRAY)))) 130 | scene-list)) 131 | 132 | ;;;;; render queue 133 | (define (run-render-queue rq) 134 | (for-each (lambda (el) (el)) rq)) 135 | -------------------------------------------------------------------------------- /lib/test.scm: -------------------------------------------------------------------------------- 1 | 2 | 3 | (include "util/remote-debugger/debuggee.scm") 4 | (rdi-set-host! "127.0.0.1:20000") 5 | 6 | ;(##repl-debug-main) 7 | -------------------------------------------------------------------------------- /lib/texture.scm: -------------------------------------------------------------------------------- 1 | 2 | (declare (block) 3 | (standard-bindings) 4 | (extended-bindings)) 5 | 6 | (include "ffi/ffi#.scm") 7 | 8 | (define (alloc-opengl-image) 9 | (with-alloc (img (make-unsigned-int-array 1)) 10 | (glGenTextures 1 img) 11 | (unsigned-int-array-ref img 0))) 12 | 13 | (define (image-opengl-upload data width height) 14 | (let ((tex (alloc-opengl-image))) 15 | (glBindTexture GL_TEXTURE_2D tex) 16 | (glTexEnvi GL_TEXTURE_ENV GL_TEXTURE_ENV_MODE GL_MODULATE) 17 | (glTexImage2D GL_TEXTURE_2D 18 | 0 19 | GL_RGBA 20 | width 21 | height 22 | 0 23 | GL_RGBA 24 | GL_UNSIGNED_BYTE 25 | (->void-array data)) 26 | (glTexParameteri GL_TEXTURE_2D 27 | GL_TEXTURE_MIN_FILTER 28 | GL_LINEAR) 29 | (glTexParameteri GL_TEXTURE_2D 30 | GL_TEXTURE_MAG_FILTER 31 | GL_LINEAR) 32 | (glTexParameteri GL_TEXTURE_2D 33 | GL_TEXTURE_WRAP_S 34 | GL_CLAMP_TO_EDGE) 35 | (glTexParameteri GL_TEXTURE_2D 36 | GL_TEXTURE_WRAP_T 37 | GL_CLAMP_TO_EDGE) 38 | (glBindTexture GL_TEXTURE_2D 0) 39 | tex)) 40 | 41 | (define square-pos 42 | (vector->float-array (vector 0. 0. 43 | 0. 1. 44 | 1. 0. 45 | 1. 1.))) 46 | 47 | (define square-texcoords 48 | (->void-array 49 | (vector->float-array (vector 0. 0. 50 | 0. 1. 51 | 1. 0. 52 | 1. 1.)))) 53 | 54 | (define (image-render tex) 55 | (glBindTexture GL_TEXTURE_2D tex) 56 | 57 | (glEnable GL_TEXTURE_2D) 58 | (glDisable GL_DEPTH_TEST) 59 | (glDisable GL_LIGHTING) 60 | 61 | (glVertexPointer 2 GL_FLOAT 0 square-pos) 62 | (glEnableClientState GL_VERTEX_ARRAY) 63 | 64 | (glTexCoordPointer 2 GL_FLOAT 0 square-texcoords) 65 | (glEnableClientState GL_TEXTURE_COORD_ARRAY) 66 | 67 | (glDrawArrays GL_TRIANGLE_STRIP 0 4) 68 | 69 | (glDisableClientState GL_TEXTURE_COORD_ARRAY) 70 | (glEnable GL_DEPTH_TEST) 71 | (glDisable GL_TEXTURE_2D) 72 | (glEnable GL_LIGHTING)) 73 | -------------------------------------------------------------------------------- /lib/util-3d.scm: -------------------------------------------------------------------------------- 1 | 2 | (define line (vector->float-array (vector 0. 0. 0. 3 | 1. 0. 0.))) 4 | 5 | (define (render-grid grid-size) 6 | (define (draw) 7 | (glScalef grid-size 0. 0.) 8 | (glDrawArrays GL_LINES 0 2)) 9 | 10 | (define offset (/ grid-size 2.)) 11 | 12 | (define (render-lines) 13 | (unfold (lambda (i) (> i grid-size)) 14 | (lambda (i) 15 | (reset-camera) 16 | ;;(glRotatef 45. 1. 0. 0.) 17 | (glTranslatef (- offset) -5. (- (exact->inexact i) offset)) 18 | (draw)) 19 | (lambda (i) (+ i 1)) 20 | 0) 21 | 22 | (unfold (lambda (i) (> i grid-size)) 23 | (lambda (i) 24 | (reset-camera) 25 | ;;(glRotatef 45. 0. 0. 0.) 26 | (glTranslatef (- (exact->inexact i) offset) -5. (- offset)) 27 | (glRotatef -90. 0. 1. 0.) 28 | (draw)) 29 | (lambda (i) (+ i 1)) 30 | 0)) 31 | 32 | (glDisable GL_LIGHTING) 33 | (glVertexPointer 3 GL_FLOAT 0 line) 34 | (glEnableClientState GL_VERTEX_ARRAY) 35 | (glColor4f 0. 1. 0. 1.) 36 | (render-lines) 37 | (glEnable GL_LIGHTING)) 38 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/README: -------------------------------------------------------------------------------- 1 | You need to run this example in Mac OS X, from 2 xterms. 2 | 3 | In xterm #1 start the debugger by entering: 4 | 5 | % gsi -:dar,h10000 debugger.scm 20000 6 | 7 | In xterm #2 start the debuggee by entering: 8 | 9 | % gsi -:dar,h10000 debuggee.scm 10 | 11 | This will pop up a new xterm (#3) which has the main Gambit REPL. 12 | 13 | In xterm #3 you can try to evaluate expressions, and errors. If the 14 | error is in a different thread then a new xterm will pop up for that 15 | thread's REPL. For example: 16 | 17 | Gambit v4.2.8 18 | 19 | > (expt 2 100) 20 | 1267650600228229401496703205376 21 | > (+ 1 xx) 22 | *** ERROR IN (console)@2.6 -- Unbound variable: xx 23 | 1> (thread-start! (make-thread (lambda () (* 2 yy)))) 24 | # 25 | 1> 26 | 27 | The opening of a window for new REPLs is meant to model the IDE which will 28 | create a new tab, a new error list item, etc 29 | 30 | debuggee.scm calls ##repl-debug-main to start the REPL automatically. 31 | You can remove this and include debuggee.scm somewhere else if you 32 | want to embed it. Also, in your client application, you can configure 33 | where the server is running by calling rdi-set-host! with the 34 | host/port as a string or the port as an integer, e.g. 35 | "localhost:20000" or 20000. If just the port is given, the host 36 | defaults to localhost. 37 | 38 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/debuggee.scm: -------------------------------------------------------------------------------- 1 | ;;; File: "debuggee.scm" 2 | 3 | (include "rdi.scm") 4 | 5 | ;;;----------------------------------------------------------------------------- 6 | 7 | (define rdi #f) 8 | 9 | (define (make-rdi-host host) 10 | (set! rdi (rdi-create-client host))) 11 | 12 | (define (rdi-function fn) 13 | (case fn 14 | ((console-input) 15 | rdi-console-input) 16 | (else 17 | (error "unknown function")))) 18 | 19 | ;;;----------------------------------------------------------------------------- 20 | 21 | (define rdi-console-table (make-table)) 22 | 23 | (define (rdi-console-input console-id input) 24 | (let ((remote-port 25 | (table-ref rdi-console-table console-id #f))) 26 | (if remote-port 27 | (begin 28 | (display input remote-port) 29 | (force-output remote-port)))) 30 | #t) 31 | 32 | (define (read-substring-blocking-for-1 str start end port) 33 | (if (< start end) 34 | (begin 35 | (input-port-timeout-set! port +inf.0) ;; block for the first byte 36 | (let ((n (read-substring str start (+ start 1) port))) 37 | (input-port-timeout-set! port -inf.0) ;; don't block for the rest 38 | (if (= n 1) 39 | (+ 1 (read-substring str (+ start 1) end port)) 40 | n))) 41 | 0)) 42 | 43 | (define (rdi-console-output-pump-start! console-id remote-port) 44 | (thread-start! 45 | (make-thread 46 | (lambda () 47 | (let* ((buflen 1000) 48 | (buf (make-string buflen))) 49 | (let loop () 50 | (let ((n (read-substring-blocking-for-1 buf 0 buflen remote-port))) 51 | (if (> n 0) 52 | (begin 53 | (rdi-remote-call rdi 54 | 'console-output 55 | console-id 56 | (substring buf 0 n)) 57 | (loop)))))))))) 58 | 59 | (define (rdi-register-console thread remote-port) 60 | (let ((console-id (object->serial-number thread))) 61 | (table-set! rdi-console-table console-id remote-port) 62 | (rdi-remote-call rdi 'register-console console-id) 63 | (rdi-console-output-pump-start! console-id remote-port))) 64 | 65 | (define (make-repl-channel-remote-port thread) 66 | (receive (local-port remote-port) (open-string-pipe) 67 | (begin 68 | 69 | ;; Hack... set the name of the port to pretend it is the "console" 70 | (##vector-set! local-port 4 (lambda (port) '(console))) 71 | 72 | (rdi-register-console thread remote-port) 73 | local-port))) 74 | 75 | (define open-dummy-console? #t) 76 | 77 | (define (thread-make-repl-channel-remote thread) 78 | (with-exception-catcher 79 | (lambda (e) 80 | (let ((i (open-input-string "")) 81 | (o (open-output-string))) 82 | (##make-repl-channel-ports i o))) 83 | (lambda () 84 | (let ((local-port (make-repl-channel-remote-port thread))) 85 | (##make-repl-channel-ports local-port local-port))))) 86 | 87 | (set! ##thread-make-repl-channel 88 | thread-make-repl-channel-remote) 89 | 90 | ;;;----------------------------------------------------------------------------- 91 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/debugger.scm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gsi-script 2 | 3 | ;;; File: "debugger.scm" 4 | 5 | (include "rdi.scm") 6 | 7 | ;;;---------------------------------------------------------------------------- 8 | 9 | (define console-window-num 0) 10 | 11 | (define (new-console-window-num) 12 | (let ((x (+ console-window-num 1))) 13 | (set! console-window-num x) 14 | x)) 15 | 16 | (define (open-console-window console-id) 17 | (let ((tcp-port (+ 9000 (new-console-window-num)))) 18 | (pp `(grime-open-client ,console-id ,tcp-port)) 19 | ;; (let ((window 20 | ;; (open-process 21 | ;; (list path: "xterm" 22 | ;; arguments: (list "-e" 23 | ;; "gsi" 24 | ;; "pump.scm" 25 | ;; (numbqer->string tcp-port))))))) 26 | (let loop () 27 | (let ((port 28 | (with-exception-catcher 29 | (lambda (e) 30 | #f) 31 | (lambda () 32 | (let ((port (open-tcp-client 33 | (list server-address: "localhost" 34 | port-number: tcp-port)))) 35 | (tcp-client-peer-socket-info port) 36 | port))))) 37 | (if (not port) 38 | (begin 39 | (thread-sleep! .1) ;; wait until the pump starts 40 | (loop)) 41 | port))))) 42 | 43 | ;;;----------------------------------------------------------------------------- 44 | 45 | (define rdi #f) 46 | 47 | (define (rdi-function fn) 48 | (case fn 49 | ((register-console) 50 | rdi-register-console) 51 | ((console-output) 52 | rdi-console-output) 53 | (else 54 | (error "unknown function")))) 55 | 56 | (define (main #!optional port) 57 | (set! rdi (rdi-create-server (and port (string->number port)))) 58 | (rdi-force-connection rdi)) 59 | 60 | ;;;----------------------------------------------------------------------------- 61 | 62 | (define rdi-console-table (make-table)) 63 | 64 | (define (rdi-register-console console-id) 65 | (let ((console-port (open-console-window console-id))) 66 | (table-set! rdi-console-table console-id console-port) 67 | (rdi-console-input-pump-start! console-id console-port) 68 | #f)) 69 | 70 | (define (rdi-console-output console-id output) 71 | (let ((console-port 72 | (table-ref rdi-console-table console-id #f))) 73 | (if console-port 74 | (begin 75 | (display output console-port) 76 | (force-output console-port)))) 77 | #t) 78 | 79 | (define (read-substring-blocking-for-1 str start end port) 80 | (if (< start end) 81 | (begin 82 | (input-port-timeout-set! port +inf.0) ;; block for the first byte 83 | (let ((n (read-substring str start (+ start 1) port))) 84 | (input-port-timeout-set! port -inf.0) ;; don't block for the rest 85 | (if (= n 1) 86 | (+ 1 (read-substring str (+ start 1) end port)) 87 | n))) 88 | 0)) 89 | 90 | (define (rdi-console-input-pump-start! console-id console-port) 91 | (thread-start! 92 | (make-thread 93 | (lambda () 94 | (let* ((buflen 1000) 95 | (buf (make-string buflen))) 96 | (let loop () 97 | (let ((n (read-substring-blocking-for-1 buf 0 buflen console-port))) 98 | (if (> n 0) 99 | (begin 100 | (rdi-remote-call rdi 101 | 'console-input 102 | console-id 103 | (substring buf 0 n)) 104 | (loop)))))))))) 105 | 106 | ;;;----------------------------------------------------------------------------- 107 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/grime: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | where="/Users/james/projects/scheme/gambit-iphone-example/lib/util/remote-debugger" 4 | exec gsi -:dar,h10000 "$where/debugger.scm" "$1" 5 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/grime-client: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | where="/Users/james/projects/scheme/gambit-iphone-example/lib/util/remote-debugger" 4 | exec gsi "$where/pump.scm" "$1" 5 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/grime.el: -------------------------------------------------------------------------------- 1 | 2 | (defun get-grime-process () 3 | (get-process "grime")) 4 | 5 | (defun grime-receive-command (proc string) 6 | (message string) 7 | (grime-display-msg string) 8 | (grime-run-command string)) 9 | 10 | (defun grime-display-msg (str) 11 | (with-current-buffer (process-buffer (get-grime-process)) 12 | (let ((move (= (point) (process-mark proc)))) 13 | (save-excursion 14 | (goto-char (process-mark proc)) 15 | (insert str) 16 | (set-marker (process-mark proc) (point))) 17 | (if move (goto-char (process-mark proc)))))) 18 | 19 | (defun grime-run-command (cmd) 20 | ;; Todo, don't do this 21 | (eval (read cmd))) 22 | 23 | (defun grime-client-buffer-name (id) 24 | (concat "grime-client-" (number-to-string id))) 25 | 26 | (defun grime-open-client (id port) 27 | (let* ((name (grime-client-buffer-name id)) 28 | (buffer-name (concat "*" name "*")) 29 | (master (if (or (get-buffer buffer-name) 30 | (not (grime-any-buffersp))) 31 | (progn 32 | (grime-cleanup) 33 | t) 34 | nil))) 35 | (set-buffer (make-comint name "grime-client" 36 | nil (number-to-string port))) 37 | (inferior-scheme-mode) 38 | (condition-case err 39 | (split-window) 40 | (error (delete-other-windows) (split-window))) 41 | (display-buffer buffer-name) 42 | 43 | (if master (grime-make-scheme-buffer)))) 44 | 45 | (defun grime () 46 | (interactive) 47 | (grime-kill) 48 | (let ((proc (start-process "grime" 49 | "*grime-messages*" 50 | "grime" 51 | "20000"))) 52 | (set-process-filter proc 'grime-receive-command) 53 | (with-current-buffer "*grime-messages*" 54 | (switch-to-buffer (current-buffer)) 55 | (insert "\n\nFinding some grime...\n\n") 56 | (set-marker (process-mark proc) (point)) 57 | (sit-for 1)) 58 | (switch-to-buffer (current-buffer)))) 59 | 60 | (defun grime-make-scheme-buffer () 61 | (interactive) 62 | (setq scheme-buffer (current-buffer))) 63 | 64 | (defun grime-any-buffersp () 65 | (setq res nil) 66 | (dolist (buf (buffer-list) res) 67 | (setq res 68 | (or res 69 | (string-match "grime-client" (buffer-name buf)))))) 70 | 71 | (defun grime-cleanup () 72 | (interactive) 73 | (dolist (buf (buffer-list)) 74 | (if (string-match "grime-client" (buffer-name buf)) 75 | (progn 76 | (if (get-buffer-process buf) 77 | (kill-process (get-buffer-process buf))) 78 | (kill-buffer buf) 79 | (message "killing buffer..."))))) 80 | 81 | (defun grime-kill () 82 | (interactive) 83 | (grime-cleanup) 84 | (let ((proc (get-process "grime"))) 85 | (if proc (kill-process proc))) 86 | (let ((buf (get-buffer "*grime-messages*"))) 87 | (if buf (kill-buffer buf)))) 88 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/pump.scm: -------------------------------------------------------------------------------- 1 | #! 2 | 3 | ;;; File: "pump.scm" 4 | 5 | ;; start like this: 6 | ;; 7 | ;; % xterm gsi -:tE pump.scm 9000 8 | ;; 9 | ;; then 10 | ;; 11 | ;; % telnet localhost 9000 12 | 13 | (define port-num (string->number (cadr (command-line)))) 14 | 15 | (define listen-port (open-tcp-server port-num)) 16 | 17 | (define connection (read listen-port)) 18 | 19 | (define (read-subu8vector-blocking-for-1 u8vect start end port) 20 | (if (< start end) 21 | (begin 22 | (input-port-timeout-set! port +inf.0) ;; block for the first byte 23 | (let ((n (read-subu8vector u8vect start (+ start 1) port))) 24 | (input-port-timeout-set! port -inf.0) ;; don't block for the rest 25 | (if (= n 1) 26 | (+ 1 (read-subu8vector u8vect (+ start 1) end port)) 27 | n))) 28 | 0)) 29 | 30 | (define (copy in out) 31 | (let* ((buflen 1000) 32 | (buf (make-u8vector buflen))) 33 | (let loop () 34 | (let ((n (read-subu8vector-blocking-for-1 buf 0 buflen in))) 35 | (if (> n 0) 36 | (begin 37 | (write-subu8vector buf 0 n out) 38 | (force-output out) 39 | (loop))))))) 40 | 41 | (let ((in (repl-input-port)) 42 | (out (repl-output-port))) 43 | (if (tty? in) 44 | (tty-mode-set! in #f #t #f #f 38400)) ;; disallow ^C 45 | (thread-start! (make-thread (lambda () 46 | (copy connection out) 47 | (exit)))) 48 | (copy in connection)) 49 | -------------------------------------------------------------------------------- /lib/util/remote-debugger/rdi.scm: -------------------------------------------------------------------------------- 1 | ;;; File: "rdi.scm" 2 | 3 | ;;;---------------------------------------------------------------------------- 4 | 5 | (define default-remote-debugger-address "192.168.1.162") 6 | (define default-remote-debugger-port-num 20000) 7 | 8 | (define (rdi-set-host! address) 9 | (set! default-remote-debugger-address address)) 10 | 11 | (define (split-address str) 12 | (call-with-input-string 13 | str 14 | (lambda (port) 15 | (let* ((x (read-all port (lambda (port) (read-line port #\:)))) 16 | (len (length x))) 17 | (cond ((<= len 1) 18 | (cons (if (= len 1) 19 | (car x) 20 | default-remote-debugger-address) 21 | default-remote-debugger-port-num)) 22 | ((= len 2) 23 | (let ((address (car x)) 24 | (port-num (string->number (cadr x) 10))) 25 | (if (and port-num 26 | (exact? port-num) 27 | (integer? port-num) 28 | (>= port-num 1) 29 | (<= port-num 65535)) 30 | (cons (if (string=? address "") 31 | default-remote-debugger-address 32 | address) 33 | port-num) 34 | #f))) 35 | (else 36 | #f)))))) 37 | 38 | ;;;---------------------------------------------------------------------------- 39 | 40 | (define-type rdi 41 | address 42 | port-num 43 | seq-num 44 | call-table 45 | connection 46 | writer-thread 47 | ) 48 | 49 | (define (rdi-create-client remote-debugger-address) 50 | (and remote-debugger-address 51 | (let ((x (split-address remote-debugger-address))) 52 | (if (not x) 53 | (error "invalid remote debugger address") 54 | (let* ((address 55 | (car x)) 56 | (port-num 57 | (cdr x)) 58 | (rdi 59 | (make-rdi 60 | address 61 | port-num 62 | 0 63 | (make-table) 64 | #f 65 | #f)) 66 | (writer-thread 67 | (rdi-create-writer-thread rdi))) 68 | (rdi-writer-thread-set! rdi writer-thread) 69 | (thread-start! writer-thread) 70 | rdi))))) 71 | 72 | (define (rdi-create-server remote-debugger-port-num) 73 | (let* ((address 74 | #f) 75 | (port-num 76 | (or remote-debugger-port-num 77 | default-remote-debugger-port-num)) 78 | (rdi 79 | (make-rdi 80 | address 81 | port-num 82 | 0 83 | (make-table) 84 | #f 85 | #f)) 86 | (writer-thread 87 | (rdi-create-writer-thread rdi))) 88 | (rdi-writer-thread-set! rdi writer-thread) 89 | (thread-start! writer-thread) 90 | rdi)) 91 | 92 | (define (rdi-force-connection rdi) 93 | (or (rdi-connection rdi) 94 | (if (rdi-address rdi) 95 | (rdi-open-client rdi) 96 | (rdi-open-server rdi)))) 97 | 98 | (define rdi-version1 '());(gambit-debuggee-version 0)) 99 | (define rdi-version2 '());(gambit-debugger-version 0)) 100 | 101 | (define (rdi-open-client rdi) 102 | (let ((connection 103 | (open-tcp-client 104 | (list server-address: (rdi-address rdi) 105 | port-number: (rdi-port-num rdi))))) 106 | 107 | (write rdi-version1 connection) 108 | (force-output connection) 109 | 110 | (let ((response (read connection))) 111 | (if (not (equal? response rdi-version2)) 112 | (error "unexpected debugger version") 113 | (let ((reader-thread (rdi-create-reader-thread rdi connection))) 114 | (rdi-connection-set! rdi connection) 115 | (thread-start! reader-thread) 116 | connection))))) 117 | 118 | (define (rdi-open-server rdi) 119 | (let ((listen-port 120 | (open-tcp-server 121 | (list server-address: (string-append "*:" (number->string (rdi-port-num rdi))) 122 | reuse-address: #t)))) 123 | (let loop () 124 | (let ((connection 125 | (read listen-port))) 126 | (let ((request (read connection))) 127 | (if (not (equal? request rdi-version1)) 128 | (error "unexpected debuggee version") 129 | (begin 130 | 131 | (write rdi-version2 connection) 132 | (force-output connection) 133 | 134 | (let ((reader-thread (rdi-create-reader-thread rdi connection))) 135 | (rdi-connection-set! rdi connection) 136 | (thread-start! reader-thread) 137 | (loop))))))))) 138 | 139 | (define (rdi-create-reader-thread rdi connection) 140 | (make-thread 141 | (lambda () 142 | (let loop () 143 | (let ((msg (read connection))) 144 | (if (not (eof-object? msg)) 145 | (begin 146 | (thread-send (rdi-writer-thread rdi) msg) 147 | (loop))))) 148 | (thread-send (rdi-writer-thread rdi) '(reader-thread-terminated))))) 149 | 150 | (define (rdi-create-writer-thread rdi) 151 | (make-thread 152 | (lambda () 153 | (let loop () 154 | (let ((msg (thread-receive))) 155 | (and (rdi-handle-message rdi msg) 156 | (loop))))))) 157 | 158 | (define (rdi-new-seqnum rdi) 159 | (let ((seq-num (+ (rdi-seq-num rdi) 1))) 160 | (rdi-seq-num-set! rdi seq-num) 161 | seq-num)) 162 | 163 | (define (rdi-handle-message rdi msg) 164 | (if (pair? msg) 165 | 166 | (case (car msg) 167 | 168 | ((reader-thread-terminated) 169 | ;; (pretty-print 170 | ;; '(rdi reader-thread is terminating) 171 | ;; ##stdout-port) 172 | #t) 173 | 174 | ((terminate) 175 | ;; (pretty-print 176 | ;; '(rdi writer-thread is terminating) 177 | ;; ##stdout-port) 178 | #f) 179 | 180 | ((call) 181 | (let* ((seq-num 182 | (cadr msg)) 183 | (call 184 | (caddr msg)) 185 | (result 186 | (apply (rdi-function (car call)) 187 | (cdr call)))) 188 | (rdi-send rdi (list 'return seq-num result)) 189 | #t)) 190 | 191 | ((remote-call) 192 | (let* ((result-mutex (cadr msg)) 193 | (call (caddr msg)) 194 | (seq-num (rdi-new-seqnum rdi))) 195 | (rdi-send rdi (list 'call seq-num call)) 196 | (table-set! (rdi-call-table rdi) 197 | seq-num 198 | result-mutex) 199 | #t)) 200 | 201 | ((return) 202 | (let* ((seq-num (cadr msg)) 203 | (result (caddr msg)) 204 | (call-table (rdi-call-table rdi)) 205 | (result-mutex (table-ref call-table seq-num #f))) 206 | (if (not result-mutex) 207 | (error "invalid call sequence number") 208 | (begin 209 | (table-set! call-table seq-num) 210 | (mutex-specific-set! result-mutex result) 211 | (mutex-unlock! result-mutex) 212 | #t)))) 213 | 214 | (else 215 | (pretty-print 216 | (list 'unhandled-message msg) 217 | ##stdout-port) 218 | #t)) 219 | 220 | #f)) 221 | 222 | (define (rdi-send rdi msg) 223 | (let ((connection (rdi-connection rdi))) 224 | (write msg connection) 225 | (force-output connection))) 226 | 227 | (define (rdi-remote-call rdi fn . args) 228 | (rdi-force-connection rdi) 229 | (let ((result-mutex (make-mutex 'remote-call))) 230 | (mutex-lock! result-mutex) ;; result not ready yet... 231 | (thread-send 232 | (rdi-writer-thread rdi) 233 | (list 'remote-call result-mutex (cons fn args))) 234 | (mutex-lock! result-mutex) ;; wait until result is ready 235 | (mutex-specific result-mutex))) 236 | 237 | ;;;----------------------------------------------------------------------------- 238 | -------------------------------------------------------------------------------- /lib/util/sort.scm: -------------------------------------------------------------------------------- 1 | 2 | (define (sort-list lst less?) 3 | 4 | (define (mergesort lst) 5 | 6 | (define (merge lst1 lst2) 7 | (cond ((null? lst1) lst2) 8 | ((null? lst2) lst1) 9 | (else 10 | (let ((e1 (car lst1)) (e2 (car lst2))) 11 | (if (less? e1 e2) 12 | (cons e1 (merge (cdr lst1) lst2)) 13 | (cons e2 (merge lst1 (cdr lst2)))))))) 14 | 15 | (define (split lst) 16 | (if (or (null? lst) (null? (cdr lst))) 17 | lst 18 | (cons (car lst) (split (cddr lst))))) 19 | 20 | (if (or (null? lst) (null? (cdr lst))) 21 | lst 22 | (let* ((lst1 (mergesort (split lst))) 23 | (lst2 (mergesort (split (cdr lst))))) 24 | (merge lst1 lst2)))) 25 | 26 | (mergesort lst)) 27 | -------------------------------------------------------------------------------- /lib/util/srfi-2.scm: -------------------------------------------------------------------------------- 1 | ; Checking of a LAND* special form 2 | ; 3 | ; LAND* is a generalized AND: it evaluates a sequence of forms one after another 4 | ; till the first one that yields #f; the non-#f result of a form can be bound 5 | ; to a fresh variable and used in the subsequent forms. 6 | ; 7 | ; When an ordinary AND is formed of _proper_ boolean expressions: 8 | ; (AND E1 E2 ...) 9 | ; expression E2, if it gets to be evaluated, knows that E1 has returned non-#f. 10 | ; Moreover, E2 knows exactly what the result of E1 was - #t - so E2 can use 11 | ; this knowledge to its advantage. If E1 however is an _extended_ 12 | ; boolean expression, E2 can no longer tell which particular non-#f 13 | ; value E1 has returned. Chances are it took a lot of work to evaluate E1, 14 | ; and the produced result (a number, a vector, a string, etc) may be of 15 | ; value to E2. Alas, the AND form merely checks that the result is not an #f, 16 | ; and throws it away. If E2 needs it, it has to recompute the value again. 17 | ; This proposed LAND* special form lets constituent expressions get 18 | ; hold of the results of already evaluated expressions, without re-doing 19 | ; their work. 20 | ; 21 | ; Syntax: 22 | ; LAND* (CLAWS) BODY 23 | ; 24 | ; where CLAWS is a list of expressions or bindings: 25 | ; CLAWS ::= '() | (cons CLAW CLAWS) 26 | ; Every element of the CLAWS list, a CLAW, must be one of the following: 27 | ; (VARIABLE EXPRESSION) 28 | ; or 29 | ; (EXPRESSION) 30 | ; or 31 | ; BOUND-VARIABLE 32 | ; These CLAWS are evaluated in the strict left-to-right order. For each 33 | ; CLAW, the EXPRESSION part is evaluated first (or BOUND-VARIABLE is looked up). 34 | ; If the result is #f, LAND* immediately returns #f, thus disregarding the rest 35 | ; of the CLAWS and the BODY. If the EXPRESSION evaluates to not-#f, and 36 | ; the CLAW is of the form 37 | ; (VARIABLE EXPRESSION) 38 | ; the EXPRESSION's value is bound to a freshly made VARIABLE. The VARIABLE is 39 | ; available for _the rest_ of the CLAWS, and the BODY. As usual, all 40 | ; VARIABLEs must be unique (like in let*). 41 | ; 42 | ; Thus LAND* is a sort of cross-breed between LET* and AND. 43 | ; 44 | ; Denotation semantics: 45 | ; 46 | ; Eval[ (LAND* (CLAW1 ...) BODY), Env] = 47 | ; EvalClaw[ CLAW1, Env ] andalso 48 | ; Eval[ (LAND* ( ...) BODY), ExtClawEnv[ CLAW1, Env]] 49 | ; 50 | ; Eval[ (LAND* (CLAW) ), Env] = EvalClaw[ CLAW, Env ] 51 | ; Eval[ (LAND* () FORM1 ...), Env] = Eval[ (BEGIN FORM1 ...), Env ] 52 | ; Eval[ (LAND* () ), Env] = #t 53 | ; 54 | ; EvalClaw[ BOUND-VARIABLE, Env ] = Eval[ BOUND-VARIABLE, Env ] 55 | ; EvalClaw[ (EXPRESSION), Env ] = Eval[ EXPRESSION, Env ] 56 | ; EvalClaw[ (VARIABLE EXPRESSION), Env ] = Eval[ EXPRESSION, Env ] 57 | ; 58 | ; ExtClawEnv[ BOUND-VARIABLE, Env ] = Env 59 | ; ExtClawEnv[ (EXPRESSION), Env ] = EnvAfterEval[ EXPRESSION, Env ] 60 | ; ExtClawEnv[ (VARIABLE EXPRESSION), Env ] = 61 | ; ExtendEnv[ EnvAfterEval[ EXPRESSION, Env ], 62 | ; VARIABLE boundto Eval[ EXPRESSION, Env ]] 63 | ; 64 | ; 65 | ; If one has a Scheme interpreter written in Prolog/ML/Haskell, he can 66 | ; implement the above semantics right away. Within Scheme, it is trivial to 67 | ; code LAND* with R4RS "define-syntax". Alas, Gambit does not have this 68 | ; facility. So this implementation uses macros instead. 69 | ; 70 | ; The following LAND* macro will convert a LAND* expression into a "tree" of 71 | ; AND and LET expressions. For example, 72 | ; (LAND* ((my-list (compute-list)) ((not (null? my-list)))) 73 | ; (do-something my-list)) 74 | ; is transformed into 75 | ; (and (let ((my-list (compute-list))) 76 | ; (and my-list (not (null? my-list)) (begin (do-something my-list))))) 77 | ; 78 | ; I must admit the LAND* macro is written in a pathetic anti-functional style. 79 | ; To my excuse, the macro's goal is a syntactic transformation of source 80 | ; code, that is, performing a re-writing. IMHO, rewriting kind of suggests 81 | ; mutating. 82 | ; 83 | ; Sample applications: 84 | ; 85 | ; The following piece of code (from my treap package) 86 | ; (let ((new-root (node:dispatch-on-key root key ...))) 87 | ; (if new-root (set! root new-root))) 88 | ; could be elegantly re-written as 89 | ; (land* ((new-root (node:dispatch-on-key root key ...))) 90 | ; (set! root new-root)) 91 | ; 92 | ; A very common application of land* is looking up a value 93 | ; associated with a given key in an assoc list, returning #f in case of a 94 | ; look-up failure: 95 | ; 96 | ; ; Standard implementation 97 | ; (define (look-up key alist) 98 | ; (let ((found-assoc (assq key alist))) 99 | ; (and found-assoc (cdr found-assoc)))) 100 | ; 101 | ; ; A more elegant solution 102 | ; (define (look-up key alist) 103 | ; (cdr (or (assq key alist) '(#f . #f)))) 104 | ; 105 | ; ; An implementation which is just as graceful as the latter 106 | ; ; and just as efficient as the former: 107 | ; (define (look-up key alist) 108 | ; (land* ((x (assq key alist))) (cdr x))) 109 | ; 110 | ; Generalized cond: 111 | ; 112 | ; (or 113 | ; (land* (bindings-cond1) body1) 114 | ; (land* (bindings-cond2) body2) 115 | ; (begin else-clause)) 116 | ; 117 | ; Unlike => (cond's send), LAND* applies beyond cond. LAND* can also be used 118 | ; to generalize cond, as => is limited to sending of only a single value; 119 | ; LAND* allows as many bindings as necessary (which are performed in sequence) 120 | ; 121 | ; (or 122 | ; (land* ((c (read-char)) ((not (eof-object? c)))) 123 | ; (string-set! some-str i c) (++! i)) 124 | ; (begin (do-process-eof))) 125 | ; 126 | ; Another concept LAND* is reminiscent of is programming with guards: 127 | ; a LAND* form can be considered a sequence of _guarded_ expressions. 128 | ; In a regular program, forms may produce results, bind them to variables 129 | ; and let other forms use these results. LAND* differs in that it checks 130 | ; to make sure that every produced result "makes sense" (that is, not an #f). 131 | ; The first "failure" triggers the guard and aborts the rest of the 132 | ; sequence (which presumably would not make any sense to execute anyway). 133 | ; 134 | ; $Id: vland-gambit.scm,v 1.1 1998/12/28 23:54:29 srfimgr Exp $ 135 | 136 | 137 | (define-macro (and-let* claws . body) 138 | (let* ((new-vars '()) (result (cons 'and '())) (growth-point result)) 139 | 140 | ; We need a way to report a syntax error 141 | ; the following is how Gambit compiler does it... 142 | (##define-macro (ct-error-syntax msg . args) 143 | `(##signal '##signal.syntax-error #t ,msg ,@args)) 144 | 145 | (define (andjoin! clause) 146 | (let ((prev-point growth-point) (clause-cell (cons clause '()))) 147 | (set-cdr! growth-point clause-cell) 148 | (set! growth-point clause-cell))) 149 | 150 | (if (not (list? claws)) 151 | (ct-error-syntax "bindings must be a list " bindings)) 152 | (for-each 153 | (lambda (claw) 154 | (cond 155 | ((symbol? claw) ; BOUND-VARIABLE form 156 | (andjoin! claw)) 157 | ((and (pair? claw) (null? (cdr claw))) ; (EXPRESSION) form 158 | (andjoin! (car claw))) 159 | ; (VARIABLE EXPRESSION) form 160 | ((and (pair? claw) (symbol? (car claw)) 161 | (pair? (cdr claw)) (null? (cddr claw))) 162 | (let* ((var (car claw)) (var-cell (cons var '()))) 163 | (if (memq var new-vars) 164 | (ct-error-syntax "duplicate variable " var " in the bindings")) 165 | (set! new-vars (cons var new-vars)) 166 | (set-cdr! growth-point `((let (,claw) (and . ,var-cell)))) 167 | (set! growth-point var-cell))) 168 | (else 169 | (ct-error-syntax "An ill-formed binding in a syntactic form land* " 170 | claw)) 171 | )) 172 | claws) 173 | (if (not (null? body)) 174 | (andjoin! `(begin ,@body))) 175 | result)) 176 | 177 | 178 | -------------------------------------------------------------------------------- /lib/util/tests.scm: -------------------------------------------------------------------------------- 1 | 2 | (define-macro (define-test name . code) 3 | `(begin 4 | (display (string-append "Testing " 5 | (symbol->string ',name) 6 | "... ")) 7 | ,@code 8 | (display "OK\n"))) 9 | 10 | (define-type assert-exception 11 | id: 214FB272-AC60-4F1D-87CA-8BD9EC8F164B 12 | expr) 13 | 14 | (define-type assert-equal-exception 15 | id: 1A637BD4-DB81-4AF4-BEF7-BBF19AC6A9C9 16 | expr1 17 | res1 18 | expr2 19 | res2) 20 | 21 | (define-macro (assert expr) 22 | `(if (not ,expr) 23 | (raise (make-assert-exception ',expr)))) 24 | 25 | (define-macro (assert-equal expr1 expr2) 26 | `(let ((res1 ,expr1) 27 | (res2 ,expr2)) 28 | (if (not (equal? res1 res2)) 29 | (raise (make-assert-equal-exception ',expr1 30 | res1 31 | ',expr2 32 | res2))))) 33 | -------------------------------------------------------------------------------- /lib/vectors.scm: -------------------------------------------------------------------------------- 1 | 2 | (declare (block) 3 | (standard-bindings) 4 | (extended-bindings)) 5 | 6 | (define (make-vec2d x y) (f64vector x y)) 7 | (define (vec2d-x v) (f64vector-ref v 0)) 8 | (define (vec2d-y v) (f64vector-ref v 1)) 9 | 10 | (define (vec2d-add v1 v2) 11 | (make-vec2d (fl+ (vec2d-x v1) (vec2d-x v2)) 12 | (fl+ (vec2d-y v1) (vec2d-y v2)))) 13 | 14 | (define (vec2d-sub v1 v2) 15 | (make-vec2d (fl- (vec2d-x v1) (vec2d-x v2)) 16 | (fl- (vec2d-y v1) (vec2d-y v2)))) 17 | 18 | (define (vec2d-length v1) 19 | (flsqrt (fl+ (fl* (vec2d-x v1) (vec2d-x v1)) 20 | (fl* (vec2d-y v1) (vec2d-y v1))))) 21 | 22 | (define (vec2d-scalar-mul v1 f) 23 | (make-vec2d (fl* (vec2d-x v1) f) 24 | (fl* (vec2d-y v1) f))) 25 | 26 | (define (make-vec3d x y z) (f64vector x y z)) 27 | (define (vec3d-x v) (f64vector-ref v 0)) 28 | (define (vec3d-y v) (f64vector-ref v 1)) 29 | (define (vec3d-z v) (f64vector-ref v 2)) 30 | (define (vec3d-x-set! v f) (f64vector-set! v 0 f)) 31 | (define (vec3d-y-set! v f) (f64vector-set! v 1 f)) 32 | (define (vec3d-z-set! v f) (f64vector-set! v 2 f)) 33 | 34 | (define (make-vec4d x y z w) (f64vector x y z w)) 35 | (define (vec4d-x v) (f64vector-ref v 0)) 36 | (define (vec4d-y v) (f64vector-ref v 1)) 37 | (define (vec4d-z v) (f64vector-ref v 2)) 38 | (define (vec4d-w v) (f64vector-ref v 3)) 39 | 40 | (define (vec3d-op v1 v2 op) 41 | (make-vec3d (op (vec3d-x v1) (vec3d-x v2)) 42 | (op (vec3d-y v1) (vec3d-y v2)) 43 | (op (vec3d-z v1) (vec3d-z v2)))) 44 | 45 | (define (vec3d-add v1 v2) 46 | (declare (inlining-limit 10000)) 47 | (vec3d-op v1 v2 fl+)) 48 | 49 | (define (vec3d-sub v1 v2) 50 | (declare (inlining-limit 10000)) 51 | (vec3d-op v1 v2 fl-)) 52 | 53 | (define (vec3d-component-mul v1 v2) 54 | (declare (inlining-limit 10000)) 55 | (vec3d-op v1 v2 fl*)) 56 | 57 | (define (vec3d-scalar-mul v1 f) 58 | (make-vec3d (fl* (vec3d-x v1) f) 59 | (fl* (vec3d-y v1) f) 60 | (fl* (vec3d-z v1) f))) 61 | 62 | (define (vec3d-length v1) 63 | (declare (inlining-limit 10000)) 64 | (flsqrt (vec3d-dot v1 v1))) 65 | 66 | (define (vec3d-unit v1) 67 | (declare (inlining-limit 10000)) 68 | (vec3d-scalar-mul v1 (fl/ (vec3d-length v1)))) 69 | 70 | (define (vec3d-dot v1 v2) 71 | (fl+ (fl* (vec3d-x v1) (vec3d-x v2)) 72 | (fl* (vec3d-y v1) (vec3d-y v2)) 73 | (fl* (vec3d-z v1) (vec3d-z v2)))) 74 | 75 | (define (vec3d-cross v1 v2) 76 | (let ((v1-x (vec3d-x v1)) (v2-x (vec3d-x v2)) 77 | (v1-y (vec3d-y v1)) (v2-y (vec3d-y v2)) 78 | (v1-z (vec3d-z v1)) (v2-z (vec3d-z v2))) 79 | (make-vec3d (fl- (fl* v1-y v2-z(vec3d-z v2)) 80 | (fl* v1-z v2-y)) 81 | (fl- (fl* v1-z v2-x) 82 | (fl* v1-x v2-z)) 83 | (fl- (fl* v1-x v2-y) 84 | (fl* v1-y v2-x))))) 85 | 86 | (define (vec4d-add v1 v2) 87 | (make-vec4d (+ (vec4d-x v1) (vec4d-x v2)) 88 | (+ (vec4d-y v1) (vec4d-y v2)) 89 | (+ (vec4d-z v1) (vec4d-z v2)) 90 | (+ (vec4d-w v1) (vec4d-w v2)))) 91 | -------------------------------------------------------------------------------- /resources/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/.DS_Store -------------------------------------------------------------------------------- /resources/box.obj: -------------------------------------------------------------------------------- 1 | # Blender3D v249 OBJ File: 2 | # www.blender3d.org 3 | v 1.000000 -1.000000 -1.000000 4 | v 1.000000 -1.000000 1.000000 5 | v -1.000000 -1.000000 1.000000 6 | v -1.000000 -1.000000 -1.000000 7 | v 1.000000 1.000000 -1.000000 8 | v 1.000000 1.000000 1.000000 9 | v -1.000000 1.000000 1.000000 10 | v -1.000000 1.000000 -1.000000 11 | usemtl Material 12 | s off 13 | f 5 1 4 14 | f 5 4 8 15 | f 3 7 8 16 | f 3 8 4 17 | f 2 6 3 18 | f 6 7 3 19 | f 1 5 2 20 | f 5 6 2 21 | f 5 8 6 22 | f 8 7 6 23 | f 1 2 3 24 | f 1 3 4 25 | -------------------------------------------------------------------------------- /resources/collision.obj.gso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/collision.obj.gso -------------------------------------------------------------------------------- /resources/gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/gradient.png -------------------------------------------------------------------------------- /resources/ico.obj: -------------------------------------------------------------------------------- 1 | # Blender3D v249 OBJ File: 2 | # www.blender3d.org 3 | v 0.000000 0.000000 -0.500000 4 | v 0.404506 -0.309014 -0.223607 5 | v -0.154504 -0.500000 -0.223607 6 | v -0.500000 0.000000 -0.223607 7 | v -0.154504 0.500000 -0.223607 8 | v 0.404506 0.309014 -0.223607 9 | v 0.154504 -0.500000 0.223607 10 | v -0.404506 -0.309014 0.223607 11 | v -0.404506 0.309014 0.223607 12 | v 0.154504 0.500000 0.223607 13 | v 0.500000 0.000000 0.223607 14 | v 0.000000 0.000000 0.500000 15 | vn 0.000000 0.000000 -1.000000 16 | vn 0.719352 -0.505997 -0.475845 17 | vn -0.278634 -0.830531 -0.482223 18 | vn -0.881588 0.000000 -0.471969 19 | vn -0.278634 0.830531 -0.482223 20 | vn 0.719352 0.505997 -0.475845 21 | vn 0.278634 -0.830531 0.482223 22 | vn -0.719352 -0.505997 0.475845 23 | vn -0.719352 0.505997 0.475845 24 | vn 0.278634 0.830531 0.482223 25 | vn 0.881588 0.000000 0.471969 26 | vn 0.000000 0.000000 1.000000 27 | usemtl (null) 28 | s off 29 | f 3 1 2 30 | f 2 1 6 31 | f 4 1 3 32 | f 5 1 4 33 | f 6 1 5 34 | f 2 6 11 35 | f 3 2 7 36 | f 4 3 8 37 | f 5 4 9 38 | f 6 5 10 39 | f 11 7 2 40 | f 7 8 3 41 | f 8 9 4 42 | f 9 10 5 43 | f 10 11 6 44 | f 7 11 12 45 | f 8 7 12 46 | f 9 8 12 47 | f 10 9 12 48 | f 11 10 12 49 | -------------------------------------------------------------------------------- /resources/ico.obj.gso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/ico.obj.gso -------------------------------------------------------------------------------- /resources/jlongster.obj.gso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/jlongster.obj.gso -------------------------------------------------------------------------------- /resources/logo.3ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/logo.3ds -------------------------------------------------------------------------------- /resources/logo.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/logo.blend -------------------------------------------------------------------------------- /resources/logo.blend1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/logo.blend1 -------------------------------------------------------------------------------- /resources/logo.obj.gso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/logo.obj.gso -------------------------------------------------------------------------------- /resources/mass.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/mass.blend -------------------------------------------------------------------------------- /resources/mass.mtl: -------------------------------------------------------------------------------- 1 | # Blender3D MTL File: 2 | # Material Count: 2 3 | newmtl Material.002 4 | Ns 96.078431 5 | Ka 0.000000 0.000000 0.000000 6 | Kd 0.221785 0.221722 0.764894 7 | Ks 0.500000 0.500000 0.500000 8 | Ni 1.000000 9 | d 1.000000 10 | illum 2 11 | 12 | 13 | newmtl Material.001 14 | Ns 96.078431 15 | Ka 0.000000 0.000000 0.000000 16 | Kd 0.117647 0.395178 0.254707 17 | Ks 0.500000 0.500000 0.500000 18 | Ni 1.000000 19 | d 1.000000 20 | illum 2 21 | 22 | 23 | -------------------------------------------------------------------------------- /resources/mass.obj.gso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/mass.obj.gso -------------------------------------------------------------------------------- /resources/sphere.obj: -------------------------------------------------------------------------------- 1 | # Blender3D v249 OBJ File: 2 | # www.blender3d.org 3 | v 0.206747 0.000000 0.456773 4 | v 0.298776 0.000000 0.404509 5 | v 0.377746 0.000000 0.334565 6 | v 0.440208 0.000000 0.250000 7 | v 0.483430 0.000000 0.154508 8 | v 0.505523 0.000000 0.052264 9 | v 0.505523 0.000000 -0.052264 10 | v 0.483430 0.000000 -0.154509 11 | v 0.440208 0.000000 -0.250000 12 | v 0.377746 0.000000 -0.334565 13 | v 0.298776 0.000000 -0.404509 14 | v 0.206747 0.000000 -0.456773 15 | v 0.105683 0.000000 -0.489074 16 | v 0.096546 0.042750 -0.489074 17 | v 0.188873 0.083631 -0.456773 18 | v 0.272945 0.120857 -0.404509 19 | v 0.345089 0.152802 -0.334565 20 | v 0.402150 0.178068 -0.250000 21 | v 0.441635 0.195551 -0.154509 22 | v 0.461819 0.204489 -0.052264 23 | v 0.461819 0.204489 0.052264 24 | v 0.441635 0.195551 0.154508 25 | v 0.402150 0.178068 0.250000 26 | v 0.345089 0.152802 0.334565 27 | v 0.272945 0.120857 0.404509 28 | v 0.188873 0.083631 0.456773 29 | v 0.096546 0.042750 0.489074 30 | v 0.070716 0.078108 0.489074 31 | v 0.138341 0.152802 0.456773 32 | v 0.199920 0.220818 0.404509 33 | v 0.252762 0.279183 0.334565 34 | v 0.294556 0.325346 0.250000 35 | v 0.323478 0.357290 0.154508 36 | v 0.338261 0.373619 0.052264 37 | v 0.338261 0.373619 -0.052264 38 | v 0.323478 0.357290 -0.154509 39 | v 0.294556 0.325346 -0.250000 40 | v 0.252762 0.279183 -0.334565 41 | v 0.199920 0.220817 -0.404509 42 | v 0.138341 0.152802 -0.456773 43 | v 0.070716 0.078108 -0.489074 44 | v -0.000000 -0.000000 -0.500000 45 | v 0.032658 0.099960 -0.489074 46 | v 0.063888 0.195551 -0.456773 47 | v 0.092327 0.282596 -0.404509 48 | v 0.116730 0.357290 -0.334565 49 | v 0.136032 0.416369 -0.250000 50 | v 0.149388 0.457250 -0.154509 51 | v 0.156215 0.478148 -0.052264 52 | v 0.156215 0.478148 0.052264 53 | v 0.149388 0.457250 0.154508 54 | v 0.136032 0.416369 0.250000 55 | v 0.116730 0.357290 0.334565 56 | v 0.092327 0.282596 0.404509 57 | v 0.063888 0.195551 0.456773 58 | v 0.032658 0.099960 0.489074 59 | v -0.011047 0.104528 0.489074 60 | v -0.021611 0.204489 0.456773 61 | v -0.031231 0.295511 0.404509 62 | v -0.039485 0.373619 0.334565 63 | v -0.046014 0.435398 0.250000 64 | v -0.050532 0.478148 0.154508 65 | v -0.052842 0.500000 0.052264 66 | v -0.052842 0.500000 -0.052264 67 | v -0.050532 0.478148 -0.154509 68 | v -0.046014 0.435398 -0.250000 69 | v -0.039485 0.373619 -0.334565 70 | v -0.031231 0.295511 -0.404509 71 | v -0.021611 0.204489 -0.456773 72 | v -0.011047 0.104528 -0.489074 73 | v -0.052842 0.091023 -0.489074 74 | v -0.103374 0.178068 -0.456773 75 | v -0.149388 0.257330 -0.404509 76 | v -0.188873 0.325346 -0.334565 77 | v -0.220104 0.379143 -0.250000 78 | v -0.241715 0.416369 -0.154509 79 | v -0.252762 0.435398 -0.052264 80 | v -0.252762 0.435398 0.052264 81 | v -0.241715 0.416369 0.154508 82 | v -0.220104 0.379143 0.250000 83 | v -0.188873 0.325346 0.334565 84 | v -0.149388 0.257330 0.404509 85 | v -0.103374 0.178068 0.456773 86 | v -0.052842 0.091023 0.489074 87 | v -0.085499 0.061779 0.489074 88 | v -0.167262 0.120857 0.456773 89 | v -0.241715 0.174654 0.404509 90 | v -0.305603 0.220817 0.334565 91 | v -0.356136 0.257330 0.250000 92 | v -0.391103 0.282596 0.154508 93 | v -0.408977 0.295511 0.052264 94 | v -0.408977 0.295511 -0.052264 95 | v -0.391103 0.282596 -0.154509 96 | v -0.356136 0.257330 -0.250000 97 | v -0.305603 0.220817 -0.334565 98 | v -0.241715 0.174654 -0.404509 99 | v -0.167262 0.120857 -0.456773 100 | v -0.085499 0.061779 -0.489074 101 | v -0.103374 0.021852 -0.489074 102 | v -0.202230 0.042750 -0.456773 103 | v -0.292247 0.061779 -0.404509 104 | v -0.369492 0.078108 -0.334565 105 | v -0.430588 0.091023 -0.250000 106 | v -0.472865 0.099960 -0.154509 107 | v -0.494477 0.104528 -0.052264 108 | v -0.494477 0.104528 0.052264 109 | v -0.472865 0.099960 0.154508 110 | v -0.430588 0.091023 0.250000 111 | v -0.369492 0.078108 0.334565 112 | v -0.292247 0.061779 0.404509 113 | v -0.202230 0.042750 0.456773 114 | v -0.103374 0.021852 0.489074 115 | v -0.103374 -0.021852 0.489074 116 | v -0.202230 -0.042750 0.456773 117 | v -0.292247 -0.061779 0.404509 118 | v -0.369492 -0.078108 0.334565 119 | v -0.430588 -0.091023 0.250000 120 | v -0.472865 -0.099960 0.154508 121 | v -0.494476 -0.104529 0.052264 122 | v -0.494476 -0.104529 -0.052264 123 | v -0.472865 -0.099960 -0.154509 124 | v -0.430588 -0.091023 -0.250000 125 | v -0.369492 -0.078108 -0.334565 126 | v -0.292247 -0.061779 -0.404509 127 | v -0.202229 -0.042750 -0.456773 128 | v -0.103374 -0.021852 -0.489074 129 | v -0.085499 -0.061779 -0.489074 130 | v -0.167262 -0.120857 -0.456773 131 | v -0.241715 -0.174654 -0.404509 132 | v -0.305603 -0.220818 -0.334565 133 | v -0.356135 -0.257330 -0.250000 134 | v -0.391103 -0.282596 -0.154509 135 | v -0.408977 -0.295512 -0.052264 136 | v -0.408977 -0.295512 0.052264 137 | v -0.391103 -0.282596 0.154508 138 | v -0.356135 -0.257330 0.250000 139 | v -0.305603 -0.220818 0.334565 140 | v -0.241715 -0.174654 0.404509 141 | v -0.167262 -0.120857 0.456773 142 | v -0.085499 -0.061779 0.489074 143 | v -0.052842 -0.091023 0.489074 144 | v -0.103374 -0.178068 0.456773 145 | v -0.149388 -0.257330 0.404509 146 | v -0.188873 -0.325346 0.334565 147 | v -0.220104 -0.379143 0.250000 148 | v -0.241715 -0.416369 0.154508 149 | v -0.252762 -0.435398 0.052264 150 | v -0.252762 -0.435398 -0.052264 151 | v -0.241715 -0.416369 -0.154509 152 | v -0.220104 -0.379143 -0.250000 153 | v -0.188873 -0.325346 -0.334565 154 | v -0.149388 -0.257330 -0.404509 155 | v -0.103374 -0.178068 -0.456773 156 | v -0.052842 -0.091023 -0.489074 157 | v -0.011047 -0.104528 -0.489074 158 | v -0.021611 -0.204489 -0.456773 159 | v -0.031230 -0.295511 -0.404509 160 | v -0.039485 -0.373619 -0.334565 161 | v -0.046014 -0.435398 -0.250000 162 | v -0.050532 -0.478148 -0.154509 163 | v -0.052841 -0.500000 -0.052264 164 | v -0.052841 -0.500000 0.052264 165 | v -0.050532 -0.478148 0.154508 166 | v -0.046014 -0.435398 0.250000 167 | v -0.039485 -0.373619 0.334565 168 | v -0.031230 -0.295511 0.404509 169 | v -0.021611 -0.204489 0.456773 170 | v -0.011047 -0.104528 0.489074 171 | v 0.032658 -0.099960 0.489074 172 | v 0.063889 -0.195551 0.456773 173 | v 0.092327 -0.282596 0.404509 174 | v 0.116730 -0.357290 0.334565 175 | v 0.136032 -0.416369 0.250000 176 | v 0.149388 -0.457250 0.154508 177 | v 0.156216 -0.478148 0.052264 178 | v 0.156216 -0.478148 -0.052264 179 | v 0.149388 -0.457250 -0.154509 180 | v 0.136032 -0.416369 -0.250000 181 | v 0.116730 -0.357290 -0.334565 182 | v 0.092327 -0.282596 -0.404509 183 | v 0.063889 -0.195551 -0.456773 184 | v 0.032658 -0.099960 -0.489074 185 | v 0.070716 -0.078108 -0.489074 186 | v 0.138341 -0.152802 -0.456773 187 | v 0.199920 -0.220817 -0.404509 188 | v 0.252762 -0.279182 -0.334565 189 | v 0.294557 -0.325346 -0.250000 190 | v 0.323478 -0.357290 -0.154509 191 | v 0.338261 -0.373619 -0.052264 192 | v 0.338261 -0.373619 0.052264 193 | v 0.323478 -0.357290 0.154508 194 | v 0.294557 -0.325346 0.250000 195 | v 0.252762 -0.279182 0.334565 196 | v 0.199920 -0.220817 0.404509 197 | v 0.138341 -0.152802 0.456773 198 | v 0.070716 -0.078108 0.489074 199 | v 0.096546 -0.042750 0.489074 200 | v 0.188873 -0.083631 0.456773 201 | v 0.272945 -0.120857 0.404509 202 | v 0.345089 -0.152802 0.334565 203 | v 0.402150 -0.178068 0.250000 204 | v 0.441635 -0.195551 0.154508 205 | v 0.461819 -0.204488 0.052264 206 | v 0.461819 -0.204488 -0.052264 207 | v 0.441635 -0.195551 -0.154509 208 | v 0.402150 -0.178068 -0.250000 209 | v 0.345089 -0.152802 -0.334565 210 | v 0.272945 -0.120857 -0.404509 211 | v 0.188873 -0.083631 -0.456773 212 | v 0.096546 -0.042750 -0.489074 213 | v 0.105683 0.000000 0.489074 214 | v 0.000000 0.000000 0.500000 215 | vn 0.401105 -0.006714 0.915983 216 | vn 0.581378 -0.005951 0.813593 217 | vn 0.737571 -0.004913 0.675222 218 | vn 0.862362 -0.003693 0.506211 219 | vn 0.949522 -0.002258 0.313669 220 | vn 0.994324 -0.000763 0.106235 221 | vn 0.994324 0.000763 -0.106235 222 | vn 0.955138 0.041902 -0.293100 223 | vn 0.869686 -0.024720 -0.492965 224 | vn 0.737571 0.004913 -0.675222 225 | vn 0.581378 0.005951 -0.813593 226 | vn 0.401105 0.006714 -0.915983 227 | vn 0.224830 0.013062 -0.974303 228 | vn 0.200079 0.103854 -0.974242 229 | vn 0.363628 0.170141 -0.915860 230 | vn 0.528520 0.243080 -0.813349 231 | vn 0.671468 0.305918 -0.674886 232 | vn 0.785821 0.355693 -0.505905 233 | vn 0.865841 0.389935 -0.313425 234 | vn 0.907285 0.406812 -0.106174 235 | vn 0.907926 0.405408 0.106113 236 | vn 0.867702 0.385784 0.313395 237 | vn 0.788842 0.348979 0.505875 238 | vn 0.675497 0.296915 0.674886 239 | vn 0.533372 0.232215 0.813349 240 | vn 0.369091 0.157842 0.915860 241 | vn 0.210669 0.079989 0.974273 242 | vn 0.160070 0.159215 0.974151 243 | vn 0.273232 0.295053 0.915555 244 | vn 0.393048 0.429945 0.812769 245 | vn 0.496414 0.546861 0.674123 246 | vn 0.578570 0.640400 0.505081 247 | vn 0.635426 0.705924 0.312784 248 | vn 0.664083 0.740104 0.105899 249 | vn 0.662923 0.741111 -0.105960 250 | vn 0.632069 0.708914 -0.312845 251 | vn 0.573107 0.645253 -0.505112 252 | vn 0.489120 0.553423 -0.674123 253 | vn 0.384228 0.437880 -0.812769 254 | vn 0.263283 0.304025 -0.915525 255 | vn 0.140751 0.176702 -0.974120 256 | vn 0.000000 0.000000 -1.000000 257 | vn 0.057070 0.218970 -0.974059 258 | vn 0.117466 0.385296 -0.915250 259 | vn 0.173742 0.556810 -0.812250 260 | vn 0.222694 0.704856 -0.673452 261 | vn 0.262093 0.822687 -0.504410 262 | vn 0.290048 0.904599 -0.312326 263 | vn 0.305155 0.946379 -0.105747 264 | vn 0.306589 0.945921 0.105716 265 | vn 0.294351 0.903226 0.312265 266 | vn 0.269021 0.820460 0.504379 267 | vn 0.231971 0.701865 0.673421 268 | vn 0.184973 0.553148 0.812250 269 | vn 0.130192 0.381146 0.915281 270 | vn 0.081790 0.210883 0.974059 271 | vn -0.010559 0.226112 0.974029 272 | vn -0.035218 0.401410 0.915189 273 | vn -0.054781 0.580859 0.812128 274 | vn -0.072024 0.735862 0.673269 275 | vn -0.086184 0.859249 0.504227 276 | vn -0.096561 0.945097 0.312174 277 | vn -0.102664 0.989074 0.105686 278 | vn -0.104160 0.988922 -0.105686 279 | vn -0.127720 0.936552 -0.326395 280 | vn -0.054506 0.851161 -0.522019 281 | vn -0.081729 0.734825 -0.673269 282 | vn -0.066530 0.579638 -0.812128 283 | vn -0.048524 0.400006 -0.915189 284 | vn -0.036409 0.223365 -0.974029 285 | vn -0.123630 0.189184 -0.974120 286 | vn -0.206214 0.345653 -0.915403 287 | vn -0.295419 0.502548 -0.812494 288 | vn -0.372234 0.638325 -0.673727 289 | vn -0.376415 0.777551 -0.503647 290 | vn -0.530137 0.788446 -0.311930 291 | vn -0.495956 0.861843 -0.105777 292 | vn -0.494644 0.862606 0.105838 293 | vn -0.471175 0.824763 0.312540 294 | vn -0.426801 0.750359 0.504715 295 | vn -0.345103 0.669637 0.657582 296 | vn -0.309366 0.508347 0.803613 297 | vn -0.194617 0.352367 0.915372 298 | vn -0.101108 0.202246 0.974090 299 | vn -0.174230 0.143406 0.974181 300 | vn -0.320444 0.242409 0.915708 301 | vn -0.493881 0.309641 0.812494 302 | vn -0.564562 0.477096 0.673482 303 | vn -0.694601 0.511795 0.505539 304 | vn -0.765618 0.561876 0.313181 305 | vn -0.802576 0.586993 0.106082 306 | vn -0.803491 0.585772 -0.106021 307 | vn -0.804865 0.504471 -0.312540 308 | vn -0.659474 0.557298 -0.504440 309 | vn -0.599017 0.431410 -0.674551 310 | vn -0.473556 0.338511 -0.813074 311 | vn -0.328349 0.231513 -0.915708 312 | vn -0.189489 0.122288 -0.974212 313 | vn -0.222602 0.034211 -0.974303 314 | vn -0.393719 0.077242 -0.915952 315 | vn -0.569872 0.115665 -0.813532 316 | vn -0.722404 0.149297 -0.675130 317 | vn -0.829035 0.239784 -0.505142 318 | vn -0.940550 0.131932 -0.312937 319 | vn -0.972533 0.206946 -0.106204 320 | vn -0.972228 0.208472 0.106235 321 | vn -0.928098 0.200598 0.313608 322 | vn -0.842616 0.183782 0.506149 323 | vn -0.709464 0.205206 0.674154 324 | vn -0.576739 0.080935 0.812891 325 | vn -0.390912 0.090426 0.915952 326 | vn -0.217200 0.059755 0.974273 327 | vn -0.222602 -0.034211 0.974303 328 | vn -0.393719 -0.077242 0.915952 329 | vn -0.559557 -0.161870 0.812799 330 | vn -0.731284 -0.102603 0.674276 331 | vn -0.844172 -0.176580 0.506119 332 | vn -0.929044 -0.196142 0.313578 333 | vn -0.972533 -0.206946 0.106204 334 | vn -0.972228 -0.208472 -0.106235 335 | vn -0.912381 -0.263894 -0.312845 336 | vn -0.854579 -0.119877 -0.505234 337 | vn -0.720328 -0.158940 -0.675130 338 | vn -0.567370 -0.127323 -0.813532 339 | vn -0.390912 -0.090426 -0.915952 340 | vn -0.217200 -0.059755 -0.974273 341 | vn -0.174230 -0.143406 -0.974181 342 | vn -0.320444 -0.242409 -0.915708 343 | vn -0.466536 -0.348125 -0.813074 344 | vn -0.593219 -0.439344 -0.674551 345 | vn -0.731437 -0.458480 -0.504715 346 | vn -0.725578 -0.613117 -0.312326 347 | vn -0.802576 -0.586993 -0.106082 348 | vn -0.829157 -0.552507 0.084750 349 | vn -0.753960 -0.585131 0.298502 350 | vn -0.698935 -0.505875 0.505509 351 | vn -0.626087 -0.392468 0.673757 352 | vn -0.445418 -0.376446 0.812311 353 | vn -0.328349 -0.231513 0.915708 354 | vn -0.189489 -0.122288 0.974212 355 | vn -0.123630 -0.189184 0.974120 356 | vn -0.206214 -0.345653 0.915403 357 | vn -0.254433 -0.525681 0.811701 358 | vn -0.412671 -0.613819 0.672964 359 | vn -0.433119 -0.746757 0.504685 360 | vn -0.414014 -0.855190 0.311747 361 | vn -0.554857 -0.825190 0.105594 362 | vn -0.494644 -0.862606 -0.105838 363 | vn -0.414014 -0.855190 -0.311747 364 | vn -0.481918 -0.716788 -0.503891 365 | vn -0.363750 -0.643178 -0.673757 366 | vn -0.285165 -0.508438 -0.812464 367 | vn -0.194617 -0.352367 -0.915372 368 | vn -0.101108 -0.202246 -0.974090 369 | vn -0.010559 -0.226112 -0.974029 370 | vn -0.035218 -0.401410 -0.915189 371 | vn -0.054781 -0.580859 -0.812128 372 | vn -0.072024 -0.735862 -0.673269 373 | vn -0.150029 -0.850948 -0.503311 374 | vn -0.032136 -0.949705 -0.311441 375 | vn -0.102664 -0.989074 -0.105686 376 | vn -0.172674 -0.979308 0.105441 377 | vn -0.032136 -0.949705 0.311441 378 | vn -0.093417 -0.858486 0.504227 379 | vn -0.128513 -0.728935 0.672384 380 | vn -0.019745 -0.584063 0.811426 381 | vn -0.048524 -0.400006 0.915189 382 | vn -0.036409 -0.223365 0.974029 383 | vn 0.057070 -0.218970 0.974029 384 | vn 0.117466 -0.385296 0.915250 385 | vn 0.218299 -0.541795 0.811640 386 | vn 0.177496 -0.718497 0.672445 387 | vn 0.262093 -0.822687 0.504410 388 | vn 0.355174 -0.881283 0.311655 389 | vn 0.238533 -0.965361 0.105441 390 | vn 0.306589 -0.945921 -0.105716 391 | vn 0.355174 -0.881283 -0.311655 392 | vn 0.207251 -0.838801 -0.503372 393 | vn 0.231971 -0.701865 -0.673421 394 | vn 0.184973 -0.553148 -0.812250 395 | vn 0.130192 -0.381146 -0.915281 396 | vn 0.081790 -0.210883 -0.974059 397 | vn 0.160070 -0.159215 -0.974151 398 | vn 0.273232 -0.295053 -0.915555 399 | vn 0.393048 -0.429945 -0.812769 400 | vn 0.496414 -0.546861 -0.674123 401 | vn 0.529374 -0.682394 -0.504013 402 | vn 0.682272 -0.661031 -0.312235 403 | vn 0.664083 -0.740104 -0.105899 404 | vn 0.609546 -0.785638 0.105625 405 | vn 0.682272 -0.661031 0.312235 406 | vn 0.573107 -0.645253 0.505112 407 | vn 0.453291 -0.584338 0.673086 408 | vn 0.418897 -0.405957 0.812189 409 | vn 0.263283 -0.304025 0.915525 410 | vn 0.140751 -0.176702 0.974120 411 | vn 0.200079 -0.103854 0.974242 412 | vn 0.363628 -0.170141 0.915860 413 | vn 0.523820 -0.211188 0.825190 414 | vn 0.653951 -0.319620 0.685659 415 | vn 0.785821 -0.355693 0.505905 416 | vn 0.875790 -0.349071 0.333354 417 | vn 0.893094 -0.433180 0.121250 418 | vn 0.907926 -0.405408 -0.106113 419 | vn 0.892300 -0.325480 -0.312784 420 | vn 0.760888 -0.407575 -0.504837 421 | vn 0.675497 -0.296915 -0.674886 422 | vn 0.533372 -0.232215 -0.813349 423 | vn 0.369091 -0.157842 -0.915860 424 | vn 0.210669 -0.079989 -0.974273 425 | vn 0.224830 -0.013062 0.974303 426 | vn 0.000000 0.000000 1.000000 427 | usemtl (null) 428 | s off 429 | f 42 14 13 430 | f 211 27 212 431 | f 27 28 212 432 | f 42 41 14 433 | f 42 43 41 434 | f 28 56 212 435 | f 56 57 212 436 | f 42 70 43 437 | f 42 71 70 438 | f 57 84 212 439 | f 84 85 212 440 | f 42 98 71 441 | f 42 99 98 442 | f 85 112 212 443 | f 112 113 212 444 | f 42 126 99 445 | f 42 127 126 446 | f 113 140 212 447 | f 140 141 212 448 | f 42 154 127 449 | f 42 155 154 450 | f 141 168 212 451 | f 168 169 212 452 | f 42 182 155 453 | f 42 183 182 454 | f 169 196 212 455 | f 196 197 212 456 | f 42 210 183 457 | f 42 13 210 458 | f 197 211 212 459 | f 198 1 211 460 | f 198 211 197 461 | f 1 198 199 462 | f 1 199 2 463 | f 200 3 2 464 | f 200 2 199 465 | f 201 4 3 466 | f 201 3 200 467 | f 202 5 4 468 | f 202 4 201 469 | f 203 6 5 470 | f 203 5 202 471 | f 204 7 6 472 | f 204 6 203 473 | f 205 8 7 474 | f 205 7 204 475 | f 206 9 205 476 | f 9 8 205 477 | f 207 10 9 478 | f 207 9 206 479 | f 208 11 10 480 | f 208 10 207 481 | f 209 12 11 482 | f 209 11 208 483 | f 210 13 12 484 | f 210 12 209 485 | f 183 210 209 486 | f 183 209 184 487 | f 184 209 208 488 | f 184 208 185 489 | f 185 208 207 490 | f 185 207 186 491 | f 186 207 206 492 | f 186 206 187 493 | f 187 206 188 494 | f 206 205 188 495 | f 188 205 204 496 | f 188 204 189 497 | f 189 204 203 498 | f 189 203 190 499 | f 190 203 191 500 | f 203 202 191 501 | f 191 202 201 502 | f 191 201 192 503 | f 192 201 200 504 | f 192 200 193 505 | f 193 200 194 506 | f 200 199 194 507 | f 194 199 198 508 | f 194 198 195 509 | f 195 198 197 510 | f 195 197 196 511 | f 170 195 196 512 | f 170 196 169 513 | f 171 194 195 514 | f 171 195 170 515 | f 172 193 171 516 | f 193 194 171 517 | f 173 192 193 518 | f 173 193 172 519 | f 174 191 192 520 | f 174 192 173 521 | f 175 190 174 522 | f 190 191 174 523 | f 176 189 190 524 | f 176 190 175 525 | f 177 188 189 526 | f 177 189 176 527 | f 178 187 177 528 | f 187 188 177 529 | f 179 186 187 530 | f 179 187 178 531 | f 180 185 186 532 | f 180 186 179 533 | f 181 184 185 534 | f 181 185 180 535 | f 182 183 184 536 | f 182 184 181 537 | f 155 182 181 538 | f 155 181 156 539 | f 156 181 180 540 | f 156 180 157 541 | f 157 180 179 542 | f 157 179 158 543 | f 158 179 178 544 | f 158 178 159 545 | f 159 178 160 546 | f 178 177 160 547 | f 160 177 176 548 | f 160 176 161 549 | f 161 176 175 550 | f 161 175 162 551 | f 162 175 163 552 | f 175 174 163 553 | f 163 174 173 554 | f 163 173 164 555 | f 164 173 172 556 | f 164 172 165 557 | f 165 172 166 558 | f 172 171 166 559 | f 166 171 170 560 | f 166 170 167 561 | f 167 170 169 562 | f 167 169 168 563 | f 142 167 168 564 | f 142 168 141 565 | f 143 166 167 566 | f 143 167 142 567 | f 144 165 143 568 | f 165 166 143 569 | f 145 164 165 570 | f 145 165 144 571 | f 146 163 164 572 | f 146 164 145 573 | f 147 162 146 574 | f 162 163 146 575 | f 148 161 162 576 | f 148 162 147 577 | f 149 160 161 578 | f 149 161 148 579 | f 150 159 149 580 | f 159 160 149 581 | f 151 158 159 582 | f 151 159 150 583 | f 152 157 158 584 | f 152 158 151 585 | f 153 156 157 586 | f 153 157 152 587 | f 154 155 156 588 | f 154 156 153 589 | f 127 154 153 590 | f 127 153 128 591 | f 128 153 152 592 | f 128 152 129 593 | f 129 152 151 594 | f 129 151 130 595 | f 130 151 150 596 | f 130 150 131 597 | f 131 150 132 598 | f 150 149 132 599 | f 132 149 148 600 | f 132 148 133 601 | f 133 148 147 602 | f 133 147 134 603 | f 134 147 135 604 | f 147 146 135 605 | f 135 146 145 606 | f 135 145 136 607 | f 136 145 144 608 | f 136 144 137 609 | f 137 144 138 610 | f 144 143 138 611 | f 138 143 142 612 | f 138 142 139 613 | f 139 142 141 614 | f 139 141 140 615 | f 114 139 140 616 | f 114 140 113 617 | f 115 138 139 618 | f 115 139 114 619 | f 116 137 115 620 | f 137 138 115 621 | f 117 136 137 622 | f 117 137 116 623 | f 118 135 136 624 | f 118 136 117 625 | f 119 134 135 626 | f 119 135 118 627 | f 120 133 134 628 | f 120 134 119 629 | f 121 132 133 630 | f 121 133 120 631 | f 122 131 121 632 | f 131 132 121 633 | f 123 130 131 634 | f 123 131 122 635 | f 124 129 130 636 | f 124 130 123 637 | f 125 128 129 638 | f 125 129 124 639 | f 126 127 128 640 | f 126 128 125 641 | f 99 126 125 642 | f 99 125 100 643 | f 100 125 124 644 | f 100 124 101 645 | f 101 124 123 646 | f 101 123 102 647 | f 102 123 122 648 | f 102 122 103 649 | f 103 122 104 650 | f 122 121 104 651 | f 104 121 120 652 | f 104 120 105 653 | f 105 120 119 654 | f 105 119 106 655 | f 106 119 118 656 | f 106 118 107 657 | f 107 118 117 658 | f 107 117 108 659 | f 108 117 116 660 | f 108 116 109 661 | f 109 116 110 662 | f 116 115 110 663 | f 110 115 114 664 | f 110 114 111 665 | f 111 114 113 666 | f 111 113 112 667 | f 86 111 112 668 | f 86 112 85 669 | f 87 110 111 670 | f 87 111 86 671 | f 88 109 87 672 | f 109 110 87 673 | f 89 108 109 674 | f 89 109 88 675 | f 90 107 108 676 | f 90 108 89 677 | f 91 106 107 678 | f 91 107 90 679 | f 92 105 106 680 | f 92 106 91 681 | f 93 104 105 682 | f 93 105 92 683 | f 94 103 93 684 | f 103 104 93 685 | f 95 102 103 686 | f 95 103 94 687 | f 96 101 102 688 | f 96 102 95 689 | f 97 100 101 690 | f 97 101 96 691 | f 98 99 100 692 | f 98 100 97 693 | f 71 98 97 694 | f 71 97 72 695 | f 72 97 96 696 | f 72 96 73 697 | f 73 96 95 698 | f 73 95 74 699 | f 74 95 94 700 | f 74 94 75 701 | f 75 94 76 702 | f 94 93 76 703 | f 76 93 92 704 | f 76 92 77 705 | f 77 92 91 706 | f 77 91 78 707 | f 78 91 90 708 | f 78 90 79 709 | f 79 90 89 710 | f 79 89 80 711 | f 80 89 88 712 | f 80 88 81 713 | f 81 88 82 714 | f 88 87 82 715 | f 82 87 86 716 | f 82 86 83 717 | f 83 86 85 718 | f 83 85 84 719 | f 58 83 84 720 | f 58 84 57 721 | f 59 82 83 722 | f 59 83 58 723 | f 60 81 82 724 | f 60 82 59 725 | f 61 80 81 726 | f 61 81 60 727 | f 62 79 80 728 | f 62 80 61 729 | f 63 78 79 730 | f 63 79 62 731 | f 64 77 78 732 | f 64 78 63 733 | f 65 76 77 734 | f 65 77 64 735 | f 66 75 65 736 | f 75 76 65 737 | f 67 74 75 738 | f 67 75 66 739 | f 68 73 74 740 | f 68 74 67 741 | f 69 72 73 742 | f 69 73 68 743 | f 70 71 72 744 | f 70 72 69 745 | f 43 70 69 746 | f 43 69 44 747 | f 44 69 68 748 | f 44 68 45 749 | f 45 68 67 750 | f 45 67 46 751 | f 46 67 66 752 | f 46 66 47 753 | f 47 66 65 754 | f 47 65 48 755 | f 48 65 64 756 | f 48 64 49 757 | f 49 64 63 758 | f 49 63 50 759 | f 50 63 62 760 | f 50 62 51 761 | f 51 62 61 762 | f 51 61 52 763 | f 52 61 60 764 | f 52 60 53 765 | f 53 60 59 766 | f 53 59 54 767 | f 54 59 58 768 | f 54 58 55 769 | f 55 58 57 770 | f 55 57 56 771 | f 29 55 56 772 | f 29 56 28 773 | f 30 54 55 774 | f 30 55 29 775 | f 31 53 54 776 | f 31 54 30 777 | f 32 52 53 778 | f 32 53 31 779 | f 33 51 52 780 | f 33 52 32 781 | f 34 50 51 782 | f 34 51 33 783 | f 35 49 50 784 | f 35 50 34 785 | f 36 48 49 786 | f 36 49 35 787 | f 37 47 48 788 | f 37 48 36 789 | f 38 46 47 790 | f 38 47 37 791 | f 39 45 46 792 | f 39 46 38 793 | f 40 44 45 794 | f 40 45 39 795 | f 41 43 44 796 | f 41 44 40 797 | f 14 41 40 798 | f 14 40 15 799 | f 15 40 39 800 | f 15 39 16 801 | f 16 39 38 802 | f 16 38 17 803 | f 17 38 37 804 | f 17 37 18 805 | f 18 37 36 806 | f 18 36 19 807 | f 19 36 35 808 | f 19 35 20 809 | f 20 35 34 810 | f 20 34 21 811 | f 21 34 33 812 | f 21 33 22 813 | f 22 33 32 814 | f 22 32 23 815 | f 23 32 31 816 | f 23 31 24 817 | f 24 31 30 818 | f 24 30 25 819 | f 25 30 29 820 | f 25 29 26 821 | f 26 29 28 822 | f 26 28 27 823 | f 1 26 27 824 | f 1 27 211 825 | f 26 1 2 826 | f 26 2 25 827 | f 3 24 25 828 | f 3 25 2 829 | f 4 23 24 830 | f 4 24 3 831 | f 5 22 23 832 | f 5 23 4 833 | f 6 21 22 834 | f 6 22 5 835 | f 7 20 21 836 | f 7 21 6 837 | f 8 19 20 838 | f 8 20 7 839 | f 9 18 19 840 | f 9 19 8 841 | f 10 17 18 842 | f 10 18 9 843 | f 11 16 17 844 | f 11 17 10 845 | f 12 15 16 846 | f 12 16 11 847 | f 13 14 15 848 | f 13 15 12 849 | -------------------------------------------------------------------------------- /resources/sphere.obj.gso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/gambit-iphone-example/e55d915180cb6c57312cbb683d81823ea455e14f/resources/sphere.obj.gso -------------------------------------------------------------------------------- /test.c: -------------------------------------------------------------------------------- 1 | #ifdef ___LINKER_INFO 2 | ; File: "test.c", produced by Gambit-C v4.5.2 3 | ( 4 | 405002 5 | " test.o1" 6 | (" test.o1") 7 | ( 8 | ) 9 | ( 10 | ) 11 | ( 12 | " test.o1" 13 | ) 14 | ( 15 | "a" 16 | ) 17 | ( 18 | ) 19 | #f 20 | ) 21 | #else 22 | #define ___VERSION 405002 23 | #define ___MODULE_NAME " test.o1" 24 | #define ___LINKER_ID ____20_test_2e_o1 25 | #define ___MH_PROC ___H__20_test_2e_o1 26 | #define ___SCRIPT_LINE 0 27 | #define ___GLO_COUNT 2 28 | #define ___SUP_COUNT 2 29 | #define ___LBL_COUNT 2 30 | #include "gambit.h" 31 | 32 | ___NEED_GLO(___G__20_test_2e_o1) 33 | ___NEED_GLO(___G_a) 34 | 35 | ___BEGIN_GLO 36 | ___DEF_GLO(0," test.o1") 37 | ___DEF_GLO(1,"a") 38 | ___END_GLO 39 | 40 | 41 | #undef ___MD_ALL 42 | #define ___MD_ALL ___D_R0 ___D_R1 43 | #undef ___MR_ALL 44 | #define ___MR_ALL ___R_R0 ___R_R1 45 | #undef ___MW_ALL 46 | #define ___MW_ALL ___W_R1 47 | ___BEGIN_M_COD 48 | ___BEGIN_M_HLBL 49 | ___DEF_M_HLBL_INTRO 50 | ___DEF_M_HLBL(___L0__20_test_2e_o1) 51 | ___END_M_HLBL 52 | 53 | ___BEGIN_M_SW 54 | 55 | #undef ___PH_PROC 56 | #define ___PH_PROC ___H__20_test_2e_o1 57 | #undef ___PH_LBL0 58 | #define ___PH_LBL0 1 59 | #undef ___PD_ALL 60 | #define ___PD_ALL ___D_R0 ___D_R1 61 | #undef ___PR_ALL 62 | #define ___PR_ALL ___R_R0 ___R_R1 63 | #undef ___PW_ALL 64 | #define ___PW_ALL ___W_R1 65 | ___BEGIN_P_COD 66 | ___BEGIN_P_HLBL 67 | ___DEF_P_HLBL_INTRO 68 | ___DEF_P_HLBL(___L0__20_test_2e_o1) 69 | ___END_P_HLBL 70 | ___BEGIN_P_SW 71 | ___DEF_SLBL(0,___L0__20_test_2e_o1) 72 | ___IF_NARGS_EQ(0,___NOTHING) 73 | ___WRONG_NARGS(0,0,0,0) 74 | ___DEF_GLBL(___L__20_test_2e_o1) 75 | ___SET_GLO(1,___G_a,___FIX(5L)) 76 | ___SET_R1(___VOID) 77 | ___JUMPPRM(___NOTHING,___R0) 78 | ___END_P_SW 79 | ___END_P_COD 80 | 81 | ___END_M_SW 82 | ___END_M_COD 83 | 84 | ___BEGIN_LBL 85 | ___DEF_LBL_INTRO(___H__20_test_2e_o1," test.o1",___REF_FAL,1,0) 86 | ,___DEF_LBL_PROC(___H__20_test_2e_o1,0,0) 87 | ___END_LBL 88 | 89 | ___BEGIN_MOD1 90 | ___DEF_PRM(0,___G__20_test_2e_o1,1) 91 | ___END_MOD1 92 | 93 | ___BEGIN_MOD2 94 | ___END_MOD2 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /test.scm: -------------------------------------------------------------------------------- 1 | (define a 5) 2 | -------------------------------------------------------------------------------- /tosser.xcodeproj/james.pbxuser: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | 1A062E371010F501002F8C30 /* main.m */ = { 4 | isa = PBXFileReference; 5 | lastKnownFileType = sourcecode.c.objc; 6 | name = main.m; 7 | path = "/Users/james/projects/scheme/gambit-iphone-example/app/main.m"; 8 | sourceTree = ""; 9 | }; 10 | 1A3B7340101900D300887149 /* PBXTextBookmark */ = { 11 | isa = PBXTextBookmark; 12 | fRef = 1A5E086410119543006647CF /* EAGLView.m */; 13 | name = "EAGLView.m: 94"; 14 | rLen = 0; 15 | rLoc = 2218; 16 | rType = 0; 17 | vrLen = 845; 18 | vrLoc = 1377; 19 | }; 20 | 1A4EBE0C0FDA21CD000F4C9F /* init_.c */ = { 21 | uiCtxt = { 22 | sepNavIntBoundsRect = "{{0, 0}, {852, 172445}}"; 23 | sepNavSelRange = "{0, 0}"; 24 | sepNavVisRange = "{0, 290}"; 25 | }; 26 | }; 27 | 1A5300D6103E52D200859416 /* PBXTextBookmark */ = { 28 | isa = PBXTextBookmark; 29 | fRef = 1AC6904E101E8ECE002D468D /* medium.obj */; 30 | name = "medium.obj: 1"; 31 | rLen = 0; 32 | rLoc = 0; 33 | rType = 0; 34 | vrLen = 1107; 35 | vrLoc = 0; 36 | }; 37 | 1A5E086410119543006647CF /* EAGLView.m */ = { 38 | isa = PBXFileReference; 39 | lastKnownFileType = sourcecode.c.objc; 40 | name = EAGLView.m; 41 | path = "/Users/james/projects/scheme/gambit-iphone-example/app/EAGLView.m"; 42 | sourceTree = ""; 43 | }; 44 | 1A8888681079AB6D00E1E774 /* PlistBookmark */ = { 45 | isa = PlistBookmark; 46 | fRef = 1AC651A60FE710DB004C15CB /* Info.plist */; 47 | fallbackIsa = PBXBookmark; 48 | isK = 0; 49 | kPath = ( 50 | ); 51 | name = "/Users/james/Projects/scheme/gambit-iphone-example/Info.plist"; 52 | rLen = 0; 53 | rLoc = 9223372036854775808; 54 | }; 55 | 1A8888691079AB6D00E1E774 /* PBXTextBookmark */ = { 56 | isa = PBXTextBookmark; 57 | fRef = 1AC651260FE70FD1004C15CB /* EAGLView.h */; 58 | name = "EAGLView.h: 26"; 59 | rLen = 0; 60 | rLoc = 670; 61 | rType = 0; 62 | vrLen = 1152; 63 | vrLoc = 3; 64 | }; 65 | 1A9614811012282700A54EBA /* PBXTextBookmark */ = { 66 | isa = PBXTextBookmark; 67 | fRef = 1A062E371010F501002F8C30 /* main.m */; 68 | name = "main.m: 62"; 69 | rLen = 0; 70 | rLoc = 1573; 71 | rType = 0; 72 | vrLen = 998; 73 | vrLoc = 575; 74 | }; 75 | 1AAF6B470FD9A049000698DA /* init.c */ = { 76 | uiCtxt = { 77 | sepNavIntBoundsRect = "{{0, 0}, {835, 741910}}"; 78 | sepNavSelRange = "{16438, 0}"; 79 | sepNavVisRange = "{15922, 1480}"; 80 | sepNavWindowFrame = "{{75, 0}, {894, 878}}"; 81 | }; 82 | }; 83 | 1AC651260FE70FD1004C15CB /* EAGLView.h */ = { 84 | uiCtxt = { 85 | sepNavIntBoundsRect = "{{0, 0}, {831, 637}}"; 86 | sepNavSelRange = "{670, 0}"; 87 | sepNavVisRange = "{3, 1152}"; 88 | }; 89 | }; 90 | 1AC651270FE70FD1004C15CB /* EAGLView.m */ = { 91 | uiCtxt = { 92 | sepNavIntBoundsRect = "{{0, 0}, {1202, 2782}}"; 93 | sepNavSelRange = "{2218, 0}"; 94 | sepNavVisRange = "{1375, 973}"; 95 | }; 96 | }; 97 | 1AC651280FE70FD1004C15CB /* main.m */ = { 98 | uiCtxt = { 99 | sepNavIntBoundsRect = "{{0, 0}, {835, 840}}"; 100 | sepNavSelRange = "{1522, 0}"; 101 | sepNavVisRange = "{0, 1405}"; 102 | }; 103 | }; 104 | 1AC651A60FE710DB004C15CB /* Info.plist */ = { 105 | uiCtxt = { 106 | sepNavWindowFrame = "{{80, 0}, {894, 878}}"; 107 | }; 108 | }; 109 | 1AC6904E101E8ECE002D468D /* medium.obj */ = { 110 | uiCtxt = { 111 | sepNavIntBoundsRect = "{{0, 0}, {869, 45626}}"; 112 | sepNavSelRange = "{0, 0}"; 113 | sepNavVisRange = "{0, 1107}"; 114 | }; 115 | }; 116 | 1ACA2F310FD4E7FC005851FB /* tosser */ = { 117 | isa = PBXExecutable; 118 | activeArgIndices = ( 119 | ); 120 | argumentStrings = ( 121 | ); 122 | autoAttachOnCrash = 1; 123 | breakpointsEnabled = 0; 124 | configStateDict = { 125 | }; 126 | customDataFormattersEnabled = 1; 127 | dataTipCustomDataFormattersEnabled = 1; 128 | dataTipShowTypeColumn = 1; 129 | dataTipSortType = 0; 130 | debuggerPlugin = GDBDebugging; 131 | disassemblyDisplayState = 0; 132 | dylibVariantSuffix = ""; 133 | enableDebugStr = 1; 134 | environmentEntries = ( 135 | ); 136 | executableSystemSymbolLevel = 0; 137 | executableUserSymbolLevel = 0; 138 | libgmallocEnabled = 0; 139 | name = tosser; 140 | savedGlobals = { 141 | }; 142 | showTypeColumn = 0; 143 | sourceDirectories = ( 144 | ); 145 | variableFormatDictionary = { 146 | }; 147 | }; 148 | 1ACA2F450FD4E803005851FB /* Source Control */ = { 149 | isa = PBXSourceControlManager; 150 | fallbackIsa = XCSourceControlManager; 151 | isSCMEnabled = 0; 152 | scmConfiguration = { 153 | repositoryNamesForRoots = { 154 | "" = ""; 155 | }; 156 | }; 157 | }; 158 | 1ACA2F460FD4E803005851FB /* Code sense */ = { 159 | isa = PBXCodeSenseManager; 160 | indexTemplatePath = ""; 161 | }; 162 | 1D6058900D05DD3D006BFB54 /* tosser */ = { 163 | activeExec = 0; 164 | executables = ( 165 | 1ACA2F310FD4E7FC005851FB /* tosser */, 166 | ); 167 | }; 168 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 169 | activeBuildConfigurationName = Debug; 170 | activeExecutable = 1ACA2F310FD4E7FC005851FB /* tosser */; 171 | activeSDKPreference = iphonesimulator3.1.2; 172 | activeTarget = 1D6058900D05DD3D006BFB54 /* tosser */; 173 | addToTargets = ( 174 | 1D6058900D05DD3D006BFB54 /* tosser */, 175 | ); 176 | codeSenseManager = 1ACA2F460FD4E803005851FB /* Code sense */; 177 | executables = ( 178 | 1ACA2F310FD4E7FC005851FB /* tosser */, 179 | ); 180 | perUserDictionary = { 181 | PBXConfiguration.PBXFileTableDataSource3.PBXErrorsWarningsDataSource = { 182 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 183 | PBXFileTableDataSourceColumnSortingKey = PBXErrorsWarningsDataSource_LocationID; 184 | PBXFileTableDataSourceColumnWidthsKey = ( 185 | 20, 186 | 575, 187 | 306.20849609375, 188 | ); 189 | PBXFileTableDataSourceColumnsKey = ( 190 | PBXErrorsWarningsDataSource_TypeID, 191 | PBXErrorsWarningsDataSource_MessageID, 192 | PBXErrorsWarningsDataSource_LocationID, 193 | ); 194 | }; 195 | PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = { 196 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 197 | PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID; 198 | PBXFileTableDataSourceColumnWidthsKey = ( 199 | 22, 200 | 300, 201 | 451.58349609375, 202 | ); 203 | PBXFileTableDataSourceColumnsKey = ( 204 | PBXExecutablesDataSource_ActiveFlagID, 205 | PBXExecutablesDataSource_NameID, 206 | PBXExecutablesDataSource_CommentsID, 207 | ); 208 | }; 209 | PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { 210 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 211 | PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; 212 | PBXFileTableDataSourceColumnWidthsKey = ( 213 | 20, 214 | 394, 215 | 20, 216 | 48, 217 | 43, 218 | 43, 219 | 20, 220 | ); 221 | PBXFileTableDataSourceColumnsKey = ( 222 | PBXFileDataSource_FiletypeID, 223 | PBXFileDataSource_Filename_ColumnID, 224 | PBXFileDataSource_Built_ColumnID, 225 | PBXFileDataSource_ObjectSize_ColumnID, 226 | PBXFileDataSource_Errors_ColumnID, 227 | PBXFileDataSource_Warnings_ColumnID, 228 | PBXFileDataSource_Target_ColumnID, 229 | ); 230 | }; 231 | PBXConfiguration.PBXFileTableDataSource3.PBXFindDataSource = { 232 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 233 | PBXFileTableDataSourceColumnSortingKey = PBXFindDataSource_LocationID; 234 | PBXFileTableDataSourceColumnWidthsKey = ( 235 | 200, 236 | 578, 237 | ); 238 | PBXFileTableDataSourceColumnsKey = ( 239 | PBXFindDataSource_MessageID, 240 | PBXFindDataSource_LocationID, 241 | ); 242 | }; 243 | PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { 244 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 245 | PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; 246 | PBXFileTableDataSourceColumnWidthsKey = ( 247 | 20, 248 | 524, 249 | 60, 250 | 20, 251 | 48, 252 | 43, 253 | 43, 254 | ); 255 | PBXFileTableDataSourceColumnsKey = ( 256 | PBXFileDataSource_FiletypeID, 257 | PBXFileDataSource_Filename_ColumnID, 258 | PBXTargetDataSource_PrimaryAttribute, 259 | PBXFileDataSource_Built_ColumnID, 260 | PBXFileDataSource_ObjectSize_ColumnID, 261 | PBXFileDataSource_Errors_ColumnID, 262 | PBXFileDataSource_Warnings_ColumnID, 263 | ); 264 | }; 265 | PBXPerProjectTemplateStateSaveDate = 287001357; 266 | PBXWorkspaceStateSaveDate = 287001357; 267 | }; 268 | perUserProjectItems = { 269 | 1A3B7340101900D300887149 /* PBXTextBookmark */ = 1A3B7340101900D300887149 /* PBXTextBookmark */; 270 | 1A5300D6103E52D200859416 /* PBXTextBookmark */ = 1A5300D6103E52D200859416 /* PBXTextBookmark */; 271 | 1A8888681079AB6D00E1E774 /* PlistBookmark */ = 1A8888681079AB6D00E1E774 /* PlistBookmark */; 272 | 1A8888691079AB6D00E1E774 /* PBXTextBookmark */ = 1A8888691079AB6D00E1E774 /* PBXTextBookmark */; 273 | 1A9614811012282700A54EBA /* PBXTextBookmark */ = 1A9614811012282700A54EBA /* PBXTextBookmark */; 274 | }; 275 | sourceControlManager = 1ACA2F450FD4E803005851FB /* Source Control */; 276 | userBuildSettings = { 277 | }; 278 | }; 279 | } 280 | -------------------------------------------------------------------------------- /tosser.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 45; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1A1D5ACA109A349500ED980E /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A1D5AC9109A349500ED980E /* OpenAL.framework */; }; 11 | 1A1D5ACE109A34A600ED980E /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A1D5ACD109A34A600ED980E /* AudioToolbox.framework */; }; 12 | 1A2DA1901047358B00D90110 /* jlongster.obj.gso in Resources */ = {isa = PBXBuildFile; fileRef = 1A2DA18F1047358B00D90110 /* jlongster.obj.gso */; }; 13 | 1A4EBE0D0FDA21CD000F4C9F /* init_.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A4EBE0C0FDA21CD000F4C9F /* init_.c */; }; 14 | 1A53011D103E5A9700859416 /* sphere.obj.gso in Resources */ = {isa = PBXBuildFile; fileRef = 1A53011C103E5A9700859416 /* sphere.obj.gso */; }; 15 | 1A5BC5CC102B80FA001FEDD9 /* sphere.obj in Resources */ = {isa = PBXBuildFile; fileRef = 1A5BC5C9102B80FA001FEDD9 /* sphere.obj */; }; 16 | 1A5BC5CD102B80FA001FEDD9 /* mass.obj in Resources */ = {isa = PBXBuildFile; fileRef = 1A5BC5CA102B80FA001FEDD9 /* mass.obj */; }; 17 | 1A5BC5CE102B80FA001FEDD9 /* mass.mtl in Resources */ = {isa = PBXBuildFile; fileRef = 1A5BC5CB102B80FA001FEDD9 /* mass.mtl */; }; 18 | 1A5BC5DA102D21E8001FEDD9 /* collision.obj in Resources */ = {isa = PBXBuildFile; fileRef = 1A5BC5D9102D21E8001FEDD9 /* collision.obj */; }; 19 | 1A861A8510916C0500706CC5 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A861A8410916C0500706CC5 /* CoreGraphics.framework */; }; 20 | 1A8BCDB0101A1BEA00DED70B /* box.obj in Resources */ = {isa = PBXBuildFile; fileRef = 1A8BCDAF101A1BEA00DED70B /* box.obj */; }; 21 | 1AAF6B480FD9A049000698DA /* init.c in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF6B470FD9A049000698DA /* init.c */; }; 22 | 1AC6512C0FE70FD1004C15CB /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AC651270FE70FD1004C15CB /* EAGLView.m */; }; 23 | 1AC6512D0FE70FD1004C15CB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AC651280FE70FD1004C15CB /* main.m */; }; 24 | 1AC6512E0FE70FD1004C15CB /* tosserAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6512A0FE70FD1004C15CB /* tosserAppDelegate.m */; }; 25 | 1AC651320FE70FE9004C15CB /* window.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1AC651300FE70FE9004C15CB /* window.xib */; }; 26 | 1AC651A70FE710DB004C15CB /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AC651A60FE710DB004C15CB /* Info.plist */; }; 27 | 1AC6904F101E8ECE002D468D /* medium.obj in Resources */ = {isa = PBXBuildFile; fileRef = 1AC6904E101E8ECE002D468D /* medium.obj */; }; 28 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 29 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 30 | 28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD14FF0DC6FC520079059D /* OpenGLES.framework */; }; 31 | 28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD15070DC6FC5B0079059D /* QuartzCore.framework */; }; 32 | /* End PBXBuildFile section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | 1A1D5AC9109A349500ED980E /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = /System/Library/Frameworks/OpenAL.framework; sourceTree = ""; }; 36 | 1A1D5ACD109A34A600ED980E /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; 37 | 1A2DA18F1047358B00D90110 /* jlongster.obj.gso */ = {isa = PBXFileReference; lastKnownFileType = file; path = jlongster.obj.gso; sourceTree = ""; }; 38 | 1A4EBE0C0FDA21CD000F4C9F /* init_.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = init_.c; path = lib/init_.c; sourceTree = ""; }; 39 | 1A53011C103E5A9700859416 /* sphere.obj.gso */ = {isa = PBXFileReference; lastKnownFileType = file; path = sphere.obj.gso; sourceTree = ""; }; 40 | 1A5BC5C9102B80FA001FEDD9 /* sphere.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sphere.obj; sourceTree = ""; }; 41 | 1A5BC5CA102B80FA001FEDD9 /* mass.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mass.obj; sourceTree = ""; }; 42 | 1A5BC5CB102B80FA001FEDD9 /* mass.mtl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mass.mtl; sourceTree = ""; }; 43 | 1A5BC5D9102D21E8001FEDD9 /* collision.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = collision.obj; sourceTree = ""; }; 44 | 1A861A8410916C0500706CC5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 45 | 1A8BCDAF101A1BEA00DED70B /* box.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = box.obj; sourceTree = ""; }; 46 | 1AAF6B470FD9A049000698DA /* init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = init.c; path = lib/init.c; sourceTree = ""; }; 47 | 1AC651260FE70FD1004C15CB /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EAGLView.h; path = app/EAGLView.h; sourceTree = ""; }; 48 | 1AC651270FE70FD1004C15CB /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EAGLView.m; path = app/EAGLView.m; sourceTree = ""; }; 49 | 1AC651280FE70FD1004C15CB /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = app/main.m; sourceTree = ""; }; 50 | 1AC651290FE70FD1004C15CB /* tosserAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tosserAppDelegate.h; path = app/tosserAppDelegate.h; sourceTree = ""; }; 51 | 1AC6512A0FE70FD1004C15CB /* tosserAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = tosserAppDelegate.m; path = app/tosserAppDelegate.m; sourceTree = ""; }; 52 | 1AC651300FE70FE9004C15CB /* window.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = window.xib; path = app/window.xib; sourceTree = ""; }; 53 | 1AC651A60FE710DB004C15CB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 1AC6904E101E8ECE002D468D /* medium.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = medium.obj; sourceTree = ""; }; 55 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 56 | 1D6058910D05DD3D006BFB54 /* tosser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = tosser.app; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 58 | 28FD14FF0DC6FC520079059D /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 59 | 28FD15070DC6FC5B0079059D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 68 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 69 | 28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */, 70 | 28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */, 71 | 1A861A8510916C0500706CC5 /* CoreGraphics.framework in Frameworks */, 72 | 1A1D5ACA109A349500ED980E /* OpenAL.framework in Frameworks */, 73 | 1A1D5ACE109A34A600ED980E /* AudioToolbox.framework in Frameworks */, 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | /* End PBXFrameworksBuildPhase section */ 78 | 79 | /* Begin PBXGroup section */ 80 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 1D6058910D05DD3D006BFB54 /* tosser.app */, 84 | ); 85 | name = Products; 86 | sourceTree = ""; 87 | }; 88 | 1A8BCDAE101A1BEA00DED70B /* resources */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 1A2DA18F1047358B00D90110 /* jlongster.obj.gso */, 92 | 1A53011C103E5A9700859416 /* sphere.obj.gso */, 93 | 1A5BC5D9102D21E8001FEDD9 /* collision.obj */, 94 | 1A5BC5C9102B80FA001FEDD9 /* sphere.obj */, 95 | 1A5BC5CA102B80FA001FEDD9 /* mass.obj */, 96 | 1A5BC5CB102B80FA001FEDD9 /* mass.mtl */, 97 | 1AC6904E101E8ECE002D468D /* medium.obj */, 98 | 1A8BCDAF101A1BEA00DED70B /* box.obj */, 99 | ); 100 | path = resources; 101 | sourceTree = ""; 102 | }; 103 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 1A8BCDAE101A1BEA00DED70B /* resources */, 107 | 1AC651A60FE710DB004C15CB /* Info.plist */, 108 | 1AC651300FE70FE9004C15CB /* window.xib */, 109 | 1AC651260FE70FD1004C15CB /* EAGLView.h */, 110 | 1AC651270FE70FD1004C15CB /* EAGLView.m */, 111 | 1AC651280FE70FD1004C15CB /* main.m */, 112 | 1AC651290FE70FD1004C15CB /* tosserAppDelegate.h */, 113 | 1AC6512A0FE70FD1004C15CB /* tosserAppDelegate.m */, 114 | 1A4EBE0C0FDA21CD000F4C9F /* init_.c */, 115 | 1AAF6B470FD9A049000698DA /* init.c */, 116 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 117 | 19C28FACFE9D520D11CA2CBB /* Products */, 118 | ); 119 | name = CustomTemplate; 120 | sourceTree = ""; 121 | }; 122 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 1A861A8410916C0500706CC5 /* CoreGraphics.framework */, 126 | 28FD15070DC6FC5B0079059D /* QuartzCore.framework */, 127 | 28FD14FF0DC6FC520079059D /* OpenGLES.framework */, 128 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 129 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 130 | 1A1D5AC9109A349500ED980E /* OpenAL.framework */, 131 | 1A1D5ACD109A34A600ED980E /* AudioToolbox.framework */, 132 | ); 133 | name = Frameworks; 134 | sourceTree = ""; 135 | }; 136 | /* End PBXGroup section */ 137 | 138 | /* Begin PBXNativeTarget section */ 139 | 1D6058900D05DD3D006BFB54 /* tosser */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "tosser" */; 142 | buildPhases = ( 143 | 1D60588D0D05DD3D006BFB54 /* Resources */, 144 | 1D60588E0D05DD3D006BFB54 /* Sources */, 145 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 146 | ); 147 | buildRules = ( 148 | ); 149 | dependencies = ( 150 | ); 151 | name = tosser; 152 | productName = tosser; 153 | productReference = 1D6058910D05DD3D006BFB54 /* tosser.app */; 154 | productType = "com.apple.product-type.application"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 160 | isa = PBXProject; 161 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "tosser" */; 162 | compatibilityVersion = "Xcode 3.1"; 163 | hasScannedForEncodings = 1; 164 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 165 | projectDirPath = ""; 166 | projectRoot = ""; 167 | targets = ( 168 | 1D6058900D05DD3D006BFB54 /* tosser */, 169 | ); 170 | }; 171 | /* End PBXProject section */ 172 | 173 | /* Begin PBXResourcesBuildPhase section */ 174 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 175 | isa = PBXResourcesBuildPhase; 176 | buildActionMask = 2147483647; 177 | files = ( 178 | 1AC651320FE70FE9004C15CB /* window.xib in Resources */, 179 | 1AC651A70FE710DB004C15CB /* Info.plist in Resources */, 180 | 1A8BCDB0101A1BEA00DED70B /* box.obj in Resources */, 181 | 1AC6904F101E8ECE002D468D /* medium.obj in Resources */, 182 | 1A5BC5CC102B80FA001FEDD9 /* sphere.obj in Resources */, 183 | 1A5BC5CD102B80FA001FEDD9 /* mass.obj in Resources */, 184 | 1A5BC5CE102B80FA001FEDD9 /* mass.mtl in Resources */, 185 | 1A5BC5DA102D21E8001FEDD9 /* collision.obj in Resources */, 186 | 1A53011D103E5A9700859416 /* sphere.obj.gso in Resources */, 187 | 1A2DA1901047358B00D90110 /* jlongster.obj.gso in Resources */, 188 | ); 189 | runOnlyForDeploymentPostprocessing = 0; 190 | }; 191 | /* End PBXResourcesBuildPhase section */ 192 | 193 | /* Begin PBXSourcesBuildPhase section */ 194 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 195 | isa = PBXSourcesBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | 1AAF6B480FD9A049000698DA /* init.c in Sources */, 199 | 1A4EBE0D0FDA21CD000F4C9F /* init_.c in Sources */, 200 | 1AC6512C0FE70FD1004C15CB /* EAGLView.m in Sources */, 201 | 1AC6512D0FE70FD1004C15CB /* main.m in Sources */, 202 | 1AC6512E0FE70FD1004C15CB /* tosserAppDelegate.m in Sources */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | /* End PBXSourcesBuildPhase section */ 207 | 208 | /* Begin XCBuildConfiguration section */ 209 | 1ABC50B2101254C200811E0D /* Debug iPhone */ = { 210 | isa = XCBuildConfiguration; 211 | buildSettings = { 212 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 213 | CODE_SIGN_IDENTITY = ""; 214 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: James Long"; 215 | COPY_PHASE_STRIP = NO; 216 | GCC_C_LANGUAGE_STANDARD = c99; 217 | GCC_VERSION = 4.2; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 219 | GCC_WARN_UNUSED_VARIABLE = NO; 220 | ONLY_ACTIVE_ARCH = YES; 221 | OTHER_CFLAGS = ( 222 | "-D___LIBRARY", 223 | "-x", 224 | "objective-c", 225 | "-Wno-unused", 226 | "-fno-math-errno", 227 | "-fschedule-insns2", 228 | "-fno-trapping-math", 229 | "-fno-strict-aliasing", 230 | "-fwrapv", 231 | "-fmodulo-sched", 232 | "-freschedule-modulo-scheduled-loops", 233 | "-fno-common", 234 | ); 235 | OTHER_LDFLAGS = ( 236 | "-L/usr/local/Gambit-C/iPhoneOS-3.1.2/lib", 237 | "-lgambc", 238 | ); 239 | PREBINDING = NO; 240 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 241 | SDKROOT = iphoneos3.0; 242 | USER_HEADER_SEARCH_PATHS = "/usr/local/Gambit-C/iPhoneOS-3.1.2/include"; 243 | }; 244 | name = "Debug iPhone"; 245 | }; 246 | 1ABC50B3101254C200811E0D /* Debug iPhone */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ALWAYS_SEARCH_USER_PATHS = NO; 250 | COPY_PHASE_STRIP = NO; 251 | GCC_DYNAMIC_NO_PIC = NO; 252 | GCC_OPTIMIZATION_LEVEL = 0; 253 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 254 | GCC_PREFIX_HEADER = tosser_Prefix.pch; 255 | INFOPLIST_FILE = Info.plist; 256 | PRODUCT_NAME = tosser; 257 | }; 258 | name = "Debug iPhone"; 259 | }; 260 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | ALWAYS_SEARCH_USER_PATHS = NO; 264 | COPY_PHASE_STRIP = NO; 265 | GCC_DYNAMIC_NO_PIC = NO; 266 | GCC_OPTIMIZATION_LEVEL = 0; 267 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 268 | GCC_PREFIX_HEADER = tosser_Prefix.pch; 269 | INFOPLIST_FILE = Info.plist; 270 | PRODUCT_NAME = tosser; 271 | }; 272 | name = Debug; 273 | }; 274 | 1D6058950D05DD3E006BFB54 /* Release */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | ALWAYS_SEARCH_USER_PATHS = NO; 278 | COPY_PHASE_STRIP = YES; 279 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 280 | GCC_PREFIX_HEADER = tosser_Prefix.pch; 281 | INFOPLIST_FILE = Info.plist; 282 | PRODUCT_NAME = tosser; 283 | }; 284 | name = Release; 285 | }; 286 | C01FCF4F08A954540054247B /* Debug */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 290 | CODE_SIGN_IDENTITY = ""; 291 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: James Long"; 292 | COPY_PHASE_STRIP = NO; 293 | GCC_C_LANGUAGE_STANDARD = c99; 294 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 295 | GCC_WARN_UNUSED_VARIABLE = NO; 296 | ONLY_ACTIVE_ARCH = YES; 297 | OTHER_CFLAGS = ( 298 | "-D___LIBRARY", 299 | "-x", 300 | "objective-c", 301 | "-Wno-unused", 302 | "-fno-math-errno", 303 | "-fschedule-insns2", 304 | "-fno-trapping-math", 305 | "-fno-strict-aliasing", 306 | "-fwrapv", 307 | "-fmodulo-sched", 308 | "-freschedule-modulo-scheduled-loops", 309 | "-fomit-frame-pointer", 310 | "-fno-common", 311 | ); 312 | OTHER_LDFLAGS = ( 313 | "-L/usr/local/Gambit-C/iPhoneSimulator-3.1.2/lib", 314 | "-lgambc", 315 | ); 316 | PREBINDING = NO; 317 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 318 | SDKROOT = iphonesimulator3.1; 319 | USER_HEADER_SEARCH_PATHS = "/usr/local/Gambit-C/iPhoneSimulator-3.1.2/include"; 320 | }; 321 | name = Debug; 322 | }; 323 | C01FCF5008A954540054247B /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 327 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 328 | GCC_C_LANGUAGE_STANDARD = c99; 329 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | PREBINDING = NO; 332 | SDKROOT = iphoneos2.0; 333 | }; 334 | name = Release; 335 | }; 336 | /* End XCBuildConfiguration section */ 337 | 338 | /* Begin XCConfigurationList section */ 339 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "tosser" */ = { 340 | isa = XCConfigurationList; 341 | buildConfigurations = ( 342 | 1D6058940D05DD3E006BFB54 /* Debug */, 343 | 1ABC50B3101254C200811E0D /* Debug iPhone */, 344 | 1D6058950D05DD3E006BFB54 /* Release */, 345 | ); 346 | defaultConfigurationIsVisible = 0; 347 | defaultConfigurationName = Release; 348 | }; 349 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "tosser" */ = { 350 | isa = XCConfigurationList; 351 | buildConfigurations = ( 352 | C01FCF4F08A954540054247B /* Debug */, 353 | 1ABC50B2101254C200811E0D /* Debug iPhone */, 354 | C01FCF5008A954540054247B /* Release */, 355 | ); 356 | defaultConfigurationIsVisible = 0; 357 | defaultConfigurationName = Release; 358 | }; 359 | /* End XCConfigurationList section */ 360 | }; 361 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 362 | } 363 | -------------------------------------------------------------------------------- /tosser_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'tosser' target in the 'tosser' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | --------------------------------------------------------------------------------