├── documentation ├── razeBanner.png ├── Blender │ └── BlenderWorkshopImages │ │ ├── uvEditing.png │ │ ├── localViewMap1.png │ │ ├── localViewMap2.png │ │ ├── modeSelector.png │ │ ├── editModeAndLayers.png │ │ ├── editingInterface.png │ │ ├── emulationSelection.png │ │ ├── interfaceSettings.png │ │ └── removingTheTimeline.png └── Overview │ └── overview.md ├── Utilites └── blenderLaunch.command ├── Raze ├── Products │ ├── RazeCore.framework │ │ ├── RazeCore │ │ ├── Info.plist │ │ ├── Modules │ │ │ └── module.modulemap │ │ └── Headers │ │ │ ├── RZXRenderable.h │ │ │ ├── RZXUpdateable.h │ │ │ ├── NSValue+RZXExtensions.h │ │ │ ├── RazeCore.h │ │ │ ├── RZXQuadMesh.h │ │ │ ├── RZXDynamicTexture.h │ │ │ ├── RZXStaticTexture.h │ │ │ ├── RZXTexture.h │ │ │ ├── RZXCamera.h │ │ │ ├── RZXTransform3D.h │ │ │ ├── RZXGLView.h │ │ │ ├── RZXMesh.h │ │ │ ├── RZXGPUObject.h │ │ │ └── RZXBase.h │ ├── RazeScene.framework │ │ ├── RazeScene │ │ ├── Info.plist │ │ ├── Modules │ │ │ └── module.modulemap │ │ └── Headers │ │ │ ├── RZXScene.h │ │ │ ├── RazeScene.h │ │ │ ├── RZXSceneView.h │ │ │ ├── RZXModelNode.h │ │ │ ├── RZXNode.h │ │ │ ├── RZXTextNode.h │ │ │ └── RZXNode+RZXAnimation.h │ ├── RazeUIKit.framework │ │ ├── RazeUIKit │ │ ├── Info.plist │ │ ├── Modules │ │ │ └── module.modulemap │ │ └── Headers │ │ │ ├── RazeUIKit.h │ │ │ ├── RZXViewTexture.h │ │ │ └── RZXEffectView.h │ ├── RazeEffects.framework │ │ ├── Info.plist │ │ ├── RazeEffects │ │ ├── Modules │ │ │ └── module.modulemap │ │ └── Headers │ │ │ ├── RZXGrayscaleEffect.h │ │ │ ├── RZXBlurEffect.h │ │ │ ├── RZXPassthroughEffect.h │ │ │ ├── RZXImageFilter.h │ │ │ ├── RZXConvolutionEffect.h │ │ │ ├── RZXCompositeEffect.h │ │ │ ├── RazeEffects.h │ │ │ ├── RZXClothEffect.h │ │ │ ├── RZXADSPhongEffect.h │ │ │ └── RZXEffect.h │ └── RazeAnimation.framework │ │ ├── Info.plist │ │ ├── RazeAnimation │ │ ├── Modules │ │ └── module.modulemap │ │ └── Headers │ │ ├── RazeCore+RZXAnimation.h │ │ ├── RZXBasicAnimation.h │ │ ├── RZXAnimatable.h │ │ ├── RZXInterpolator.h │ │ ├── CAAnimation+RZXExtensions.h │ │ ├── RazeAnimation.h │ │ └── RZXAnimationBase.h ├── Raze.xcodeproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── RazeEffects │ ├── RZXGrayscaleEffect.h │ ├── RZXBlurEffect.h │ ├── RZXPassthroughEffect.h │ ├── RZXImageFilter.h │ ├── RZXConvolutionEffect.h │ ├── RZXCompositeEffect.h │ ├── RazeEffects.h │ ├── RZXClothEffect.h │ ├── Info.plist │ ├── RZXADSPhongEffect.h │ ├── RZXGrayscaleEffect.m │ ├── RZXPassthroughEffect.m │ ├── RZXEffect.h │ ├── RZXADSPhongEffect.m │ ├── RZXConvolutionEffect.m │ └── RZXCompositeEffect.m ├── RazeAnimation │ ├── RazeCore+RZXAnimation.h │ ├── RZXBasicAnimation.h │ ├── Private │ │ ├── RZXValueProxy.h │ │ ├── CAAnimation+RZXPrivateExtensions.h │ │ ├── RZXAnimationState.h │ │ └── RZXAnimationState.m │ ├── RZXAnimatable.h │ ├── RZXInterpolator.h │ ├── CAAnimation+RZXExtensions.h │ ├── RazeAnimation.h │ ├── RazeCore+RZXAnimation.m │ ├── RZXAnimationBase.h │ ├── Info.plist │ ├── RZXBasicAnimation.m │ └── CAAnimation+RZXExtensions.m ├── RazeUIKit │ ├── RazeUIKit.h │ ├── Info.plist │ ├── RZXViewTexture.h │ ├── RZXEffectView.h │ └── RZXViewTexture.m ├── RazeCore │ ├── RZXRenderable.h │ ├── RZXUpdateable.h │ ├── NSValue+RZXExtensions.h │ ├── Private │ │ ├── RZXCache.h │ │ ├── RZXRenderLoop.h │ │ ├── RZXRenderLoop.m │ │ └── RZXCache.m │ ├── RazeCore.h │ ├── RZXQuadMesh.h │ ├── Info.plist │ ├── RZXDynamicTexture.h │ ├── RZXStaticTexture.h │ ├── RZXTexture.h │ ├── NSValue+RZXExtensions.m │ ├── RZXCamera.h │ ├── RZXTransform3D.h │ ├── RZXGLView.h │ ├── RZXGPUObject.m │ ├── RZXMesh.h │ ├── RZXGPUObject.h │ ├── RZXTexture.m │ ├── RZXBase.h │ ├── RZXCamera.m │ ├── RZXStaticTexture.m │ └── RZXQuadMesh.m ├── RazeScene │ ├── RZXScene.h │ ├── RazeScene.h │ ├── RZXSceneView.h │ ├── RZXModelNode.h │ ├── RZXScene.m │ ├── Info.plist │ ├── RZXSceneView.m │ ├── RZXNode.h │ ├── RZXTextNode.h │ ├── RZXModelNode.m │ └── RZXNode+RZXAnimation.h ├── RazeCoreTests │ ├── Info.plist │ └── RazeCoreTests.m ├── RazeSceneTests │ ├── Info.plist │ └── RazeSceneTests.m ├── RazeUIKitTests │ ├── Info.plist │ └── RazeUIKitTests.m ├── RazeAnimationTests │ ├── Info.plist │ └── RazeAnimationTests.m └── RazeEffectsTests │ ├── Info.plist │ └── RazeEffectsTests.m ├── Example └── RazeEffectsDemo │ ├── RazeEffectsDemo │ ├── Images.xcassets │ │ ├── Contents.json │ │ ├── rzlogo.imageset │ │ │ ├── rzlogo.png │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── Info.plist │ ├── ViewController.m │ ├── AppDelegate.m │ └── Base.lproj │ │ └── LaunchScreen.xib │ └── RazeEffectsDemo.xcodeproj │ └── project.xcworkspace │ └── contents.xcworkspacedata ├── Sandbox ├── Raze Scene Sandbox │ ├── Raze Scene Sandbox │ │ ├── greyTexture.png │ │ ├── rzUnicorn.png │ │ ├── marshmellow.mesh │ │ ├── officeBanner.mesh │ │ ├── officeScreen.mesh │ │ ├── officeTexture.png │ │ ├── retroOffice.mesh │ │ ├── razeRedTexture.png │ │ ├── RZXViewNode.h │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── ViewController.h │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── RZXViewNode.m │ │ ├── Info.plist │ │ ├── AppDelegate.m │ │ ├── RZXExampleSceneviewController.m │ │ └── Base.lproj │ │ │ └── LaunchScreen.xib │ ├── Raze Scene Sandbox.xcodeproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── Raze Scene SandboxTests │ │ ├── Info.plist │ │ └── Raze_Scene_SandboxTests.m └── Sandbox.xcworkspace │ └── contents.xcworkspacedata ├── .gitignore ├── LICENSE └── README.md /documentation/razeBanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/razeBanner.png -------------------------------------------------------------------------------- /Utilites/blenderLaunch.command: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | /Applications/Blender/blender.app/Contents/MacOS/blender -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/RazeCore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeCore.framework/RazeCore -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeCore.framework/Info.plist -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/RazeScene: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeScene.framework/RazeScene -------------------------------------------------------------------------------- /Raze/Products/RazeUIKit.framework/RazeUIKit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeUIKit.framework/RazeUIKit -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeEffects.framework/Info.plist -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeScene.framework/Info.plist -------------------------------------------------------------------------------- /Raze/Products/RazeUIKit.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeUIKit.framework/Info.plist -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeAnimation.framework/Info.plist -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/RazeEffects: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeEffects.framework/RazeEffects -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/RazeAnimation: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Raze/Products/RazeAnimation.framework/RazeAnimation -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/uvEditing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/uvEditing.png -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/greyTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/greyTexture.png -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/rzUnicorn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/rzUnicorn.png -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/localViewMap1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/localViewMap1.png -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/localViewMap2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/localViewMap2.png -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/modeSelector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/modeSelector.png -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module RazeCore { 2 | umbrella header "RazeCore.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/marshmellow.mesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/marshmellow.mesh -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/officeBanner.mesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/officeBanner.mesh -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/officeScreen.mesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/officeScreen.mesh -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/officeTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/officeTexture.png -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/retroOffice.mesh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/retroOffice.mesh -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module RazeScene { 2 | umbrella header "RazeScene.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Raze/Products/RazeUIKit.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module RazeUIKit { 2 | umbrella header "RazeUIKit.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/razeRedTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/razeRedTexture.png -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/editModeAndLayers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/editModeAndLayers.png -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/editingInterface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/editingInterface.png -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/emulationSelection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/emulationSelection.png -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/interfaceSettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/interfaceSettings.png -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module RazeEffects { 2 | umbrella header "RazeEffects.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /documentation/Blender/BlenderWorkshopImages/removingTheTimeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/documentation/Blender/BlenderWorkshopImages/removingTheTimeline.png -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module RazeAnimation { 2 | umbrella header "RazeAnimation.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/Images.xcassets/rzlogo.imageset/rzlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rightpoint/Raze/HEAD/Example/RazeEffectsDemo/RazeEffectsDemo/Images.xcassets/rzlogo.imageset/rzlogo.png -------------------------------------------------------------------------------- /Raze/Raze.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // RazeEffectsDemo 4 | // 5 | // Created by Rob Visentin on 1/15/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXGrayscaleEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGrayscaleEffect.h 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/21/15. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * A grayscale 2D effect 12 | */ 13 | @interface RZXGrayscaleEffect : RZXEffect 14 | 15 | + (instancetype)effect; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RazeCore+RZXAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeCore+RZXAnimation.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Adds KVC compliance for GLKit math types for Raze objects. 12 | */ 13 | @interface NSObject (RZXAnimation) 14 | @end 15 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXGrayscaleEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGrayscaleEffect.h 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/21/15. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * A grayscale 2D effect 12 | */ 13 | @interface RZXGrayscaleEffect : RZXEffect 14 | 15 | + (instancetype)effect; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Sandbox/Sandbox.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Headers/RazeCore+RZXAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeCore+RZXAnimation.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Adds KVC compliance for GLKit math types for Raze objects. 12 | */ 13 | @interface NSObject (RZXAnimation) 14 | @end 15 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RZXBasicAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXBasicAnimation.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/13/15. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXBasicAnimation : CABasicAnimation 11 | 12 | + (instancetype)animationWithKeyPath:(NSString *)path options:(RZXAnimationOptions)options; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Headers/RZXBasicAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXBasicAnimation.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/13/15. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXBasicAnimation : CABasicAnimation 11 | 12 | + (instancetype)animationWithKeyPath:(NSString *)path options:(RZXAnimationOptions)options; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // RazeEffectsDemo 4 | // 5 | // Created by Rob Visentin on 1/15/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/RZXViewNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXViewNode.h 3 | // Raze Scene Sandbox 4 | // 5 | // Created by Rob Visentin on 8/7/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | @import RazeUIKit; 10 | 11 | #import 12 | 13 | @interface RZXViewNode : RZXModelNode 14 | 15 | + (instancetype)nodeWithView:(UIView *)view; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Raze Scene Sandbox 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Raze/RazeUIKit/RazeUIKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeUIKit.h 3 | // 4 | // Created by Rob Visentin on 4/17/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | FOUNDATION_EXPORT double RazeUIKitVersionNumber; 11 | FOUNDATION_EXPORT const unsigned char RazeUIKitVersionString[]; 12 | 13 | #import 14 | #import 15 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXBlurEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXBlurEffect.h 3 | // 4 | // Created by Rob Visentin on 1/16/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Blur 2D Effect 12 | */ 13 | @interface RZXBlurEffect : RZXEffect 14 | 15 | @property (assign, nonatomic) GLfloat sigma; 16 | 17 | + (instancetype)effectWithSigma:(GLfloat)sigma; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXRenderable.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXRenderable.h 3 | // 4 | // Created by Rob Visentin on 1/14/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Protocol for any object to be renderered. Requires - (void)rzx_render 12 | */ 13 | @protocol RZXRenderable 14 | 15 | /** 16 | * Render the object 17 | */ 18 | - (void)rzx_render; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Raze/Products/RazeUIKit.framework/Headers/RazeUIKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeUIKit.h 3 | // 4 | // Created by Rob Visentin on 4/17/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | FOUNDATION_EXPORT double RazeUIKitVersionNumber; 11 | FOUNDATION_EXPORT const unsigned char RazeUIKitVersionString[]; 12 | 13 | #import 14 | #import 15 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RazeEffectsDemo 4 | // 5 | // Created by Rob Visentin on 1/15/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXBlurEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXBlurEffect.h 3 | // 4 | // Created by Rob Visentin on 1/16/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Blur 2D Effect 12 | */ 13 | @interface RZXBlurEffect : RZXEffect 14 | 15 | @property (assign, nonatomic) GLfloat sigma; 16 | 17 | + (instancetype)effectWithSigma:(GLfloat)sigma; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Raze Scene Sandbox 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/Images.xcassets/rzlogo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "rzlogo.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXRenderable.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXRenderable.h 3 | // 4 | // Created by Rob Visentin on 1/14/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Protocol for any object to be renderered. Requires - (void)rzx_render 12 | */ 13 | @protocol RZXRenderable 14 | 15 | /** 16 | * Render the object 17 | */ 18 | - (void)rzx_render; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/Private/RZXValueProxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXValueProxy.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/25/15. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXValueProxy : NSObject 11 | 12 | @property (weak, nonatomic) id proxyOwner; 13 | @property (copy, nonatomic) NSString *proxiedKey; 14 | 15 | - (instancetype)initWithBytes:(const void *)value objCType:(const char *)type; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RZXAnimatable.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXAnimatable.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import 9 | 10 | @class RZXInterpolator; 11 | 12 | @protocol RZXAnimatable 13 | 14 | + (RZXInterpolator *)rzx_interpolatorForKey:(NSString *)key; 15 | 16 | @end 17 | 18 | @interface NSObject (RZXAnimatable) 19 | 20 | + (void)rzx_addKVCComplianceForGLKTypes; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXScene.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RZXScene : RZXNode 12 | 13 | /** 14 | * The parent node of a scene. 15 | * 16 | * @param effect effect to apply to the scene 17 | * 18 | * @return RZXScene 19 | */ 20 | + (instancetype)sceneWithEffect:(RZXEffect *)effect; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Headers/RZXAnimatable.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXAnimatable.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import 9 | 10 | @class RZXInterpolator; 11 | 12 | @protocol RZXAnimatable 13 | 14 | + (RZXInterpolator *)rzx_interpolatorForKey:(NSString *)key; 15 | 16 | @end 17 | 18 | @interface NSObject (RZXAnimatable) 19 | 20 | + (void)rzx_addKVCComplianceForGLKTypes; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Headers/RZXScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXScene.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RZXScene : RZXNode 12 | 13 | /** 14 | * The parent node of a scene. 15 | * 16 | * @param effect effect to apply to the scene 17 | * 18 | * @return RZXScene 19 | */ 20 | + (instancetype)sceneWithEffect:(RZXEffect *)effect; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXUpdateable.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXUpdateable.h 3 | // 4 | // Created by Rob Visentin on 3/6/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | Protocol for any object that will be updated typically as part of a update/rendering 12 | */ 13 | @protocol RZXUpdateable 14 | 15 | /** 16 | * Update method to typically be called per frame 17 | * 18 | * @param dt time elapsed since last update 19 | */ 20 | - (void)rzx_update:(NSTimeInterval)dt; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXUpdateable.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXUpdateable.h 3 | // 4 | // Created by Rob Visentin on 3/6/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | Protocol for any object that will be updated typically as part of a update/rendering 12 | */ 13 | @protocol RZXUpdateable 14 | 15 | /** 16 | * Update method to typically be called per frame 17 | * 18 | * @param dt time elapsed since last update 19 | */ 20 | - (void)rzx_update:(NSTimeInterval)dt; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/RazeScene/RazeScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeScene.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 5/1/15. 6 | // 7 | // 8 | /** 9 | The header file for all Scene Components 10 | */ 11 | 12 | #import 13 | 14 | FOUNDATION_EXPORT double RazeSceneVersionNumber; 15 | 16 | FOUNDATION_EXPORT const unsigned char RazeSceneVersionString[]; 17 | 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXPassthroughEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXPassthroughEffect.h 3 | // Raze 4 | // 5 | // Created by Rob Visentin on 6/19/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | OBJC_EXTERN NSString* const kRZXEffectPassthroughVSH2D; 12 | OBJC_EXTERN NSString* const kRZXEffectPassthroughVSH3D; 13 | OBJC_EXTERN NSString* const kRZXEffectPassthroughFSH; 14 | 15 | /** 16 | * Generic effects applying the minimum values needed for a simple 2D or 3D effect 17 | */ 18 | @interface RZXPassthroughEffect : RZXEffect 19 | 20 | + (instancetype)effect2D; 21 | + (instancetype)effect3D; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RZXInterpolator.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXInterpolator.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXInterpolator : NSObject 11 | 12 | + (instancetype)floatInterpolator; 13 | + (instancetype)vec2Interpolator; 14 | + (instancetype)vec3Interpolator; 15 | + (instancetype)vec4Interpolator; 16 | + (instancetype)quaternionInterpolator; 17 | 18 | - (id)invertValue:(id)value; 19 | 20 | - (id)addValue:(id)val1 toValue:(id)val2; 21 | 22 | - (id)interpolatedValueFrom:(id)fromValue to:(id)toValue t:(float)t; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXImageFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXImageFilter.h 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/23/15. 6 | // 7 | 8 | #import 9 | 10 | @class RZXEffect; 11 | 12 | /** 13 | * Applies an effect to an image 14 | */ 15 | @interface RZXImageFilter : NSObject 16 | 17 | @property (assign, nonatomic) CGImageRef sourceImage; 18 | @property (strong, nonatomic) RZXEffect *effect; 19 | 20 | - (instancetype)initWithSourceImage:(CGImageRef)sourceImage effect:(RZXEffect *)effect; 21 | 22 | - (CGImageRef)outputImage NS_RETURNS_INNER_POINTER CF_RETURNS_NOT_RETAINED; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Headers/RazeScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeScene.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 5/1/15. 6 | // 7 | // 8 | /** 9 | The header file for all Scene Components 10 | */ 11 | 12 | #import 13 | 14 | FOUNDATION_EXPORT double RazeSceneVersionNumber; 15 | 16 | FOUNDATION_EXPORT const unsigned char RazeSceneVersionString[]; 17 | 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXPassthroughEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXPassthroughEffect.h 3 | // Raze 4 | // 5 | // Created by Rob Visentin on 6/19/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | OBJC_EXTERN NSString* const kRZXEffectPassthroughVSH2D; 12 | OBJC_EXTERN NSString* const kRZXEffectPassthroughVSH3D; 13 | OBJC_EXTERN NSString* const kRZXEffectPassthroughFSH; 14 | 15 | /** 16 | * Generic effects applying the minimum values needed for a simple 2D or 3D effect 17 | */ 18 | @interface RZXPassthroughEffect : RZXEffect 19 | 20 | + (instancetype)effect2D; 21 | + (instancetype)effect3D; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Headers/RZXInterpolator.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXInterpolator.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXInterpolator : NSObject 11 | 12 | + (instancetype)floatInterpolator; 13 | + (instancetype)vec2Interpolator; 14 | + (instancetype)vec3Interpolator; 15 | + (instancetype)vec4Interpolator; 16 | + (instancetype)quaternionInterpolator; 17 | 18 | - (id)invertValue:(id)value; 19 | 20 | - (id)addValue:(id)val1 toValue:(id)val2; 21 | 22 | - (id)interpolatedValueFrom:(id)fromValue to:(id)toValue t:(float)t; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXImageFilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXImageFilter.h 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/23/15. 6 | // 7 | 8 | #import 9 | 10 | @class RZXEffect; 11 | 12 | /** 13 | * Applies an effect to an image 14 | */ 15 | @interface RZXImageFilter : NSObject 16 | 17 | @property (assign, nonatomic) CGImageRef sourceImage; 18 | @property (strong, nonatomic) RZXEffect *effect; 19 | 20 | - (instancetype)initWithSourceImage:(CGImageRef)sourceImage effect:(RZXEffect *)effect; 21 | 22 | - (CGImageRef)outputImage NS_RETURNS_INNER_POINTER CF_RETURNS_NOT_RETAINED; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXConvolutionEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXConvolutionEffect.h 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/23/15. 6 | // 7 | 8 | #import 9 | 10 | OBJC_EXTERN GLKMatrix3 const kRZXConvoultionKernelIdentity; 11 | OBJC_EXTERN NSString* const kRZXEffectConvolutionVSH; 12 | 13 | /** 14 | * Convolution 2D effect 15 | */ 16 | @interface RZXConvolutionEffect : RZXEffect 17 | 18 | @property (assign, nonatomic) GLKMatrix3 kernel; 19 | 20 | // Post processing src e.g. @"rgb = normalize(rgb);" 21 | + (instancetype)effectWithKernel:(GLKMatrix3)kernel postProcessing:(NSString *)postProcessingSrc; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/Private/CAAnimation+RZXPrivateExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // CAAnimation+RZXPrivateExtensions.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import 9 | 10 | @class RZXAnimationState; 11 | @class RZXInterpolator; 12 | 13 | @interface CAAnimation (RZXPrivateExtensions) 14 | 15 | @property (strong, nonatomic, readonly) RZXAnimationState *rzx_state; 16 | 17 | - (float)rzx_interpolationFactorForTime:(CFTimeInterval)currentTime; 18 | 19 | - (id)rzx_interpolateAtTime:(CFTimeInterval)time withInterpolator:(RZXInterpolator *)interpolator currentValue:(id)currentValue; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXConvolutionEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXConvolutionEffect.h 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/23/15. 6 | // 7 | 8 | #import 9 | 10 | OBJC_EXTERN GLKMatrix3 const kRZXConvoultionKernelIdentity; 11 | OBJC_EXTERN NSString* const kRZXEffectConvolutionVSH; 12 | 13 | /** 14 | * Convolution 2D effect 15 | */ 16 | @interface RZXConvolutionEffect : RZXEffect 17 | 18 | @property (assign, nonatomic) GLKMatrix3 kernel; 19 | 20 | // Post processing src e.g. @"rgb = normalize(rgb);" 21 | + (instancetype)effectWithKernel:(GLKMatrix3)kernel postProcessing:(NSString *)postProcessingSrc; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXSceneView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXSceneView.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class RZXScene; 12 | 13 | /** 14 | * An RZXGLView with a scene attached. All update and display calls will update and display the attached scene. 15 | */ 16 | @interface RZXSceneView : RZXGLView 17 | 18 | // TODO: elimineate confusion between two seperate core renderables (scene here and model in RZXGLView) 19 | @property (strong, nonatomic) RZXScene *scene; 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame scene:(RZXScene *)scene; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXCompositeEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCompositeEffect.h 3 | // 4 | // Created by Rob Visentin on 1/16/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Helper class for managing two effects at the same time 12 | */ 13 | @interface RZXCompositeEffect : RZXEffect 14 | 15 | @property (strong, nonatomic, readonly) RZXEffect *firstEffect; 16 | @property (strong, nonatomic, readonly) RZXEffect *secondEffect; 17 | 18 | @property (strong, nonatomic, readonly) RZXEffect *currentEffect; 19 | 20 | + (instancetype)compositeEffectWithFirstEffect:(RZXEffect *)first secondEffect:(RZXEffect *)second; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Raze Scene Sandbox 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | // This demo uses a blender model built by soloarforge and released under teh Creative Commons Attribution-ShareAlike License. The blender model was modified by changing its colors using UV mapping. The original model can be found at htttp://www.blendswap.com/blends/view/76269. 9 | 10 | 11 | 12 | #import 13 | @import RazeCore; 14 | @import RazeScene; 15 | @import RazeEffects; 16 | 17 | @interface ViewController : UIViewController 18 | 19 | 20 | @end 21 | 22 | -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Headers/RZXSceneView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXSceneView.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class RZXScene; 12 | 13 | /** 14 | * An RZXGLView with a scene attached. All update and display calls will update and display the attached scene. 15 | */ 16 | @interface RZXSceneView : RZXGLView 17 | 18 | // TODO: elimineate confusion between two seperate core renderables (scene here and model in RZXGLView) 19 | @property (strong, nonatomic) RZXScene *scene; 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame scene:(RZXScene *)scene; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/CAAnimation+RZXExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // CAAnimation+RZXExtensions.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface CAAnimation (RZXExtensions) 12 | 13 | @property (copy, nonatomic, setter=rzx_setStartBlock:) RZXAnimationStartBlock rzx_startBlock; 14 | 15 | @property (copy, nonatomic, setter=rzx_setCompletionBlock:) RZXAnimationCompletionBlock rzx_completionBlock; 16 | 17 | @property (assign, nonatomic, readonly, getter=rzx_isFinished) BOOL rzx_finished; 18 | 19 | - (void)rzx_applyToObject:(id)object; 20 | - (void)rzx_interrupt; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RazeAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeAnimation.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | 10 | //! Project version number for RazeAnimation. 11 | FOUNDATION_EXPORT double RazeAnimationVersionNumber; 12 | 13 | //! Project version string for RazeAnimation. 14 | FOUNDATION_EXPORT const unsigned char RazeAnimationVersionString[]; 15 | 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXCompositeEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCompositeEffect.h 3 | // 4 | // Created by Rob Visentin on 1/16/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Helper class for managing two effects at the same time 12 | */ 13 | @interface RZXCompositeEffect : RZXEffect 14 | 15 | @property (strong, nonatomic, readonly) RZXEffect *firstEffect; 16 | @property (strong, nonatomic, readonly) RZXEffect *secondEffect; 17 | 18 | @property (strong, nonatomic, readonly) RZXEffect *currentEffect; 19 | 20 | + (instancetype)compositeEffectWithFirstEffect:(RZXEffect *)first secondEffect:(RZXEffect *)second; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Headers/CAAnimation+RZXExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // CAAnimation+RZXExtensions.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface CAAnimation (RZXExtensions) 12 | 13 | @property (copy, nonatomic, setter=rzx_setStartBlock:) RZXAnimationStartBlock rzx_startBlock; 14 | 15 | @property (copy, nonatomic, setter=rzx_setCompletionBlock:) RZXAnimationCompletionBlock rzx_completionBlock; 16 | 17 | @property (assign, nonatomic, readonly, getter=rzx_isFinished) BOOL rzx_finished; 18 | 19 | - (void)rzx_applyToObject:(id)object; 20 | - (void)rzx_interrupt; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Headers/RazeAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeAnimation.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | 10 | //! Project version number for RazeAnimation. 11 | FOUNDATION_EXPORT double RazeAnimationVersionNumber; 12 | 13 | //! Project version string for RazeAnimation. 14 | FOUNDATION_EXPORT const unsigned char RazeAnimationVersionString[]; 15 | 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | -------------------------------------------------------------------------------- /Raze/RazeCore/NSValue+RZXExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSValue+RZXExtensions.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | /** 12 | * Translates GLKit math types to and from NSValue 13 | */ 14 | @interface NSValue (RZXExtensions) 15 | 16 | + (instancetype)rzx_valueWithVec2:(GLKVector2)vec2; 17 | + (instancetype)rzx_valueWithVec3:(GLKVector3)vec3; 18 | + (instancetype)rzx_valueWithVec4:(GLKVector4)vec4; 19 | + (instancetype)rzx_valueWithQuaternion:(GLKQuaternion)quaternion; 20 | 21 | - (GLKVector2)rzx_vec2Value; 22 | - (GLKVector3)rzx_vec3Value; 23 | - (GLKVector4)rzx_vec4Value; 24 | - (GLKQuaternion)rzx_quaternionValue; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RazeEffects.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeEffects.h 3 | // 4 | // Created by Rob Visentin on 4/17/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | FOUNDATION_EXPORT double RazeEffectsVersionNumber; 11 | FOUNDATION_EXPORT const unsigned char RazeEffectsVersionString[]; 12 | 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RazeCore+RZXAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // RazeCore+RZXAnimation.m 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | @implementation NSObject (RZXAnimation) 16 | 17 | + (void)load 18 | { 19 | @autoreleasepool { 20 | [[RZXTransform3D class] rzx_addKVCComplianceForGLKTypes]; 21 | [[RZXCamera class] rzx_addKVCComplianceForGLKTypes]; 22 | [[RZXEffect class] rzx_addKVCComplianceForGLKTypes]; 23 | [[RZXGLView class] rzx_addKVCComplianceForGLKTypes]; 24 | } 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/NSValue+RZXExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSValue+RZXExtensions.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | /** 12 | * Translates GLKit math types to and from NSValue 13 | */ 14 | @interface NSValue (RZXExtensions) 15 | 16 | + (instancetype)rzx_valueWithVec2:(GLKVector2)vec2; 17 | + (instancetype)rzx_valueWithVec3:(GLKVector3)vec3; 18 | + (instancetype)rzx_valueWithVec4:(GLKVector4)vec4; 19 | + (instancetype)rzx_valueWithQuaternion:(GLKQuaternion)quaternion; 20 | 21 | - (GLKVector2)rzx_vec2Value; 22 | - (GLKVector3)rzx_vec3Value; 23 | - (GLKVector4)rzx_vec4Value; 24 | - (GLKQuaternion)rzx_quaternionValue; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RazeEffects.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeEffects.h 3 | // 4 | // Created by Rob Visentin on 4/17/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | FOUNDATION_EXPORT double RazeEffectsVersionNumber; 11 | FOUNDATION_EXPORT const unsigned char RazeEffectsVersionString[]; 12 | 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXModelNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXModeNodel.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class RZXMesh; 12 | @class RZXTexture; 13 | 14 | /** 15 | * The basic node used for 3D Models. It contains a mesh object containing the model's construction data and a texture object that will be applied to the model. 16 | */ 17 | @interface RZXModelNode : RZXNode 18 | 19 | // Contains the model data used by this node 20 | @property (strong, nonatomic) RZXMesh *mesh; 21 | 22 | // 2D texture to be applied to the mesh 23 | @property (strong, nonatomic) RZXTexture *texture; 24 | 25 | + (instancetype)modelNodeWithMesh:(RZXMesh *)mesh texture:(RZXTexture *)texture; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXClothEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXClothEffect.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Waving Cloth Effect 12 | */ 13 | @interface RZXClothEffect : RZXEffect 14 | 15 | @property (assign, nonatomic) GLKVector2 anchors; 16 | 17 | @property (assign, nonatomic) GLfloat waveCount; 18 | @property (assign, nonatomic) GLfloat waveAmplitude; 19 | @property (assign, nonatomic) GLfloat waveVelocity; 20 | 21 | @property (assign, nonatomic) GLKVector3 lightOffset; 22 | @property (assign, nonatomic) GLKVector3 ambientLight; 23 | @property (assign, nonatomic) GLKVector3 diffuseLight; 24 | @property (assign, nonatomic) GLKVector3 specularLight; 25 | 26 | + (instancetype)effect; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Headers/RZXModelNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXModeNodel.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class RZXMesh; 12 | @class RZXTexture; 13 | 14 | /** 15 | * The basic node used for 3D Models. It contains a mesh object containing the model's construction data and a texture object that will be applied to the model. 16 | */ 17 | @interface RZXModelNode : RZXNode 18 | 19 | // Contains the model data used by this node 20 | @property (strong, nonatomic) RZXMesh *mesh; 21 | 22 | // 2D texture to be applied to the mesh 23 | @property (strong, nonatomic) RZXTexture *texture; 24 | 25 | + (instancetype)modelNodeWithMesh:(RZXMesh *)mesh texture:(RZXTexture *)texture; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Raze/RazeCore/Private/RZXCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCache.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXCache : NSObject 11 | 12 | - (void)cacheObject:(id)object forKey:(id)key; 13 | 14 | // These are not "true" -retain, -release calls, but rather used for the cache's 15 | // own internal reference count. 16 | - (void)retainObjectForKey:(id)key; 17 | - (void)releaseObjectForKey:(id)key; 18 | 19 | - (id)objectForKey:(id)key; 20 | 21 | - (void)removeObjectForKey:(id)key; 22 | - (void)removeAllObjects; 23 | 24 | @end 25 | 26 | @interface RZXCache (RZXSubscripting) 27 | 28 | - (id)objectForKeyedSubscript:(id)key; 29 | - (void)setObject:(id)obj forKeyedSubscript:(id )key; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RZXAnimationBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXAnimationBase.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/13/15. 6 | // 7 | 8 | #import 9 | 10 | #ifndef RZXAnimationBase_h 11 | #define RZXAnimationBase_h 12 | 13 | typedef NS_OPTIONS(NSUInteger, RZXAnimationOptions) { 14 | kRZXAnimationOptionRepeat = 1 << 0, 15 | kRZXAnimationOptionAutoReverse = 1 << 1, 16 | 17 | kRZXAnimationOptionCurveLinear = 0 << 8, // default 18 | kRZXAnimationOptionCurveEaseIn = 1 << 8, 19 | kRZXAnimationOptionCurveEaseOut = 2 << 8, 20 | kRZXAnimationOptionCurveEaseInOut = 3 << 8 21 | }; 22 | 23 | typedef void (^RZXAnimationStartBlock)(CAAnimation *animation); 24 | typedef void (^RZXAnimationCompletionBlock)(CAAnimation *animation, BOOL finished); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXScene.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXScene.m 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "RZXScene.h" 12 | 13 | @implementation RZXScene 14 | 15 | + (instancetype)sceneWithEffect:(RZXEffect *)effect 16 | { 17 | return [[RZXScene alloc] initWithEffect:effect]; 18 | } 19 | 20 | - (instancetype)init 21 | { 22 | return [self initWithEffect:[RZXPassthroughEffect effect3D]]; 23 | } 24 | 25 | - (instancetype)initWithEffect:(RZXEffect *)effect 26 | { 27 | self = [super init]; 28 | if (self) { 29 | self.effect = effect; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)rzx_bindGL 35 | { 36 | // no-op. The scene object itself isn't renderable 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXClothEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXClothEffect.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * Waving Cloth Effect 12 | */ 13 | @interface RZXClothEffect : RZXEffect 14 | 15 | @property (assign, nonatomic) GLKVector2 anchors; 16 | 17 | @property (assign, nonatomic) GLfloat waveCount; 18 | @property (assign, nonatomic) GLfloat waveAmplitude; 19 | @property (assign, nonatomic) GLfloat waveVelocity; 20 | 21 | @property (assign, nonatomic) GLKVector3 lightOffset; 22 | @property (assign, nonatomic) GLKVector3 ambientLight; 23 | @property (assign, nonatomic) GLKVector3 diffuseLight; 24 | @property (assign, nonatomic) GLKVector3 specularLight; 25 | 26 | + (instancetype)effect; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Raze/RazeCore/RazeCore.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeCore.h 3 | // 4 | // Created by Rob Visentin on 4/17/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | FOUNDATION_EXPORT double RazeCoreVersionNumber; 11 | FOUNDATION_EXPORT const unsigned char RazeCoreVersionString[]; 12 | 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | -------------------------------------------------------------------------------- /Raze/RazeCoreTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Raze/RazeSceneTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Raze/RazeUIKitTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Raze/Products/RazeAnimation.framework/Headers/RZXAnimationBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXAnimationBase.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/13/15. 6 | // 7 | 8 | #import 9 | 10 | #ifndef RZXAnimationBase_h 11 | #define RZXAnimationBase_h 12 | 13 | typedef NS_OPTIONS(NSUInteger, RZXAnimationOptions) { 14 | kRZXAnimationOptionRepeat = 1 << 0, 15 | kRZXAnimationOptionAutoReverse = 1 << 1, 16 | 17 | kRZXAnimationOptionCurveLinear = 0 << 8, // default 18 | kRZXAnimationOptionCurveEaseIn = 1 << 8, 19 | kRZXAnimationOptionCurveEaseOut = 2 << 8, 20 | kRZXAnimationOptionCurveEaseInOut = 3 << 8 21 | }; 22 | 23 | typedef void (^RZXAnimationStartBlock)(CAAnimation *animation); 24 | typedef void (^RZXAnimationCompletionBlock)(CAAnimation *animation, BOOL finished); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Raze/RazeAnimationTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Raze/RazeEffectsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXQuadMesh.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXQuadMesh.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 1/10/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | OBJC_EXTERN NSInteger const kRZXQuadMeshMaxSubdivisions; 12 | 13 | /** 14 | * A procedurally generated rectangular mesh. 15 | */ 16 | @interface RZXQuadMesh : RZXMesh 17 | 18 | /** Initialize a basic quad. */ 19 | + (instancetype)quad; 20 | 21 | /** Initialize a quad with a specific number of subdivisions. */ 22 | + (instancetype)quadWithSubdivisionLevel:(NSInteger)subdivisons; 23 | 24 | @end 25 | 26 | @interface RZXQuadMesh (RZXUnavailable) 27 | 28 | // The mesh data will be procedurally generated rather then loaded from a file. 29 | + (instancetype)meshWithName:(NSString *)name usingCache:(BOOL)useCache UNAVAILABLE_ATTRIBUTE; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RazeCore.h: -------------------------------------------------------------------------------- 1 | // 2 | // RazeCore.h 3 | // 4 | // Created by Rob Visentin on 4/17/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | FOUNDATION_EXPORT double RazeCoreVersionNumber; 11 | FOUNDATION_EXPORT const unsigned char RazeCoreVersionString[]; 12 | 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene SandboxTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXQuadMesh.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXQuadMesh.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 1/10/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | OBJC_EXTERN NSInteger const kRZXQuadMeshMaxSubdivisions; 12 | 13 | /** 14 | * A procedurally generated rectangular mesh. 15 | */ 16 | @interface RZXQuadMesh : RZXMesh 17 | 18 | /** Initialize a basic quad. */ 19 | + (instancetype)quad; 20 | 21 | /** Initialize a quad with a specific number of subdivisions. */ 22 | + (instancetype)quadWithSubdivisionLevel:(NSInteger)subdivisons; 23 | 24 | @end 25 | 26 | @interface RZXQuadMesh (RZXUnavailable) 27 | 28 | // The mesh data will be procedurally generated rather then loaded from a file. 29 | + (instancetype)meshWithName:(NSString *)name usingCache:(BOOL)useCache UNAVAILABLE_ATTRIBUTE; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Raze/RazeCore/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Raze/RazeEffects/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Raze/RazeScene/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Raze/RazeUIKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Raze/RazeCore/Private/RZXRenderLoop.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXRenderLoop.h 3 | // 4 | // Created by Rob Visentin on 1/10/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface RZXRenderLoop : NSObject 12 | 13 | @property (assign, nonatomic, readonly) CFTimeInterval lastRender; 14 | @property (assign, nonatomic, readonly, getter=isRunning) BOOL running; 15 | 16 | @property (assign, nonatomic, readonly, getter=isValid) BOOL valid; 17 | 18 | @property (assign, nonatomic) BOOL automaticallyResumeWhenForegrounded; // default YES 19 | 20 | @property (assign, nonatomic) NSInteger preferredFPS; // default 30 21 | 22 | + (instancetype)renderLoop; 23 | 24 | - (void)setUpdateTarget:(id)updateTarget; 25 | - (void)setRenderTarget:(id)renderTarget; 26 | 27 | - (void)run; 28 | - (void)stop; 29 | 30 | - (void)invalidate; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXADSPhongEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXADSPhongEffect.h 3 | // Raze 4 | // 5 | // Created by John Stricker on 6/22/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * This effect is design for generic purpose display of 3D models. It incorporates a single light, and use ADS (ambient, diffise, and specular) constants to describe the effects of that single light on the model. The lighting effects are applied per fragment (aka Phong shading). 13 | */ 14 | @interface RZXADSPhongEffect : RZXEffect 15 | 16 | @property (assign, nonatomic) GLKVector4 lightPosition; 17 | @property (assign, nonatomic) GLKVector3 lightIntensity; 18 | @property (assign, nonatomic) GLKVector3 ambientReflection; 19 | @property (assign, nonatomic) GLKVector3 diffuseReflection; 20 | @property (assign, nonatomic) GLKVector3 specularReflection; 21 | @property (assign, nonatomic) GLfloat specularShininess; 22 | 23 | +(instancetype)effect; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXADSPhongEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXADSPhongEffect.h 3 | // Raze 4 | // 5 | // Created by John Stricker on 6/22/15. 6 | // 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * This effect is design for generic purpose display of 3D models. It incorporates a single light, and use ADS (ambient, diffise, and specular) constants to describe the effects of that single light on the model. The lighting effects are applied per fragment (aka Phong shading). 13 | */ 14 | @interface RZXADSPhongEffect : RZXEffect 15 | 16 | @property (assign, nonatomic) GLKVector4 lightPosition; 17 | @property (assign, nonatomic) GLKVector3 lightIntensity; 18 | @property (assign, nonatomic) GLKVector3 ambientReflection; 19 | @property (assign, nonatomic) GLKVector3 diffuseReflection; 20 | @property (assign, nonatomic) GLKVector3 specularReflection; 21 | @property (assign, nonatomic) GLfloat specularShininess; 22 | 23 | +(instancetype)effect; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/Private/RZXAnimationState.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXAnimationState.h 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | 10 | @class CAAnimation; 11 | 12 | @interface RZXAnimationState : NSObject 13 | 14 | @property (assign, nonatomic, getter=isStarted) BOOL started; 15 | @property (assign, nonatomic, getter=isFinished) BOOL finished; 16 | 17 | @property (assign, nonatomic) CFTimeInterval currentTime; 18 | @property (assign, nonatomic) float repetition; 19 | 20 | // if animation is absolute, this is the initial value of the animated property 21 | @property (strong, nonatomic) id initialValue; 22 | 23 | // if animation is absolute, this is the target value of the animated property 24 | @property (strong, nonatomic) id targetValue; 25 | 26 | // the interpolated value applied so far 27 | @property (strong, nonatomic) id appliedValue; 28 | 29 | - (BOOL)updateWithAnimation:(CAAnimation *)animation; 30 | 31 | @end -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/RZXViewNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXViewNode.m 3 | // Raze Scene Sandbox 4 | // 5 | // Created by Rob Visentin on 8/7/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import "RZXViewNode.h" 10 | 11 | @interface RZXViewNode () 12 | 13 | @property (weak, nonatomic) UIView *view; 14 | 15 | @end 16 | 17 | @implementation RZXViewNode 18 | 19 | + (instancetype)nodeWithView:(UIView *)view 20 | { 21 | RZXViewNode *node = [super node]; 22 | node.view = view; 23 | 24 | return node; 25 | } 26 | 27 | - (BOOL)setupGL 28 | { 29 | self.texture = [RZXViewTexture textureWithSize:self.view.frame.size]; 30 | 31 | return [super setupGL]; 32 | } 33 | 34 | - (void)rzx_update:(NSTimeInterval)dt 35 | { 36 | if ( [self.texture isKindOfClass:[RZXViewTexture class]] ) { 37 | [(RZXViewTexture *)self.texture updateWithView:self.view synchronous:YES]; 38 | } 39 | 40 | [super rzx_update:dt]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXDynamicTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXDynamicTexture.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | 12 | typedef void (^RZXTextureRenderBlock)(id self, CGContextRef ctx); 13 | 14 | /** 15 | * A texture that is expected to be modified with each update call. Core video pixel buffers are used for rapid texture generation. (Note that on the simulator this approach is not used and dynamic textures will perform exceptionally poorly. 16 | */ 17 | @interface RZXDynamicTexture : RZXTexture 18 | 19 | 20 | @property (assign, nonatomic, readonly) CGFloat scale; 21 | 22 | // Initialize a dynamic texture. Screen scale is typcially UIScreen.MainScreen.Scale 23 | + (instancetype)textureWithSize:(CGSize)size scale:(CGFloat)scale; 24 | 25 | - (void)updateWithBlock:(RZXTextureRenderBlock)renderBlock; 26 | 27 | - (CGImageRef)createImageRepresentation CF_RETURNS_RETAINED; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Raze/RazeCoreTests/RazeCoreTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RazeCoreTests.m 3 | // RazeCoreTests 4 | // 5 | // Created by Rob Visentin on 4/17/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RazeCoreTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation RazeCoreTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Raze/RazeSceneTests/RazeSceneTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RazeSceneTests.m 3 | // RazeSceneTests 4 | // 5 | // Created by John Stricker on 5/1/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RazeSceneTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation RazeSceneTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Raze/RazeUIKitTests/RazeUIKitTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RazeUIKitTests.m 3 | // RazeUIKitTests 4 | // 5 | // Created by Rob Visentin on 4/17/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RazeUIKitTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation RazeUIKitTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXDynamicTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXDynamicTexture.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | 12 | typedef void (^RZXTextureRenderBlock)(id self, CGContextRef ctx); 13 | 14 | /** 15 | * A texture that is expected to be modified with each update call. Core video pixel buffers are used for rapid texture generation. (Note that on the simulator this approach is not used and dynamic textures will perform exceptionally poorly. 16 | */ 17 | @interface RZXDynamicTexture : RZXTexture 18 | 19 | 20 | @property (assign, nonatomic, readonly) CGFloat scale; 21 | 22 | // Initialize a dynamic texture. Screen scale is typcially UIScreen.MainScreen.Scale 23 | + (instancetype)textureWithSize:(CGSize)size scale:(CGFloat)scale; 24 | 25 | - (void)updateWithBlock:(RZXTextureRenderBlock)renderBlock; 26 | 27 | - (CGImageRef)createImageRepresentation CF_RETURNS_RETAINED; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Raze/RazeEffectsTests/RazeEffectsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RazeEffectsTests.m 3 | // RazeEffectsTests 4 | // 5 | // Created by Rob Visentin on 4/17/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RazeEffectsTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation RazeEffectsTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Raze/RazeAnimationTests/RazeAnimationTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RazeAnimationTests.m 3 | // RazeAnimationTests 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface RazeAnimationTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation RazeAnimationTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXStaticTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXStaticTexture.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * A texture whose contents are not expected to be updated frequently, as in the case of most models. 12 | */ 13 | @interface RZXStaticTexture : RZXTexture 14 | 15 | @property (copy, nonatomic, readonly) NSString *fileName; 16 | 17 | // Load texture from a file. If using the cache and this file was loaded previously, then the texture will make use of a previously created OpenGL texture buffer 18 | + (instancetype)textureFromFile:(NSString *)fileName usingCache:(BOOL)useCache; 19 | 20 | //Load a texture from a file and also generate mipmaps of the texture. If available, Mipmaps will be automatically utlized by Raze and will maintain texture clarity when using a large texture that appears on a small object (or an object that will at times be far away and appear small). 21 | + (instancetype)mipmappedTextureFromFile:(NSString *)fileName usingCache:(BOOL)useCache; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXStaticTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXStaticTexture.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * A texture whose contents are not expected to be updated frequently, as in the case of most models. 12 | */ 13 | @interface RZXStaticTexture : RZXTexture 14 | 15 | @property (copy, nonatomic, readonly) NSString *fileName; 16 | 17 | // Load texture from a file. If using the cache and this file was loaded previously, then the texture will make use of a previously created OpenGL texture buffer 18 | + (instancetype)textureFromFile:(NSString *)fileName usingCache:(BOOL)useCache; 19 | 20 | //Load a texture from a file and also generate mipmaps of the texture. If available, Mipmaps will be automatically utlized by Raze and will maintain texture clarity when using a large texture that appears on a small object (or an object that will at times be far away and appear small). 21 | + (instancetype)mipmappedTextureFromFile:(NSString *)fileName usingCache:(BOOL)useCache; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene SandboxTests/Raze_Scene_SandboxTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // Raze_Scene_SandboxTests.m 3 | // Raze Scene SandboxTests 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface Raze_Scene_SandboxTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation Raze_Scene_SandboxTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Raizlabs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXSceneView.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXSceneView.m 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @implementation RZXSceneView 13 | 14 | - (instancetype)initWithFrame:(CGRect)frame scene:(RZXScene *)scene 15 | { 16 | self = [self initWithFrame:frame]; 17 | if (self) { 18 | self.scene = scene; 19 | } 20 | return self; 21 | } 22 | 23 | - (void)setScene:(RZXScene *)scene 24 | { 25 | _scene = scene; 26 | 27 | [_context runBlock:^(RZXGLContext *context) { 28 | [scene setupGL]; 29 | }]; 30 | 31 | self.model = scene; 32 | } 33 | 34 | - (void)setupGL 35 | { 36 | [super setupGL]; 37 | 38 | [self.scene setupGL]; 39 | } 40 | 41 | #pragma mark - drawing 42 | 43 | - (void)rzx_update:(NSTimeInterval)dt 44 | { 45 | [super rzx_update:dt]; 46 | [self.scene rzx_update:dt]; 47 | } 48 | 49 | - (void)display 50 | { 51 | self.scene.resolution = GLKVector2Make(_backingWidth, _backingHeight); 52 | [super display]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Raze/RazeUIKit/RZXViewTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXViewTexture.h 3 | // 4 | // Created by Rob Visentin on 1/9/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | /** 12 | * Creates a dynamic texture from a UIView. 13 | */ 14 | @interface RZXViewTexture : RZXDynamicTexture 15 | 16 | + (instancetype)textureWithSize:(CGSize)size; 17 | 18 | /** 19 | * Renders the contents of the given view into the receiver's texture buffer. 20 | * 21 | * @param view The view to render to the receiver's texture buffer. 22 | * @param synchronous Whether the rendering should be performed synchronously. 23 | * 24 | * @note This method uses drawViewHierarchyInRect to render the view. 25 | * Although not documented, this method is NOT threadsafe (specifically when layers are added or removed during view rendering). 26 | * Updating the texture asynchronously is significantly more performant, 27 | * but if there is question whether or not async will be safe, then pass YES for the synchronous parameter. 28 | */ 29 | - (void)updateWithView:(UIView *)view synchronous:(BOOL)synchronous; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Raze/Products/RazeUIKit.framework/Headers/RZXViewTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXViewTexture.h 3 | // 4 | // Created by Rob Visentin on 1/9/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | /** 12 | * Creates a dynamic texture from a UIView. 13 | */ 14 | @interface RZXViewTexture : RZXDynamicTexture 15 | 16 | + (instancetype)textureWithSize:(CGSize)size; 17 | 18 | /** 19 | * Renders the contents of the given view into the receiver's texture buffer. 20 | * 21 | * @param view The view to render to the receiver's texture buffer. 22 | * @param synchronous Whether the rendering should be performed synchronously. 23 | * 24 | * @note This method uses drawViewHierarchyInRect to render the view. 25 | * Although not documented, this method is NOT threadsafe (specifically when layers are added or removed during view rendering). 26 | * Updating the texture asynchronously is significantly more performant, 27 | * but if there is question whether or not async will be safe, then pass YES for the synchronous parameter. 28 | */ 29 | - (void)updateWithView:(UIView *)view synchronous:(BOOL)synchronous; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXTexture.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | 10 | OBJC_EXTERN NSString* const kRZXTextureMinFilterKey; /** Default GL_NEAREST */ 11 | OBJC_EXTERN NSString* const kRZXTextureMagFilterKey; /** Default GL_LINEAR */ 12 | OBJC_EXTERN NSString* const kRZXTextureSWrapKey; /** Default GL_REPEAT */ 13 | OBJC_EXTERN NSString* const kRZXTextureTWrapKey; /** Default GL_REPEAT */ 14 | 15 | #pragma clang diagnostic push 16 | #pragma clang diagnostic ignored "-Wobjc-interface-ivars" 17 | 18 | /** 19 | * Base 2D image texture class. Textures in use should be subclasses: RZXStaticTexture or RZXDynamicTexture. 20 | */ 21 | @interface RZXTexture : RZXGPUObject { 22 | @protected 23 | GLuint _name; 24 | CGSize _size; 25 | } 26 | 27 | /** 28 | * Returns the width and height of the texture. 29 | * @note If the texture is not yet loaded, it will be loaded in the default context before returning. 30 | */ 31 | @property (assign, nonatomic, readonly) CGSize size; 32 | 33 | - (void)applyOptions:(NSDictionary *)options; 34 | 35 | - (void)attachToFramebuffer:(GLenum)framebuffer; 36 | 37 | @end 38 | 39 | #pragma clang diagnostic pop 40 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXTexture.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | 10 | OBJC_EXTERN NSString* const kRZXTextureMinFilterKey; /** Default GL_NEAREST */ 11 | OBJC_EXTERN NSString* const kRZXTextureMagFilterKey; /** Default GL_LINEAR */ 12 | OBJC_EXTERN NSString* const kRZXTextureSWrapKey; /** Default GL_REPEAT */ 13 | OBJC_EXTERN NSString* const kRZXTextureTWrapKey; /** Default GL_REPEAT */ 14 | 15 | #pragma clang diagnostic push 16 | #pragma clang diagnostic ignored "-Wobjc-interface-ivars" 17 | 18 | /** 19 | * Base 2D image texture class. Textures in use should be subclasses: RZXStaticTexture or RZXDynamicTexture. 20 | */ 21 | @interface RZXTexture : RZXGPUObject { 22 | @protected 23 | GLuint _name; 24 | CGSize _size; 25 | } 26 | 27 | /** 28 | * Returns the width and height of the texture. 29 | * @note If the texture is not yet loaded, it will be loaded in the default context before returning. 30 | */ 31 | @property (assign, nonatomic, readonly) CGSize size; 32 | 33 | - (void)applyOptions:(NSDictionary *)options; 34 | 35 | - (void)attachToFramebuffer:(GLenum)framebuffer; 36 | 37 | @end 38 | 39 | #pragma clang diagnostic pop 40 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/RZXBasicAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXBasicAnimation.m 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/13/15. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @implementation RZXBasicAnimation 13 | 14 | + (instancetype)animationWithKeyPath:(NSString *)path options:(RZXAnimationOptions)options 15 | { 16 | RZXBasicAnimation *animation = [self animationWithKeyPath:path]; 17 | 18 | if ( options & kRZXAnimationOptionRepeat ) { 19 | animation.repeatCount = HUGE_VALF; 20 | } 21 | 22 | if ( options & kRZXAnimationOptionAutoReverse ) { 23 | animation.autoreverses = YES; 24 | } 25 | 26 | if ( options & kRZXAnimationOptionCurveEaseIn ) { 27 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 28 | } 29 | else if ( options & kRZXAnimationOptionCurveEaseOut ) { 30 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; 31 | } 32 | else if ( options & kRZXAnimationOptionCurveEaseInOut ) { 33 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 34 | } 35 | 36 | return animation; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Raze/RazeCore/NSValue+RZXExtensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSValue+RZXExtensions.m 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/24/15. 6 | // 7 | 8 | #import "NSValue+RZXExtensions.h" 9 | 10 | @implementation NSValue (RZXExtensions) 11 | 12 | + (instancetype)rzx_valueWithVec2:(GLKVector2)vec2 13 | { 14 | return [self valueWithBytes:vec2.v objCType:@encode(GLKVector2)]; 15 | } 16 | 17 | + (instancetype)rzx_valueWithVec3:(GLKVector3)vec3 18 | { 19 | return [self valueWithBytes:vec3.v objCType:@encode(GLKVector3)]; 20 | } 21 | 22 | + (instancetype)rzx_valueWithVec4:(GLKVector4)vec4 23 | { 24 | return [self valueWithBytes:vec4.v objCType:@encode(GLKVector4)]; 25 | } 26 | 27 | + (instancetype)rzx_valueWithQuaternion:(GLKQuaternion)quaternion 28 | { 29 | return [self valueWithBytes:quaternion.q objCType:@encode(GLKQuaternion)]; 30 | } 31 | 32 | - (GLKVector2)rzx_vec2Value 33 | { 34 | GLKVector2 v; 35 | [self getValue:v.v]; 36 | return v; 37 | } 38 | 39 | - (GLKVector3)rzx_vec3Value 40 | { 41 | GLKVector3 v; 42 | [self getValue:v.v]; 43 | return v; 44 | } 45 | 46 | - (GLKVector4)rzx_vec4Value 47 | { 48 | GLKVector4 v; 49 | [self getValue:v.v]; 50 | return v; 51 | } 52 | 53 | - (GLKQuaternion)rzx_quaternionValue 54 | { 55 | GLKQuaternion q; 56 | [self getValue:q.q]; 57 | return q; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationLandscapeLeft 36 | UIInterfaceOrientationLandscapeRight 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCamera.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * An object representing a projective camera. 12 | */ 13 | @interface RZXCamera : NSObject 14 | 15 | @property (strong, nonatomic) RZXTransform3D *transform; 16 | 17 | /** A unit vector in the "up" direction. Default is (0, 1, 0) */ 18 | @property (nonatomic, assign) GLKVector3 up; 19 | 20 | @property (nonatomic, assign) float fieldOfView; 21 | 22 | @property (nonatomic, assign) float aspectRatio; 23 | 24 | /** The near clipping plane. Must be positive. */ 25 | @property (nonatomic, assign) float near; 26 | 27 | /** The far clipping plane. Must be positive. */ 28 | @property (nonatomic, assign) float far; 29 | 30 | /** The current view matrix based on the camera's transform and up properties. */ 31 | @property (nonatomic, readonly) GLKMatrix4 viewMatrix; 32 | 33 | /** The current projection matrix of the camera based on the fieldOfView, aspectRatio, near, and far properties. 34 | * @note This value is cached, so is not recomputed unless a contributing property changes. 35 | */ 36 | @property (nonatomic, readonly) GLKMatrix4 projectionMatrix; 37 | 38 | + (instancetype)cameraWithFieldOfView:(float)fov aspectRatio:(float)aspectRatio nearClipping:(float)near farClipping:(float)far; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCamera.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /** 11 | * An object representing a projective camera. 12 | */ 13 | @interface RZXCamera : NSObject 14 | 15 | @property (strong, nonatomic) RZXTransform3D *transform; 16 | 17 | /** A unit vector in the "up" direction. Default is (0, 1, 0) */ 18 | @property (nonatomic, assign) GLKVector3 up; 19 | 20 | @property (nonatomic, assign) float fieldOfView; 21 | 22 | @property (nonatomic, assign) float aspectRatio; 23 | 24 | /** The near clipping plane. Must be positive. */ 25 | @property (nonatomic, assign) float near; 26 | 27 | /** The far clipping plane. Must be positive. */ 28 | @property (nonatomic, assign) float far; 29 | 30 | /** The current view matrix based on the camera's transform and up properties. */ 31 | @property (nonatomic, readonly) GLKMatrix4 viewMatrix; 32 | 33 | /** The current projection matrix of the camera based on the fieldOfView, aspectRatio, near, and far properties. 34 | * @note This value is cached, so is not recomputed unless a contributing property changes. 35 | */ 36 | @property (nonatomic, readonly) GLKMatrix4 projectionMatrix; 37 | 38 | + (instancetype)cameraWithFieldOfView:(float)fov aspectRatio:(float)aspectRatio nearClipping:(float)near farClipping:(float)far; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Raze/RazeScene/RZXNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXNode.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | #import 13 | #import 14 | 15 | @class RZXTransform3D; 16 | @class RZXEffect; 17 | @class RZXCamera; 18 | 19 | /** 20 | * The base unit of any scene object. In most cases anything applied to a node (transform, camera, effect, animation) will also be applied to that node's children if the child node does not have a value specified. 21 | */ 22 | @interface RZXNode : RZXGPUObject 23 | 24 | @property (strong, nonatomic) RZXTransform3D *transform; 25 | @property (strong, nonatomic) RZXEffect *effect; 26 | @property (strong, nonatomic) RZXCamera *camera; 27 | 28 | @property (assign, nonatomic) GLKVector2 resolution; 29 | 30 | @property (copy, nonatomic, readonly) NSArray *children; 31 | @property (weak, nonatomic, readonly) RZXNode *parent; 32 | 33 | + (instancetype)node; 34 | 35 | - (void)addChild:(RZXNode *)child; 36 | - (void)insertChild:(RZXNode *)child atIndex:(NSUInteger)index; 37 | 38 | - (void)removeFromParent; 39 | 40 | - (GLKMatrix4)modelMatrix; 41 | - (GLKMatrix4)viewMatrix; 42 | - (GLKMatrix4)projectionMatrix; 43 | 44 | - (void)addAnimation:(CAAnimation *)animation forKey:(NSString *)key; 45 | - (CAAnimation *)animationForKey:(NSString *)key; 46 | - (void)removeAnimationForKey:(NSString *)key; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Headers/RZXNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXNode.h 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | #import 13 | #import 14 | 15 | @class RZXTransform3D; 16 | @class RZXEffect; 17 | @class RZXCamera; 18 | 19 | /** 20 | * The base unit of any scene object. In most cases anything applied to a node (transform, camera, effect, animation) will also be applied to that node's children if the child node does not have a value specified. 21 | */ 22 | @interface RZXNode : RZXGPUObject 23 | 24 | @property (strong, nonatomic) RZXTransform3D *transform; 25 | @property (strong, nonatomic) RZXEffect *effect; 26 | @property (strong, nonatomic) RZXCamera *camera; 27 | 28 | @property (assign, nonatomic) GLKVector2 resolution; 29 | 30 | @property (copy, nonatomic, readonly) NSArray *children; 31 | @property (weak, nonatomic, readonly) RZXNode *parent; 32 | 33 | + (instancetype)node; 34 | 35 | - (void)addChild:(RZXNode *)child; 36 | - (void)insertChild:(RZXNode *)child atIndex:(NSUInteger)index; 37 | 38 | - (void)removeFromParent; 39 | 40 | - (GLKMatrix4)modelMatrix; 41 | - (GLKMatrix4)viewMatrix; 42 | - (GLKMatrix4)projectionMatrix; 43 | 44 | - (void)addAnimation:(CAAnimation *)animation forKey:(NSString *)key; 45 | - (CAAnimation *)animationForKey:(NSString *)key; 46 | - (void)removeAnimationForKey:(NSString *)key; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.raizlabs.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXTextNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXTextNode.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | #import 13 | #else 14 | #import 15 | #endif 16 | 17 | typedef NS_ENUM(NSUInteger, RZXHorizontalAlignment) { 18 | RZXHorizontalAlignmentCenter, 19 | RZXHorizontalAlignmentLeft, 20 | RZXHorizontalAlignmentRight 21 | }; 22 | 23 | typedef NS_ENUM(NSUInteger, RZXVerticalAlignment) { 24 | RZXVerticalAlignmentCenter, 25 | RZXVerticalAlignmentTop, 26 | RZXVerticalAlignmentBottom 27 | }; 28 | 29 | @class RZXFont; 30 | @class RZXColor; 31 | 32 | /** 33 | * A model node whose model is a quad upon which is drawn a texture created from text 34 | */ 35 | @interface RZXTextNode : RZXModelNode 36 | 37 | @property (copy, nonatomic) NSString *text; 38 | 39 | @property (strong, nonatomic) RZXFont *font; 40 | @property (strong, nonatomic) RZXColor *textColor; 41 | 42 | @property (assign, nonatomic) NSLineBreakMode lineBreakMode; 43 | @property (assign, nonatomic) NSTextAlignment textAlignment; 44 | 45 | @property (copy, nonatomic) NSAttributedString *attributedText; 46 | 47 | @property (assign, nonatomic) RZXHorizontalAlignment horizontalAlignment; 48 | @property (assign, nonatomic) RZXVerticalAlignment verticalAlignment; 49 | 50 | // TODO: this is currently specified in screen points. Ideally this should be in GL units. 51 | @property (assign, nonatomic) CGSize boundingSize; 52 | 53 | + (instancetype)nodeWithText:(NSString *)text; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXModelNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXModelNode.m 3 | // RazeScene 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @implementation RZXModelNode 14 | 15 | + (instancetype)modelNodeWithMesh:(RZXMesh *)mesh texture:(RZXTexture *)texture 16 | { 17 | return [[self alloc] initWithMesh:mesh texture:texture]; 18 | } 19 | 20 | - (instancetype)initWithMesh:(RZXMesh *)mesh texture:(RZXTexture *)texture 21 | { 22 | self = [super init]; 23 | if (self) { 24 | _mesh = mesh; 25 | _texture = texture; 26 | } 27 | return self; 28 | } 29 | 30 | - (RZXTexture *)texture 31 | { 32 | if ( _texture == nil ) { 33 | _texture = [[RZXTexture alloc] init]; 34 | } 35 | return _texture; 36 | } 37 | 38 | - (RZXMesh *)mesh 39 | { 40 | if ( _mesh == nil ) { 41 | _mesh = [[RZXMesh alloc] init]; 42 | } 43 | return _mesh; 44 | } 45 | 46 | #pragma mark - RZXRenderable 47 | 48 | - (void)rzx_render 49 | { 50 | [self.mesh rzx_render]; 51 | 52 | [super rzx_render]; 53 | } 54 | 55 | #pragma mark - RZXGPUObject overrides 56 | 57 | - (BOOL)setupGL 58 | { 59 | return ([super setupGL] && [self.texture setupGL] && [self.mesh setupGL]); 60 | } 61 | 62 | - (BOOL)bindGL 63 | { 64 | return ([super bindGL] && [self.texture bindGL] && [self.mesh bindGL]); 65 | } 66 | 67 | - (void)teardownGL 68 | { 69 | [super teardownGL]; 70 | 71 | [self.texture teardownGL]; 72 | [self.mesh teardownGL]; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Headers/RZXTextNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXTextNode.h 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | #import 13 | #else 14 | #import 15 | #endif 16 | 17 | typedef NS_ENUM(NSUInteger, RZXHorizontalAlignment) { 18 | RZXHorizontalAlignmentCenter, 19 | RZXHorizontalAlignmentLeft, 20 | RZXHorizontalAlignmentRight 21 | }; 22 | 23 | typedef NS_ENUM(NSUInteger, RZXVerticalAlignment) { 24 | RZXVerticalAlignmentCenter, 25 | RZXVerticalAlignmentTop, 26 | RZXVerticalAlignmentBottom 27 | }; 28 | 29 | @class RZXFont; 30 | @class RZXColor; 31 | 32 | /** 33 | * A model node whose model is a quad upon which is drawn a texture created from text 34 | */ 35 | @interface RZXTextNode : RZXModelNode 36 | 37 | @property (copy, nonatomic) NSString *text; 38 | 39 | @property (strong, nonatomic) RZXFont *font; 40 | @property (strong, nonatomic) RZXColor *textColor; 41 | 42 | @property (assign, nonatomic) NSLineBreakMode lineBreakMode; 43 | @property (assign, nonatomic) NSTextAlignment textAlignment; 44 | 45 | @property (copy, nonatomic) NSAttributedString *attributedText; 46 | 47 | @property (assign, nonatomic) RZXHorizontalAlignment horizontalAlignment; 48 | @property (assign, nonatomic) RZXVerticalAlignment verticalAlignment; 49 | 50 | // TODO: this is currently specified in screen points. Ideally this should be in GL units. 51 | @property (assign, nonatomic) CGSize boundingSize; 52 | 53 | + (instancetype)nodeWithText:(NSString *)text; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXGrayscaleEffect.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGrayscaleEffect.m 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/21/15. 6 | // 7 | 8 | #import 9 | 10 | static NSString* const kRZXEffectIntensityVSH = RZX_SHADER_SRC( 11 | uniform mat4 u_MVPMatrix; 12 | 13 | attribute vec4 a_position; 14 | attribute vec2 a_texCoord0; 15 | 16 | varying vec2 v_texCoord0; 17 | 18 | void main(void) 19 | { 20 | v_texCoord0 = a_texCoord0; 21 | gl_Position = u_MVPMatrix * a_position; 22 | }); 23 | 24 | static NSString* const kRZXEffectIntensityFSH = RZX_SHADER_SRC( 25 | const highp vec3 W = vec3(0.2125, 0.7154, 0.0721); 26 | 27 | uniform lowp sampler2D u_Texture; 28 | 29 | varying highp vec2 v_texCoord0; 30 | 31 | void main() 32 | { 33 | lowp vec4 texel = texture2D(u_Texture, v_texCoord0); 34 | highp float luminance = dot(texel.rgb, W); 35 | gl_FragColor = vec4(vec3(luminance), texel.a); 36 | }); 37 | 38 | @implementation RZXGrayscaleEffect 39 | 40 | + (instancetype)effect 41 | { 42 | RZXGrayscaleEffect *effect = [RZXGrayscaleEffect effectWithVertexShader:kRZXEffectIntensityVSH fragmentShader:kRZXEffectIntensityFSH]; 43 | effect.mvpUniform = @"u_MVPMatrix"; 44 | 45 | return effect; 46 | } 47 | 48 | - (BOOL)link 49 | { 50 | [self bindAttribute:@"a_position" location:kRZXVertexAttribPosition]; 51 | [self bindAttribute:@"a_texCoord0" location:kRZXVertexAttribTexCoord]; 52 | 53 | return [super link]; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXTransform3D.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXTransform3D.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXTransform3D : NSObject 11 | 12 | @property (nonatomic, assign) GLKVector3 translation; 13 | @property (nonatomic, assign) GLKQuaternion rotation; 14 | @property (nonatomic, assign) GLKVector3 scale; 15 | 16 | /** 17 | * Returns the current TRS matrix from the translation, rotation, and scale properties. 18 | * @note This matrix is cached, and therefore is not recomputed unless a contributing property changes. 19 | */ 20 | @property (nonatomic, readonly) GLKMatrix4 modelMatrix; 21 | 22 | + (instancetype)transform; 23 | + (instancetype)transformWithTranslation:(GLKVector3)trans rotation:(GLKQuaternion)rot scale:(GLKVector3)scale; 24 | 25 | // delta is added to current value 26 | - (void)translateXBy:(float)dx; 27 | - (void)translateYBy:(float)dy; 28 | - (void)translateZBy:(float)dz; 29 | 30 | // current value is set to given value 31 | - (void)translateXTo:(float)tx; 32 | - (void)translateYTo:(float)ty; 33 | - (void)translateZTo:(float)tz; 34 | 35 | // current value is multiplied by delta 36 | - (void)scaleXBy:(float)dx; 37 | - (void)scaleYBy:(float)dy; 38 | - (void)scaleZBy:(float)dz; 39 | 40 | // current value is set to given value 41 | - (void)scaleXTo:(float)sx; 42 | - (void)scaleYTo:(float)sy; 43 | - (void)scaleZTo:(float)sz; 44 | 45 | // current rotation is multiplied by given quaternion 46 | - (void)rotateXBy:(float)angle; 47 | - (void)rotateYBy:(float)angle; 48 | - (void)rotateZBy:(float)angle; 49 | - (void)rotateBy:(GLKQuaternion)rotation; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXTransform3D.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXTransform3D.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface RZXTransform3D : NSObject 11 | 12 | @property (nonatomic, assign) GLKVector3 translation; 13 | @property (nonatomic, assign) GLKQuaternion rotation; 14 | @property (nonatomic, assign) GLKVector3 scale; 15 | 16 | /** 17 | * Returns the current TRS matrix from the translation, rotation, and scale properties. 18 | * @note This matrix is cached, and therefore is not recomputed unless a contributing property changes. 19 | */ 20 | @property (nonatomic, readonly) GLKMatrix4 modelMatrix; 21 | 22 | + (instancetype)transform; 23 | + (instancetype)transformWithTranslation:(GLKVector3)trans rotation:(GLKQuaternion)rot scale:(GLKVector3)scale; 24 | 25 | // delta is added to current value 26 | - (void)translateXBy:(float)dx; 27 | - (void)translateYBy:(float)dy; 28 | - (void)translateZBy:(float)dz; 29 | 30 | // current value is set to given value 31 | - (void)translateXTo:(float)tx; 32 | - (void)translateYTo:(float)ty; 33 | - (void)translateZTo:(float)tz; 34 | 35 | // current value is multiplied by delta 36 | - (void)scaleXBy:(float)dx; 37 | - (void)scaleYBy:(float)dy; 38 | - (void)scaleZBy:(float)dz; 39 | 40 | // current value is set to given value 41 | - (void)scaleXTo:(float)sx; 42 | - (void)scaleYTo:(float)sy; 43 | - (void)scaleZTo:(float)sz; 44 | 45 | // current rotation is multiplied by given quaternion 46 | - (void)rotateXBy:(float)angle; 47 | - (void)rotateYBy:(float)angle; 48 | - (void)rotateZBy:(float)angle; 49 | - (void)rotateBy:(GLKQuaternion)rotation; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/Private/RZXAnimationState.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXAnimationState.m 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @implementation RZXAnimationState 12 | 13 | - (BOOL)updateWithAnimation:(CAAnimation *)animation 14 | { 15 | BOOL reset = NO; 16 | 17 | NSTimeInterval duration = animation.duration; 18 | float repeatCount = animation.repeatCount; 19 | CFTimeInterval repeatDuration = animation.repeatDuration; 20 | 21 | if ( self.currentTime > 0.0 && !self.isStarted ) { 22 | self.started = YES; 23 | reset = YES; 24 | } 25 | 26 | if ( repeatCount > 0.0f && self.repetition >= repeatCount + 1 ) { 27 | CFTimeInterval remainingTime = fmod(repeatCount * duration, duration); 28 | 29 | self.currentTime = remainingTime > 0.0 ? remainingTime : duration; 30 | self.repetition = repeatCount; 31 | self.finished = YES; 32 | } 33 | else if ( repeatDuration > 0.0 && self.repetition * duration >= repeatDuration ) { 34 | CFTimeInterval remainingTime = fmod(repeatDuration, duration); 35 | 36 | self.currentTime = remainingTime > 0.0 ? remainingTime : duration; 37 | self.repetition = repeatDuration / duration; 38 | self.finished = YES; 39 | } 40 | else if ( self.currentTime >= duration ) { 41 | if ( repeatCount > 0.0f || repeatDuration > 0.0 ) { 42 | self.currentTime -= duration; 43 | reset = YES; 44 | } 45 | else { 46 | self.currentTime = duration; 47 | self.finished = YES; 48 | } 49 | } 50 | 51 | return reset; 52 | } 53 | 54 | @end -------------------------------------------------------------------------------- /Raze/RazeCore/RZXGLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGLView.h 3 | // 4 | // Created by Rob Visentin on 3/15/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import 12 | 13 | @class RZXGLContext; 14 | 15 | #pragma clang diagnostic push 16 | #pragma clang diagnostic ignored "-Wobjc-interface-ivars" 17 | 18 | /** 19 | * UIView with a CAEAGLayer, used for all OpenGL rendering. 20 | * Subclasses should be used to perform more nuanced rendering. 21 | */ 22 | @interface RZXGLView : UIView { 23 | @protected 24 | RZXGLContext *_context; 25 | 26 | // buffer indices for frame buffer, color render buffer, and depth render buffer 27 | GLuint _fbo; 28 | GLuint _crb; 29 | GLuint _drb; 30 | 31 | // buffer indices for multisampling 32 | GLuint _msFbo; 33 | GLuint _msCrb; 34 | GLuint _msDrb; 35 | 36 | GLint _backingWidth; 37 | GLint _backingHeight; 38 | } 39 | 40 | /** Frames per second specified between 1 and 60. */ 41 | @property (assign, nonatomic) IBInspectable NSInteger framesPerSecond; 42 | 43 | /* Multisample level specified between 0 and 4. */ 44 | @property (assign, nonatomic) IBInspectable GLsizei multisampleLevel; 45 | 46 | // Pausing will stop the render loop 47 | @property (assign, nonatomic, getter=isPaused) BOOL paused; 48 | 49 | // Model for the view 50 | @property (strong, nonatomic) id model; 51 | 52 | @property (nonatomic, readonly) RZXGPUObjectTeardownBlock teardownHandler; 53 | 54 | - (void)setupGL; 55 | - (void)teardownGL; 56 | 57 | - (void)display; 58 | 59 | @end 60 | 61 | #pragma clang diagnostic pop 62 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXGLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGLView.h 3 | // 4 | // Created by Rob Visentin on 3/15/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | #import 12 | 13 | @class RZXGLContext; 14 | 15 | #pragma clang diagnostic push 16 | #pragma clang diagnostic ignored "-Wobjc-interface-ivars" 17 | 18 | /** 19 | * UIView with a CAEAGLayer, used for all OpenGL rendering. 20 | * Subclasses should be used to perform more nuanced rendering. 21 | */ 22 | @interface RZXGLView : UIView { 23 | @protected 24 | RZXGLContext *_context; 25 | 26 | // buffer indices for frame buffer, color render buffer, and depth render buffer 27 | GLuint _fbo; 28 | GLuint _crb; 29 | GLuint _drb; 30 | 31 | // buffer indices for multisampling 32 | GLuint _msFbo; 33 | GLuint _msCrb; 34 | GLuint _msDrb; 35 | 36 | GLint _backingWidth; 37 | GLint _backingHeight; 38 | } 39 | 40 | /** Frames per second specified between 1 and 60. */ 41 | @property (assign, nonatomic) IBInspectable NSInteger framesPerSecond; 42 | 43 | /* Multisample level specified between 0 and 4. */ 44 | @property (assign, nonatomic) IBInspectable GLsizei multisampleLevel; 45 | 46 | // Pausing will stop the render loop 47 | @property (assign, nonatomic, getter=isPaused) BOOL paused; 48 | 49 | // Model for the view 50 | @property (strong, nonatomic) id model; 51 | 52 | @property (nonatomic, readonly) RZXGPUObjectTeardownBlock teardownHandler; 53 | 54 | - (void)setupGL; 55 | - (void)teardownGL; 56 | 57 | - (void)display; 58 | 59 | @end 60 | 61 | #pragma clang diagnostic pop 62 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXGPUObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGPUObject.m 3 | // Raze 4 | // 5 | // Created by Rob Visentin on 7/16/15. 6 | // 7 | // 8 | 9 | #import "RZXGPUObject.h" 10 | 11 | @interface RZXGPUObject () 12 | 13 | @property (strong, nonatomic, readwrite) RZXGLContext *configuredContext; 14 | 15 | @end 16 | 17 | @implementation RZXGPUObject 18 | 19 | - (RZXGPUObjectTeardownBlock)teardownHandler 20 | { 21 | return nil; 22 | } 23 | 24 | - (BOOL)setupGL 25 | { 26 | // TODO: when supporting multiple contexts, also ensure that the current context is the configured context 27 | BOOL setup = (self.configuredContext != nil); 28 | 29 | if ( !setup ) { 30 | // TODO: when supporting multiple contexts, also teardown in previous context 31 | 32 | RZXGLContext *currentContext = [RZXGLContext currentContext]; 33 | 34 | if ( currentContext != nil ) { 35 | self.configuredContext = currentContext; 36 | setup = YES; 37 | } 38 | else { 39 | RZXLog(@"Failed to setup %@: No active context!", NSStringFromClass([self class])); 40 | } 41 | } 42 | 43 | return setup; 44 | } 45 | 46 | - (BOOL)bindGL 47 | { 48 | // TODO: when supporting multiple contexts, also ensure that the current context is the configured context 49 | BOOL bound = (self.configuredContext != nil); 50 | 51 | if ( !bound ) { 52 | bound = [self setupGL]; 53 | } 54 | 55 | return bound; 56 | } 57 | 58 | - (void)teardownGL 59 | { 60 | if ( self.configuredContext != nil && self.teardownHandler != nil ) { 61 | [self.configuredContext runBlock:self.teardownHandler wait:NO]; 62 | } 63 | 64 | self.configuredContext = nil; 65 | } 66 | 67 | - (void)dealloc 68 | { 69 | [self teardownGL]; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXMesh.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXMesh.h 3 | // RazeCore 4 | // 5 | // Created by John Stricker on 3/19/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | OBJC_EXTERN NSString* const kRZXMeshFileExtension; 13 | 14 | typedef struct _RZXBufferSet { 15 | GLuint vbo, ibo; 16 | } RZXBufferSet; 17 | 18 | #pragma clang diagnostic push 19 | #pragma clang diagnostic ignored "-Wobjc-interface-ivars" 20 | 21 | /** 22 | * Represents an object stored in OpenGL Memory by default loaded from a .mesh file. 23 | * Currently .mesh files are created from Blender via an export script that can be found in the Utilities folder of this SDK. 24 | */ 25 | @interface RZXMesh : RZXGPUObject { 26 | @protected 27 | GLuint _vao; 28 | RZXBufferSet _bufferSet; 29 | GLuint _indexCount; 30 | 31 | // TODO: this is a hack until meshes are more unified 32 | BOOL (^_configurationBlock)(RZXMesh *self); 33 | } 34 | 35 | /** Max width, height, and depth of the mesh. */ 36 | @property (nonatomic, readonly) GLKVector3 bounds; 37 | 38 | /** The key to use when caching the mesh. */ 39 | @property (nonatomic, readonly) NSString *cacheKey; 40 | 41 | // Load .mesh file. Use of cache means that if this file has already been loaded, then the buffer values will simply be copied rather then reloading the file and creating a new OpenGL VAO. 42 | /** 43 | * Creates a new RZXMesh object. 44 | * 45 | * @param name The name of the .mesh file to load. The main bundle will be searched for a .mesh file with this name. 46 | * @param useCache If YES, the mesh checks the cache for an existing VAO object before creating a new one. 47 | * If none is found, a new object is created and then cached. 48 | * 49 | */ 50 | + (instancetype)meshWithName:(NSString *)name usingCache:(BOOL)useCache; 51 | 52 | @end 53 | 54 | #pragma clang diagnostic pop 55 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXMesh.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXMesh.h 3 | // RazeCore 4 | // 5 | // Created by John Stricker on 3/19/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | OBJC_EXTERN NSString* const kRZXMeshFileExtension; 13 | 14 | typedef struct _RZXBufferSet { 15 | GLuint vbo, ibo; 16 | } RZXBufferSet; 17 | 18 | #pragma clang diagnostic push 19 | #pragma clang diagnostic ignored "-Wobjc-interface-ivars" 20 | 21 | /** 22 | * Represents an object stored in OpenGL Memory by default loaded from a .mesh file. 23 | * Currently .mesh files are created from Blender via an export script that can be found in the Utilities folder of this SDK. 24 | */ 25 | @interface RZXMesh : RZXGPUObject { 26 | @protected 27 | GLuint _vao; 28 | RZXBufferSet _bufferSet; 29 | GLuint _indexCount; 30 | 31 | // TODO: this is a hack until meshes are more unified 32 | BOOL (^_configurationBlock)(RZXMesh *self); 33 | } 34 | 35 | /** Max width, height, and depth of the mesh. */ 36 | @property (nonatomic, readonly) GLKVector3 bounds; 37 | 38 | /** The key to use when caching the mesh. */ 39 | @property (nonatomic, readonly) NSString *cacheKey; 40 | 41 | // Load .mesh file. Use of cache means that if this file has already been loaded, then the buffer values will simply be copied rather then reloading the file and creating a new OpenGL VAO. 42 | /** 43 | * Creates a new RZXMesh object. 44 | * 45 | * @param name The name of the .mesh file to load. The main bundle will be searched for a .mesh file with this name. 46 | * @param useCache If YES, the mesh checks the cache for an existing VAO object before creating a new one. 47 | * If none is found, a new object is created and then cached. 48 | * 49 | */ 50 | + (instancetype)meshWithName:(NSString *)name usingCache:(BOOL)useCache; 51 | 52 | @end 53 | 54 | #pragma clang diagnostic pop 55 | -------------------------------------------------------------------------------- /Raze/RazeUIKit/RZXEffectView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXEffectView.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @interface RZXEffectView : RZXGLView 13 | 14 | /** 15 | * The effect to apply to the source view. 16 | * @see RZXEffect 17 | */ 18 | @property (strong, nonatomic) RZXEffect *effect; 19 | 20 | /** 21 | * The transform with which to render the source view. 22 | */ 23 | @property (strong, nonatomic) RZXTransform3D *effectTransform; 24 | 25 | /** 26 | * Whether the contents of the view texture are updated each frame. 27 | * If the source view contents never change, set this property to NO for best performance. 28 | */ 29 | @property (assign, nonatomic, getter=isDynamic) IBInspectable BOOL dynamic; 30 | 31 | /** 32 | * Whether the view texture should be updated synchronously. Default NO. 33 | * @see RZXViewTexture 34 | */ 35 | @property (assign, nonatomic) BOOL synchronousUpdate; 36 | 37 | /** 38 | * Creates a new RZXEffect view that will apply an RZXEffect to a given view. 39 | * 40 | * @param view The view to apply an effect to. It must be currently on screen. 41 | * @param effect The effect to apply to the view. 42 | * @param dynamic Whether the source view has dynamic contents. If the source will never change, pass NO. 43 | * 44 | * @note The sourceView should NOT be an ancestor of the effect view. 45 | */ 46 | - (instancetype)initWithSourceView:(UIView *)view effect:(RZXEffect *)effect dynamicContent:(BOOL)dynamic; 47 | 48 | @end 49 | 50 | @interface RZXEffectView (RZUnavailable) 51 | 52 | - (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("Use -initWithSourceView: instead."))); 53 | 54 | - (void)setMultisampleLevel:(GLsizei)multisampleLevel __attribute__((unavailable("RZXEffectView does not support multisample antialiasing."))); 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Raze/Products/RazeUIKit.framework/Headers/RZXEffectView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXEffectView.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @interface RZXEffectView : RZXGLView 13 | 14 | /** 15 | * The effect to apply to the source view. 16 | * @see RZXEffect 17 | */ 18 | @property (strong, nonatomic) RZXEffect *effect; 19 | 20 | /** 21 | * The transform with which to render the source view. 22 | */ 23 | @property (strong, nonatomic) RZXTransform3D *effectTransform; 24 | 25 | /** 26 | * Whether the contents of the view texture are updated each frame. 27 | * If the source view contents never change, set this property to NO for best performance. 28 | */ 29 | @property (assign, nonatomic, getter=isDynamic) IBInspectable BOOL dynamic; 30 | 31 | /** 32 | * Whether the view texture should be updated synchronously. Default NO. 33 | * @see RZXViewTexture 34 | */ 35 | @property (assign, nonatomic) BOOL synchronousUpdate; 36 | 37 | /** 38 | * Creates a new RZXEffect view that will apply an RZXEffect to a given view. 39 | * 40 | * @param view The view to apply an effect to. It must be currently on screen. 41 | * @param effect The effect to apply to the view. 42 | * @param dynamic Whether the source view has dynamic contents. If the source will never change, pass NO. 43 | * 44 | * @note The sourceView should NOT be an ancestor of the effect view. 45 | */ 46 | - (instancetype)initWithSourceView:(UIView *)view effect:(RZXEffect *)effect dynamicContent:(BOOL)dynamic; 47 | 48 | @end 49 | 50 | @interface RZXEffectView (RZUnavailable) 51 | 52 | - (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("Use -initWithSourceView: instead."))); 53 | 54 | - (void)setMultisampleLevel:(GLsizei)multisampleLevel __attribute__((unavailable("RZXEffectView does not support multisample antialiasing."))); 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXPassthroughEffect.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXPassthroughEffect.m 3 | // Raze 4 | // 5 | // Created by Rob Visentin on 6/19/15. 6 | // 7 | // 8 | 9 | #import "RZXPassthroughEffect.h" 10 | 11 | NSString* const kRZXEffectPassthroughVSH2D = RZX_SHADER_SRC( 12 | attribute vec4 a_position; 13 | attribute vec2 a_texCoord0; 14 | 15 | varying vec2 v_texCoord0; 16 | 17 | void main(void) 18 | { 19 | v_texCoord0 = a_texCoord0; 20 | gl_Position = a_position; 21 | }); 22 | 23 | NSString* const kRZXEffectPassthroughVSH3D = RZX_SHADER_SRC( 24 | uniform mat4 u_MVPMatrix; 25 | 26 | attribute vec4 a_position; 27 | attribute vec2 a_texCoord0; 28 | 29 | varying vec2 v_texCoord0; 30 | 31 | void main(void) 32 | { 33 | v_texCoord0 = a_texCoord0; 34 | gl_Position = u_MVPMatrix * a_position; 35 | }); 36 | 37 | NSString* const kRZXEffectPassthroughFSH = RZX_SHADER_SRC( 38 | uniform lowp sampler2D u_Texture; 39 | 40 | varying highp vec2 v_texCoord0; 41 | 42 | void main() 43 | { 44 | gl_FragColor = texture2D(u_Texture, v_texCoord0); 45 | }); 46 | 47 | @implementation RZXPassthroughEffect 48 | 49 | + (instancetype)effect2D 50 | { 51 | RZXPassthroughEffect *effect = [super effectWithVertexShader:kRZXEffectPassthroughVSH2D fragmentShader:kRZXEffectPassthroughFSH]; 52 | effect.mvpUniform = @"u_MVPMatrix"; 53 | 54 | return effect; 55 | } 56 | 57 | + (instancetype)effect3D 58 | { 59 | RZXPassthroughEffect *effect = [super effectWithVertexShader:kRZXEffectPassthroughVSH3D fragmentShader:kRZXEffectPassthroughFSH]; 60 | effect.mvpUniform = @"u_MVPMatrix"; 61 | 62 | return effect; 63 | } 64 | 65 | - (BOOL)link 66 | { 67 | [self bindAttribute:@"a_position" location:kRZXVertexAttribPosition]; 68 | [self bindAttribute:@"a_texCoord0" location:kRZXVertexAttribTexCoord]; 69 | 70 | return [super link]; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXEffect.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #define RZX_EFFECT_MAX_DOWNSAMPLE 4 11 | 12 | #define RZX_SHADER_SRC(src) (@#src) 13 | 14 | /** 15 | * Manages a shader. Any new shaders should subclass this. Override link to set up attributes (and call super), and override preprare to draw to assign uniforms (and call super). See RZXADSPhongEffect for an example of how a typical OpenGL shader can be implemented. 16 | */ 17 | @interface RZXEffect : RZXGPUObject 18 | 19 | @property (nonatomic, readonly, getter = isLinked) BOOL linked; 20 | 21 | @property (assign, nonatomic) GLKMatrix4 modelViewMatrix; 22 | @property (assign, nonatomic) GLKMatrix4 projectionMatrix; 23 | @property (assign, nonatomic) GLKMatrix3 normalMatrix; 24 | 25 | @property (copy, nonatomic) NSString *mvpUniform; 26 | @property (copy, nonatomic) NSString *mvUniform; 27 | @property (copy, nonatomic) NSString *normalMatrixUniform; 28 | 29 | @property (assign, nonatomic) GLKVector2 resolution; 30 | @property (assign, nonatomic) GLuint downsampleLevel; 31 | 32 | @property (nonatomic, readonly) NSInteger preferredLevelOfDetail; 33 | 34 | + (instancetype)effectWithVertexShader:(NSString *)vsh fragmentShader:(NSString *)fsh; 35 | 36 | - (BOOL)link; 37 | 38 | - (BOOL)prepareToDraw; 39 | 40 | - (void)bindAttribute:(NSString *)attribute location:(GLuint)location; 41 | - (GLint)uniformLoc:(NSString *)uniformName; 42 | 43 | - (void)setFloatUniform:(NSString *)name value:(const GLfloat *)value length:(GLsizei)length count:(GLsizei)count; 44 | 45 | - (void)setIntUniform:(NSString *)name value:(const GLint *)value length:(GLsizei)length count:(GLsizei)count; 46 | 47 | - (void)setMatrix2Uniform:(NSString *)name value:(const GLKMatrix2 *)value transpose:(GLboolean)transpose count:(GLsizei)count; 48 | - (void)setMatrix3Uniform:(NSString *)name value:(const GLKMatrix3 *)value transpose:(GLboolean)transpose count:(GLsizei)count; 49 | - (void)setMatrix4Uniform:(NSString *)name value:(const GLKMatrix4 *)value transpose:(GLboolean)transpose count:(GLsizei)count; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // RazeEffectsDemo 4 | // 5 | // Created by Rob Visentin on 1/15/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @import RazeUIKit; 12 | @import RazeEffects; 13 | 14 | @interface ViewController () 15 | 16 | @property (weak, nonatomic) IBOutlet UIView *contentView; 17 | 18 | @property (strong, nonatomic) RZXEffectView *effectView; 19 | @property (strong, nonatomic) RZXClothEffect *effect; 20 | 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (BOOL)prefersStatusBarHidden 26 | { 27 | return YES; 28 | } 29 | 30 | - (void)viewDidLoad 31 | { 32 | [super viewDidLoad]; 33 | 34 | [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{ 35 | [self.contentView.subviews[1] setAlpha:0.0f]; 36 | } completion:nil]; 37 | 38 | [UIView animateWithDuration:3.0 delay:0.0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{ 39 | [(UIView *)self.contentView.subviews[2] setTransform:CGAffineTransformMakeTranslation(200.0f, 0.0f)]; 40 | } completion:nil]; 41 | } 42 | 43 | - (void)viewDidLayoutSubviews 44 | { 45 | [super viewDidLayoutSubviews]; 46 | 47 | if ( self.effectView == nil ) { 48 | self.effect = [RZXClothEffect effect]; 49 | 50 | // uncomment this line for a super shiny cloth 51 | // self.effect.lightOffset = GLKVector3Make(0.0f, 1.1f, -3.0f); 52 | 53 | self.effectView = [[RZXEffectView alloc] initWithSourceView:self.contentView effect:self.effect dynamicContent:YES]; 54 | self.effectView.backgroundColor = [UIColor blackColor]; 55 | self.effectView.framesPerSecond = 60; 56 | 57 | self.effectView.effectTransform.rotation = GLKQuaternionMake(-0.133518726, 0.259643972, 0.0340433009, 0.955821096); 58 | 59 | [self.view addSubview:self.effectView]; 60 | } 61 | } 62 | 63 | - (IBAction)sliderChanged:(UISlider *)slider 64 | { 65 | self.effect.waveAmplitude = 0.05f + 0.2f * slider.value; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Raze/Products/RazeEffects.framework/Headers/RZXEffect.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXEffect.h 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #define RZX_EFFECT_MAX_DOWNSAMPLE 4 11 | 12 | #define RZX_SHADER_SRC(src) (@#src) 13 | 14 | /** 15 | * Manages a shader. Any new shaders should subclass this. Override link to set up attributes (and call super), and override preprare to draw to assign uniforms (and call super). See RZXADSPhongEffect for an example of how a typical OpenGL shader can be implemented. 16 | */ 17 | @interface RZXEffect : RZXGPUObject 18 | 19 | @property (nonatomic, readonly, getter = isLinked) BOOL linked; 20 | 21 | @property (assign, nonatomic) GLKMatrix4 modelViewMatrix; 22 | @property (assign, nonatomic) GLKMatrix4 projectionMatrix; 23 | @property (assign, nonatomic) GLKMatrix3 normalMatrix; 24 | 25 | @property (copy, nonatomic) NSString *mvpUniform; 26 | @property (copy, nonatomic) NSString *mvUniform; 27 | @property (copy, nonatomic) NSString *normalMatrixUniform; 28 | 29 | @property (assign, nonatomic) GLKVector2 resolution; 30 | @property (assign, nonatomic) GLuint downsampleLevel; 31 | 32 | @property (nonatomic, readonly) NSInteger preferredLevelOfDetail; 33 | 34 | + (instancetype)effectWithVertexShader:(NSString *)vsh fragmentShader:(NSString *)fsh; 35 | 36 | - (BOOL)link; 37 | 38 | - (BOOL)prepareToDraw; 39 | 40 | - (void)bindAttribute:(NSString *)attribute location:(GLuint)location; 41 | - (GLint)uniformLoc:(NSString *)uniformName; 42 | 43 | - (void)setFloatUniform:(NSString *)name value:(const GLfloat *)value length:(GLsizei)length count:(GLsizei)count; 44 | 45 | - (void)setIntUniform:(NSString *)name value:(const GLint *)value length:(GLsizei)length count:(GLsizei)count; 46 | 47 | - (void)setMatrix2Uniform:(NSString *)name value:(const GLKMatrix2 *)value transpose:(GLboolean)transpose count:(GLsizei)count; 48 | - (void)setMatrix3Uniform:(NSString *)name value:(const GLKMatrix3 *)value transpose:(GLboolean)transpose count:(GLsizei)count; 49 | - (void)setMatrix4Uniform:(NSString *)name value:(const GLKMatrix4 *)value transpose:(GLboolean)transpose count:(GLsizei)count; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // RazeEffectsDemo 4 | // 5 | // Created by Rob Visentin on 1/15/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Raze Scene Sandbox 4 | // 5 | // Created by John Stricker on 4/17/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Raze/RazeUIKit/RZXViewTexture.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXViewTexture.m 3 | // 4 | // Created by Rob Visentin on 1/9/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation RZXViewTexture 11 | 12 | + (instancetype)textureWithSize:(CGSize)size 13 | { 14 | return [self textureWithSize:size scale:[UIScreen mainScreen].scale]; 15 | } 16 | 17 | - (void)updateWithView:(UIView *)view synchronous:(BOOL)synchronous 18 | { 19 | if ( synchronous ) { 20 | [self rz_renderView:view]; 21 | } 22 | else if ( dispatch_semaphore_wait([[self class] renderSemaphore], DISPATCH_TIME_NOW) == 0 ) { 23 | dispatch_async([[self class] renderQueue], ^{ 24 | [self rz_renderView:view]; 25 | 26 | dispatch_semaphore_signal([[self class] renderSemaphore]); 27 | }); 28 | } 29 | } 30 | 31 | - (BOOL)setupGL 32 | { 33 | BOOL setup = [super setupGL]; 34 | 35 | if ( setup ) { 36 | [self applyOptions:@{ kRZXTextureSWrapKey : @(GL_CLAMP_TO_EDGE), 37 | kRZXTextureTWrapKey : @(GL_CLAMP_TO_EDGE) }]; 38 | } 39 | 40 | return setup; 41 | } 42 | 43 | #pragma mark - private methods 44 | 45 | + (dispatch_queue_t)renderQueue 46 | { 47 | static dispatch_queue_t s_RenderQueue = nil; 48 | 49 | static dispatch_once_t onceToken; 50 | dispatch_once(&onceToken, ^{ 51 | s_RenderQueue = dispatch_queue_create("com.razeeffects.view-texture-render", DISPATCH_QUEUE_SERIAL); 52 | dispatch_set_target_queue(s_RenderQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)); 53 | }); 54 | 55 | return s_RenderQueue; 56 | } 57 | 58 | + (dispatch_semaphore_t)renderSemaphore 59 | { 60 | static dispatch_semaphore_t s_RenderSemaphore = nil; 61 | 62 | static dispatch_once_t onceToken; 63 | dispatch_once(&onceToken, ^{ 64 | s_RenderSemaphore = dispatch_semaphore_create(2); 65 | }); 66 | 67 | return s_RenderSemaphore; 68 | } 69 | 70 | - (void)rz_renderView:(UIView *)view 71 | { 72 | @autoreleasepool { 73 | [self updateWithBlock:^(RZXTexture *self, CGContextRef ctx) { 74 | [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; 75 | }]; 76 | } 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Raze/RazeAnimation/CAAnimation+RZXExtensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // CAAnimation+RZXExtensions.m 3 | // RazeAnimation 4 | // 5 | // Created by Rob Visentin on 7/10/15. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | static NSString* const kRZXAnimationStartBlockKey = @"_RZXAnimationStartBlock"; 13 | static NSString* const kRZXAnimationCompletionBlockKey = @"_RZXAnimationCompletionBlock"; 14 | 15 | @implementation CAAnimation (RZXExtensions) 16 | 17 | - (RZXAnimationStartBlock)rzx_startBlock 18 | { 19 | return [self valueForKey:kRZXAnimationStartBlockKey]; 20 | } 21 | 22 | - (void)rzx_setStartBlock:(RZXAnimationStartBlock)rzx_startBlock 23 | { 24 | [self setValue:rzx_startBlock forKey:kRZXAnimationStartBlockKey]; 25 | } 26 | 27 | - (RZXAnimationCompletionBlock)rzx_completionBlock 28 | { 29 | return [self valueForKey:kRZXAnimationCompletionBlockKey]; 30 | } 31 | 32 | - (void)rzx_setCompletionBlock:(RZXAnimationCompletionBlock)rzx_completion 33 | { 34 | [self setValue:[rzx_completion copy] forKey:kRZXAnimationCompletionBlockKey]; 35 | } 36 | 37 | - (BOOL)rzx_isFinished 38 | { 39 | return self.rzx_state.isFinished; 40 | } 41 | 42 | - (CFTimeInterval)rzx_currentTime 43 | { 44 | return self.rzx_state.currentTime; 45 | } 46 | 47 | - (void)rzx_applyToObject:(id)object 48 | { 49 | // base class is a no-op. subclasses override 50 | self.rzx_state.finished = YES; 51 | } 52 | 53 | - (void)rzx_interrupt 54 | { 55 | RZXAnimationState *state = [self rzx_state]; 56 | 57 | if ( state.isStarted && !state.isFinished ) { 58 | dispatch_async(dispatch_get_main_queue(), ^{ 59 | if ( [self.delegate respondsToSelector:@selector(animationDidStop:finished:)] ) { 60 | [self.delegate animationDidStop:self finished:NO]; 61 | } 62 | 63 | if ( self.rzx_completionBlock != nil ) { 64 | self.rzx_completionBlock(self, NO); 65 | } 66 | }); 67 | } 68 | } 69 | 70 | #pragma mark - RZXUpdateable 71 | 72 | - (void)rzx_update:(NSTimeInterval)dt 73 | { 74 | RZXAnimationState *state = self.rzx_state; 75 | 76 | state.currentTime += dt; 77 | state.repetition += dt / self.duration; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXGPUObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGPUObject.h 3 | // RazeCode 4 | // 5 | // Created by Rob Visentin on 7/16/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | typedef void (^RZXGPUObjectTeardownBlock)(RZXGLContext *context); 12 | 13 | /** 14 | * The base class for objects representing a GPU resource. 15 | * Examples include textures, meshes, and shader programs. 16 | */ 17 | @interface RZXGPUObject : NSObject 18 | 19 | /** 20 | * The context in which the object is currently configured, or nil if it has not been configured. 21 | */ 22 | @property (strong, nonatomic, readonly) RZXGLContext *configuredContext; 23 | 24 | /** 25 | * The block to invoke when the object is destroyed or explicitly torn down. 26 | * This block must free any GPU or other resources before it exits. 27 | * 28 | * @note Because this block is run asynchronously, it may be invoked after the RZXGPUObject has been deallocted. 29 | * Therefore it MUST NOT contain any implicit or explicity reference to self. 30 | */ 31 | @property (nonatomic, readonly) RZXGPUObjectTeardownBlock teardownHandler; 32 | 33 | /** 34 | * Configure the receiver in the current RZX context. 35 | * If there is no current context, this method returns NO. 36 | * 37 | * Subclasses must invoke super if overriding this method. 38 | * 39 | * @return YES if configuration succeeded, NO otherwise. 40 | * 41 | * @note In most cases this method is invoked internally at the appropriate times. 42 | * Therefore, you should generally not call this method. 43 | */ 44 | - (BOOL)setupGL; 45 | 46 | /** 47 | * Binds any necessary GPU resources in the current context. 48 | * If there is no current context, this method returns NO. 49 | * 50 | * Subclasses must invoke super if overriding this method. 51 | * 52 | * @return YES if the binding succeeded, NO otherwise. 53 | * 54 | * @note If the object is not yet configured in the current context, this method first calls setupGL. 55 | */ 56 | - (BOOL)bindGL; 57 | 58 | /** 59 | * Invokes the teardownHandler asynchronously on the configuredContext, and then sets the currentContext to nil. 60 | * This method is called automatically from dealloc, so you generally do not need to call this method. 61 | * 62 | * Subclasses must invoke super if overriding this method. 63 | */ 64 | - (void)teardownGL; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXGPUObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXGPUObject.h 3 | // RazeCode 4 | // 5 | // Created by Rob Visentin on 7/16/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | typedef void (^RZXGPUObjectTeardownBlock)(RZXGLContext *context); 12 | 13 | /** 14 | * The base class for objects representing a GPU resource. 15 | * Examples include textures, meshes, and shader programs. 16 | */ 17 | @interface RZXGPUObject : NSObject 18 | 19 | /** 20 | * The context in which the object is currently configured, or nil if it has not been configured. 21 | */ 22 | @property (strong, nonatomic, readonly) RZXGLContext *configuredContext; 23 | 24 | /** 25 | * The block to invoke when the object is destroyed or explicitly torn down. 26 | * This block must free any GPU or other resources before it exits. 27 | * 28 | * @note Because this block is run asynchronously, it may be invoked after the RZXGPUObject has been deallocted. 29 | * Therefore it MUST NOT contain any implicit or explicity reference to self. 30 | */ 31 | @property (nonatomic, readonly) RZXGPUObjectTeardownBlock teardownHandler; 32 | 33 | /** 34 | * Configure the receiver in the current RZX context. 35 | * If there is no current context, this method returns NO. 36 | * 37 | * Subclasses must invoke super if overriding this method. 38 | * 39 | * @return YES if configuration succeeded, NO otherwise. 40 | * 41 | * @note In most cases this method is invoked internally at the appropriate times. 42 | * Therefore, you should generally not call this method. 43 | */ 44 | - (BOOL)setupGL; 45 | 46 | /** 47 | * Binds any necessary GPU resources in the current context. 48 | * If there is no current context, this method returns NO. 49 | * 50 | * Subclasses must invoke super if overriding this method. 51 | * 52 | * @return YES if the binding succeeded, NO otherwise. 53 | * 54 | * @note If the object is not yet configured in the current context, this method first calls setupGL. 55 | */ 56 | - (BOOL)bindGL; 57 | 58 | /** 59 | * Invokes the teardownHandler asynchronously on the configuredContext, and then sets the currentContext to nil. 60 | * This method is called automatically from dealloc, so you generally do not need to call this method. 61 | * 62 | * Subclasses must invoke super if overriding this method. 63 | */ 64 | - (void)teardownGL; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/RZXExampleSceneviewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXExampleSceneviewController.m 3 | // Raze Scene Sandbox 4 | // 5 | // Created by John Stricker on 6/22/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import "RZXExampleSceneviewController.h" 10 | @import RazeCore; 11 | @import RazeScene; 12 | @import RazeEffects; 13 | 14 | @interface RZXExampleSceneviewController () 15 | 16 | @property (nonatomic, readonly) RZXSceneView *sceneView; 17 | 18 | @end 19 | 20 | @implementation RZXExampleSceneviewController 21 | 22 | - (void)viewDidLoad 23 | { 24 | [super viewDidLoad]; 25 | 26 | self.sceneView.backgroundColor = [UIColor whiteColor]; 27 | self.sceneView.framesPerSecond = 60; 28 | self.sceneView.multisampleLevel = 4; 29 | 30 | RZXADSPhongEffect *effect = [RZXADSPhongEffect effect]; 31 | effect.lightPosition = GLKVector4Make(0.0f, 10.0f, 20.0f, 0.0f); 32 | 33 | RZXScene *scene = [RZXScene sceneWithEffect: effect]; 34 | 35 | RZXMesh *mesh = [RZXMesh meshWithName:@"cube" usingCache:YES]; 36 | RZXStaticTexture *texture = [RZXStaticTexture mipmappedTextureFromFile:@"gridTexture.png" usingCache:YES]; 37 | 38 | RZXModelNode *modelNode = [RZXModelNode modelNodeWithMesh:mesh texture:texture]; 39 | [modelNode.transform translateZBy:-9.0f]; 40 | 41 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 42 | animation.byValue = [NSValue rzx_valueWithQuaternion:GLKQuaternionMakeWithAngleAndAxis(M_PI, 0.0f, 1.0f, 0.0f)]; 43 | animation.duration = 3.0; 44 | animation.repeatCount = 1; 45 | // [modelNode addAnimation:animation forKey:@"rotation"]; 46 | 47 | RZXTextNode *textNode = [RZXTextNode nodeWithText:@"This is a test"]; 48 | textNode.font = [RZXFont systemFontOfSize:50.0f]; 49 | textNode.textColor = [RZXColor purpleColor]; 50 | textNode.transform.translation = GLKVector3Make(0.0f, 0.0f, 0.34f); 51 | [modelNode addChild:textNode]; 52 | 53 | [scene addChild:modelNode]; 54 | 55 | self.sceneView.scene = scene; 56 | self.view.backgroundColor = [UIColor blueColor]; 57 | } 58 | 59 | - (void)viewWillLayoutSubviews 60 | { 61 | float ratio = CGRectGetWidth(self.view.bounds) / CGRectGetHeight(self.view.bounds); 62 | self.sceneView.scene.camera = [RZXCamera cameraWithFieldOfView:GLKMathDegreesToRadians(30) aspectRatio:ratio nearClipping:0.001 farClipping:50]; 63 | 64 | } 65 | 66 | - (RZXSceneView *)sceneView 67 | { 68 | return (RZXSceneView *)self.view; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![Raze banner image](documentation/razeBanner.png) 3 | 4 | Raze : A supplemental graphics engine for apps 5 | = 6 | 7 | Why Raze? 8 | - 9 | #### Designed for apps 10 | Raze is designed from the ground up to provide a way for developers to add customized hardware accelerated graphics and effects to their applications. While other APIs exist for mobile accelerated graphics, they typically assume that the developer is going to be using that API as the app's core functionality: for example, when making a game. In contrast, Raze is designed to provide similar functionality to commercial graphics engine, but is built around the concept that the Raze engine is likely *not* going to be the app's primary method of displaying the user interface: in nearly all cases this will be done via Apple's UIKit. This means that Raze must have little to no impact on an existing app architecture when it is dropped in, it should only use CPU and GPU processing when it is active, and after it is used by an app it should leave no trace of its use in memory. 11 | 12 | #### Open source 13 | Frequently when using existing graphics APIs developers will encounter cases where the API does not function as desired, this is often not necessarily due to bugs in the API, but rather a lack of the developer's ability to fully understand the API due to the black box nature of proprietary code. By making Raze open source we will be allowing users full access to the API's code. This also would allow us to continue to develop and extend Raze based upon community feedback. 14 | 15 | #### Minimal Footprint 16 | As part of being designed for Apps, Raze is designed from the ground up to be modular in nature. The code base is divided up into a set of frameworks (e.g. Core, UIKit, Scene, Animations). As Raze develops we will continue with this modular approach so that users of the API will be able to take only what they need from the API. 17 | 18 | Using Raze 19 | - 20 | 21 | Raze is designed to be used in a modular fashion with the two primary modules being UIKit and Scene. 22 | 23 | #### UIKit 24 | The UIKit module is for applying effects to UIKit 25 | elements, see the Examples/RazeEffectDemo folder for an example of using the UIKit module. 26 | 27 | #### Scene 28 | The scene module is for incorporating 3D objects into apps. See the Sandbox/Raze Scene Sandbox/ folder or an example of using this module. 29 | 30 | This module makes use of objects generated by [blender](www.blender.org) and then exported into .mesh models that Raze can read via a blender script we created: RZXBlenderModelExportIndexed.py (you can find it in the Utilities folder). 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Raze/RazeScene/RZXNode+RZXAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXNode+RZXAnimation.h 3 | // RazeScene 4 | // 5 | // Created by Rob Visentin on 7/13/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | /** 12 | * Helpers for applying animations to RZXNodes 13 | */ 14 | @interface RZXNode (RZXAnimation) 15 | 16 | #pragma mark - Relative Animations 17 | 18 | - (void)translateBy:(GLKVector3)translation withDuration:(NSTimeInterval)duration; 19 | 20 | - (void)translateBy:(GLKVector3)translation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 21 | 22 | - (void)translateBy:(GLKVector3)translation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 23 | 24 | - (void)scaleBy:(GLKVector3)scale withDuration:(NSTimeInterval)duration; 25 | 26 | - (void)scaleBy:(GLKVector3)scale withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 27 | 28 | - (void)scaleBy:(GLKVector3)scale withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 29 | 30 | - (void)rotateBy:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration; 31 | 32 | - (void)rotateBy:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 33 | 34 | - (void)rotateBy:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 35 | 36 | #pragma mark - Absolute Animations 37 | 38 | - (void)translateTo:(GLKVector3)translation withDuration:(NSTimeInterval)duration; 39 | 40 | - (void)translateTo:(GLKVector3)translation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 41 | 42 | - (void)translateTo:(GLKVector3)translation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 43 | 44 | - (void)scaleTo:(GLKVector3)scale withDuration:(NSTimeInterval)duration; 45 | 46 | - (void)scaleTo:(GLKVector3)scale withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 47 | 48 | - (void)scaleTo:(GLKVector3)scale withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 49 | 50 | - (void)rotateTo:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration; 51 | 52 | - (void)rotateTo:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 53 | 54 | - (void)rotateTo:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Raze/Products/RazeScene.framework/Headers/RZXNode+RZXAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXNode+RZXAnimation.h 3 | // RazeScene 4 | // 5 | // Created by Rob Visentin on 7/13/15. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | /** 12 | * Helpers for applying animations to RZXNodes 13 | */ 14 | @interface RZXNode (RZXAnimation) 15 | 16 | #pragma mark - Relative Animations 17 | 18 | - (void)translateBy:(GLKVector3)translation withDuration:(NSTimeInterval)duration; 19 | 20 | - (void)translateBy:(GLKVector3)translation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 21 | 22 | - (void)translateBy:(GLKVector3)translation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 23 | 24 | - (void)scaleBy:(GLKVector3)scale withDuration:(NSTimeInterval)duration; 25 | 26 | - (void)scaleBy:(GLKVector3)scale withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 27 | 28 | - (void)scaleBy:(GLKVector3)scale withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 29 | 30 | - (void)rotateBy:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration; 31 | 32 | - (void)rotateBy:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 33 | 34 | - (void)rotateBy:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 35 | 36 | #pragma mark - Absolute Animations 37 | 38 | - (void)translateTo:(GLKVector3)translation withDuration:(NSTimeInterval)duration; 39 | 40 | - (void)translateTo:(GLKVector3)translation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 41 | 42 | - (void)translateTo:(GLKVector3)translation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 43 | 44 | - (void)scaleTo:(GLKVector3)scale withDuration:(NSTimeInterval)duration; 45 | 46 | - (void)scaleTo:(GLKVector3)scale withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 47 | 48 | - (void)scaleTo:(GLKVector3)scale withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 49 | 50 | - (void)rotateTo:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration; 51 | 52 | - (void)rotateTo:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration completion:(RZXAnimationCompletionBlock)completion; 53 | 54 | - (void)rotateTo:(GLKQuaternion)rotation withDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(RZXAnimationOptions)options start:(RZXAnimationStartBlock)start completion:(RZXAnimationCompletionBlock)completion; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXTexture.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXTexture.m 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | 10 | NSString* const kRZXTextureMinFilterKey = @"RZXTextureMinFilter"; 11 | NSString* const kRZXTextureMagFilterKey = @"RZXTextureMagFilter"; 12 | NSString* const kRZXTextureSWrapKey = @"RZXTextureSWrap"; 13 | NSString* const kRZXTextureTWrapKey = @"RZXTextureTWrap"; 14 | 15 | @implementation RZXTexture 16 | 17 | #pragma mark - public methods 18 | 19 | - (CGSize)size 20 | { 21 | if ( self.configuredContext == nil ) { 22 | [[RZXGLContext defaultContext] runBlock:^(RZXGLContext *context) { 23 | [self setupGL]; 24 | }]; 25 | } 26 | 27 | return _size; 28 | } 29 | 30 | - (void)applyOptions:(NSDictionary *)options 31 | { 32 | if ( options.count ) { 33 | GLuint name = _name; 34 | 35 | [self.configuredContext runBlock:^(RZXGLContext *context) { 36 | if ( name ) { 37 | glBindTexture(GL_TEXTURE_2D, name); 38 | 39 | if ( options[kRZXTextureMinFilterKey] != nil ) { 40 | GLint minFilter = [[options objectForKey:kRZXTextureMinFilterKey] intValue]; 41 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); 42 | } 43 | 44 | if ( options[kRZXTextureMagFilterKey] != nil ) { 45 | GLint magFilter = [[options objectForKey:kRZXTextureMagFilterKey] intValue]; 46 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); 47 | } 48 | 49 | if ( options[kRZXTextureSWrapKey] != nil ) { 50 | GLint sWrap = [[options objectForKey:kRZXTextureSWrapKey] intValue]; 51 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, sWrap); 52 | } 53 | 54 | if ( options[kRZXTextureTWrapKey] != nil ) { 55 | GLint tWrap = [[options objectForKey:kRZXTextureTWrapKey] intValue]; 56 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, tWrap); 57 | } 58 | } 59 | } wait:NO]; 60 | } 61 | } 62 | 63 | - (void)attachToFramebuffer:(GLenum)framebuffer 64 | { 65 | glFramebufferTexture2D(framebuffer, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _name, 0); 66 | } 67 | 68 | - (NSString *)description 69 | { 70 | return [NSString stringWithFormat:@"<%@: %p [%i, %i]>", [self class], self, (int)self.size.width, (int)self.size.height]; 71 | } 72 | 73 | #pragma mark - RZXGPUObject overrides 74 | 75 | - (RZXGPUObjectTeardownBlock)teardownHandler 76 | { 77 | GLuint name = _name; 78 | return ^(RZXGLContext *context) { 79 | glDeleteTextures(1, &name); 80 | }; 81 | } 82 | 83 | - (BOOL)bindGL 84 | { 85 | BOOL bound = [super bindGL]; 86 | 87 | if ( bound ) { 88 | self.configuredContext.activeTexture = GL_TEXTURE0; 89 | glBindTexture(GL_TEXTURE_2D, _name); 90 | } 91 | 92 | #if RZX_DEBUG 93 | bound &= !RZXGLError(); 94 | #endif 95 | 96 | return bound; 97 | } 98 | 99 | - (void)teardownGL 100 | { 101 | [super teardownGL]; 102 | 103 | _name = 0; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXADSPhongEffect.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXADSPhongEffect.m 3 | // Raze 4 | // 5 | // Created by John Stricker on 6/22/15. 6 | // 7 | // 8 | 9 | #import "RZXADSPhongEffect.h" 10 | 11 | static NSString* const kRZXADSPhongVSH = RZX_SHADER_SRC( 12 | uniform mat4 u_MVPMatrix; 13 | uniform mat3 u_normalMatrix; 14 | 15 | attribute vec4 a_position; 16 | attribute vec3 a_normal; 17 | attribute vec2 a_texCoord0; 18 | 19 | varying vec3 v_position; 20 | varying vec3 v_normal; 21 | varying vec2 v_texCoord0; 22 | 23 | void main() 24 | { 25 | vec4 position = u_MVPMatrix * a_position; 26 | v_normal = normalize(u_normalMatrix * a_normal); 27 | v_position = vec3(position); 28 | v_texCoord0 = a_texCoord0; 29 | gl_Position = position; 30 | } 31 | ); 32 | 33 | static NSString* const kRZXADSPhongFSH = RZX_SHADER_SRC( 34 | precision mediump float; 35 | uniform highp vec4 u_lightPosition; 36 | uniform vec3 u_lightIntensity; 37 | uniform vec3 u_ambientReflection; 38 | uniform vec3 u_diffuseReflection; 39 | uniform vec3 u_specularReflection; 40 | uniform float u_specularShininess; 41 | uniform lowp sampler2D u_Texture; 42 | 43 | varying highp vec3 v_position; 44 | varying highp vec3 v_normal; 45 | varying highp vec2 v_texCoord0; 46 | 47 | vec3 ads() 48 | { 49 | vec3 n = normalize(v_normal); 50 | vec3 s = normalize(vec3(u_lightPosition) - v_position); 51 | vec3 v = normalize(vec3(-v_position)); 52 | vec3 r = reflect(-s,n); 53 | return u_lightIntensity * (u_ambientReflection + u_diffuseReflection * max(dot(s, n), 0.0) + u_specularReflection * pow(max(dot(r, v), 0.0), u_specularShininess)); 54 | } 55 | 56 | void main() 57 | { 58 | gl_FragColor = texture2D(u_Texture, v_texCoord0) * vec4(ads(),1.0); 59 | } 60 | ); 61 | 62 | @implementation RZXADSPhongEffect 63 | 64 | + (instancetype)effect 65 | { 66 | RZXADSPhongEffect *effect = [super effectWithVertexShader:kRZXADSPhongVSH fragmentShader:kRZXADSPhongFSH]; 67 | 68 | effect.lightPosition = GLKVector4Make(0.0f, 0.0f, 10.0f, 0.0f); 69 | effect.lightIntensity = GLKVector3Make(1.0f, 1.0f, 1.0f); 70 | effect.ambientReflection = GLKVector3Make(0.5f, 0.5f, 0.5f); 71 | effect.diffuseReflection = GLKVector3Make(0.5f, 0.5f, 0.5f); 72 | effect.specularReflection = GLKVector3Make(0.5f, 0.5f, 0.5f); 73 | effect.specularShininess = 1.0f; 74 | 75 | effect.mvpUniform = @"u_MVPMatrix"; 76 | effect.normalMatrixUniform = @"u_normalMatrix"; 77 | 78 | return effect; 79 | } 80 | 81 | 82 | - (BOOL)link 83 | { 84 | [self bindAttribute:@"a_position" location:kRZXVertexAttribPosition]; 85 | [self bindAttribute:@"a_normal" location:kRZXVertexAttribNormal]; 86 | [self bindAttribute:@"a_texCoord0" location:kRZXVertexAttribTexCoord]; 87 | 88 | return [super link]; 89 | } 90 | 91 | - (BOOL)prepareToDraw 92 | { 93 | BOOL ret = [super prepareToDraw]; 94 | 95 | [self setFloatUniform:@"u_lightPosition" value:_lightPosition.v length:4 count:1]; 96 | [self setFloatUniform:@"u_lightIntensity" value:_lightIntensity.v length:3 count:1]; 97 | [self setFloatUniform:@"u_ambientReflection" value:_ambientReflection.v length:3 count:1]; 98 | [self setFloatUniform:@"u_diffuseReflection" value:_diffuseReflection.v length:3 count:1]; 99 | [self setFloatUniform:@"u_specularReflection" value:_specularReflection.v length:3 count:1]; 100 | [self setFloatUniform:@"u_specularShininess" value:&_specularShininess length:1 count:1]; 101 | 102 | return ret; 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXBase.h 3 | // 4 | // Created by Rob Visentin on 1/14/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | /** 9 | * Contains imports, macros, & enums, to supply base functionality to RZX Objects 10 | */ 11 | 12 | #ifndef _RZXBase_h 13 | #define _RZXBase_h 14 | 15 | #import 16 | 17 | #import 18 | #import 19 | 20 | #if TARGET_OS_IPHONE 21 | #import 22 | #import 23 | #define RZXColor UIColor 24 | #define RZXFont UIFont 25 | #else 26 | #include 27 | #define RZXColor NSColor 28 | #define RZXFont NSFont 29 | #endif 30 | 31 | #define RZX_DEBUG (DEBUG || TARGET_IPHONE_SIMULATOR) 32 | 33 | #if RZX_DEBUG 34 | #define RZXLog NSLog 35 | #else 36 | #define RZXLog(...) 37 | #endif 38 | 39 | #define RZX_CV_AVAILABLE !(TARGET_IPHONE_SIMULATOR) 40 | 41 | /** 42 | * Convenience macros for creating keypaths. An invalid keypath will throw a compile-time error when compiling in debug mode. 43 | * 44 | * The first parameter of these macros is used only for compile-time validation of the keypath. 45 | * 46 | * @return An NSString containing the keypath. 47 | * 48 | * @example RZX_KP(NSObject, description.length) -> @"description.length" 49 | * RZX_KP_OBJ(transform, scale) -> @"scale" 50 | * RZX_KP_SELF(transform, scale.x) -> @"scale.x" 51 | */ 52 | #if RZX_DEBUG 53 | #define RZX_KP(Classname, keypath) ({\ 54 | Classname *_rzdb_keypath_obj; \ 55 | __unused __typeof(_rzdb_keypath_obj.keypath) _rzdb_keypath_prop; \ 56 | @#keypath; \ 57 | }) 58 | 59 | #define RZX_KP_OBJ(object, keypath) ({\ 60 | __typeof(object) _rzdb_keypath_obj; \ 61 | __unused __typeof(_rzdb_keypath_obj.keypath) _rzdb_keypath_prop; \ 62 | @#keypath; \ 63 | }) 64 | #else 65 | #define RZX_KP(Classname, keypath) (@#keypath) 66 | #define RZX_KP_OBJ(self, keypath) (@#keypath) 67 | #endif 68 | 69 | /** 70 | * @note This macro will implicitly retain self from within blocks while running in debug mode. 71 | * The safe way to generate a keypath on self from within a block 72 | * is to define a weak reference to self outside the block, and then use RZX_KP_OBJ(weakSelf, keypath). 73 | */ 74 | #define RZX_KP_SELF(keypath) RZX_KP_OBJ(self, keypath) 75 | 76 | 77 | /** 78 | * Convenience enum to have unified attribute positions in shaders. 79 | */ 80 | typedef enum _RZXVertexAttrib { 81 | kRZXVertexAttribPosition, 82 | kRZXVertexAttribTexCoord, 83 | kRZXVertexAttribNormal 84 | } RZXVertexAttrib; 85 | 86 | /** 87 | * Function to flush (and print in DEBUG mode) the current OpenGL error. 88 | */ 89 | CF_INLINE GLenum RZXGLError() 90 | { 91 | GLenum errCode = glGetError(); 92 | 93 | #if RZX_DEBUG 94 | const GLchar *errString = NULL; 95 | 96 | switch( errCode ) { 97 | case GL_NO_ERROR: 98 | break; 99 | 100 | case GL_INVALID_ENUM: 101 | errString = "GL_INVALID_ENUM"; 102 | break; 103 | 104 | case GL_INVALID_VALUE: 105 | errString = "GL_INVALID_VALUE"; 106 | break; 107 | 108 | case GL_INVALID_OPERATION: 109 | errString = "GL_INVALID_OPERATION"; 110 | break; 111 | 112 | case GL_INVALID_FRAMEBUFFER_OPERATION: 113 | errString = "GL_INVALID_FRAMEBUFFER_OPERATION"; 114 | break; 115 | 116 | default: 117 | errString = "UNKNOWN GL ERROR"; 118 | } 119 | 120 | if ( errString != NULL ) { 121 | fprintf(stderr, "GL Error: %s\n", errString); 122 | } 123 | #endif 124 | 125 | return errCode; 126 | } 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXConvolutionEffect.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXConvolutionEffect.m 3 | // RazeEffects 4 | // 5 | // Created by Rob Visentin on 7/23/15. 6 | // 7 | 8 | #import 9 | 10 | const GLKMatrix3 kRZXConvoultionKernelIdentity = (GLKMatrix3){0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f}; 11 | 12 | NSString* const kRZXEffectConvolutionVSH = RZX_SHADER_SRC( 13 | uniform mat4 u_MVPMatrix; 14 | uniform vec2 u_Step; 15 | 16 | attribute vec4 a_position; 17 | attribute vec2 a_texCoord0; 18 | 19 | varying vec2 v_texCoords[9]; 20 | 21 | void main(void) 22 | { 23 | v_texCoords[0] = a_texCoord0; 24 | v_texCoords[1] = a_texCoord0 - vec2(u_Step.x, 0.0); 25 | v_texCoords[2] = a_texCoord0 - u_Step; 26 | v_texCoords[3] = a_texCoord0 - vec2(0.0, u_Step.y); 27 | v_texCoords[4] = a_texCoord0 + vec2(u_Step.x, -u_Step.y); 28 | v_texCoords[5] = a_texCoord0 + vec2(u_Step.x, 0.0); 29 | v_texCoords[6] = a_texCoord0 + u_Step; 30 | v_texCoords[7] = a_texCoord0 + vec2(0.0, u_Step.y); 31 | v_texCoords[8] = a_texCoord0 + vec2(-u_Step.x, u_Step.y); 32 | 33 | gl_Position = u_MVPMatrix * a_position; 34 | }); 35 | 36 | static NSString* const kRZXEffectConvolutionFSHStart = RZX_SHADER_SRC( 37 | uniform highp mat3 u_Convolution; 38 | 39 | uniform lowp sampler2D u_Texture; 40 | 41 | varying highp vec2 v_texCoords[9]; 42 | 43 | void main() 44 | { 45 | lowp vec4 center = texture2D(u_Texture, v_texCoords[0]); 46 | lowp vec3 left = texture2D(u_Texture, v_texCoords[1]).rgb; 47 | lowp vec3 topLeft = texture2D(u_Texture, v_texCoords[2]).rgb; 48 | lowp vec3 top = texture2D(u_Texture, v_texCoords[3]).rgb; 49 | lowp vec3 topRight = texture2D(u_Texture, v_texCoords[4]).rgb; 50 | lowp vec3 right = texture2D(u_Texture, v_texCoords[5]).rgb; 51 | lowp vec3 bottomRight = texture2D(u_Texture, v_texCoords[6]).rgb; 52 | lowp vec3 bottom = texture2D(u_Texture, v_texCoords[7]).rgb; 53 | lowp vec3 bottomLeft = texture2D(u_Texture, v_texCoords[8]).rgb; 54 | 55 | highp vec3 rgb = topLeft * u_Convolution[0][0] + top * u_Convolution[1][0] + topRight * u_Convolution[2][0]; 56 | rgb += left * u_Convolution[0][1] + center.rgb * u_Convolution[1][1] + right * u_Convolution[2][1]; 57 | rgb += bottomLeft * u_Convolution[0][2] + bottom * u_Convolution[1][2] + bottomRight * u_Convolution[2][2]; 58 | ); 59 | 60 | static NSString* const kRZXEffectConvolutionFSHEnd = RZX_SHADER_SRC( 61 | gl_FragColor = vec4(rgb, center.a); 62 | }); 63 | 64 | @implementation RZXConvolutionEffect 65 | 66 | + (instancetype)effectWithKernel:(GLKMatrix3)kernel postProcessing:(NSString *)postProcessingSrc 67 | { 68 | NSString *fsh = [NSString stringWithFormat:@"%@%@;\n%@", kRZXEffectConvolutionFSHStart, postProcessingSrc ?: @"", kRZXEffectConvolutionFSHEnd]; 69 | 70 | RZXConvolutionEffect *effect = [RZXConvolutionEffect effectWithVertexShader:kRZXEffectConvolutionVSH fragmentShader:fsh]; 71 | effect.mvpUniform = @"u_MVPMatrix"; 72 | effect.kernel = kernel; 73 | 74 | return effect; 75 | } 76 | 77 | - (BOOL)link 78 | { 79 | [self bindAttribute:@"a_position" location:kRZXVertexAttribPosition]; 80 | [self bindAttribute:@"a_texCoord0" location:kRZXVertexAttribTexCoord]; 81 | 82 | return [super link]; 83 | } 84 | - (BOOL)prepareToDraw 85 | { 86 | GLKVector2 step = GLKVector2Make(1.0f / self.resolution.x, 1.0f / self.resolution.y); 87 | [self setFloatUniform:@"u_Step" value:step.v length:2 count:1]; 88 | 89 | [self setMatrix3Uniform:@"u_Convolution" value:&_kernel transpose:GL_FALSE count:1]; 90 | 91 | return [super prepareToDraw]; 92 | } 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /documentation/Overview/overview.md: -------------------------------------------------------------------------------- 1 | 2 | Raze : A supplemental graphics engine for apps 3 | = 4 | 5 | Why Raze? 6 | - 7 | ####Designed for apps 8 | Raze is designed from the ground up to provide a way for developers to add customized hardware accelerated graphics and effects to their applications. While other APIs exist for mobile accelerated graphics, they typically assume that the developer is going to be using that API as the app's core functionality: for example, when making a game. In contrast, Raze is designed to provide similar functionality to commercial graphics engine, but is built around the concept that the Raze engine is likely *not* going to be the app's primary method of displaying the user interface: in nearly all cases this will be done via Apple's UIKit. This means that Raze must have little to no impact on an existing app architecture when it is dropped in, it should only use CPU and GPU processing when it is active, and after it is used by an app it should leave no trace of its use in memory. 9 | 10 | ####Open source 11 | Frequently when using existing graphics APIs developers will encounter cases where the API does not function as desired, this is often not necessarily due to bugs in the API, but rather a lack of the developer's ability to fully understand the API due to the black box nature of proprietary code. By making Raze open source we will be allowing users full access to the API's code. This also would allow us to continue to develop and extend Raze based upon community feedback. 12 | 13 | ####Minimal Footprint 14 | As part of being designed for Apps, Raze is designed from the ground up to be modular in nature. The code base is divided up into a set of frameworks (e.g. Core, UIKit, Scene, Animations). As Raze develops we will continue with this modular approach so that users of the API will be able to take only what they need from the API. 15 | 16 | 17 | Internal Justification 18 | - 19 | At Raizlabs, those of us who are familiar with openGL have pushed for its use more extensively in our applications. However, the problem with the use of openGL in apps is that 1) it can be intrusive (either it does not appear to fit with the rest of the app or it requires too much in the way of resources to make it worth using) 2) it is difficult to maintain (only someone who has specialized knowledge can debug and extend the code). Raze is designed to address both of these issues. 20 | 21 | ####Extending Design 22 | Not only is the API designed to play nicely with UIKit as described above, we want the API to specialize in effects that would not be jarring within most iOS applications. To that end, as we develop Raze we are looking to our designers and asking them: "what would you like to do that is currently difficult for developers to pull off?", and "how can we take design in new directions?". One example of this is we have discussed taking material design and extending it to have materials behave even more like materials by introducing effects that enable folding, bending, and tearing. 23 | 24 | ####Free polish 25 | The additional benefit of having Raze be an active hack project at Raizlabs is that other products can utilize the Raze team to work on special effects for a given app without having to add developer resources. For the Raze team, this will only improve the engine by testing it in production apps and adding to its library of effects and capabilities. 26 | 27 | ####Internal training 28 | The extensive documentation of Raze is also designed to allow Raizlabs developers to keep up to speed on making use of accelerated graphics within a modular, flexible architecture. We hope to continue to push Raze to incoporate the latest technologies including moving to having the majority of the code base be in Swift, using Apple's Metal and eventually including a GPU computation module. -------------------------------------------------------------------------------- /Raze/Products/RazeCore.framework/Headers/RZXBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // RZXBase.h 3 | // 4 | // Created by Rob Visentin on 1/14/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | /** 9 | * Contains imports, macros, & enums, to supply base functionality to RZX Objects 10 | */ 11 | 12 | #ifndef _RZXBase_h 13 | #define _RZXBase_h 14 | 15 | #import 16 | 17 | #import 18 | #import 19 | 20 | #if TARGET_OS_IPHONE 21 | #import 22 | #import 23 | #define RZXColor UIColor 24 | #define RZXFont UIFont 25 | #else 26 | #include 27 | #define RZXColor NSColor 28 | #define RZXFont NSFont 29 | #endif 30 | 31 | #define RZX_DEBUG (DEBUG || TARGET_IPHONE_SIMULATOR) 32 | 33 | #if RZX_DEBUG 34 | #define RZXLog NSLog 35 | #else 36 | #define RZXLog(...) 37 | #endif 38 | 39 | #define RZX_CV_AVAILABLE !(TARGET_IPHONE_SIMULATOR) 40 | 41 | /** 42 | * Convenience macros for creating keypaths. An invalid keypath will throw a compile-time error when compiling in debug mode. 43 | * 44 | * The first parameter of these macros is used only for compile-time validation of the keypath. 45 | * 46 | * @return An NSString containing the keypath. 47 | * 48 | * @example RZX_KP(NSObject, description.length) -> @"description.length" 49 | * RZX_KP_OBJ(transform, scale) -> @"scale" 50 | * RZX_KP_SELF(transform, scale.x) -> @"scale.x" 51 | */ 52 | #if RZX_DEBUG 53 | #define RZX_KP(Classname, keypath) ({\ 54 | Classname *_rzdb_keypath_obj; \ 55 | __unused __typeof(_rzdb_keypath_obj.keypath) _rzdb_keypath_prop; \ 56 | @#keypath; \ 57 | }) 58 | 59 | #define RZX_KP_OBJ(object, keypath) ({\ 60 | __typeof(object) _rzdb_keypath_obj; \ 61 | __unused __typeof(_rzdb_keypath_obj.keypath) _rzdb_keypath_prop; \ 62 | @#keypath; \ 63 | }) 64 | #else 65 | #define RZX_KP(Classname, keypath) (@#keypath) 66 | #define RZX_KP_OBJ(self, keypath) (@#keypath) 67 | #endif 68 | 69 | /** 70 | * @note This macro will implicitly retain self from within blocks while running in debug mode. 71 | * The safe way to generate a keypath on self from within a block 72 | * is to define a weak reference to self outside the block, and then use RZX_KP_OBJ(weakSelf, keypath). 73 | */ 74 | #define RZX_KP_SELF(keypath) RZX_KP_OBJ(self, keypath) 75 | 76 | 77 | /** 78 | * Convenience enum to have unified attribute positions in shaders. 79 | */ 80 | typedef enum _RZXVertexAttrib { 81 | kRZXVertexAttribPosition, 82 | kRZXVertexAttribTexCoord, 83 | kRZXVertexAttribNormal 84 | } RZXVertexAttrib; 85 | 86 | /** 87 | * Function to flush (and print in DEBUG mode) the current OpenGL error. 88 | */ 89 | CF_INLINE GLenum RZXGLError() 90 | { 91 | GLenum errCode = glGetError(); 92 | 93 | #if RZX_DEBUG 94 | const GLchar *errString = NULL; 95 | 96 | switch( errCode ) { 97 | case GL_NO_ERROR: 98 | break; 99 | 100 | case GL_INVALID_ENUM: 101 | errString = "GL_INVALID_ENUM"; 102 | break; 103 | 104 | case GL_INVALID_VALUE: 105 | errString = "GL_INVALID_VALUE"; 106 | break; 107 | 108 | case GL_INVALID_OPERATION: 109 | errString = "GL_INVALID_OPERATION"; 110 | break; 111 | 112 | case GL_INVALID_FRAMEBUFFER_OPERATION: 113 | errString = "GL_INVALID_FRAMEBUFFER_OPERATION"; 114 | break; 115 | 116 | default: 117 | errString = "UNKNOWN GL ERROR"; 118 | } 119 | 120 | if ( errString != NULL ) { 121 | fprintf(stderr, "GL Error: %s\n", errString); 122 | } 123 | #endif 124 | 125 | return errCode; 126 | } 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /Raze/RazeEffects/RZXCompositeEffect.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCompositeEffect.m 3 | // 4 | // Created by Rob Visentin on 1/16/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import "RZXCompositeEffect.h" 9 | 10 | @interface RZXCompositeEffect () 11 | 12 | @property (strong, nonatomic, readwrite) RZXEffect *firstEffect; 13 | @property (strong, nonatomic, readwrite) RZXEffect *secondEffect; 14 | 15 | @property (strong, nonatomic, readwrite) RZXEffect *currentEffect; 16 | 17 | @end 18 | 19 | @implementation RZXCompositeEffect 20 | 21 | + (instancetype)compositeEffectWithFirstEffect:(RZXEffect *)first secondEffect:(RZXEffect *)second 22 | { 23 | RZXCompositeEffect *effect = [[self alloc] init]; 24 | effect.firstEffect = first; 25 | effect.secondEffect = second; 26 | effect.currentEffect = effect.firstEffect; 27 | 28 | return effect; 29 | } 30 | 31 | - (BOOL)isLinked 32 | { 33 | return self.firstEffect.isLinked && self.secondEffect.isLinked; 34 | } 35 | 36 | - (void)setModelViewMatrix:(GLKMatrix4)modelViewMatrix 37 | { 38 | [super setModelViewMatrix:modelViewMatrix]; 39 | 40 | self.firstEffect.modelViewMatrix = modelViewMatrix; 41 | self.secondEffect.modelViewMatrix = modelViewMatrix; 42 | } 43 | 44 | - (void)setProjectionMatrix:(GLKMatrix4)projectionMatrix 45 | { 46 | [super setProjectionMatrix:projectionMatrix]; 47 | 48 | self.firstEffect.projectionMatrix = projectionMatrix; 49 | self.secondEffect.projectionMatrix = projectionMatrix; 50 | } 51 | 52 | - (void)setNormalMatrix:(GLKMatrix3)normalMatrix 53 | { 54 | [super setNormalMatrix:normalMatrix]; 55 | 56 | self.firstEffect.normalMatrix = normalMatrix; 57 | self.secondEffect.normalMatrix = normalMatrix; 58 | } 59 | 60 | - (void)setResolution:(GLKVector2)resolution 61 | { 62 | [super setResolution:resolution]; 63 | 64 | self.firstEffect.resolution = resolution; 65 | self.secondEffect.resolution = resolution; 66 | } 67 | 68 | - (GLuint)downsampleLevel 69 | { 70 | return [super downsampleLevel] + self.currentEffect.downsampleLevel; 71 | } 72 | 73 | - (NSInteger)preferredLevelOfDetail 74 | { 75 | return MAX(self.firstEffect.preferredLevelOfDetail, self.secondEffect.preferredLevelOfDetail); 76 | } 77 | 78 | - (BOOL)link 79 | { 80 | return [self.firstEffect link] && [self.secondEffect link]; 81 | } 82 | 83 | - (BOOL)prepareToDraw 84 | { 85 | BOOL unfinished = YES; 86 | 87 | if ( self.currentEffect == self.firstEffect ) { 88 | if ( ![self.firstEffect prepareToDraw] ) { 89 | if ( self.secondEffect != nil ) { 90 | self.currentEffect = self.secondEffect; 91 | } 92 | else { 93 | unfinished = NO; 94 | } 95 | } 96 | } 97 | else { 98 | unfinished = [self.secondEffect prepareToDraw]; 99 | 100 | if ( !unfinished ) { 101 | self.currentEffect = self.firstEffect; 102 | } 103 | } 104 | 105 | return unfinished; 106 | } 107 | 108 | - (void)bindAttribute:(NSString *)attribute location:(GLuint)location 109 | { 110 | [self.currentEffect bindAttribute:attribute location:location]; 111 | } 112 | 113 | - (GLint)uniformLoc:(NSString *)uniformName 114 | { 115 | return [self.currentEffect uniformLoc:uniformName]; 116 | } 117 | 118 | #pragma mark - RZXGPUObject overrides 119 | 120 | - (BOOL)setupGL 121 | { 122 | return ([self.firstEffect setupGL] && [self.secondEffect setupGL]); 123 | } 124 | 125 | - (BOOL)bindGL 126 | { 127 | return [self.currentEffect bindGL]; 128 | } 129 | 130 | - (void)teardownGL 131 | { 132 | [super teardownGL]; 133 | 134 | [self.firstEffect teardownGL]; 135 | [self.secondEffect teardownGL]; 136 | } 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /Example/RazeEffectsDemo/RazeEffectsDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Sandbox/Raze Scene Sandbox/Raze Scene Sandbox/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Raze/RazeCore/Private/RZXRenderLoop.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXRenderLoop.m 3 | // 4 | // Created by Rob Visentin on 1/10/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import "RZXRenderLoop.h" 11 | 12 | static const NSInteger kRZRenderLoopDefaultFPS = 30; 13 | 14 | @interface RZXRenderLoop () 15 | 16 | @property (strong, nonatomic) CADisplayLink *displayLink; 17 | @property (assign, nonatomic) BOOL pausedWhileInactive; 18 | 19 | @property (weak, nonatomic) id updateTarget; 20 | @property (weak, nonatomic) id renderTarget; 21 | 22 | @property (assign, nonatomic, readwrite) CFTimeInterval lastRender; 23 | @property (assign, nonatomic, readwrite, getter=isRunning) BOOL running; 24 | @property (assign, nonatomic, readwrite, getter=isValid) BOOL valid; 25 | 26 | @end 27 | 28 | @implementation RZXRenderLoop 29 | 30 | + (instancetype)renderLoop 31 | { 32 | return [[[self class] alloc] init]; 33 | } 34 | 35 | - (instancetype)init 36 | { 37 | self = [super init]; 38 | if ( self ) { 39 | _automaticallyResumeWhenForegrounded = YES; 40 | 41 | [self setupDisplayLink]; 42 | } 43 | return self; 44 | } 45 | 46 | - (void)dealloc 47 | { 48 | [self teardownDisplayLink]; 49 | } 50 | 51 | - (void)setPreferredFPS:(NSInteger)preferredFPS 52 | { 53 | _preferredFPS = MAX(1, MIN(preferredFPS, 60)); 54 | self.displayLink.frameInterval = 60 / _preferredFPS; 55 | } 56 | 57 | - (void)run 58 | { 59 | self.lastRender = CACurrentMediaTime(); 60 | 61 | self.running = YES; 62 | } 63 | 64 | - (void)stop 65 | { 66 | self.running = NO; 67 | } 68 | 69 | - (void)invalidate 70 | { 71 | [self teardownDisplayLink]; 72 | } 73 | 74 | #pragma mark - private methods 75 | 76 | - (void)setupDisplayLink 77 | { 78 | self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkTick:)]; 79 | self.displayLink.paused = YES; 80 | 81 | self.preferredFPS = kRZRenderLoopDefaultFPS; 82 | 83 | [self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 84 | 85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; 86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil]; 87 | 88 | self.valid = YES; 89 | } 90 | 91 | - (void)teardownDisplayLink 92 | { 93 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; 94 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil]; 95 | 96 | [self.displayLink invalidate]; 97 | self.displayLink = nil; 98 | 99 | self.valid = NO; 100 | } 101 | 102 | - (void)setRunning:(BOOL)running 103 | { 104 | _running = running; 105 | self.displayLink.paused = !running; 106 | } 107 | 108 | - (void)didEnterBackground:(NSNotification *)notification 109 | { 110 | if ( self.isRunning ) { 111 | [self stop]; 112 | self.pausedWhileInactive = YES; 113 | } 114 | } 115 | 116 | - (void)willEnterForeground:(NSNotification *)notification 117 | { 118 | if ( self.pausedWhileInactive && self.automaticallyResumeWhenForegrounded ) { 119 | [self run]; 120 | } 121 | } 122 | 123 | - (void)displayLinkTick:(CADisplayLink *)displayLink 124 | { 125 | CFTimeInterval dt = displayLink.timestamp - self.lastRender; 126 | 127 | [self.updateTarget rzx_update:dt]; 128 | 129 | [self.renderTarget rzx_render]; 130 | 131 | self.lastRender = displayLink.timestamp; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXCamera.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCamera.m 3 | // 4 | // Created by Rob Visentin on 1/11/15. 5 | // Copyright (c) 2015 Raizlabs. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @implementation RZXCamera { 11 | GLKMatrix4 *_cachedProjectionMatrix; 12 | } 13 | 14 | + (instancetype)cameraWithFieldOfView:(float)fov aspectRatio:(float)aspectRatio nearClipping:(float)near farClipping:(float)far 15 | { 16 | return [[[self class] alloc] initWithFieldOfView:fov aspectRatio:aspectRatio nearClipping:near farClipping:far]; 17 | } 18 | 19 | - (instancetype)init 20 | { 21 | self = [super init]; 22 | if ( self ) { 23 | _up = GLKVector3Make(0.0f, 1.0f, 0.0f); 24 | _transform = [RZXTransform3D transform]; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)dealloc 30 | { 31 | [self invalidateProjectionMatrixCache]; 32 | } 33 | 34 | - (void)setUp:(GLKVector3)up 35 | { 36 | _up = GLKVector3Normalize(up); 37 | } 38 | 39 | - (void)setFieldOfView:(float)fieldOfView 40 | { 41 | _fieldOfView = fieldOfView; 42 | [self invalidateProjectionMatrixCache]; 43 | } 44 | 45 | - (void)setAspectRatio:(float)aspectRatio 46 | { 47 | _aspectRatio = aspectRatio; 48 | [self invalidateProjectionMatrixCache]; 49 | } 50 | 51 | - (void)setNear:(float)near 52 | { 53 | _near = near; 54 | [self invalidateProjectionMatrixCache]; 55 | } 56 | 57 | - (void)setFar:(float)far 58 | { 59 | _far = far; 60 | [self invalidateProjectionMatrixCache]; 61 | } 62 | 63 | - (GLKMatrix4)projectionMatrix 64 | { 65 | @synchronized (self ) { 66 | if ( _cachedProjectionMatrix == NULL ) { 67 | GLKMatrix4 proj = GLKMatrix4MakePerspective(_fieldOfView, _aspectRatio, _near, _far); 68 | 69 | _cachedProjectionMatrix = (GLKMatrix4 *)malloc(sizeof(GLKMatrix4)); 70 | memcpy(_cachedProjectionMatrix, &proj, sizeof(GLKMatrix4)); 71 | } 72 | 73 | return *_cachedProjectionMatrix; 74 | } 75 | } 76 | 77 | - (GLKMatrix4)viewMatrix 78 | { 79 | GLKMatrix4 camWorldMatrix = self.transform.modelMatrix; 80 | 81 | GLKVector4 forward = GLKVector4Make(_up.x, _up.z, -_up.y, 1); 82 | GLKVector4 to4 = GLKMatrix4MultiplyVector4(camWorldMatrix, forward); 83 | 84 | GLKVector3 to = GLKVector3Make(to4.x, to4.y, to4.z); 85 | GLKVector3 from = GLKVector3Make(camWorldMatrix.m[12], camWorldMatrix.m[13], camWorldMatrix.m[14]); 86 | GLKVector3 up = GLKMatrix4MultiplyVector3(camWorldMatrix, _up); 87 | 88 | GLKVector3 zAxis = GLKVector3Normalize(GLKVector3Subtract(from, to)); 89 | GLKVector3 xAxis = GLKVector3Normalize(GLKVector3CrossProduct(up, zAxis)); 90 | GLKVector3 yAxis = GLKVector3Normalize(GLKVector3CrossProduct(zAxis, xAxis)); 91 | 92 | float tx = -GLKVector3DotProduct(xAxis, from); 93 | float ty = -GLKVector3DotProduct(yAxis, from); 94 | float tz = -GLKVector3DotProduct(zAxis, from); 95 | 96 | GLKMatrix4 m; 97 | 98 | m.m00 = xAxis.x; m.m01 = yAxis.x; m.m02 = zAxis.x; m.m03 = 0; 99 | m.m10 = xAxis.y; m.m11 = yAxis.y; m.m12 = zAxis.y; m.m13 = 0; 100 | m.m20 = xAxis.z; m.m21 = yAxis.z; m.m22 = zAxis.z; m.m23 = 0; 101 | m.m30 = tx; m.m31 = ty; m.m32 = tz; m.m33 = 1; 102 | 103 | return m; 104 | } 105 | 106 | #pragma mark - private methods 107 | 108 | - (instancetype)initWithFieldOfView:(float)fov aspectRatio:(float)aspectRatio nearClipping:(float)near farClipping:(float)far 109 | { 110 | self = [self init]; 111 | if ( self ) { 112 | _fieldOfView = fov; 113 | _aspectRatio = aspectRatio; 114 | _near = near; 115 | _far = far; 116 | } 117 | return self; 118 | } 119 | 120 | - (void)invalidateProjectionMatrixCache 121 | { 122 | free(_cachedProjectionMatrix); 123 | _cachedProjectionMatrix = NULL; 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /Raze/RazeCore/Private/RZXCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXCache.m 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import "RZXCache.h" 9 | 10 | @interface RZXCache () 11 | 12 | @property (strong, nonatomic) NSMutableDictionary *cachedObjects; 13 | @property (strong, nonatomic) NSMutableDictionary *referenceCounts; 14 | @property (strong, nonatomic) dispatch_queue_t cacheQueue; 15 | 16 | @end 17 | 18 | @implementation RZXCache 19 | 20 | #pragma mark - lifecycle 21 | 22 | - (instancetype)init 23 | { 24 | if ( (self = [super init]) ) { 25 | _cachedObjects = [NSMutableDictionary dictionary]; 26 | _referenceCounts = [NSMutableDictionary dictionary]; 27 | 28 | const char *queueLabel = [NSString stringWithFormat:@"com.raze.cache-%lu", (unsigned long)self.hash].UTF8String; 29 | _cacheQueue = dispatch_queue_create(queueLabel, DISPATCH_QUEUE_SERIAL); 30 | } 31 | return self; 32 | } 33 | 34 | #pragma mark - public methods 35 | 36 | - (void)cacheObject:(id)object forKey:(id)key 37 | { 38 | if ( object != nil ) { 39 | __weak typeof(self) wself = self; 40 | dispatch_async(self.cacheQueue, ^{ 41 | __strong typeof(wself) sself = wself; 42 | sself.cachedObjects[key] = object; 43 | [sself retainObjectImmediatelyForKey:key]; 44 | }); 45 | } 46 | } 47 | 48 | - (void)retainObjectForKey:(id)key 49 | { 50 | __weak typeof(self) wself = self; 51 | dispatch_async(self.cacheQueue, ^{ 52 | __strong typeof(wself) sself = wself; 53 | [sself retainObjectImmediatelyForKey:key]; 54 | }); 55 | } 56 | 57 | - (void)releaseObjectForKey:(id)key 58 | { 59 | __weak typeof(self) wself = self; 60 | dispatch_async(self.cacheQueue, ^{ 61 | __strong typeof(wself) sself = wself; 62 | [sself releaseObjectImmediatelyForKey:key]; 63 | }); 64 | } 65 | 66 | - (id)objectForKey:(id)key 67 | { 68 | __block id object = nil; 69 | 70 | dispatch_sync(self.cacheQueue, ^{ 71 | object = self.cachedObjects[key]; 72 | }); 73 | 74 | return object; 75 | } 76 | 77 | - (void)removeObjectForKey:(id)key 78 | { 79 | __weak typeof(self) wself = self; 80 | dispatch_async(self.cacheQueue, ^{ 81 | __strong typeof(wself) sself = wself; 82 | [sself.cachedObjects removeObjectForKey:key]; 83 | [sself.referenceCounts removeObjectForKey:key]; 84 | }); 85 | } 86 | 87 | - (void)removeAllObjects 88 | { 89 | __weak typeof(self) wself = self; 90 | dispatch_async(self.cacheQueue, ^{ 91 | __strong typeof(wself) sself = wself; 92 | [sself.cachedObjects removeAllObjects]; 93 | [sself.referenceCounts removeAllObjects]; 94 | }); 95 | } 96 | 97 | #pragma mark - private methods 98 | 99 | - (void)retainObjectImmediatelyForKey:(id)key 100 | { 101 | NSNumber *refCount = self.referenceCounts[key]; 102 | 103 | if ( refCount == nil ) { 104 | self.referenceCounts[key] = @(1); 105 | } 106 | else { 107 | self.referenceCounts[key] = @(refCount.intValue + 1); 108 | } 109 | } 110 | 111 | - (void)releaseObjectImmediatelyForKey:(id)key 112 | { 113 | int refCount = [self.referenceCounts[key] intValue]; 114 | 115 | if ( refCount <= 1 ) { 116 | [self.referenceCounts removeObjectForKey:key]; 117 | [self.cachedObjects removeObjectForKey:key]; 118 | } 119 | else { 120 | self.referenceCounts[key] = @(refCount - 1); 121 | } 122 | } 123 | 124 | @end 125 | 126 | @implementation RZXCache (RZXSubscripting) 127 | 128 | - (id)objectForKeyedSubscript:(id)key 129 | { 130 | return [self objectForKey:key]; 131 | } 132 | 133 | - (void)setObject:(id)obj forKeyedSubscript:(id)key 134 | { 135 | if ( obj != nil ) { 136 | [self cacheObject:obj forKey:key]; 137 | } 138 | else { 139 | [self removeObjectForKey:key]; 140 | } 141 | } 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXStaticTexture.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXStaticTexture.m 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 6/29/15. 6 | // 7 | 8 | #import 9 | #import 10 | #import 11 | 12 | @interface RZXStaticTexture () 13 | 14 | @property (assign, nonatomic) BOOL usingCache; 15 | @property (assign, nonatomic) BOOL usingMipmapping; 16 | 17 | @end 18 | 19 | @implementation RZXStaticTexture 20 | 21 | + (instancetype)textureFromFile:(NSString *)fileName usingCache:(BOOL)useCache 22 | { 23 | return [[self alloc] initWithFileName:fileName useMipMapping:NO useCache:useCache]; 24 | } 25 | 26 | + (instancetype)mipmappedTextureFromFile:(NSString *)fileName usingCache:(BOOL)useCache 27 | { 28 | return [[self alloc] initWithFileName:fileName useMipMapping:YES useCache:useCache]; 29 | } 30 | 31 | #pragma mark - RZXGPUObject overrides 32 | 33 | - (RZXGPUObjectTeardownBlock)teardownHandler 34 | { 35 | RZXGPUObjectTeardownBlock teardown = nil; 36 | 37 | RZXCache *cache = self.usingCache ? [self.configuredContext cacheForClass:[RZXStaticTexture class]] : nil; 38 | if ( cache[self.fileName] == nil ) { 39 | teardown = [super teardownHandler]; 40 | } 41 | 42 | return teardown; 43 | } 44 | 45 | - (BOOL)setupGL 46 | { 47 | return ([super setupGL] && [self assignIdentifer]); 48 | } 49 | 50 | - (void)teardownGL 51 | { 52 | if ( self.usingCache ) { 53 | RZXCache *cache = [self.configuredContext cacheForClass:[RZXStaticTexture class]]; 54 | [cache releaseObjectForKey:self.fileName]; 55 | } 56 | 57 | [super teardownGL]; 58 | } 59 | 60 | #pragma mark - private methods 61 | 62 | - (instancetype)initWithFileName:(NSString *)fileName useMipMapping:(BOOL)useMipMapping useCache:(BOOL)useCache 63 | { 64 | self = [super init]; 65 | if (self) { 66 | _fileName = fileName; 67 | _usingCache = useCache; 68 | _usingMipmapping = useMipMapping; 69 | } 70 | return self; 71 | } 72 | 73 | - (BOOL)assignIdentifer 74 | { 75 | BOOL assigned = NO; 76 | 77 | RZXCache *cache = self.usingCache ? [self.configuredContext cacheForClass:[RZXStaticTexture class]] : nil; 78 | 79 | GLKTextureInfo *cachedTextureInfo = cache[self.fileName]; 80 | 81 | if ( cachedTextureInfo != nil ) { 82 | [cache retainObjectForKey:self.fileName]; 83 | [self applyTextureInfo:cachedTextureInfo]; 84 | 85 | assigned = YES; 86 | } 87 | else { 88 | NSString *name = [self.fileName stringByDeletingPathExtension]; 89 | NSString *extension = [self.fileName pathExtension]; 90 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:extension]; 91 | 92 | if ( path == nil ) { 93 | RZXLog(@"Failed to setup %@: %@ not found in the main bundle.", NSStringFromClass([self class]), self.fileName); 94 | } 95 | else { 96 | NSDictionary *options = @{ GLKTextureLoaderOriginBottomLeft : @(YES), 97 | GLKTextureLoaderGenerateMipmaps : @(_usingMipmapping) }; 98 | 99 | // GLKTextureLoader will throw a random error if an OpenGL error exists prior to texture loading. 100 | // This appears to be a bug, but a workaround is to flush the error ahead of time. 101 | RZXGLError(); 102 | 103 | NSError *error; 104 | GLKTextureInfo *textureInfo = [GLKTextureLoader textureWithContentsOfFile:path options:options error:&error]; 105 | 106 | if ( error != nil ) { 107 | RZXLog(@"Failed to setup %@: %@", NSStringFromClass([self class]), error.localizedDescription); 108 | } 109 | else { 110 | [self applyTextureInfo:textureInfo]; 111 | 112 | if ( self.usingCache ) { 113 | cache[self.fileName] = textureInfo; 114 | } 115 | 116 | assigned = YES; 117 | } 118 | } 119 | } 120 | 121 | return assigned; 122 | } 123 | 124 | - (void)applyTextureInfo:(GLKTextureInfo *)textureInfo 125 | { 126 | _size.width = textureInfo.width; 127 | _size.height = textureInfo.height; 128 | _name = textureInfo.name; 129 | } 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /Raze/RazeCore/RZXQuadMesh.m: -------------------------------------------------------------------------------- 1 | // 2 | // RZXQuadMesh.m 3 | // RazeCore 4 | // 5 | // Created by Rob Visentin on 1/10/15. 6 | // Copyright (c) 2015 Raizlabs. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NSInteger const kRZXQuadMeshMaxSubdivisions = 8; 12 | 13 | void RZXGenerateQuadMesh(NSInteger subdivisions, GLvoid **vertices, GLuint *numVerts, GLvoid **indices, GLuint *numIdxs); 14 | 15 | @interface RZXQuadMesh () 16 | 17 | @property (assign, nonatomic) NSInteger subdivisions; 18 | 19 | @end 20 | 21 | @implementation RZXQuadMesh 22 | 23 | #pragma mark - lifecycle 24 | 25 | + (instancetype)quad 26 | { 27 | return [self quadWithSubdivisionLevel:0]; 28 | } 29 | 30 | + (instancetype)quadWithSubdivisionLevel:(NSInteger)subdivisons 31 | { 32 | return [[self alloc] initWithSubdivisionLevel:subdivisons]; 33 | } 34 | 35 | #pragma mark - getters 36 | 37 | - (GLKVector3)bounds 38 | { 39 | return (GLKVector3){2.0f, 2.0f, 0.0f}; 40 | } 41 | 42 | - (NSString *)cacheKey 43 | { 44 | return [NSString stringWithFormat:@"com.raze.mesh-builtin-quad-%i", (int)self.subdivisions]; 45 | } 46 | 47 | #pragma mark - private methods 48 | 49 | - (instancetype)initWithSubdivisionLevel:(NSInteger)subdivisions 50 | { 51 | self = [self init]; 52 | if ( self ) { 53 | subdivisions = MAX(0, MIN(subdivisions, kRZXQuadMeshMaxSubdivisions)); 54 | _subdivisions = subdivisions; 55 | 56 | _configurationBlock = ^BOOL (RZXMesh *self) { 57 | GLvoid *vertexData, *indexData; 58 | GLuint vertexCount; 59 | RZXGenerateQuadMesh(subdivisions, &vertexData, &vertexCount, &indexData, &self->_indexCount); 60 | 61 | [self.configuredContext genVertexArrays:&self->_vao count:1]; 62 | glGenBuffers(2, &self->_bufferSet.vbo); 63 | 64 | [self.configuredContext bindVertexArray:self->_vao]; 65 | 66 | glBindBuffer(GL_ARRAY_BUFFER, self->_bufferSet.vbo); 67 | glBufferData(GL_ARRAY_BUFFER, 5 * vertexCount * sizeof(GLfloat), vertexData, GL_STATIC_DRAW); 68 | 69 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self->_bufferSet.ibo); 70 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, self->_indexCount * sizeof(GLushort), indexData, GL_STATIC_DRAW); 71 | 72 | glEnableVertexAttribArray(kRZXVertexAttribPosition); 73 | glVertexAttribPointer(kRZXVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (const GLvoid *)0); 74 | 75 | glEnableVertexAttribArray(kRZXVertexAttribTexCoord); 76 | glVertexAttribPointer(kRZXVertexAttribTexCoord, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (const GLvoid *)12); 77 | 78 | glBindBuffer(GL_ARRAY_BUFFER, 0); 79 | 80 | free(vertexData); 81 | free(indexData); 82 | 83 | return YES; 84 | }; 85 | } 86 | return self; 87 | } 88 | 89 | void RZXGenerateQuadMesh(NSInteger subdivisions, GLvoid **vertices, GLuint *numVerts, GLvoid **indices, GLuint *numIdxs) 90 | { 91 | GLuint subs = pow(2.0, subdivisions); 92 | GLuint pts = subs + 1; 93 | 94 | GLfloat ptStep = 2.0f / subs; 95 | GLfloat texStep = 1.0f / subs; 96 | 97 | *numVerts = pts * pts; 98 | *numIdxs = 6 * subs * subs; 99 | 100 | GLfloat *verts = (GLfloat *)malloc(5 * *numVerts * sizeof(GLfloat)); 101 | GLushort *idxs = (GLushort *)malloc(*numIdxs * sizeof(GLushort)); 102 | 103 | int v = 0; 104 | int i = 0; 105 | 106 | for ( int y = 0; y < pts; y++ ) { 107 | for ( int x = 0; x < pts; x++ ) { 108 | verts[v++] = -1.0f + ptStep * x; 109 | verts[v++] = 1.0f - ptStep * y; 110 | verts[v++] = 0.0f; 111 | verts[v++] = texStep * x; 112 | verts[v++] = 1.0f - texStep * y; 113 | 114 | if ( x < subs && y < subs ) { 115 | idxs[i++] = y * pts + x; 116 | idxs[i++] = (y + 1) * pts + x; 117 | idxs[i++] = y * pts + x + 1; 118 | idxs[i++] = y * pts + x + 1; 119 | idxs[i++] = (y + 1) * pts + x; 120 | idxs[i++] = (y + 1) * pts + x + 1; 121 | } 122 | } 123 | } 124 | 125 | *vertices = verts; 126 | *indices = idxs; 127 | } 128 | 129 | @end 130 | --------------------------------------------------------------------------------