joybox 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +27 -0
  5. data/LICENSE +22 -0
  6. data/README.md +86 -0
  7. data/Rakefile +14 -0
  8. data/app/app_delegate.rb +49 -0
  9. data/app/layers/box2d_layer.rb +109 -0
  10. data/app/layers/cocos2d_layer.rb +14 -0
  11. data/app/layers/cocos_motion_layer.rb +145 -0
  12. data/app/layers/menu_layer.rb +59 -0
  13. data/joybox.gemspec +25 -0
  14. data/lib/joybox.rb +47 -0
  15. data/lib/joybox/box2d/body.rb +106 -0
  16. data/lib/joybox/box2d/world.rb +79 -0
  17. data/lib/joybox/cocos2d/actions/actions.rb +7 -0
  18. data/lib/joybox/cocos2d/actions/move.rb +31 -0
  19. data/lib/joybox/cocos2d/actions/repeat.rb +24 -0
  20. data/lib/joybox/cocos2d/actions/rotate.rb +31 -0
  21. data/lib/joybox/cocos2d/actions/scale.rb +31 -0
  22. data/lib/joybox/cocos2d/actions/sequence.rb +22 -0
  23. data/lib/joybox/cocos2d/actions/skew.rb +36 -0
  24. data/lib/joybox/cocos2d/cocos2d.rb +15 -0
  25. data/lib/joybox/cocos2d/common/cg_point.rb +37 -0
  26. data/lib/joybox/cocos2d/common/color.rb +49 -0
  27. data/lib/joybox/cocos2d/common/gc_size.rb +39 -0
  28. data/lib/joybox/cocos2d/common/ns_set.rb +5 -0
  29. data/lib/joybox/cocos2d/common/numeric.rb +14 -0
  30. data/lib/joybox/cocos2d/common/screen.rb +39 -0
  31. data/lib/joybox/cocos2d/common/ui_touch.rb +15 -0
  32. data/lib/joybox/cocos2d/configuration/configuration.rb +68 -0
  33. data/lib/joybox/cocos2d/configuration/file_utils.rb +33 -0
  34. data/lib/joybox/cocos2d/configuration/gl_view.rb +44 -0
  35. data/lib/joybox/cocos2d/configuration/texture_2d.rb +27 -0
  36. data/lib/joybox/cocos2d/core/layer.rb +87 -0
  37. data/lib/joybox/cocos2d/core/node.rb +26 -0
  38. data/lib/joybox/cocos2d/core/physics_sprite.rb +52 -0
  39. data/lib/joybox/cocos2d/core/scene.rb +24 -0
  40. data/lib/joybox/cocos2d/core/sprite.rb +43 -0
  41. data/lib/joybox/cocos2d/core/sprite_batch.rb +24 -0
  42. data/lib/joybox/cocos2d/director.rb +43 -0
  43. data/lib/joybox/cocos2d/macros.rb +234 -0
  44. data/lib/joybox/cocos2d/ui/label.rb +34 -0
  45. data/lib/joybox/cocos2d/ui/menu.rb +25 -0
  46. data/lib/joybox/cocos2d/ui/menu_image.rb +22 -0
  47. data/lib/joybox/cocos2d/ui/menu_label.rb +45 -0
  48. data/lib/joybox/cocos2d/ui/ui.rb +7 -0
  49. data/lib/joybox/version.rb +3 -0
  50. data/resources/box2d/blocks_sprite_sheet.png +0 -0
  51. data/resources/cocos_motion/dot.png +0 -0
  52. data/resources/cocos_motion/dot_selected.png +0 -0
  53. data/resources/cocos_motion/grossini.png +0 -0
  54. data/resources/cocos_motion/grossinis_sister.png +0 -0
  55. data/resources/cocos_motion/grossinis_sister_two.png +0 -0
  56. data/resources/cocos_motion/left_arrow.png +0 -0
  57. data/resources/cocos_motion/left_arrow_selected.png +0 -0
  58. data/resources/cocos_motion/right_arrow.png +0 -0
  59. data/resources/cocos_motion/right_arrow_selected.png +0 -0
  60. data/resources/fps_images-hd.png +0 -0
  61. data/resources/fps_images-ipadhd.png +0 -0
  62. data/resources/fps_images.png +0 -0
  63. data/spec/lib/joybox/cocos2d/cocos2d_spec.rb +7 -0
  64. data/spec/lib/joybox/cocos2d/macros_spec.rb +37 -0
  65. data/spec/main_spec.rb +9 -0
  66. data/vendor/Box2D.framework/Box2D +0 -0
  67. data/vendor/Box2D.framework/Box2D.framework.bridgesupport +166 -0
  68. data/vendor/Box2D.framework/Versions/A/Box2D +0 -0
  69. data/vendor/Box2D.framework/Versions/A/Headers/Collision/B2DContactListener.h +25 -0
  70. data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DEdgeShape.h +17 -0
  71. data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DPolygonShape.h +16 -0
  72. data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DShape.h +15 -0
  73. data/vendor/Box2D.framework/Versions/A/Headers/Dynamics/B2DBody.h +43 -0
  74. data/vendor/Box2D.framework/Versions/A/Headers/Dynamics/B2DWorld.h +41 -0
  75. data/vendor/Box2D.framework/Versions/A/Resources/Box2DConfig.cmake +3 -0
  76. data/vendor/Box2D.framework/Versions/A/Resources/CMakeLists.txt +205 -0
  77. data/vendor/Cocos2D/Cocos2D.bridgesupport +7808 -0
  78. data/vendor/Cocos2D/include/CCAction.h +195 -0
  79. data/vendor/Cocos2D/include/CCActionCamera.h +73 -0
  80. data/vendor/Cocos2D/include/CCActionCatmullRom.h +139 -0
  81. data/vendor/Cocos2D/include/CCActionEase.h +159 -0
  82. data/vendor/Cocos2D/include/CCActionGrid.h +165 -0
  83. data/vendor/Cocos2D/include/CCActionGrid3D.h +205 -0
  84. data/vendor/Cocos2D/include/CCActionInstant.h +227 -0
  85. data/vendor/Cocos2D/include/CCActionInterval.h +431 -0
  86. data/vendor/Cocos2D/include/CCActionManager.h +113 -0
  87. data/vendor/Cocos2D/include/CCActionPageTurn3D.h +42 -0
  88. data/vendor/Cocos2D/include/CCActionProgressTimer.h +59 -0
  89. data/vendor/Cocos2D/include/CCActionTiledGrid.h +211 -0
  90. data/vendor/Cocos2D/include/CCActionTween.h +62 -0
  91. data/vendor/Cocos2D/include/CCAnimation.h +150 -0
  92. data/vendor/Cocos2D/include/CCAnimationCache.h +74 -0
  93. data/vendor/Cocos2D/include/CCArray.h +119 -0
  94. data/vendor/Cocos2D/include/CCAtlasNode.h +96 -0
  95. data/vendor/Cocos2D/include/CCCamera.h +98 -0
  96. data/vendor/Cocos2D/include/CCConfiguration.h +126 -0
  97. data/vendor/Cocos2D/include/CCDirector.h +344 -0
  98. data/vendor/Cocos2D/include/CCDirectorIOS.h +104 -0
  99. data/vendor/Cocos2D/include/CCDrawingPrimitives.h +139 -0
  100. data/vendor/Cocos2D/include/CCES2Renderer.h +83 -0
  101. data/vendor/Cocos2D/include/CCESRenderer.h +54 -0
  102. data/vendor/Cocos2D/include/CCFileUtils.h +188 -0
  103. data/vendor/Cocos2D/include/CCGL.h +72 -0
  104. data/vendor/Cocos2D/include/CCGLProgram.h +150 -0
  105. data/vendor/Cocos2D/include/CCGLView.h +160 -0
  106. data/vendor/Cocos2D/include/CCGrabber.h +44 -0
  107. data/vendor/Cocos2D/include/CCGrid.h +130 -0
  108. data/vendor/Cocos2D/include/CCLabelAtlas.h +68 -0
  109. data/vendor/Cocos2D/include/CCLabelBMFont.h +216 -0
  110. data/vendor/Cocos2D/include/CCLabelTTF.h +132 -0
  111. data/vendor/Cocos2D/include/CCLayer.h +280 -0
  112. data/vendor/Cocos2D/include/CCMenu.h +100 -0
  113. data/vendor/Cocos2D/include/CCMenuItem.h +423 -0
  114. data/vendor/Cocos2D/include/CCMotionStreak.h +87 -0
  115. data/vendor/Cocos2D/include/CCNS.h +54 -0
  116. data/vendor/Cocos2D/include/CCNode+Debug.h +39 -0
  117. data/vendor/Cocos2D/include/CCNode.h +569 -0
  118. data/vendor/Cocos2D/include/CCParallaxNode.h +50 -0
  119. data/vendor/Cocos2D/include/CCParticleBatchNode.h +99 -0
  120. data/vendor/Cocos2D/include/CCParticleExamples.h +95 -0
  121. data/vendor/Cocos2D/include/CCParticleSystem.h +453 -0
  122. data/vendor/Cocos2D/include/CCParticleSystemQuad.h +73 -0
  123. data/vendor/Cocos2D/include/CCProfiling.h +89 -0
  124. data/vendor/Cocos2D/include/CCProgressTimer.h +94 -0
  125. data/vendor/Cocos2D/include/CCProtocols.h +132 -0
  126. data/vendor/Cocos2D/include/CCRenderTexture.h +139 -0
  127. data/vendor/Cocos2D/include/CCScene.h +43 -0
  128. data/vendor/Cocos2D/include/CCScheduler.h +230 -0
  129. data/vendor/Cocos2D/include/CCShaderCache.h +60 -0
  130. data/vendor/Cocos2D/include/CCSprite.h +288 -0
  131. data/vendor/Cocos2D/include/CCSpriteBatchNode.h +138 -0
  132. data/vendor/Cocos2D/include/CCSpriteFrame.h +126 -0
  133. data/vendor/Cocos2D/include/CCSpriteFrameCache.h +121 -0
  134. data/vendor/Cocos2D/include/CCTMXLayer.h +164 -0
  135. data/vendor/Cocos2D/include/CCTMXObjectGroup.h +67 -0
  136. data/vendor/Cocos2D/include/CCTMXTiledMap.h +145 -0
  137. data/vendor/Cocos2D/include/CCTMXXMLParser.h +217 -0
  138. data/vendor/Cocos2D/include/CCTexture2D.h +357 -0
  139. data/vendor/Cocos2D/include/CCTextureAtlas.h +188 -0
  140. data/vendor/Cocos2D/include/CCTextureCache.h +146 -0
  141. data/vendor/Cocos2D/include/CCTexturePVR.h +129 -0
  142. data/vendor/Cocos2D/include/CCTileMapAtlas.h +83 -0
  143. data/vendor/Cocos2D/include/CCTouchDelegateProtocol.h +75 -0
  144. data/vendor/Cocos2D/include/CCTouchDispatcher.h +120 -0
  145. data/vendor/Cocos2D/include/CCTouchHandler.h +93 -0
  146. data/vendor/Cocos2D/include/CCTransition.h +296 -0
  147. data/vendor/Cocos2D/include/CCTransitionPageTurn.h +60 -0
  148. data/vendor/Cocos2D/include/CCTransitionProgress.h +62 -0
  149. data/vendor/Cocos2D/include/CCVertex.h +36 -0
  150. data/vendor/Cocos2D/include/CGPointExtension.h +344 -0
  151. data/vendor/Cocos2D/include/CocosDenshion/CDAudioManager.h +243 -0
  152. data/vendor/Cocos2D/include/CocosDenshion/CDConfig.h +60 -0
  153. data/vendor/Cocos2D/include/CocosDenshion/CDOpenALSupport.h +77 -0
  154. data/vendor/Cocos2D/include/CocosDenshion/CDXPropertyModifierAction.h +45 -0
  155. data/vendor/Cocos2D/include/CocosDenshion/CocosDenshion.h +440 -0
  156. data/vendor/Cocos2D/include/CocosDenshion/SimpleAudioEngine.h +90 -0
  157. data/vendor/Cocos2D/include/NSThread+performBlock.h +22 -0
  158. data/vendor/Cocos2D/include/OpenGL_Internal.h +86 -0
  159. data/vendor/Cocos2D/include/RubyMotionSchedule.h +7 -0
  160. data/vendor/Cocos2D/include/TGAlib.h +55 -0
  161. data/vendor/Cocos2D/include/TransformUtils.h +36 -0
  162. data/vendor/Cocos2D/include/ZipUtils.h +91 -0
  163. data/vendor/Cocos2D/include/base64.h +33 -0
  164. data/vendor/Cocos2D/include/ccCArray.h +229 -0
  165. data/vendor/Cocos2D/include/ccConfig.h +245 -0
  166. data/vendor/Cocos2D/include/ccDeprecated.h +300 -0
  167. data/vendor/Cocos2D/include/ccGLStateCache.h +138 -0
  168. data/vendor/Cocos2D/include/ccMacros.h +353 -0
  169. data/vendor/Cocos2D/include/ccShader_PositionColor_frag.h +12 -0
  170. data/vendor/Cocos2D/include/ccShader_PositionColor_vert.h +17 -0
  171. data/vendor/Cocos2D/include/ccShader_PositionTextureA8Color_frag.h +16 -0
  172. data/vendor/Cocos2D/include/ccShader_PositionTextureA8Color_vert.h +21 -0
  173. data/vendor/Cocos2D/include/ccShader_PositionTextureColorAlphaTest_frag.h +23 -0
  174. data/vendor/Cocos2D/include/ccShader_PositionTextureColor_frag.h +14 -0
  175. data/vendor/Cocos2D/include/ccShader_PositionTextureColor_vert.h +22 -0
  176. data/vendor/Cocos2D/include/ccShader_PositionTexture_frag.h +13 -0
  177. data/vendor/Cocos2D/include/ccShader_PositionTexture_uColor_frag.h +16 -0
  178. data/vendor/Cocos2D/include/ccShader_PositionTexture_uColor_vert.h +18 -0
  179. data/vendor/Cocos2D/include/ccShader_PositionTexture_vert.h +17 -0
  180. data/vendor/Cocos2D/include/ccShader_Position_uColor_frag.h +12 -0
  181. data/vendor/Cocos2D/include/ccShader_Position_uColor_vert.h +19 -0
  182. data/vendor/Cocos2D/include/ccShaders.h +45 -0
  183. data/vendor/Cocos2D/include/ccTypes.h +374 -0
  184. data/vendor/Cocos2D/include/ccUtils.h +36 -0
  185. data/vendor/Cocos2D/include/cocos2d.h +178 -0
  186. data/vendor/Cocos2D/include/kazmath/GL/mat4stack.h +51 -0
  187. data/vendor/Cocos2D/include/kazmath/GL/matrix.h +58 -0
  188. data/vendor/Cocos2D/include/kazmath/aabb.h +53 -0
  189. data/vendor/Cocos2D/include/kazmath/kazmath.h +39 -0
  190. data/vendor/Cocos2D/include/kazmath/mat3.h +75 -0
  191. data/vendor/Cocos2D/include/kazmath/mat4.h +93 -0
  192. data/vendor/Cocos2D/include/kazmath/neon_matrix_impl.h +41 -0
  193. data/vendor/Cocos2D/include/kazmath/plane.h +70 -0
  194. data/vendor/Cocos2D/include/kazmath/quaternion.h +113 -0
  195. data/vendor/Cocos2D/include/kazmath/ray2.h +50 -0
  196. data/vendor/Cocos2D/include/kazmath/utility.h +74 -0
  197. data/vendor/Cocos2D/include/kazmath/vec2.h +64 -0
  198. data/vendor/Cocos2D/include/kazmath/vec3.h +68 -0
  199. data/vendor/Cocos2D/include/kazmath/vec4.h +68 -0
  200. data/vendor/Cocos2D/include/uthash.h +972 -0
  201. data/vendor/Cocos2D/include/utlist.h +490 -0
  202. data/vendor/Cocos2D/libCocosDenshion.a +0 -0
  203. data/vendor/Cocos2D/libcocos2d.a +0 -0
  204. metadata +277 -0
