summary refs log tree commit diff stats
path: root/libs/cocos2d/ccTypes.h
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
committerStarla Insigna <starla4444@gmail.com>2011-07-30 11:19:14 -0400
commit9cd57b731ab1c666d4a1cb725538fdc137763d12 (patch)
tree5bac45ae5157a1cb10c6e45500cbf72789917980 /libs/cocos2d/ccTypes.h
downloadcartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.gz
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.bz2
cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.zip
Initial commit (version 0.2.1)
Diffstat (limited to 'libs/cocos2d/ccTypes.h')
-rwxr-xr-xlibs/cocos2d/ccTypes.h287
1 files changed, 287 insertions, 0 deletions
diff --git a/libs/cocos2d/ccTypes.h b/libs/cocos2d/ccTypes.h new file mode 100755 index 0000000..46917b3 --- /dev/null +++ b/libs/cocos2d/ccTypes.h
@@ -0,0 +1,287 @@
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 @file
29 cocos2d (cc) types
30*/
31
32#import <Availability.h>
33#import <Foundation/Foundation.h>
34
35#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
36#import <CoreGraphics/CGGeometry.h> // CGPoint
37#endif
38
39#import "Platforms/CCGL.h"
40
41/** RGB color composed of bytes 3 bytes
42@since v0.8
43 */
44typedef struct _ccColor3B
45{
46 GLubyte r;
47 GLubyte g;
48 GLubyte b;
49} ccColor3B;
50
51//! helper macro that creates an ccColor3B type
52static inline ccColor3B
53ccc3(const GLubyte r, const GLubyte g, const GLubyte b)
54{
55 ccColor3B c = {r, g, b};
56 return c;
57}
58//ccColor3B predefined colors
59//! White color (255,255,255)
60static const ccColor3B ccWHITE = {255,255,255};
61//! Yellow color (255,255,0)
62static const ccColor3B ccYELLOW = {255,255,0};
63//! Blue color (0,0,255)
64static const ccColor3B ccBLUE = {0,0,255};
65//! Green Color (0,255,0)
66static const ccColor3B ccGREEN = {0,255,0};
67//! Red Color (255,0,0,)
68static const ccColor3B ccRED = {255,0,0};
69//! Magenta Color (255,0,255)
70static const ccColor3B ccMAGENTA = {255,0,255};
71//! Black Color (0,0,0)
72static const ccColor3B ccBLACK = {0,0,0};
73//! Orange Color (255,127,0)
74static const ccColor3B ccORANGE = {255,127,0};
75//! Gray Color (166,166,166)
76static const ccColor3B ccGRAY = {166,166,166};
77
78/** RGBA color composed of 4 bytes
79@since v0.8
80*/
81typedef struct _ccColor4B
82{
83 GLubyte r;
84 GLubyte g;
85 GLubyte b;
86 GLubyte a;
87} ccColor4B;
88//! helper macro that creates an ccColor4B type
89static inline ccColor4B
90ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o)
91{
92 ccColor4B c = {r, g, b, o};
93 return c;
94}
95
96
97/** RGBA color composed of 4 floats
98@since v0.8
99*/
100typedef struct _ccColor4F {
101 GLfloat r;
102 GLfloat g;
103 GLfloat b;
104 GLfloat a;
105} ccColor4F;
106
107/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
108 @since v0.99.1
109 */
110static inline ccColor4F ccc4FFromccc3B(ccColor3B c)
111{
112 return (ccColor4F){c.r/255.f, c.g/255.f, c.b/255.f, 1.f};
113}
114
115/** Returns a ccColor4F from a ccColor4B.
116 @since v0.99.1
117 */
118static inline ccColor4F ccc4FFromccc4B(ccColor4B c)
119{
120 return (ccColor4F){c.r/255.f, c.g/255.f, c.b/255.f, c.a/255.f};
121}
122
123/** returns YES if both ccColor4F are equal. Otherwise it returns NO.
124 @since v0.99.1
125 */
126static inline BOOL ccc4FEqual(ccColor4F a, ccColor4F b)
127{
128 return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
129}
130
131/** A vertex composed of 2 GLfloats: x, y
132 @since v0.8
133 */
134typedef struct _ccVertex2F
135{
136 GLfloat x;
137 GLfloat y;
138} ccVertex2F;
139
140/** A vertex composed of 2 floats: x, y
141 @since v0.8
142 */
143typedef struct _ccVertex3F
144{
145 GLfloat x;
146 GLfloat y;
147 GLfloat z;
148} ccVertex3F;
149
150/** A texcoord composed of 2 floats: u, y
151 @since v0.8
152 */
153typedef struct _ccTex2F {
154 GLfloat u;
155 GLfloat v;
156} ccTex2F;
157
158
159//! Point Sprite component
160typedef struct _ccPointSprite
161{
162 ccVertex2F pos; // 8 bytes
163 ccColor4B color; // 4 bytes
164 GLfloat size; // 4 bytes
165} ccPointSprite;
166
167//! A 2D Quad. 4 * 2 floats
168typedef struct _ccQuad2 {
169 ccVertex2F tl;
170 ccVertex2F tr;
171 ccVertex2F bl;
172 ccVertex2F br;
173} ccQuad2;
174
175
176//! A 3D Quad. 4 * 3 floats
177typedef struct _ccQuad3 {
178 ccVertex3F bl;
179 ccVertex3F br;
180 ccVertex3F tl;
181 ccVertex3F tr;
182} ccQuad3;
183
184//! A 2D grid size
185typedef struct _ccGridSize
186{
187 NSInteger x;
188 NSInteger y;
189} ccGridSize;
190
191//! helper function to create a ccGridSize
192static inline ccGridSize
193ccg(const NSInteger x, const NSInteger y)
194{
195 ccGridSize v = {x, y};
196 return v;
197}
198
199//! a Point with a vertex point, a tex coord point and a color 4B
200typedef struct _ccV2F_C4B_T2F
201{
202 //! vertices (2F)
203 ccVertex2F vertices;
204 //! colors (4B)
205 ccColor4B colors;
206 //! tex coords (2F)
207 ccTex2F texCoords;
208} ccV2F_C4B_T2F;
209
210//! a Point with a vertex point, a tex coord point and a color 4F
211typedef struct _ccV2F_C4F_T2F
212{
213 //! vertices (2F)
214 ccVertex2F vertices;
215 //! colors (4F)
216 ccColor4F colors;
217 //! tex coords (2F)
218 ccTex2F texCoords;
219} ccV2F_C4F_T2F;
220
221//! a Point with a vertex point, a tex coord point and a color 4B
222typedef struct _ccV3F_C4B_T2F
223{
224 //! vertices (3F)
225 ccVertex3F vertices; // 12 bytes
226// char __padding__[4];
227
228 //! colors (4B)
229 ccColor4B colors; // 4 bytes
230// char __padding2__[4];
231
232 // tex coords (2F)
233 ccTex2F texCoords; // 8 byts
234} ccV3F_C4B_T2F;
235
236//! 4 ccVertex2FTex2FColor4B Quad
237typedef struct _ccV2F_C4B_T2F_Quad
238{
239 //! bottom left
240 ccV2F_C4B_T2F bl;
241 //! bottom right
242 ccV2F_C4B_T2F br;
243 //! top left
244 ccV2F_C4B_T2F tl;
245 //! top right
246 ccV2F_C4B_T2F tr;
247} ccV2F_C4B_T2F_Quad;
248
249//! 4 ccVertex3FTex2FColor4B
250typedef struct _ccV3F_C4B_T2F_Quad
251{
252 //! top left
253 ccV3F_C4B_T2F tl;
254 //! bottom left
255 ccV3F_C4B_T2F bl;
256 //! top right
257 ccV3F_C4B_T2F tr;
258 //! bottom right
259 ccV3F_C4B_T2F br;
260} ccV3F_C4B_T2F_Quad;
261
262//! 4 ccVertex2FTex2FColor4F Quad
263typedef struct _ccV2F_C4F_T2F_Quad
264{
265 //! bottom left
266 ccV2F_C4F_T2F bl;
267 //! bottom right
268 ccV2F_C4F_T2F br;
269 //! top left
270 ccV2F_C4F_T2F tl;
271 //! top right
272 ccV2F_C4F_T2F tr;
273} ccV2F_C4F_T2F_Quad;
274
275//! Blend Function used for textures
276typedef struct _ccBlendFunc
277{
278 //! source blend function
279 GLenum src;
280 //! destination blend function
281 GLenum dst;
282} ccBlendFunc;
283
284//! delta time type
285//! if you want more resolution redefine it as a double
286typedef float ccTime;
287//typedef double ccTime;