|
cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
|
00001 /* 00002 * cocos2d for iPhone: http://www.cocos2d-iphone.org 00003 * 00004 * Copyright (c) 2008-2010 Ricardo Quesada 00005 * Copyright (c) 2011 Zynga Inc. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a copy 00008 * of this software and associated documentation files (the "Software"), to deal 00009 * in the Software without restriction, including without limitation the rights 00010 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00011 * copies of the Software, and to permit persons to whom the Software is 00012 * furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included in 00015 * all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00018 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00020 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00021 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00022 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00023 * THE SOFTWARE. 00024 */ 00025 00026 00032 #import <Availability.h> 00033 #import <Foundation/Foundation.h> 00034 00035 #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 00036 #import <CoreGraphics/CGGeometry.h> // CGPoint 00037 #endif 00038 00039 #import "Platforms/CCGL.h" 00040 00044 typedef struct _ccColor3B 00045 { 00046 GLubyte r; 00047 GLubyte g; 00048 GLubyte b; 00049 } ccColor3B; 00050 00052 static inline ccColor3B 00053 ccc3(const GLubyte r, const GLubyte g, const GLubyte b) 00054 { 00055 ccColor3B c = {r, g, b}; 00056 return c; 00057 } 00058 //ccColor3B predefined colors 00060 static const ccColor3B ccWHITE = {255,255,255}; 00062 static const ccColor3B ccYELLOW = {255,255,0}; 00064 static const ccColor3B ccBLUE = {0,0,255}; 00066 static const ccColor3B ccGREEN = {0,255,0}; 00068 static const ccColor3B ccRED = {255,0,0}; 00070 static const ccColor3B ccMAGENTA = {255,0,255}; 00072 static const ccColor3B ccBLACK = {0,0,0}; 00074 static const ccColor3B ccORANGE = {255,127,0}; 00076 static const ccColor3B ccGRAY = {166,166,166}; 00077 00081 typedef struct _ccColor4B 00082 { 00083 GLubyte r; 00084 GLubyte g; 00085 GLubyte b; 00086 GLubyte a; 00087 } ccColor4B; 00089 static inline ccColor4B 00090 ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o) 00091 { 00092 ccColor4B c = {r, g, b, o}; 00093 return c; 00094 } 00095 00096 00100 typedef struct _ccColor4F { 00101 GLfloat r; 00102 GLfloat g; 00103 GLfloat b; 00104 GLfloat a; 00105 } ccColor4F; 00106 00110 static inline ccColor4F ccc4FFromccc3B(ccColor3B c) 00111 { 00112 return (ccColor4F){c.r/255.f, c.g/255.f, c.b/255.f, 1.f}; 00113 } 00114 00118 static inline ccColor4F ccc4FFromccc4B(ccColor4B c) 00119 { 00120 return (ccColor4F){c.r/255.f, c.g/255.f, c.b/255.f, c.a/255.f}; 00121 } 00122 00126 static inline BOOL ccc4FEqual(ccColor4F a, ccColor4F b) 00127 { 00128 return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; 00129 } 00130 00134 typedef struct _ccVertex2F 00135 { 00136 GLfloat x; 00137 GLfloat y; 00138 } ccVertex2F; 00139 00143 typedef struct _ccVertex3F 00144 { 00145 GLfloat x; 00146 GLfloat y; 00147 GLfloat z; 00148 } ccVertex3F; 00149 00153 typedef struct _ccTex2F { 00154 GLfloat u; 00155 GLfloat v; 00156 } ccTex2F; 00157 00158 00160 typedef struct _ccPointSprite 00161 { 00162 ccVertex2F pos; // 8 bytes 00163 ccColor4B color; // 4 bytes 00164 GLfloat size; // 4 bytes 00165 } ccPointSprite; 00166 00168 typedef struct _ccQuad2 { 00169 ccVertex2F tl; 00170 ccVertex2F tr; 00171 ccVertex2F bl; 00172 ccVertex2F br; 00173 } ccQuad2; 00174 00175 00177 typedef struct _ccQuad3 { 00178 ccVertex3F bl; 00179 ccVertex3F br; 00180 ccVertex3F tl; 00181 ccVertex3F tr; 00182 } ccQuad3; 00183 00185 typedef struct _ccGridSize 00186 { 00187 NSInteger x; 00188 NSInteger y; 00189 } ccGridSize; 00190 00192 static inline ccGridSize 00193 ccg(const NSInteger x, const NSInteger y) 00194 { 00195 ccGridSize v = {x, y}; 00196 return v; 00197 } 00198 00200 typedef struct _ccV2F_C4B_T2F 00201 { 00203 ccVertex2F vertices; 00205 ccColor4B colors; 00207 ccTex2F texCoords; 00208 } ccV2F_C4B_T2F; 00209 00211 typedef struct _ccV2F_C4F_T2F 00212 { 00214 ccVertex2F vertices; 00216 ccColor4F colors; 00218 ccTex2F texCoords; 00219 } ccV2F_C4F_T2F; 00220 00222 typedef struct _ccV3F_C4B_T2F 00223 { 00225 ccVertex3F vertices; // 12 bytes 00226 // char __padding__[4]; 00227 00229 ccColor4B colors; // 4 bytes 00230 // char __padding2__[4]; 00231 00232 // tex coords (2F) 00233 ccTex2F texCoords; // 8 byts 00234 } ccV3F_C4B_T2F; 00235 00237 typedef struct _ccV2F_C4B_T2F_Quad 00238 { 00240 ccV2F_C4B_T2F bl; 00242 ccV2F_C4B_T2F br; 00244 ccV2F_C4B_T2F tl; 00246 ccV2F_C4B_T2F tr; 00247 } ccV2F_C4B_T2F_Quad; 00248 00250 typedef struct _ccV3F_C4B_T2F_Quad 00251 { 00253 ccV3F_C4B_T2F tl; 00255 ccV3F_C4B_T2F bl; 00257 ccV3F_C4B_T2F tr; 00259 ccV3F_C4B_T2F br; 00260 } ccV3F_C4B_T2F_Quad; 00261 00263 typedef struct _ccV2F_C4F_T2F_Quad 00264 { 00266 ccV2F_C4F_T2F bl; 00268 ccV2F_C4F_T2F br; 00270 ccV2F_C4F_T2F tl; 00272 ccV2F_C4F_T2F tr; 00273 } ccV2F_C4F_T2F_Quad; 00274 00276 typedef struct _ccBlendFunc 00277 { 00279 GLenum src; 00281 GLenum dst; 00282 } ccBlendFunc; 00283 00286 typedef float ccTime; 00287 //typedef double ccTime;