# HG changeset patch # User John Tsiombikas # Date 1315551822 -10800 # Node ID 23e5d274b2a2c40c524ea5e295efa04123938c77 # Parent 634c7f7c1f0f2237e2cb4d932a86aedee3cd6ddc added options panel, also added the xib files to the repository as they're needed diff -r 634c7f7c1f0f -r 23e5d274b2a2 MainWindow.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MainWindow.xib Fri Sep 09 10:03:42 2011 +0300 @@ -0,0 +1,239 @@ + + + + 800 + 10D541 + 760 + 1038.29 + 460.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 81 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + IBCocoaTouchFramework + + + + 1316 + + YES + + + 1298 + {320, 480} + + + 3 + MQA + + NO + IBCocoaTouchFramework + + + + {320, 480} + + + 1 + MSAxIDEAA + + NO + IBCocoaTouchFramework + YES + YES + + + + + YES + + + delegate + + + + 4 + + + + window + + + + 5 + + + + glView + + + + 9 + + + + + YES + + 0 + + + + + + 2 + + + YES + + + + + + -1 + + + File's Owner + + + 3 + + + + + 8 + + + + + -2 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 2.IBAttributePlaceholdersKey + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 3.CustomClassName + 3.IBPluginDependency + 8.CustomClassName + 8.IBPluginDependency + + + YES + UIApplication + UIResponder + + YES + + + YES + + + {{228, 376}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + istereoAppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + EAGLView + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 9 + + + + YES + + EAGLView + UIView + + IBProjectSource + Classes/EAGLView.h + + + + istereoAppDelegate + NSObject + + YES + + YES + glView + window + + + YES + EAGLView + UIWindow + + + + IBProjectSource + Classes/istereoAppDelegate.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + istereo.xcodeproj + 3 + 81 + + diff -r 634c7f7c1f0f -r 23e5d274b2a2 istereo.xcodeproj/project.pbxproj --- a/istereo.xcodeproj/project.pbxproj Fri Sep 09 00:31:54 2011 +0300 +++ b/istereo.xcodeproj/project.pbxproj Fri Sep 09 10:03:42 2011 +0300 @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 063C67DA1419CBFF00BA388B /* ui.m in Sources */ = {isa = PBXBuildFile; fileRef = 063C67D81419CBFF00BA388B /* ui.m */; }; + 063C67DB1419CBFF00BA388B /* ui.xib in Resources */ = {isa = PBXBuildFile; fileRef = 063C67D91419CBFF00BA388B /* ui.xib */; }; 069BEBC414188B070043D0BB /* conv.c in Sources */ = {isa = PBXBuildFile; fileRef = 069BEBBB14188B070043D0BB /* conv.c */; }; 069BEBC514188B070043D0BB /* file_jpeg.c in Sources */ = {isa = PBXBuildFile; fileRef = 069BEBBC14188B070043D0BB /* file_jpeg.c */; }; 069BEBC614188B070043D0BB /* file_png.c in Sources */ = {isa = PBXBuildFile; fileRef = 069BEBBD14188B070043D0BB /* file_png.c */; }; @@ -111,7 +113,6 @@ 069BED821418D1E90043D0BB /* ES2Renderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 06D8CEB61418314000EF1378 /* ES2Renderer.m */; }; 06D8CEC71418314000EF1378 /* cam.c in Sources */ = {isa = PBXBuildFile; fileRef = 06D8CEAE1418314000EF1378 /* cam.c */; }; 06D8CEC81418314000EF1378 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 06D8CEB21418314000EF1378 /* EAGLView.m */; }; - 06D8CEC91418314000EF1378 /* ES1Renderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 06D8CEB41418314000EF1378 /* ES1Renderer.m */; }; 06D8CECB1418314000EF1378 /* istereo.c in Sources */ = {isa = PBXBuildFile; fileRef = 06D8CEB81418314000EF1378 /* istereo.c */; }; 06D8CECD1418314000EF1378 /* istereoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 06D8CEBC1418314000EF1378 /* istereoAppDelegate.m */; }; 06D8CECE1418314000EF1378 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 06D8CEBD1418314000EF1378 /* main.m */; }; @@ -130,6 +131,9 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 063C67D71419CBFF00BA388B /* ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ui.h; path = src/ui.h; sourceTree = ""; }; + 063C67D81419CBFF00BA388B /* ui.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ui.m; path = src/ui.m; sourceTree = ""; }; + 063C67D91419CBFF00BA388B /* ui.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ui.xib; path = src/ui.xib; sourceTree = ""; }; 069BEBBB14188B070043D0BB /* conv.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; name = conv.c; path = libs/imago2/conv.c; sourceTree = ""; }; 069BEBBC14188B070043D0BB /* file_jpeg.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; name = file_jpeg.c; path = libs/imago2/file_jpeg.c; sourceTree = ""; }; 069BEBBD14188B070043D0BB /* file_png.c */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.c; name = file_png.c; path = libs/imago2/file_png.c; sourceTree = ""; }; @@ -272,8 +276,6 @@ 06D8CEB01418314000EF1378 /* config.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = config.h; path = src/config.h; sourceTree = ""; }; 06D8CEB11418314000EF1378 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = EAGLView.h; path = src/EAGLView.h; sourceTree = ""; }; 06D8CEB21418314000EF1378 /* EAGLView.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; name = EAGLView.m; path = src/EAGLView.m; sourceTree = ""; }; - 06D8CEB31418314000EF1378 /* ES1Renderer.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = ES1Renderer.h; path = src/ES1Renderer.h; sourceTree = ""; }; - 06D8CEB41418314000EF1378 /* ES1Renderer.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; name = ES1Renderer.m; path = src/ES1Renderer.m; sourceTree = ""; }; 06D8CEB51418314000EF1378 /* ES2Renderer.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = ES2Renderer.h; path = src/ES2Renderer.h; sourceTree = ""; }; 06D8CEB61418314000EF1378 /* ES2Renderer.m */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.objc; name = ES2Renderer.m; path = src/ES2Renderer.m; sourceTree = ""; }; 06D8CEB71418314000EF1378 /* ESRenderer.h */ = {isa = PBXFileReference; fileEncoding = 0; lastKnownFileType = sourcecode.c.h; name = ESRenderer.h; path = src/ESRenderer.h; sourceTree = ""; }; @@ -318,6 +320,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 063C67D61419CBD000BA388B /* ui */ = { + isa = PBXGroup; + children = ( + 063C67D71419CBFF00BA388B /* ui.h */, + 063C67D81419CBFF00BA388B /* ui.m */, + 063C67D91419CBFF00BA388B /* ui.xib */, + ); + name = ui; + sourceTree = ""; + }; 069BEBB514188ACB0043D0BB /* libs */ = { isa = PBXGroup; children = ( @@ -497,6 +509,7 @@ 06D8CEAC1418312500EF1378 /* src */ = { isa = PBXGroup; children = ( + 063C67D61419CBD000BA388B /* ui */, 06D8CED31418314700EF1378 /* gay */, 06D8CEAE1418314000EF1378 /* cam.c */, 06D8CEAF1418314000EF1378 /* cam.h */, @@ -537,8 +550,6 @@ 06D8CEBC1418314000EF1378 /* istereoAppDelegate.m */, 06D8CEB11418314000EF1378 /* EAGLView.h */, 06D8CEB21418314000EF1378 /* EAGLView.m */, - 06D8CEB31418314000EF1378 /* ES1Renderer.h */, - 06D8CEB41418314000EF1378 /* ES1Renderer.m */, 06D8CEB51418314000EF1378 /* ES2Renderer.h */, 06D8CEB61418314000EF1378 /* ES2Renderer.m */, 06D8CEB71418314000EF1378 /* ESRenderer.h */, @@ -659,6 +670,7 @@ 069BECA614188BC60043D0BB /* stonewall.jpg in Resources */, 069BECA714188BC60043D0BB /* text.png in Resources */, 069BECA814188BC60043D0BB /* tiles.jpg in Resources */, + 063C67DB1419CBFF00BA388B /* ui.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -687,7 +699,6 @@ files = ( 06D8CEC71418314000EF1378 /* cam.c in Sources */, 06D8CEC81418314000EF1378 /* EAGLView.m in Sources */, - 06D8CEC91418314000EF1378 /* ES1Renderer.m in Sources */, 06D8CECB1418314000EF1378 /* istereo.c in Sources */, 06D8CECD1418314000EF1378 /* istereoAppDelegate.m in Sources */, 06D8CECE1418314000EF1378 /* main.m in Sources */, @@ -784,6 +795,7 @@ 069BEC9714188B530043D0BB /* pngwtran.c in Sources */, 069BEC9814188B530043D0BB /* pngwutil.c in Sources */, 069BED821418D1E90043D0BB /* ES2Renderer.m in Sources */, + 063C67DA1419CBFF00BA388B /* ui.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff -r 634c7f7c1f0f -r 23e5d274b2a2 istereoViewController.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/istereoViewController.xib Fri Sep 09 10:03:42 2011 +0300 @@ -0,0 +1,389 @@ + + + + 1024 + 10F569 + 800 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 121 + + + YES + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {320, 460} + + 3 + MQA + + 2 + + + NO + IBCocoaTouchFramework + + + + + YES + + + view + + + + 3 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 2.CustomClassName + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + + + YES + istereoViewController + UIResponder + EAGLView + {{401, 662}, {320, 460}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 4 + + + + YES + + EAGLView + UIView + + drawView: + id + + + drawView: + + drawView: + id + + + + YES + + YES + displayLink + renderer + + + YES + id + id + + + + YES + + YES + displayLink + renderer + + + YES + + displayLink + id + + + renderer + id + + + + + IBProjectSource + Classes/EAGLView.h + + + + istereoViewController + UIViewController + + IBUserSource + + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + Untitled.xcodeproj + 3 + 121 + + diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/EAGLView.h --- a/src/EAGLView.h Fri Sep 09 00:31:54 2011 +0300 +++ b/src/EAGLView.h Fri Sep 09 10:03:42 2011 +0300 @@ -1,33 +1,30 @@ -// -// EAGLView.h -// istereo -// -// Created by nuclear on 9/6/11. -// Copyright __MyCompanyName__ 2011. All rights reserved. -// - #import #import #import "ESRenderer.h" + +void show_options(void); +void hide_options(void); + + // This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. // The view content is basically an EAGL surface you render your OpenGL scene into. // Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. @interface EAGLView : UIView -{ +{ @private - id renderer; + id renderer; - BOOL animating; - BOOL displayLinkSupported; - NSInteger animationFrameInterval; - // Use of the CADisplayLink class is the preferred method for controlling your animation timing. - // CADisplayLink will link to the main display and fire every vsync when added to a given run-loop. - // The NSTimer class is used only as fallback when running on a pre 3.1 device where CADisplayLink - // isn't available. - id displayLink; - NSTimer *animationTimer; + BOOL animating; + BOOL displayLinkSupported; + NSInteger animationFrameInterval; + // Use of the CADisplayLink class is the preferred method for controlling your animation timing. + // CADisplayLink will link to the main display and fire every vsync when added to a given run-loop. + // The NSTimer class is used only as fallback when running on a pre 3.1 device where CADisplayLink + // isn't available. + id displayLink; + NSTimer *animationTimer; } @property (readonly, nonatomic, getter=isAnimating) BOOL animating; diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/EAGLView.m --- a/src/EAGLView.m Fri Sep 09 00:31:54 2011 +0300 +++ b/src/EAGLView.m Fri Sep 09 10:03:42 2011 +0300 @@ -1,15 +1,10 @@ -// -// EAGLView.m -// istereo -// -// Created by nuclear on 9/6/11. -// Copyright __MyCompanyName__ 2011. All rights reserved. -// +#import "EAGLView.h" +#import "ES2Renderer.h" +#import "ui.h" -#import "EAGLView.h" -#import "ES1Renderer.h" -#import "ES2Renderer.h" +static UI *optgui; + @implementation EAGLView @@ -19,129 +14,127 @@ // You must implement this method + (Class)layerClass { - return [CAEAGLLayer class]; + return [CAEAGLLayer class]; } //The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: - (id)initWithCoder:(NSCoder*)coder { - if ((self = [super initWithCoder:coder])) - { - // Get the layer - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + if ((self = [super initWithCoder:coder])) + { + // Get the layer + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; //self.contentScaleFactor = 2.0; - eaglLayer.opaque = TRUE; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; + eaglLayer.opaque = TRUE; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - renderer = [[ES2Renderer alloc] init]; + renderer = [[ES2Renderer alloc] init]; + if (!renderer) { + [self release]; + return nil; + } - if (!renderer) - { - renderer = [[ES1Renderer alloc] init]; + animating = FALSE; + displayLinkSupported = FALSE; + animationFrameInterval = 1; + displayLink = nil; + animationTimer = nil; - if (!renderer) - { - [self release]; - return nil; - } - } - - animating = FALSE; - displayLinkSupported = FALSE; - animationFrameInterval = 1; - displayLink = nil; - animationTimer = nil; - - // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer - // class is used as fallback when it isn't available. - NSString *reqSysVer = @"3.1"; - NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; - if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) - displayLinkSupported = TRUE; + // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer + // class is used as fallback when it isn't available. + NSString *reqSysVer = @"3.1"; + NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; + if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) + displayLinkSupported = TRUE; self.multipleTouchEnabled = 1; - } - return self; + // load the options gui + optgui = [[UI alloc] initWithNibName:@"ui" bundle: [NSBundle mainBundle]]; + hide_options(); + [self addSubview: optgui.view]; + } + + return self; } - (void)drawView:(id)sender { - [renderer render]; + [renderer render]; } - (void)layoutSubviews { - [renderer resizeFromLayer:(CAEAGLLayer*)self.layer]; - [self drawView:nil]; + [renderer resizeFromLayer:(CAEAGLLayer*)self.layer]; + [self drawView:nil]; } - (NSInteger)animationFrameInterval { - return animationFrameInterval; + return animationFrameInterval; } - (void)setAnimationFrameInterval:(NSInteger)frameInterval { - // Frame interval defines how many display frames must pass between each time the - // display link fires. The display link will only fire 30 times a second when the - // frame internal is two on a display that refreshes 60 times a second. The default - // frame interval setting of one will fire 60 times a second when the display refreshes - // at 60 times a second. A frame interval setting of less than one results in undefined - // behavior. - if (frameInterval >= 1) - { - animationFrameInterval = frameInterval; + // Frame interval defines how many display frames must pass between each time the + // display link fires. The display link will only fire 30 times a second when the + // frame internal is two on a display that refreshes 60 times a second. The default + // frame interval setting of one will fire 60 times a second when the display refreshes + // at 60 times a second. A frame interval setting of less than one results in undefined + // behavior. + if (frameInterval >= 1) + { + animationFrameInterval = frameInterval; - if (animating) - { - [self stopAnimation]; - [self startAnimation]; - } - } + if (animating) + { + [self stopAnimation]; + [self startAnimation]; + } + } } - (void)startAnimation { - if (!animating) - { - if (displayLinkSupported) - { - // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed - // if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will - // not be called in system versions earlier than 3.1. + if (!animating) + { + if (displayLinkSupported) + { + // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can be dismissed + // if the system version runtime check for CADisplayLink exists in -initWithCoder:. The runtime check ensures this code will + // not be called in system versions earlier than 3.1. - displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(drawView:)]; - [displayLink setFrameInterval:animationFrameInterval]; - [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - } - else - animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 60.0) * animationFrameInterval) target:self selector:@selector(drawView:) userInfo:nil repeats:TRUE]; + displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(drawView:)]; + [displayLink setFrameInterval:animationFrameInterval]; + [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + } + else + animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 60.0) * animationFrameInterval) target:self selector:@selector(drawView:) userInfo:nil repeats:TRUE]; - animating = TRUE; - } + animating = TRUE; + } } - (void)stopAnimation { - if (animating) - { - if (displayLinkSupported) - { - [displayLink invalidate]; - displayLink = nil; - } - else - { - [animationTimer invalidate]; - animationTimer = nil; - } + if (animating) + { + if (displayLinkSupported) + { + [displayLink invalidate]; + displayLink = nil; + } + else + { + [animationTimer invalidate]; + animationTimer = nil; + } - animating = FALSE; - } + animating = FALSE; + } } static int touch_active; @@ -165,15 +158,27 @@ int dy = end_touch.y - start_touch.y; if(dx * dx + dy * dy < 30) { - use_bump = !use_bump; + show_options(); } } - (void)dealloc { - [renderer release]; + [renderer release]; - [super dealloc]; + [super dealloc]; } @end + +void show_options(void) +{ + assert(optgui); + optgui.view.hidden = NO; +} + +void hide_options(void) +{ + assert(optgui); + optgui.view.hidden = YES; +} diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/ES1Renderer.h --- a/src/ES1Renderer.h Fri Sep 09 00:31:54 2011 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -// -// ES1Renderer.h -// istereo -// -// Created by nuclear on 9/6/11. -// Copyright __MyCompanyName__ 2011. All rights reserved. -// - -#import "ESRenderer.h" - -#import -#import - -@interface ES1Renderer : NSObject -{ -@private - EAGLContext *context; - - // The pixel dimensions of the CAEAGLLayer - GLint backingWidth; - GLint backingHeight; - - // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view - GLuint defaultFramebuffer, colorRenderbuffer; -} - -- (void)render; -- (BOOL)resizeFromLayer:(CAEAGLLayer *)layer; - -@end diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/ES1Renderer.m --- a/src/ES1Renderer.m Fri Sep 09 00:31:54 2011 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -// -// ES1Renderer.m -// istereo -// -// Created by nuclear on 9/6/11. -// Copyright __MyCompanyName__ 2011. All rights reserved. -// - -#import "ES1Renderer.h" - -@implementation ES1Renderer - -// Create an OpenGL ES 1.1 context -- (id)init -{ - if ((self = [super init])) - { - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - - if (!context || ![EAGLContext setCurrentContext:context]) - { - [self release]; - return nil; - } - - // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer - glGenFramebuffersOES(1, &defaultFramebuffer); - glGenRenderbuffersOES(1, &colorRenderbuffer); - glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer); - } - - return self; -} - -- (void)render -{ - // Replace the implementation of this method to do your own custom drawing - - static const GLfloat squareVertices[] = { - -0.5f, -0.33f, - 0.5f, -0.33f, - -0.5f, 0.33f, - 0.5f, 0.33f, - }; - - static const GLubyte squareColors[] = { - 255, 255, 0, 255, - 0, 255, 255, 255, - 0, 0, 0, 0, - 255, 0, 255, 255, - }; - - static float transY = 0.0f; - - // This application only creates a single context which is already set current at this point. - // This call is redundant, but needed if dealing with multiple contexts. - [EAGLContext setCurrentContext:context]; - - // This application only creates a single default framebuffer which is already bound at this point. - // This call is redundant, but needed if dealing with multiple framebuffers. - glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer); - glViewport(0, 0, backingWidth, backingHeight); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0f, (GLfloat)(sinf(transY)/2.0f), 0.0f); - transY += 0.075f; - - glClearColor(0.5f, 0.5f, 0.5f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - - glVertexPointer(2, GL_FLOAT, 0, squareVertices); - glEnableClientState(GL_VERTEX_ARRAY); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors); - glEnableClientState(GL_COLOR_ARRAY); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - // This application only creates a single color renderbuffer which is already bound at this point. - // This call is redundant, but needed if dealing with multiple renderbuffers. - glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); - [context presentRenderbuffer:GL_RENDERBUFFER_OES]; -} - -- (BOOL)resizeFromLayer:(CAEAGLLayer *)layer -{ - // Allocate color buffer backing based on the current layer size - glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); - [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer]; - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); - - if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) - { - NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); - return NO; - } - - return YES; -} - -- (void)dealloc -{ - // Tear down GL - if (defaultFramebuffer) - { - glDeleteFramebuffersOES(1, &defaultFramebuffer); - defaultFramebuffer = 0; - } - - if (colorRenderbuffer) - { - glDeleteRenderbuffersOES(1, &colorRenderbuffer); - colorRenderbuffer = 0; - } - - // Tear down context - if ([EAGLContext currentContext] == context) - [EAGLContext setCurrentContext:nil]; - - [context release]; - context = nil; - - [super dealloc]; -} - -@end diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/ESRenderer.h --- a/src/ESRenderer.h Fri Sep 09 00:31:54 2011 +0300 +++ b/src/ESRenderer.h Fri Sep 09 10:03:42 2011 +0300 @@ -1,11 +1,3 @@ -// -// ESRenderer.h -// istereo -// -// Created by nuclear on 9/6/11. -// Copyright __MyCompanyName__ 2011. All rights reserved. -// - #import #import diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/istereo.c --- a/src/istereo.c Fri Sep 09 00:31:54 2011 +0300 +++ b/src/istereo.c Fri Sep 09 10:03:42 2011 +0300 @@ -26,11 +26,7 @@ int view_xsz, view_ysz; -#ifdef IPHONE -int stereo = 1; -#else int stereo = 0; -#endif int use_bump = 0; /* construction parameters */ @@ -139,6 +135,14 @@ render(tsec); } else { + glViewport(0, 0, view_xsz, view_ysz); + cam_aspect((float)view_ysz / (float)view_xsz); + + gl_matrix_mode(GL_PROJECTION); + gl_load_identity(); + cam_proj_matrix(); + gl_rotatef(-90, 0, 0, 1); + gl_matrix_mode(GL_MODELVIEW); gl_load_identity(); cam_view_matrix(); diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/ui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui.h Fri Sep 09 10:03:42 2011 +0300 @@ -0,0 +1,22 @@ +/* UI and shit */ + +#import + +@interface UI : UIViewController { + IBOutlet UISwitch *sw_stereo; + IBOutlet UISlider *slider_split; + IBOutlet UISegmentedControl *grp_mode; + IBOutlet UIButton *bn_done; +} + +@property (nonatomic, retain) IBOutlet UISwitch *sw_stereo; +@property (nonatomic, retain) IBOutlet UISlider *slider_split; +@property (nonatomic, retain) IBOutlet UISegmentedControl *grp_mode; +@property (nonatomic, retain) IBOutlet UIButton *bn_done; + +-(IBAction) done_clicked: (id) sender; +-(IBAction) split_changed: (id) sender; +-(IBAction) stereo_changed: (id) sender; +-(IBAction) mode_changed: (id) sender; + +@end diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/ui.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui.m Fri Sep 09 10:03:42 2011 +0300 @@ -0,0 +1,83 @@ +#import "ui.h" + +extern int stereo; +extern int use_bump; +extern float split; + + +@implementation UI + +@synthesize bn_done; +@synthesize slider_split; +@synthesize grp_mode; +@synthesize sw_stereo; + +// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +/* +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if(self) { + } + return self; +}*/ + + +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad +{ + [super viewDidLoad]; + + [slider_split setValue: 1.0 - split]; + sw_stereo.on = stereo ? YES : NO; + grp_mode.selectedSegmentIndex = use_bump ? 1 : 0; +} + + +// Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations. + return interfaceOrientation == UIInterfaceOrientationLandscapeRight; +} + + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc. that aren't in use. +} + +- (void)viewDidUnload { + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + +-(IBAction) done_clicked: (id) sender +{ + self.view.hidden = YES; +} + +-(IBAction) split_changed: (id) sender +{ + split = 1.0 - slider_split.value; +} + +-(IBAction) stereo_changed: (id) sender +{ + stereo = sw_stereo.on; +} + +-(IBAction) mode_changed: (id) sender +{ + use_bump = grp_mode.selectedSegmentIndex; +} + + +@end diff -r 634c7f7c1f0f -r 23e5d274b2a2 src/ui.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui.xib Fri Sep 09 10:03:42 2011 +0300 @@ -0,0 +1,778 @@ + + + + 1056 + 10K549 + 851 + 1038.36 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 141 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 278 + + YES + + + 292 + {{366, 20}, {94, 27}} + + NO + IBCocoaTouchFramework + 0 + 0 + YES + + + + 292 + {{172, 55}, {288, 44}} + + NO + IBCocoaTouchFramework + 2 + 0 + + YES + Simple + Bump-mapped + + + YES + + + + + YES + + + + + YES + {0, 0} + {0, 0} + + + YES + + + + + + + 292 + {{182, 23}, {176, 21}} + + NO + YES + 7 + NO + IBCocoaTouchFramework + Stereoscopic rendering + + 3 + MQA + + + 1 + 10 + + + + 292 + {{64, 66}, {100, 21}} + + NO + YES + 7 + NO + IBCocoaTouchFramework + Tunnel mode + + + 1 + 10 + + + + 292 + {{200, 106}, {262, 23}} + + NO + IBCocoaTouchFramework + 0 + 0 + 0.5 + + + + 292 + {{20, 106}, {174, 21}} + + NO + YES + 7 + NO + IBCocoaTouchFramework + Screen divider position + + + 1 + 10 + + + + 292 + {{350, 136}, {110, 37}} + + NO + IBCocoaTouchFramework + 0 + 0 + + Helvetica-Bold + 15 + 16 + + 1 + Done + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + + {480, 193} + + + 1 + MCAwIDAgMC41AA + + NO + 6 + + 3 + + IBCocoaTouchFramework + + + + + YES + + + view + + + + 3 + + + + sw_stereo + + + + 10 + + + + grp_mode + + + + 11 + + + + slider_split + + + + 12 + + + + bn_done + + + + 15 + + + + done_clicked: + + + 7 + + 16 + + + + split_changed: + + + 13 + + 17 + + + + mode_changed: + + + 13 + + 18 + + + + stereo_changed: + + + 13 + + 19 + + + + + YES + + 0 + + + + + + 1 + + + YES + + + + + + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 13 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 13.IBPluginDependency + 13.IBViewBoundsToFrameTransform + 4.IBPluginDependency + 4.IBViewBoundsToFrameTransform + 5.IBPluginDependency + 5.IBViewBoundsToFrameTransform + 6.IBPluginDependency + 6.IBViewBoundsToFrameTransform + 7.IBPluginDependency + 7.IBViewBoundsToFrameTransform + 8.IBPluginDependency + 8.IBViewBoundsToFrameTransform + 9.IBPluginDependency + 9.IBViewBoundsToFrameTransform + + + YES + UI + UIResponder + {{403, 479}, {480, 193}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDrwAAw4iAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDtwAAwxgAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDLAAAw0wAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDNgAAwigAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABCZAAAw0AAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDSAAAw2oAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABBoAAAw2gAAA + + + + + YES + + + YES + + + + + YES + + + YES + + + + 19 + + + + YES + + UI + UIViewController + + YES + + YES + done_clicked: + mode_changed: + split_changed: + stereo_changed: + + + YES + id + id + id + id + + + + YES + + YES + done_clicked: + mode_changed: + split_changed: + stereo_changed: + + + YES + + done_clicked: + id + + + mode_changed: + id + + + split_changed: + id + + + stereo_changed: + id + + + + + YES + + YES + bn_done + grp_mode + slider_split + sw_stereo + + + YES + UIButton + UISegmentedControl + UISlider + UISwitch + + + + YES + + YES + bn_done + grp_mode + slider_split + sw_stereo + + + YES + + bn_done + UIButton + + + grp_mode + UISegmentedControl + + + slider_split + UISlider + + + sw_stereo + UISwitch + + + + + IBProjectSource + src/ui.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIButton + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UIButton.h + + + + UIControl + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIControl.h + + + + UILabel + UIView + + IBFrameworkSource + UIKit.framework/Headers/UILabel.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UISegmentedControl + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISegmentedControl.h + + + + UISlider + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISlider.h + + + + UISwitch + UIControl + + IBFrameworkSource + UIKit.framework/Headers/UISwitch.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIPrintFormatter.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + ../istereo.xcodeproj + 3 + 141 + +