@@ -0,0 +1,83 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2010 Ricardo Quesada
5
+ * Copyright (c) 2011 Zynga Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ *
26
+ * File autogenerated with Xcode. Adapted for cocos2d needs.
27
+ */
28
+
29
+ // Only compile this code on iOS. These files should NOT be included on your Mac project.
30
+ // But in case they are included, it won't be compiled.
31
+ #import "../../ccMacros.h"
32
+ #ifdef __CC_PLATFORM_IOS
33
+
34
+ #import "CCESRenderer.h"
35
+
36
+ #import <OpenGLES/ES2/gl.h>
37
+ #import <OpenGLES/ES2/glext.h>
38
+
39
+ @interface CCES2Renderer : NSObject <CCESRenderer>
40
+ {
41
+ // The pixel dimensions of the CAEAGLLayer
42
+ GLint backingWidth_;
43
+ GLint backingHeight_;
44
+
45
+ unsigned int samplesToUse_;
46
+ BOOL multiSampling_;
47
+
48
+ unsigned int depthFormat_;
49
+ unsigned int pixelFormat_;
50
+
51
+ // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view
52
+ GLuint defaultFramebuffer_;
53
+ GLuint colorRenderbuffer_;
54
+ GLuint depthBuffer_;
55
+
56
+
57
+ //buffers for MSAA
58
+ GLuint msaaFramebuffer_;
59
+ GLuint msaaColorbuffer_;
60
+
61
+ EAGLContext *context_;
62
+ }
63
+
64
+ /** Color Renderbuffer */
65
+ @property (nonatomic,readonly) GLuint colorRenderbuffer;
66
+
67
+ /** Default Renderbuffer */
68
+ @property (nonatomic,readonly) GLuint defaultFramebuffer;
69
+
70
+ /** MSAA Framebuffer */
71
+ @property (nonatomic,readonly) GLuint msaaFramebuffer;
72
+
73
+ /** MSAA Color Buffer */
74
+ @property (nonatomic,readonly) GLuint msaaColorbuffer;
75
+
76
+ /** EAGLContext */
77
+ @property (nonatomic,readonly) EAGLContext* context;
78
+
79
+ - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer;
80
+ @end
81
+
82
+ #endif // __CC_PLATFORM_IOS
83
+
@@ -0,0 +1,54 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2010 Ricardo Quesada
5
+ * Copyright (c) 2011 Zynga Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ *
26
+ * File autogenerated with Xcode. Adapted for cocos2d needs.
27
+ */
28
+
29
+ // Only compile this code on iOS. These files should NOT be included on your Mac project.
30
+ // But in case they are included, it won't be compiled.
31
+ #import "../../ccMacros.h"
32
+ #ifdef __CC_PLATFORM_IOS
33
+
34
+ #import <QuartzCore/QuartzCore.h>
35
+
36
+ #import <OpenGLES/EAGL.h>
37
+ #import <OpenGLES/EAGLDrawable.h>
38
+
39
+ @protocol CCESRenderer <NSObject>
40
+
41
+ - (id) initWithDepthFormat:(unsigned int)depthFormat withPixelFormat:(unsigned int)pixelFormat withSharegroup:(EAGLSharegroup*)sharegroup withMultiSampling:(BOOL) multiSampling withNumberOfSamples:(unsigned int) requestedSamples;
42
+
43
+ - (BOOL) resizeFromLayer:(CAEAGLLayer *)layer;
44
+
45
+ - (EAGLContext*) context;
46
+ - (CGSize) backingSize;
47
+
48
+ - (unsigned int) colorRenderBuffer;
49
+ - (unsigned int) defaultFrameBuffer;
50
+ - (unsigned int) msaaFrameBuffer;
51
+ - (unsigned int) msaaColorBuffer;
52
+ @end
53
+
54
+ #endif // __CC_PLATFORM_IOS
@@ -0,0 +1,188 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2008-2010 Ricardo Quesada
5
+ * Copyright (c) 2011 Zynga Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+
27
+
28
+ #import <Foundation/Foundation.h>
29
+ #import "../ccTypes.h"
30
+
31
+ /** Helper class to handle file operations */
32
+ @interface CCFileUtils : NSObject
33
+ {
34
+ NSFileManager *fileManager_;
35
+ NSBundle *bundle_;
36
+ NSMutableDictionary *fullPathCache_;
37
+ NSMutableDictionary *removeSuffixCache_;
38
+
39
+
40
+ #ifdef __CC_PLATFORM_IOS
41
+ BOOL enableFallbackSuffixes_;
42
+
43
+ NSString *iPhoneRetinaDisplaySuffix_;
44
+ NSString *iPadSuffix_;
45
+ NSString *iPadRetinaDisplaySuffix_;
46
+ #endif // __CC_PLATFORM_IOS
47
+ }
48
+
49
+ /** NSBundle used by CCFileUtils. By default it uses [NSBundle mainBundle].
50
+ @since v2.0
51
+ */
52
+ @property (nonatomic, readwrite, retain) NSBundle *bundle;
53
+
54
+ /** NSFileManager used by CCFileUtils. By default it uses its own intance.
55
+ @since v2.0
56
+ */
57
+ @property (nonatomic, readwrite, retain) NSFileManager *fileManager;
58
+
59
+ #ifdef __CC_PLATFORM_IOS
60
+ /** The iPhone RetinaDisplay suffixes to load resources.
61
+ By default it is "-hd" and "" in that order.
62
+ Only valid on iOS. Not valid for OS X.
63
+
64
+ @since v1.1
65
+ */
66
+ @property (nonatomic,readwrite, copy, setter = setiPhoneRetinaDisplaySuffix:) NSString *iPhoneRetinaDisplaySuffix;
67
+
68
+ /** The iPad suffixes to load resources.
69
+ By default it is "-ipad", "-hd", "", in that order.
70
+ Only valid on iOS. Not valid for OS X.
71
+
72
+ @since v1.1
73
+ */
74
+ @property (nonatomic,readwrite, copy, setter = setiPadSuffix:) NSString *iPadSuffix;
75
+
76
+
77
+ /** Sets the iPad Retina Display suffixes to load resources.
78
+ By default it is "-ipadhd", "-ipad", "-hd", "", in that order.
79
+ Only valid on iOS. Not valid for OS X.
80
+
81
+ @since v2.0
82
+ */
83
+ @property (nonatomic,readwrite, copy, setter = setiPadRetinaDisplaySuffix:) NSString *iPadRetinaDisplaySuffix;
84
+
85
+ /** Whether of not the fallback sufixes is enabled.
86
+ When enabled it will try to search for the following suffixes in the following order until one is found:
87
+ * On iPad HD : iPad HD suffix, iPad suffix, iPhone HD suffix, Without suffix
88
+ * On iPad : iPad suffix, iPhone HD suffix, Without suffix
89
+ * On iPhone HD: iPhone HD suffix, Without suffix
90
+
91
+ By default this functionality is off;
92
+ */
93
+ @property (nonatomic, readwrite) BOOL enableFallbackSuffixes;
94
+
95
+ #endif // __CC_PLATFORM_IOS
96
+
97
+ /** returns the shared file utils instance */
98
+ +(CCFileUtils*) sharedFileUtils;
99
+
100
+
101
+ /** Purge cached entries.
102
+ Will be called automatically by the Director when a memory warning is received
103
+ */
104
+ -(void) purgeCachedEntries;
105
+
106
+ /** Returns the fullpath of an filename.
107
+
108
+ If in iPhoneRetinaDisplay mode, and a RetinaDisplay file is found, it will return that path.
109
+ If in iPad mode, and an iPad file is found, it will return that path.
110
+
111
+ Examples:
112
+
113
+ * In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists)
114
+ * In iPhone RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists)
115
+ * In iPad RetinaDisplay mode: "image.png" -> "/full/path/image-ipadhd.png" (in case the -ipadhd file exists)
116
+
117
+ */
118
+ -(NSString*) fullPathFromRelativePath:(NSString*) relPath;
119
+
120
+
121
+ /** Returns the fullpath of an filename including the resolution of the image.
122
+
123
+ If in RetinaDisplay mode, and a RetinaDisplay file is found, it will return that path.
124
+ If in iPad mode, and an iPad file is found, it will return that path.
125
+
126
+ Examples:
127
+
128
+ * In iPad mode: "image.png" -> "/full/path/image-ipad.png" (in case the -ipad file exists)
129
+ * In iPhone RetinaDisplay mode: "image.png" -> "/full/path/image-hd.png" (in case the -hd file exists)
130
+ * In iPad RetinaDisplay mode: "image.png" -> "/full/path/image-ipadhd.png" (in case the -ipadhd file exists)
131
+
132
+ If an iPad file is found, it will set resolution type to kCCResolutioniPad
133
+ If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay
134
+
135
+ */
136
+ -(NSString*) fullPathFromRelativePath:(NSString*)relPath resolutionType:(ccResolutionType*)resolutionType;
137
+
138
+ #ifdef __CC_PLATFORM_IOS
139
+
140
+ /** removes the suffix from a path
141
+ * On iPhone RetinaDisplay it will remove the -hd suffix
142
+ * On iPad it will remove the -ipad suffix
143
+ * On iPad RetinaDisplay it will remove the -ipadhd suffix
144
+
145
+ Only valid on iOS. Not valid for OS X.
146
+
147
+ @since v0.99.5
148
+ */
149
+ -(NSString *)removeSuffixFromFile:(NSString*) path;
150
+
151
+ /** Returns whether or not a given path exists with the iPhone RetinaDisplay suffix.
152
+ Only available on iOS. Not supported on OS X.
153
+ @since v1.1
154
+ */
155
+ -(BOOL) iPhoneRetinaDisplayFileExistsAtPath:(NSString*)filename;
156
+
157
+ /** Returns whether or not a given filename exists with the iPad suffix.
158
+ Only available on iOS. Not supported on OS X.
159
+ @since v1.1
160
+ */
161
+ -(BOOL) iPadFileExistsAtPath:(NSString*)filename;
162
+
163
+ /** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix.
164
+ Only available on iOS. Not supported on OS X.
165
+ @since v2.0
166
+ */
167
+ -(BOOL) iPadRetinaDisplayFileExistsAtPath:(NSString*)filename;
168
+
169
+ #endif // __CC_PLATFORM_IOS
170
+
171
+ @end
172
+
173
+
174
+ #ifdef __cplusplus
175
+ extern "C" {
176
+ #endif
177
+
178
+ /** loads a file into memory.
179
+ the caller should release the allocated buffer.
180
+
181
+ @returns the size of the allocated buffer
182
+ @since v0.99.5
183
+ */
184
+ NSInteger ccLoadFileIntoMemory(const char *filename, unsigned char **out);
185
+
186
+ #ifdef __cplusplus
187
+ }
188
+ #endif
@@ -0,0 +1,72 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2010 Ricardo Quesada
5
+ * Copyright (c) 2011 Zynga Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ */
25
+
26
+ //
27
+ // Common layer for OpenGL stuff
28
+ //
29
+
30
+ #import "../ccMacros.h"
31
+
32
+ #if __CC_PLATFORM_IOS
33
+ #import <OpenGLES/ES2/gl.h>
34
+ #import <OpenGLES/ES2/glext.h>
35
+ #import <OpenGLES/EAGL.h>
36
+ #import "iOS/CCGLView.h"
37
+
38
+ #elif __CC_PLATFORM_MAC
39
+ #import <OpenGL/gl.h>
40
+ #import <OpenGL/glu.h>
41
+ #import <Cocoa/Cocoa.h> // needed for NSOpenGLView
42
+ #import "Mac/CCGLView.h"
43
+ #endif
44
+
45
+
46
+ // iOS
47
+ #if __CC_PLATFORM_IOS
48
+ #define glClearDepth glClearDepthf
49
+ #define glDeleteVertexArrays glDeleteVertexArraysOES
50
+ #define glGenVertexArrays glGenVertexArraysOES
51
+ #define glBindVertexArray glBindVertexArrayOES
52
+
53
+ #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
54
+
55
+ // Mac
56
+ #elif __CC_PLATFORM_MAC
57
+
58
+ #define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
59
+
60
+ #if 1
61
+ #define glDeleteVertexArrays glDeleteVertexArraysAPPLE
62
+ #define glGenVertexArrays glGenVertexArraysAPPLE
63
+ #define glBindVertexArray glBindVertexArrayAPPLE
64
+
65
+ #else // OpenGL 3.2 Core Profile
66
+
67
+ #define glDeleteVertexArrays glDeleteVertexArrays
68
+ #define glGenVertexArrays glGenVertexArrays
69
+ #define glBindVertexArray glBindVertexArray
70
+ #endif
71
+
72
+ #endif
@@ -0,0 +1,150 @@
1
+ //
2
+ // Copyright 2011 Jeff Lamarche
3
+ //
4
+ // Copyright 2012 Goffredo Marocchi
5
+ //
6
+ // Copyright 2012 Ricardo Quesada
7
+ //
8
+ //
9
+ // Redistribution and use in source and binary forms, with or without modification, are permitted provided
10
+ // that the following conditions are met:
11
+ // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
12
+ // the following disclaimer.
13
+ //
14
+ // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
15
+ // and the following disclaimer in the documentation and/or other materials provided with the
16
+ // distribution.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
+ // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20
+ // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT
21
+ // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
+ // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24
+ // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
+ // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ //
28
+ //
29
+
30
+ #import <Foundation/Foundation.h>
31
+ #import "ccMacros.h"
32
+ #import "Platforms/CCGL.h"
33
+
34
+ enum {
35
+ kCCVertexAttrib_Position,
36
+ kCCVertexAttrib_Color,
37
+ kCCVertexAttrib_TexCoords,
38
+
39
+ kCCVertexAttrib_MAX,
40
+ };
41
+
42
+ enum {
43
+ kCCUniformMVPMatrix,
44
+ kCCUniformSampler,
45
+
46
+ kCCUniform_MAX,
47
+ };
48
+
49
+ #define kCCShader_PositionTextureColor @"ShaderPositionTextureColor"
50
+ #define kCCShader_PositionTextureColorAlphaTest @"ShaderPositionTextureColorAlphaTest"
51
+ #define kCCShader_PositionColor @"ShaderPositionColor"
52
+ #define kCCShader_PositionTexture @"ShaderPositionTexture"
53
+ #define kCCShader_PositionTexture_uColor @"ShaderPositionTexture_uColor"
54
+ #define kCCShader_PositionTextureA8Color @"ShaderPositionTextureA8Color"
55
+ #define kCCShader_Position_uColor @"ShaderPosition_uColor"
56
+
57
+ // uniform names
58
+ #define kCCUniformMVPMatrix_s "u_MVPMatrix"
59
+ #define kCCUniformSampler_s "u_texture"
60
+ #define kCCUniformAlphaTestValue "u_alpha_value"
61
+
62
+ // Attribute names
63
+ #define kCCAttributeNameColor @"a_color"
64
+ #define kCCAttributeNamePosition @"a_position"
65
+ #define kCCAttributeNameTexCoord @"a_texCoord"
66
+
67
+
68
+ struct _hashUniformEntry;
69
+
70
+ /** CCGLProgram
71
+ Class that implements a glProgram
72
+
73
+
74
+ @since v2.0.0
75
+ */
76
+ @interface CCGLProgram : NSObject
77
+ {
78
+ struct _hashUniformEntry *hashForUniforms_;
79
+
80
+ @public
81
+ GLuint program_,
82
+ vertShader_,
83
+ fragShader_;
84
+
85
+ GLint uniforms_[kCCUniform_MAX];
86
+ }
87
+
88
+ /** Initializes the CCGLProgram with a vertex and fragment with bytes array */
89
+ - (id)initWithVertexShaderByteArray:(const GLchar*)vShaderByteArray fragmentShaderByteArray:(const GLchar*)fShaderByteArray;
90
+
91
+ /** Initializes the CCGLProgram with a vertex and fragment with contents of filenames */
92
+ - (id)initWithVertexShaderFilename:(NSString *)vShaderFilename fragmentShaderFilename:(NSString *)fShaderFilename;
93
+
94
+ /** It will add a new attribute to the shader */
95
+ - (void)addAttribute:(NSString *)attributeName index:(GLuint)index;
96
+
97
+ /** links the glProgram */
98
+ - (BOOL)link;
99
+
100
+ /** it will call glUseProgram() */
101
+ - (void)use;
102
+
103
+ /** It will create 3 uniforms:
104
+ - kCCUniformPMatrix
105
+ - kCCUniformMVMatrix
106
+ - kCCUniformSampler
107
+
108
+ And it will bind "kCCUniformSampler" to 0
109
+ */
110
+ - (void) updateUniforms;
111
+
112
+ /** calls glUniform1i only if the values are different than the previous call for this same shader program. */
113
+ -(void) setUniformLocation:(NSUInteger)location withI1:(GLint)i1;
114
+
115
+ /** calls glUniform1f only if the values are different than the previous call for this same shader program. */
116
+ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1;
117
+
118
+ /** calls glUniform2f only if the values are different than the previous call for this same shader program. */
119
+ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2;
120
+
121
+ /** calls glUniform3f only if the values are different than the previous call for this same shader program. */
122
+ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3;
123
+
124
+ /** calls glUniform4f only if the values are different than the previous call for this same shader program. */
125
+ -(void) setUniformLocation:(NSUInteger)location withF1:(GLfloat)f1 f2:(GLfloat)f2 f3:(GLfloat)f3 f4:(GLfloat)f4;
126
+
127
+ /** calls glUniform2fv only if the values are different than the previous call for this same shader program. */
128
+ -(void) setUniformLocation:(NSUInteger)location with2fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays;
129
+
130
+ /** calls glUniform3fv only if the values are different than the previous call for this same shader program. */
131
+ -(void) setUniformLocation:(NSUInteger)location with3fv:(GLfloat*)floats count:(NSUInteger)numberOfArrays;
132
+
133
+ /** calls glUniform4fv only if the values are different than the previous call for this same shader program. */
134
+ -(void) setUniformLocation:(NSUInteger)location with4fv:(GLvoid*)floats count:(NSUInteger)numberOfArrays;
135
+
136
+ /** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */
137
+ -(void) setUniformLocation:(NSUInteger)location withMatrix4fv:(GLvoid*)matrix_array count:(NSUInteger)numberOfMatrix;
138
+
139
+ /** will update the MVP matrix on the MVP uniform if it is different than the previous call for this same shader program. */
140
+ -(void) setUniformForModelViewProjectionMatrix;
141
+
142
+ /** returns the vertexShader error log */
143
+ - (NSString *)vertexShaderLog;
144
+
145
+ /** returns the fragmentShader error log */
146
+ - (NSString *)fragmentShaderLog;
147
+
148
+ /** returns the program error log */
149
+ - (NSString *)programLog;
150
+ @end