├── engine ├── resources │ ├── textures │ │ ├── white.png │ │ └── transparent.png │ ├── fonts │ │ └── HelveticaNeueLight.png │ └── shaders │ │ ├── alphacolour.fx │ │ ├── basic_vc.fx │ │ ├── basic.fx │ │ ├── phong.fx │ │ └── phongenv.fx ├── source │ ├── scenes │ │ ├── CCScenes.h │ │ └── CCSceneBase.h │ ├── rendering │ │ ├── CCPrimitives.h │ │ ├── CCPrimitiveSphere.h │ │ ├── CCPrimitiveOBJ.h │ │ ├── CCTextureFontPageFile.h │ │ ├── CCModelBase.h │ │ ├── CCModel3DS.h │ │ ├── CCTextureSprites.h │ │ ├── CCMatrix.h │ │ ├── CCPrimitiveCube.h │ │ ├── CCRenderTools.h │ │ ├── CCTextureBase.h │ │ ├── CCPrimitiveBase.h │ │ ├── CCModelBase.cpp │ │ ├── CCTextureFontPageFile.cpp │ │ ├── CCTextureFontPage.h │ │ ├── CCPrimitiveSphere.cpp │ │ ├── CCFrameBufferManager.h │ │ ├── CCPrimitiveSquare.h │ │ ├── CCTextureBase.cpp │ │ ├── CCTextureSprites.cpp │ │ ├── CCTextureManager.h │ │ └── CCPrimitiveBase.cpp │ ├── objects │ │ ├── CCObjects.h │ │ ├── CCObjectText.h │ │ ├── CCMoveable.h │ │ ├── CCTile3DFrameBuffer.h │ │ ├── CCRenderable.h │ │ ├── CCObject.h │ │ ├── CCTile3D.h │ │ ├── CCCollideable.h │ │ ├── CCObjectText.cpp │ │ └── CCTile3D.cpp │ ├── tools │ │ ├── CCArray.cpp │ │ ├── CCAudioManager.h │ │ ├── CCCameraRecorder.h │ │ ├── CCAudioManager.cpp │ │ ├── CCExternalAccessoryManager.h │ │ ├── CCTools.cpp │ │ ├── CCCallbacks.cpp │ │ ├── CCTypes.h │ │ ├── CCFileManager.h │ │ ├── CCOctree.h │ │ ├── CCTools.h │ │ ├── CCControls.h │ │ ├── CCMathTools.h │ │ ├── CCExternalAccessoryManager.cpp │ │ ├── CCString.h │ │ └── CCVectors.cpp │ ├── ai │ │ ├── CCMovementInterpolator.h │ │ ├── CCPathFinderNetwork.h │ │ └── CCMovementInterpolator.cpp │ └── CCDefines.h └── .project ├── external ├── base64 │ ├── base64.h │ └── base64.cpp ├── .project ├── zlib-1.2.3 │ ├── inffast.h │ ├── uncompr.c │ ├── inftrees.h │ └── compress.c ├── libjpeg-8d │ ├── jversion.h │ ├── rdgif.c │ ├── jconfig.h │ ├── jcinit.c │ ├── jmemnobs.c │ ├── jinclude.h │ └── jcomapi.c ├── jansson-2.5 │ ├── src │ │ ├── Makefile.am │ │ ├── strbuffer.h │ │ ├── utf.h │ │ ├── memory.c │ │ ├── jansson_config.h.in │ │ ├── jansson_config.h │ │ ├── jansson.def │ │ ├── error.c │ │ ├── jansson_private.h │ │ ├── strbuffer.c │ │ └── strconv.c │ └── LICENSE ├── 3dsloader │ ├── 3dsvect.h │ ├── 3dsloader.h │ └── 3dsvect.cpp └── libpng │ └── config.h ├── .gitignore ├── web └── index.html └── README.md /engine/resources/textures/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcreatelabs/playir/HEAD/engine/resources/textures/white.png -------------------------------------------------------------------------------- /engine/resources/textures/transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcreatelabs/playir/HEAD/engine/resources/textures/transparent.png -------------------------------------------------------------------------------- /engine/resources/fonts/HelveticaNeueLight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcreatelabs/playir/HEAD/engine/resources/fonts/HelveticaNeueLight.png -------------------------------------------------------------------------------- /engine/source/scenes/CCScenes.h: -------------------------------------------------------------------------------- 1 | #ifndef __CCSCENES_H__ 2 | #define __CCSCENES_H__ 3 | 4 | 5 | #include "CCSceneBase.h" 6 | 7 | 8 | #endif // __CCSCENES_H__ 9 | -------------------------------------------------------------------------------- /external/base64/base64.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::string base64_encode(unsigned char const* , unsigned int len); 4 | std::string base64_decode(std::string const& s); 5 | 6 | -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitives.h: -------------------------------------------------------------------------------- 1 | #include "CCPrimitiveBase.h" 2 | #include "CCPrimitiveCube.h" 3 | #include "CCPrimitiveSquare.h" 4 | #include "CCPrimitiveSphere.h" 5 | 6 | #include "CCModelBase.h" 7 | #include "CCModel3D.h" 8 | -------------------------------------------------------------------------------- /external/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | CCExternal 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /engine/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | CCEngine 4 | 5 | 6 | Engine 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /engine/source/objects/CCObjects.h: -------------------------------------------------------------------------------- 1 | #ifndef __CCOBJECTS_H__ 2 | #define __CCOBJECTS_H__ 3 | 4 | 5 | #include "CCDefines.h" 6 | 7 | #include "CCPrimitives.h" 8 | 9 | #include "CCObject.h" 10 | #include "CCObjectText.h" 11 | 12 | #include "CCCollideable.h" 13 | #include "CCMoveable.h" 14 | 15 | #include "CCTile3D.h" 16 | #include "CCTile3DButton.h" 17 | #include "CCTile3DFrameBuffer.h" 18 | 19 | 20 | #endif // __CCOBJECTS_H__ 21 | -------------------------------------------------------------------------------- /external/zlib-1.2.3/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /external/libjpeg-8d/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "8d 15-Jan-2012" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 2012, Thomas G. Lane, Guido Vollbeding" 15 | -------------------------------------------------------------------------------- /engine/source/tools/CCArray.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCArray.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include 12 | 13 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = jansson.def 2 | 3 | include_HEADERS = jansson.h jansson_config.h 4 | 5 | lib_LTLIBRARIES = libjansson.la 6 | libjansson_la_SOURCES = \ 7 | dump.c \ 8 | error.c \ 9 | hashtable.c \ 10 | hashtable.h \ 11 | jansson_private.h \ 12 | load.c \ 13 | memory.c \ 14 | pack_unpack.c \ 15 | strbuffer.c \ 16 | strbuffer.h \ 17 | strconv.c \ 18 | utf.c \ 19 | utf.h \ 20 | value.c 21 | libjansson_la_LDFLAGS = \ 22 | -no-undefined \ 23 | -export-symbols-regex '^json_' \ 24 | -version-info 9:0:5 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.o 3 | Thumbs.db 4 | *.suo 5 | *.user* 6 | *.d 7 | 8 | */*/*.xcodeproj/project.xcworkspace/ 9 | */*/*.xcodepro 10 | */*/*/xcuserdata/ 11 | 12 | */Qt/*-build-*/ 13 | */Qt/Project/*.pro.user* 14 | 15 | */android/source/.settings/ 16 | */android/source/bin/ 17 | */android/source/gen/ 18 | */android/source/libs/ 19 | */android/source/obj/ 20 | */android/source/res/drawable/ 21 | */android/source/res/raw/ 22 | */android/workspace/ 23 | 24 | */windows*/*.opensdf 25 | */windows*/*.sdf 26 | */windows*/*.suo 27 | */windows*/Bin 28 | */windows*/ipch 29 | */windows*/*/obj 30 | */windows*/*/*.user 31 | */windows*/*/PerfLogs 32 | */windows*/PhoneXamlDirect3DApp/Resources/Packaged/* -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PLAYIR 4 | 5 | 6 | 7 |
8 |
9 | 10 | 11 | Embed an iframe pointing to the url http://playir.com/x/#id= 12 |
13 | and insert your app id at the end. 14 |
15 | 18 | 19 |
20 |
21 | eg. Epic Empires with an app id of 578
uses: http://playir.com/x/#id=578 22 |
23 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitiveSphere.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPrimitiveSphere.h 7 | * Description : Sphere drawable component. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCPRIMITIVESPHERE_H__ 15 | #define __CCPRIMITIVESPHERE_H__ 16 | 17 | 18 | class CCPrimitiveSphere : public CCPrimitiveBase 19 | { 20 | public: 21 | typedef CCPrimitiveBase super; 22 | 23 | // CCPrimitiveBase 24 | virtual void renderVertices(const bool textured); 25 | 26 | void setup(const float radius); 27 | protected: 28 | uint vertexCount; 29 | }; 30 | 31 | 32 | #endif // __CCPRIMITIVESPHERE_H__ 33 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/strbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef STRBUFFER_H 9 | #define STRBUFFER_H 10 | 11 | typedef struct { 12 | char *value; 13 | size_t length; /* bytes used */ 14 | size_t size; /* bytes allocated */ 15 | } strbuffer_t; 16 | 17 | int strbuffer_init(strbuffer_t *strbuff); 18 | void strbuffer_close(strbuffer_t *strbuff); 19 | 20 | void strbuffer_clear(strbuffer_t *strbuff); 21 | 22 | const char *strbuffer_value(const strbuffer_t *strbuff); 23 | 24 | /* Steal the value and close the strbuffer */ 25 | char *strbuffer_steal_value(strbuffer_t *strbuff); 26 | 27 | int strbuffer_append(strbuffer_t *strbuff, const char *string); 28 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); 29 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); 30 | 31 | char strbuffer_pop(strbuffer_t *strbuff); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /external/jansson-2.5/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2012 Petri Lehtinen 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/utf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTF_H 9 | #define UTF_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include 13 | 14 | #ifdef HAVE_INTTYPES_H 15 | /* inttypes.h includes stdint.h in a standard environment, so there's 16 | no need to include stdint.h separately. If inttypes.h doesn't define 17 | int32_t, it's defined in config.h. */ 18 | #include 19 | #endif /* HAVE_INTTYPES_H */ 20 | 21 | #else /* !HAVE_CONFIG_H */ 22 | #ifdef _WIN32 23 | typedef int int32_t; 24 | #else /* !_WIN32 */ 25 | /* Assume a standard environment */ 26 | #include 27 | #endif /* _WIN32 */ 28 | 29 | #endif /* HAVE_CONFIG_H */ 30 | 31 | int utf8_encode(int codepoint, char *buffer, int *size); 32 | 33 | int utf8_check_first(char byte); 34 | int utf8_check_full(const char *buffer, int size, int32_t *codepoint); 35 | const char *utf8_iterate(const char *buffer, int32_t *codepoint); 36 | 37 | int utf8_check_string(const char *string, int length); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /engine/source/tools/CCAudioManager.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCAudioManager.h 7 | * Description : Manages audio playback. 8 | * 9 | * Created : 11/07/13 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCAUDIOMANAGER_H__ 15 | #define __CCAUDIOMANAGER_H__ 16 | 17 | 18 | class CCAudioManager 19 | { 20 | public: 21 | static void Reset(); 22 | 23 | static void Prepare(const char *id, const char *url); 24 | static void Play(const char *id, const char *url, const bool restart, const bool loop); 25 | static void Stop(const char *id); 26 | static void Pause(const char *id); 27 | static void Resume(const char *id); 28 | static void SetTime(const char *id, const float time); 29 | static void SetVolume(const char *id, const float volume); 30 | 31 | static void Ended(const char *id, const char *url); 32 | }; 33 | 34 | 35 | #endif // __CCAUDIOMANAGER_H_ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Description 2 | =========== 3 |
4 | PLAYIR is a real-time design and development engine that allows for the editing of
5 | source code, assets and designs in real‑time.
6 | For more information visit http://playir.com/

7 | This repository contains the project files for building and deploying web, iOS, Android and Windows Phone apps. 8 |
9 | 10 | Android 11 | ------ 12 |
13 | Eclipse > import projects
14 | android > source > ndk > debugbuild.sh - Debug build
15 | android > source > ndk > releasebuild.sh - Release build
16 | * Requires Android NDK
17 | http://www.youtube.com/watch?v=A41HuQiMnY8 18 |
19 | 20 | iOS 21 | ------ 22 |
23 | ios > PLAYIR.xcodeproj
24 | http://www.youtube.com/watch?v=iatHLlmu6ds 25 |
26 | 27 | Web 28 | ------ 29 |
30 | web > index.html
31 | Example of embedding your app inside a webpage 32 |
33 | 34 | Windows Phone 35 | ------ 36 |
37 | Temporarily removed due to lack of interest.
38 | If you require in a Windows Phone build, please post an issue. 39 |
40 | 41 | 42 | Licence 43 | ======= 44 |
45 | This software is distributed under the Apache 2.0 license.
46 | http://www.apache.org/licenses/LICENSE-2.0.html 47 |
48 | -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitiveOBJ.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPrimitiveOBJ.h 7 | * Description : Loads and handles an obj model 8 | * 9 | * Created : 26/12/11 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCPRIMITIVEOBJ_H__ 15 | #define __CCPRIMITIVEOBJ_H__ 16 | 17 | 18 | #include "ObjLoader.h" 19 | 20 | 21 | class CCPrimitiveOBJ : public CCPrimitive3D 22 | { 23 | typedef CCPrimitive3D super; 24 | 25 | public: 26 | CCPrimitiveOBJ(); 27 | virtual void destruct(); 28 | 29 | static void LoadOBJ(const char *file, const CCResourceType resourceType, CCLambdaCallback *callback); 30 | virtual bool loadData(const char *fileData); 31 | protected: 32 | bool loadOBJMesh(ObjMesh *objMesh); 33 | 34 | // PrimitiveBase 35 | public: 36 | virtual void renderVertices(const bool textured); 37 | 38 | virtual void copy(const CCPrimitiveOBJ *primitive); 39 | }; 40 | 41 | 42 | #endif // __CCPRIMITIVEOBJ_H__ 43 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureFontPageFile.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureFontPageFile.h 7 | * Description : Handles loadng font description files. 8 | * 9 | * Created : 20/04/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCTEXTUREFONTPAGEFILE_H__ 15 | #define __CCTEXTUREFONTPAGEFILE_H__ 16 | 17 | 18 | #include "CCTextureFontPage.h" 19 | 20 | class CCTextureFontPageFile : public CCTextureFontPage 21 | { 22 | public: 23 | typedef CCTextureFontPage super; 24 | 25 | CCTextureFontPageFile(const char *name); 26 | virtual ~CCTextureFontPageFile(); 27 | 28 | virtual bool load(const int textureIndex, const char *csv); 29 | 30 | protected: 31 | virtual void bindTexturePage() const; 32 | 33 | public: 34 | const uint getTextureIndex() { return textureIndex; } 35 | const char* getCSV() { return csv.buffer; } 36 | 37 | protected: 38 | uint textureIndex; 39 | CCText csv; 40 | }; 41 | 42 | 43 | #endif // __CCTEXTUREFONTPAGEFILE_H__ 44 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * Copyright (c) 2011-2012 Basile Starynkevitch 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify it 6 | * under the terms of the MIT license. See LICENSE for details. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | #include "jansson.h" 13 | #include "jansson_private.h" 14 | 15 | /* memory function pointers */ 16 | static json_malloc_t do_malloc = malloc; 17 | static json_free_t do_free = free; 18 | 19 | void *jsonp_malloc(size_t size) 20 | { 21 | if(!size) 22 | return NULL; 23 | 24 | return (*do_malloc)(size); 25 | } 26 | 27 | void jsonp_free(void *ptr) 28 | { 29 | if(!ptr) 30 | return; 31 | 32 | (*do_free)(ptr); 33 | } 34 | 35 | char *jsonp_strdup(const char *str) 36 | { 37 | char *new_str; 38 | size_t len; 39 | 40 | len = strlen(str); 41 | if(len == (size_t)-1) 42 | return NULL; 43 | 44 | new_str = jsonp_malloc(len + 1); 45 | if(!new_str) 46 | return NULL; 47 | 48 | memcpy(new_str, str, len + 1); 49 | return new_str; 50 | } 51 | 52 | void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) 53 | { 54 | do_malloc = malloc_fn; 55 | do_free = free_fn; 56 | } 57 | -------------------------------------------------------------------------------- /external/3dsloader/3dsvect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ---------------- www.spacesimulator.net -------------- 3 | * ---- Space simulators and 3d engine tutorials ---- 4 | * 5 | * Author: Damiano Vitulli 6 | * 7 | * This program is released under the BSD licence 8 | * By using this program you agree to licence terms on spacesimulator.net copyright page 9 | * 10 | * 11 | * Math library for vectors management 12 | * 13 | * File header 14 | * 15 | */ 16 | 17 | #ifndef __3DSVECT_H__ 18 | #define __3DSVECT_H__ 19 | 20 | 21 | /********************************************************** 22 | * 23 | * TYPES DECLARATION 24 | * 25 | *********************************************************/ 26 | 27 | struct p3d_type 28 | { 29 | float x,y,z; 30 | }; 31 | 32 | 33 | 34 | /********************************************************** 35 | * 36 | * FUNCTIONS DECLARATION 37 | * 38 | *********************************************************/ 39 | 40 | extern void VectCreate(p3d_type *p_start, p3d_type *p_end, p3d_type *p_vector); 41 | extern float VectLength(p3d_type *p_vector); 42 | extern void VectNormalize(p3d_type *p_vector); 43 | extern float VectScalarProduct(p3d_type *p_vector1, p3d_type *p_vector2); 44 | extern void VectDotProduct(p3d_type *p_vector1, p3d_type *p_vector2, p3d_type *p_normal); 45 | 46 | 47 | #endif -------------------------------------------------------------------------------- /engine/source/rendering/CCModelBase.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCModelBase.h 7 | * Description : Represents the attributes of a renderable object. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCMODELBASE_H__ 15 | #define __CCMODELBASE_H__ 16 | 17 | 18 | #include "CCRenderable.h" 19 | 20 | class CCPrimitiveBase; 21 | 22 | class CCModelBase : public CCRenderable 23 | { 24 | typedef CCRenderable super; 25 | 26 | protected: 27 | CCText modelID; 28 | 29 | public: 30 | const char *shader; 31 | 32 | 33 | 34 | public: 35 | CCModelBase(const long jsID=-1); 36 | virtual void destruct(); 37 | 38 | // CCRenderable 39 | virtual void render(const bool alpha); 40 | 41 | void addModel(CCModelBase *model, const int index=-1); 42 | void removeModel(CCModelBase *model); 43 | void addPrimitive(CCPrimitiveBase *primitive); 44 | 45 | CCObjectPtrList models; 46 | CCObjectPtrList primitives; 47 | }; 48 | 49 | 50 | #endif // __CCMODELBASE_H__ 51 | -------------------------------------------------------------------------------- /engine/resources/shaders/alphacolour.fx: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : alphacolour.fx 7 | * Description : Used to draw fonts. 8 | * 9 | * Created : 08/09/11 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | precision mediump float; 15 | 16 | // Globals 17 | uniform highp mat4 u_projectionMatrix; 18 | uniform highp mat4 u_viewMatrix; 19 | uniform highp mat4 u_modelMatrix; 20 | uniform vec4 u_modelColour; 21 | 22 | // PS Input 23 | varying vec2 ps_texCoord; 24 | 25 | 26 | #ifdef VERTEX_SHADER 27 | 28 | // VS Input 29 | attribute highp vec3 vs_position; 30 | attribute vec2 vs_texCoord; 31 | 32 | void main() 33 | { 34 | gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * vec4( vs_position, 1.0 ); 35 | ps_texCoord = vs_texCoord; 36 | } 37 | 38 | #endif 39 | 40 | 41 | #ifdef PIXEL_SHADER 42 | 43 | uniform sampler2D s_diffuseTexture; 44 | 45 | void main() 46 | { 47 | gl_FragColor.rgb = u_modelColour.rgb; 48 | gl_FragColor.a = u_modelColour.a * texture2D( s_diffuseTexture, ps_texCoord ).a; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/jansson_config.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | 21 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 22 | defined to `inline', otherwise empty. In C++, the inline is always 23 | supported. */ 24 | #ifdef __cplusplus 25 | #define JSON_INLINE inline 26 | #else 27 | #define JSON_INLINE @json_inline@ 28 | #endif 29 | 30 | /* If your compiler supports the `long long` type and the strtoll() 31 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 32 | otherwise to 0. */ 33 | #define JSON_INTEGER_IS_LONG_LONG @json_have_long_long@ 34 | 35 | /* If locale.h and localeconv() are available, define to 1, 36 | otherwise to 0. */ 37 | #define JSON_HAVE_LOCALECONV @json_have_localeconv@ 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /external/libjpeg-8d/rdgif.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rdgif.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains routines to read input images in GIF format. 9 | * 10 | ***************************************************************************** 11 | * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * 12 | * the ability to read GIF files has been removed from the IJG distribution. * 13 | * Sorry about that. * 14 | ***************************************************************************** 15 | * 16 | * We are required to state that 17 | * "The Graphics Interchange Format(c) is the Copyright property of 18 | * CompuServe Incorporated. GIF(sm) is a Service Mark property of 19 | * CompuServe Incorporated." 20 | */ 21 | 22 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 23 | 24 | #ifdef GIF_SUPPORTED 25 | 26 | /* 27 | * The module selection routine for GIF format input. 28 | */ 29 | 30 | GLOBAL(cjpeg_source_ptr) 31 | jinit_read_gif (j_compress_ptr cinfo) 32 | { 33 | fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); 34 | exit(EXIT_FAILURE); 35 | return NULL; /* keep compiler happy */ 36 | } 37 | 38 | #endif /* GIF_SUPPORTED */ 39 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | 21 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 22 | defined to `inline', otherwise empty. In C++, the inline is always 23 | supported. */ 24 | #ifdef __cplusplus 25 | #define JSON_INLINE inline 26 | #else 27 | #define JSON_INLINE __inline 28 | #endif 29 | 30 | /* If your compiler supports the `long long` type and the strtoll() 31 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 32 | otherwise to 0. */ 33 | #define JSON_INTEGER_IS_LONG_LONG 1 34 | 35 | /* If locale.h and localeconv() are available, define to 1, 36 | otherwise to 0. */ 37 | #ifdef ANDROID 38 | #define JSON_HAVE_LOCALECONV 0 39 | #else 40 | #define JSON_HAVE_LOCALECONV 1 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /external/libjpeg-8d/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ 2 | /* see jconfig.txt for explanations */ 3 | 4 | #define HAVE_PROTOTYPES 5 | #define HAVE_UNSIGNED_CHAR 6 | #define HAVE_UNSIGNED_SHORT 7 | /* #define void char */ 8 | /* #define const */ 9 | #undef CHAR_IS_UNSIGNED 10 | #define HAVE_STDDEF_H 11 | #define HAVE_STDLIB_H 12 | #undef NEED_BSD_STRINGS 13 | #undef NEED_SYS_TYPES_H 14 | #undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ 15 | #undef NEED_SHORT_EXTERNAL_NAMES 16 | #undef INCOMPLETE_TYPES_BROKEN 17 | 18 | /* Define "boolean" as unsigned char, not int, per Windows custom */ 19 | #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ 20 | typedef unsigned char boolean; 21 | #endif 22 | #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ 23 | 24 | 25 | #ifdef JPEG_INTERNALS 26 | 27 | #undef RIGHT_SHIFT_IS_UNSIGNED 28 | 29 | #endif /* JPEG_INTERNALS */ 30 | 31 | #ifdef JPEG_CJPEG_DJPEG 32 | 33 | #define BMP_SUPPORTED /* BMP image file format */ 34 | #define GIF_SUPPORTED /* GIF image file format */ 35 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 36 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 37 | #define TARGA_SUPPORTED /* Targa image file format */ 38 | 39 | #define TWO_FILE_COMMANDLINE /* optional */ 40 | #define USE_SETMODE /* Microsoft has setmode() */ 41 | #undef NEED_SIGNAL_CATCHER 42 | #undef DONT_USE_B_MODE 43 | #undef PROGRESS_REPORT /* optional */ 44 | 45 | #endif /* JPEG_CJPEG_DJPEG */ 46 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/jansson.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | json_delete 3 | json_true 4 | json_false 5 | json_null 6 | json_string 7 | json_string_nocheck 8 | json_string_value 9 | json_string_set 10 | json_string_set_nocheck 11 | json_integer 12 | json_integer_value 13 | json_integer_set 14 | json_real 15 | json_real_value 16 | json_real_set 17 | json_number_value 18 | json_array 19 | json_array_size 20 | json_array_get 21 | json_array_set_new 22 | json_array_append_new 23 | json_array_insert_new 24 | json_array_remove 25 | json_array_clear 26 | json_array_extend 27 | json_object 28 | json_object_size 29 | json_object_get 30 | json_object_set_new 31 | json_object_set_new_nocheck 32 | json_object_del 33 | json_object_clear 34 | json_object_update 35 | json_object_update_existing 36 | json_object_update_missing 37 | json_object_iter 38 | json_object_iter_at 39 | json_object_iter_next 40 | json_object_iter_key 41 | json_object_iter_value 42 | json_object_iter_set_new 43 | json_object_key_to_iter 44 | json_dumps 45 | json_dumpf 46 | json_dump_file 47 | json_dump_callback 48 | json_loads 49 | json_loadb 50 | json_loadf 51 | json_load_file 52 | json_load_callback 53 | json_equal 54 | json_copy 55 | json_deep_copy 56 | json_pack 57 | json_pack_ex 58 | json_vpack_ex 59 | json_unpack 60 | json_unpack_ex 61 | json_vunpack_ex 62 | json_set_alloc_funcs 63 | 64 | -------------------------------------------------------------------------------- /engine/source/tools/CCCameraRecorder.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCCameraRecorder.h 7 | * Description : Manages camera input. 8 | * 9 | * Created : 27/09/13 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCCAMERAMANAGER_H__ 15 | #define __CCCAMERAMANAGER_H__ 16 | 17 | 18 | class CCCameraRecorder : public virtual CCActiveAllocation 19 | { 20 | public: 21 | struct CameraRecording 22 | { 23 | CameraRecording() 24 | { 25 | name = NULL; 26 | textureIndex = 0; 27 | vertices = NULL; 28 | uvs = NULL; 29 | vertexCount = 0; 30 | } 31 | 32 | const char *name; 33 | uint textureIndex; 34 | float *vertices; 35 | float *uvs; 36 | uint vertexCount; 37 | 38 | CCPtrList linked; 39 | }; 40 | 41 | protected: 42 | CameraRecording current; 43 | CameraRecording loading; 44 | 45 | 46 | 47 | public: 48 | CCCameraRecorder(); 49 | 50 | void updateJobsThread(); 51 | 52 | CameraRecording& getCurrent() 53 | { 54 | return current; 55 | } 56 | 57 | void unlink(void *pointer); 58 | }; 59 | 60 | 61 | #endif // __CCCAMERAMANAGER_H__ 62 | -------------------------------------------------------------------------------- /engine/source/rendering/CCModel3DS.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCModel3DS.h 7 | * Description : Loads and handles a 3ds model. 8 | * 9 | * Created : 05/08/11 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCMODEL3DS_H__ 15 | #define __CCMODEL3DS_H__ 16 | 17 | #include "3dsloader.h" 18 | 19 | class CCPrimitive3DS : public CCPrimitive3D 20 | { 21 | typedef CCPrimitive3D super; 22 | 23 | public: 24 | CCPrimitive3DS(); 25 | virtual void destruct(); 26 | 27 | bool load(const char *file); 28 | 29 | public: 30 | virtual void renderVertices(const bool textured); 31 | }; 32 | 33 | class CCModel3DS : public CCModelBase 34 | { 35 | public: 36 | typedef CCModelBase super; 37 | 38 | CCModel3DS(const char *file, 39 | const char *texture1, const CCResourceType resourceType1, const CCTextureLoadOptions options1, 40 | const char *texture2, const CCResourceType resourceType2, const CCTextureLoadOptions options2); 41 | 42 | float getWidth() { return primitive3ds->getWidth(); } 43 | float getHeight() { return primitive3ds->getHeight(); } 44 | float getDepth() { return primitive3ds->getDepth(); } 45 | 46 | public: 47 | CCPrimitive3DS *primitive3ds; 48 | }; 49 | 50 | #endif // __CCMODEL3DS_H__ 51 | -------------------------------------------------------------------------------- /engine/source/objects/CCObjectText.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCModelText.h 7 | * Description : Represents a 3d text primitive. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | // Here's a model that contains the text primitive to make things easier 15 | class CCObjectText : public CCObject 16 | { 17 | typedef CCObject super; 18 | 19 | protected: 20 | struct CCText text; 21 | 22 | CCCollideable *parent; 23 | 24 | CCTextureFontPage *fontPage; 25 | float height; 26 | bool centered; 27 | bool endMarker; 28 | 29 | public: 30 | const char *shader; 31 | 32 | 33 | 34 | public: 35 | CCObjectText(CCCollideable *inParent=NULL); 36 | CCObjectText(const long jsID); 37 | virtual void destruct(); 38 | 39 | virtual void renderObject(const CCCameraBase *camera, const bool alpha); 40 | 41 | float getWidth(); 42 | float getHeight(); 43 | void setHeight(const float height); 44 | 45 | const CCText& getText() { return text; } 46 | void setText(const char *text, const float height=-1.0f, const char *font=NULL); 47 | 48 | void setCentered(const bool centered); 49 | 50 | void setFont(const char *font); 51 | 52 | void setEndMarker(const bool toggle) { endMarker = toggle; } 53 | bool getEndMarker() { return endMarker; } 54 | }; 55 | -------------------------------------------------------------------------------- /engine/resources/shaders/basic_vc.fx: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : basic_vc.fx 7 | * Description : Basic unlit shader with vertex colours. 8 | * 9 | * Created : 21/01/12 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #define VERTEX_COLOUR 15 | 16 | precision mediump float; 17 | 18 | // Globals 19 | uniform highp mat4 u_projectionMatrix; 20 | uniform highp mat4 u_viewMatrix; 21 | uniform highp mat4 u_modelMatrix; 22 | uniform vec4 u_modelColour; 23 | 24 | // PS Input 25 | varying vec2 ps_texCoord; 26 | 27 | #ifdef VERTEX_COLOUR 28 | varying vec4 ps_colour; 29 | #endif 30 | 31 | 32 | #ifdef VERTEX_SHADER 33 | 34 | // VS Input 35 | attribute highp vec3 vs_position; 36 | attribute vec2 vs_texCoord; 37 | 38 | #ifdef VERTEX_COLOUR 39 | attribute vec4 vs_colour; 40 | #endif 41 | 42 | void main() 43 | { 44 | gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * vec4( vs_position, 1.0 ); 45 | ps_texCoord = vs_texCoord; 46 | 47 | #ifdef VERTEX_COLOUR 48 | ps_colour = vs_colour; 49 | #endif 50 | } 51 | 52 | #endif 53 | 54 | 55 | #ifdef PIXEL_SHADER 56 | 57 | uniform sampler2D s_diffuseTexture; 58 | 59 | void main() 60 | { 61 | vec4 colour = u_modelColour; 62 | 63 | #ifdef VERTEX_COLOUR 64 | colour *= ps_colour; 65 | #endif 66 | 67 | gl_FragColor = colour * texture2D( s_diffuseTexture, ps_texCoord ).rgba; 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /engine/source/ai/CCMovementInterpolator.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCMovementInterpolator 7 | * Description : Handles the movement an object 8 | * 9 | * Created : 09/09/12 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCMOVEMENTINTERPOLATOR_H__ 15 | #define __CCMOVEMENTINTERPOLATOR_H__ 16 | 17 | 18 | class CCMovementInterpolator : public CCUpdater 19 | { 20 | public: 21 | typedef CCUpdater super; 22 | 23 | CCMovementInterpolator(CCCollideable *inObject, const bool updateCollisions); 24 | 25 | bool update(const float delta); 26 | void clear(); 27 | 28 | void setMovement(const CCVector3 target, CCLambdaCallback *inCallback=NULL); 29 | void setMovementX(const float x); 30 | void translateMovementX(const float x); 31 | void setMovementY(const float y, CCLambdaCallback *inCallback=NULL); 32 | void setMovementXY(const float x, const float y, CCLambdaCallback *inCallback=NULL); 33 | void setMovementYZ(const float y, const float z, CCLambdaCallback *inCallback=NULL); 34 | const CCVector3 getMovementTarget() const; 35 | 36 | void setDuration(const float duration); 37 | 38 | protected: 39 | CCCollideable *object; 40 | bool updating; 41 | CCInterpolatorListV3 movementInterpolator; 42 | bool updateCollisions; 43 | }; 44 | 45 | 46 | #endif // __CCMOVEMENTINTERPOLATOR_H__ 47 | 48 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureSprites.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureSprites.h 7 | * Description : Handles the loading of sprite pages. 8 | * 9 | * Created : 09/06/11 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | struct CCSpriteInfo 15 | { 16 | void setUVs(CCPrimitiveSquareUVs **uvs); 17 | 18 | CCText name; 19 | float x1, y1, x2, y2, width, height, aspectRatio; 20 | }; 21 | 22 | 23 | struct CCSpritesPage 24 | { 25 | ~CCSpritesPage() 26 | { 27 | sprites.deleteObjectsAndList(); 28 | } 29 | 30 | void loadData(const CCResourceType resourceType); 31 | CCSpriteInfo* getSpriteInfo(const char *spriteName); 32 | void setUVs(CCPrimitiveSquareUVs **uvs, const char *spriteName); 33 | 34 | CCText name; 35 | int textureIndex; 36 | CCPtrList sprites; 37 | }; 38 | 39 | 40 | struct CCTextureSprites 41 | { 42 | ~CCTextureSprites() 43 | { 44 | pages.deleteObjectsAndList(); 45 | } 46 | 47 | CCSpriteInfo* getSpriteInfo(const char *pageName, const CCResourceType resourceType, 48 | const char *spriteName); 49 | 50 | void setUVs(CCPrimitiveSquareUVs **uvs, 51 | const char *pageName, const CCResourceType resourceType, 52 | const char *spriteName); 53 | 54 | protected: 55 | CCPtrList pages; 56 | }; 57 | -------------------------------------------------------------------------------- /engine/source/tools/CCAudioManager.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCAudioManager.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCAppManager.h" 12 | #include "CCDeviceAudioManager.h" 13 | 14 | 15 | void CCAudioManager::Reset() 16 | { 17 | CCDeviceAudioManager::Reset(); 18 | } 19 | 20 | 21 | void CCAudioManager::Prepare(const char *id, const char *url) 22 | { 23 | CCDeviceAudioManager::Prepare( id, url ); 24 | } 25 | 26 | 27 | void CCAudioManager::Play(const char *id, const char *url, const bool restart, const bool loop) 28 | { 29 | CCDeviceAudioManager::Play( id, url, restart, loop ); 30 | } 31 | 32 | 33 | void CCAudioManager::Stop(const char *id) 34 | { 35 | CCDeviceAudioManager::Stop( id ); 36 | } 37 | 38 | 39 | void CCAudioManager::Pause(const char *id) 40 | { 41 | CCDeviceAudioManager::Pause( id ); 42 | } 43 | 44 | 45 | void CCAudioManager::Resume(const char *id) 46 | { 47 | CCDeviceAudioManager::Resume( id ); 48 | } 49 | 50 | 51 | void CCAudioManager::SetTime(const char *id, const float time) 52 | { 53 | CCDeviceAudioManager::SetTime( id, time ); 54 | } 55 | 56 | 57 | void CCAudioManager::SetVolume(const char *id, const float volume) 58 | { 59 | CCDeviceAudioManager::SetVolume( id, volume ); 60 | } 61 | 62 | 63 | void CCAudioManager::Ended(const char *id, const char *url) 64 | { 65 | if( gEngine != NULL ) 66 | { 67 | gEngine->audioEnded( id, url ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jansson_private.h" 3 | 4 | void jsonp_error_init(json_error_t *error, const char *source) 5 | { 6 | if(error) 7 | { 8 | error->text[0] = '\0'; 9 | error->line = -1; 10 | error->column = -1; 11 | error->position = 0; 12 | if(source) 13 | jsonp_error_set_source(error, source); 14 | else 15 | error->source[0] = '\0'; 16 | } 17 | } 18 | 19 | void jsonp_error_set_source(json_error_t *error, const char *source) 20 | { 21 | size_t length; 22 | 23 | if(!error || !source) 24 | return; 25 | 26 | length = strlen(source); 27 | if(length < JSON_ERROR_SOURCE_LENGTH) 28 | strcpy(error->source, source); 29 | else { 30 | size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; 31 | strcpy(error->source, "..."); 32 | strcpy(error->source + 3, source + extra); 33 | } 34 | } 35 | 36 | void jsonp_error_set(json_error_t *error, int line, int column, 37 | size_t position, const char *msg, ...) 38 | { 39 | va_list ap; 40 | 41 | va_start(ap, msg); 42 | jsonp_error_vset(error, line, column, position, msg, ap); 43 | va_end(ap); 44 | } 45 | 46 | void jsonp_error_vset(json_error_t *error, int line, int column, 47 | size_t position, const char *msg, va_list ap) 48 | { 49 | if(!error) 50 | return; 51 | 52 | if(error->text[0] != '\0') { 53 | /* error already set */ 54 | return; 55 | } 56 | 57 | error->line = line; 58 | error->column = column; 59 | error->position = position; 60 | 61 | vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap); 62 | error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; 63 | } 64 | -------------------------------------------------------------------------------- /engine/resources/shaders/basic.fx: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : basic.fx 7 | * Description : Basic unlit shader. 8 | * 9 | * Created : 08/09/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | precision mediump float; 15 | 16 | // Globals 17 | uniform highp mat4 u_projectionMatrix; 18 | uniform highp mat4 u_viewMatrix; 19 | uniform highp mat4 u_modelMatrix; 20 | uniform vec4 u_modelColour; 21 | 22 | // PS Input 23 | varying vec2 ps_texCoord; 24 | 25 | #ifdef VERTEX_COLOUR 26 | varying vec4 ps_colour; 27 | #endif 28 | 29 | 30 | #ifdef VERTEX_SHADER 31 | 32 | // VS Input 33 | attribute highp vec3 vs_position; 34 | attribute vec2 vs_texCoord; 35 | 36 | #ifdef VERTEX_COLOUR 37 | attribute vec4 vs_colour; 38 | #endif 39 | 40 | void main() 41 | { 42 | gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * vec4( vs_position, 1.0 ); 43 | ps_texCoord = vs_texCoord; 44 | 45 | #ifdef VERTEX_COLOUR 46 | ps_colour = vs_colour; 47 | #endif 48 | } 49 | 50 | #endif 51 | 52 | 53 | #ifdef PIXEL_SHADER 54 | 55 | uniform sampler2D s_diffuseTexture; 56 | 57 | void main() 58 | { 59 | vec4 texColour = texture2D( s_diffuseTexture, ps_texCoord ); 60 | if( texColour.a < 0.05 ) 61 | { 62 | discard; 63 | } 64 | 65 | vec4 colour = u_modelColour; 66 | colour *= texColour; 67 | 68 | #ifdef VERTEX_COLOUR 69 | colour *= ps_colour; 70 | #endif 71 | 72 | gl_FragColor = colour; 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /engine/source/rendering/CCMatrix.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCMatrix.h 7 | * Description : OpenGL rendering matrix functions. 8 | * Based on OpenGL ES2.0 programming book 9 | * http://code.google.com/p/opengles-book-samples/ 10 | * 11 | * 12 | * Created : 20/09/10 13 | * Author(s) : Ashraf Samy Hegab 14 | *----------------------------------------------------------- 15 | */ 16 | 17 | #ifndef __CCMATRIX_H__ 18 | #define __CCMATRIX_H__ 19 | 20 | 21 | struct CCMatrix 22 | { 23 | inline float* data() { return (float*)&m[0][0]; } 24 | float m[4][4]; 25 | }; 26 | 27 | extern void CCMatrixLoadIdentity(CCMatrix &result); 28 | 29 | extern void CCMatrixMultiply(CCMatrix &result, const CCMatrix &srcA, const CCMatrix &srcB); 30 | 31 | extern bool CCMatrixInverse(CCMatrix &result, CCMatrix &source); 32 | extern void CCMatrixTranspose(CCMatrix &result, CCMatrix &source); 33 | 34 | extern void CCMatrixFrustum(CCMatrix &result, float left, float right, float bottom, float top, float nearZ, float farZ); 35 | extern void CCMatrixPerspective(CCMatrix &result, float fovy, float aspect, float nearZ, float farZ); 36 | extern void CCMatrixOrtho(CCMatrix &result, float left, float right, float bottom, float top, float nearZ, float farZ); 37 | 38 | extern void CCMatrixScale(CCMatrix &result, float sx, float sy, float sz); 39 | extern void CCMatrixTranslate(CCMatrix &result, float tx, float ty, float tz); 40 | extern void CCMatrixPosition(CCMatrix &result, float tx, float ty, float tz); 41 | extern void CCMatrixRotateDegrees(CCMatrix &result, float angle, float x, float y, float z); 42 | 43 | 44 | #endif // __CCMATRIX_H__ 45 | -------------------------------------------------------------------------------- /engine/source/CCDefines.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCDefines.h 7 | * Description : Includes the generic library headers. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCDEFINES_H__ 15 | #define __CCDEFINES_H__ 16 | 17 | 18 | #include "CCPlatform.h" 19 | 20 | #define MAX_OBJECTS 2048 21 | 22 | #include "CCVectors.h" 23 | #include "CCMathTools.h" 24 | #include "CCTools.h" 25 | #include "CCTypes.h" 26 | #include "CCCallbacks.h" 27 | #include "CCRenderTools.h" 28 | #include "CCCollisionTools.h" 29 | #include "CCInterpolators.h" 30 | 31 | #include "CCApp.h" 32 | extern CCAppEngine *gEngine; 33 | 34 | #ifdef WP8 35 | // Used to communicate with JS 36 | struct JSAction 37 | { 38 | CCText action; 39 | CCLambdaSafeCallback *callback; 40 | 41 | JSAction(const char *key, const char *value, CCLambdaSafeCallback *callback) 42 | { 43 | action = key; 44 | if( value != NULL ) 45 | { 46 | action += value; 47 | } 48 | 49 | this->callback = callback; 50 | } 51 | 52 | ~JSAction() 53 | { 54 | DELETE_POINTER( callback ); 55 | } 56 | }; 57 | extern CCPtrList jsActionStack; 58 | 59 | // Used to communicate with C# 60 | struct CSAction 61 | { 62 | CCText action; 63 | 64 | CSAction(const char *key, const char *value=NULL) 65 | { 66 | action = key; 67 | if( value != NULL ) 68 | { 69 | action += value; 70 | } 71 | } 72 | }; 73 | extern CCPtrList csActionStack; 74 | #endif 75 | 76 | #if defined WIN8 || defined WP8 77 | extern const char* GetChars(Platform::String^ string); 78 | extern Platform::String^ GetString(const char *c); 79 | #endif 80 | 81 | 82 | #endif // __CCDEFINES_H__ 83 | -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitiveCube.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPrimitiveCube.h 7 | * Description : Cube drawable component. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCPRIMITIVECUBE_H__ 15 | #define __CCPRIMITIVECUBE_H__ 16 | 17 | 18 | class CCPrimitiveCube : public CCPrimitiveBase 19 | { 20 | public: 21 | typedef CCPrimitiveBase super; 22 | 23 | CCPrimitiveCube(); 24 | 25 | // CCPrimitiveBase 26 | virtual void renderVertices(const bool textured); 27 | virtual void renderOutline(); 28 | 29 | // Setup square cube 30 | void setupSquare(const float size); 31 | 32 | // Setup rectangle 33 | void setupRectangle(const float width, const float height); 34 | void setupRectangle(const float depth, const float y, const float height, const float width); 35 | 36 | // Setup use the same Z for top and bottom for trapezoid 37 | void setupTrapezoid(const float depth, const float y, const float height, const float bL, const float bR, const float tL, const float tR); 38 | 39 | // Setup trapezoid 40 | void setupTrapezoidZ(const float depth, const float bZ, const float tZ, const float y, const float height, const float bL, const float bR, const float tL, const float tR); 41 | void setupTrapezoidDepths(const float bottomDepth, const float topDepth, const float y, const float height, const float bL, const float bR, const float tL, const float tR); 42 | 43 | void setup(const float bottomDepth, const float topDepth, 44 | const float bZ, const float tZ, 45 | const float y, const float height, 46 | const float leftBottom, const float rightBottom, 47 | const float leftTop, const float rightTop); 48 | }; 49 | 50 | 51 | #endif // __CCPRIMITIVECUBE_H__ -------------------------------------------------------------------------------- /engine/source/tools/CCExternalAccessoryManager.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCExternalAccessoryManager.h 7 | * Description : Manages external accessories. 8 | * 9 | * Created : 17/01/14 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCEXTERNALACCESSORYMANAGER_H_ 15 | #define __CCEXTERNALACCESSORYMANAGER_H_ 16 | 17 | 18 | #ifdef IOS 19 | #ifdef __OBJC__ 20 | #include "CCDeviceExternalAccessoryManager.h" 21 | #else 22 | #define EAAccessory void 23 | #endif 24 | #else 25 | #define EAAccessory void 26 | #endif 27 | 28 | 29 | class CCAccessoryReader : public virtual CCActiveAllocation 30 | { 31 | public: 32 | virtual void readUpdate(const CCData &bytes) = 0; 33 | }; 34 | 35 | 36 | class CCExternalAccessory 37 | { 38 | public: 39 | ~CCExternalAccessory() 40 | { 41 | protocolStrings.deleteObjects(); 42 | } 43 | 44 | EAAccessory *accessory; 45 | uint connectionID; 46 | CCPtrList protocolStrings; 47 | }; 48 | 49 | 50 | class CCExternalAccessoryManager 51 | { 52 | protected: 53 | static CCPtrList accessoryList; 54 | 55 | public: 56 | static CCAccessoryReader *accessoryReader; 57 | 58 | 59 | public: 60 | static void Reset(); 61 | static void Stop(); 62 | 63 | static const CCPtrList& getAccessoryList() 64 | { 65 | return accessoryList; 66 | } 67 | 68 | static bool openSession(); 69 | static void closeSession(); 70 | 71 | static void setupControllerForAccessory(CCExternalAccessory *accessory, const char *protocol); 72 | 73 | static void addAccessory(EAAccessory *inAccessory); 74 | static void removeAccessory(EAAccessory *inAccessory); 75 | }; 76 | 77 | 78 | #endif // __CCEXTERNALACCESSORYMANAGER_H_ -------------------------------------------------------------------------------- /engine/source/rendering/CCRenderTools.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCRenderTools.h 7 | * Description : Helper rendering functions. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCRENDERTOOLS_H__ 15 | #define __CCRENDERTOOLS_H__ 16 | 17 | 18 | // Matrix functions 19 | //----------------- 20 | // Obsolete please use CCMatrix.h implementation 21 | extern void CCMatrixMulVec(const float matrix[16], const float in[4], float out[4]); 22 | extern void CCMatrixMulMat(const float a[16], const float b[16], float r[16]); 23 | extern bool CCMatrixInvert(const float m[16], float invOut[16]); 24 | 25 | // Render functions 26 | //----------------- 27 | extern void CCRenderSquare(const CCVector3 &start, const CCVector3 &end, const bool outlined=false); 28 | extern void CCRenderSquareYAxisAligned(const CCVector3 &start, const CCVector3 &end); 29 | extern void CCRenderSquarePoint(const CCPoint &position, const float &size); 30 | extern void CCRenderRectanglePoint(const CCPoint &position, const float &sizeX, const float &sizeY, const bool outlined=false); 31 | 32 | extern void CCRenderLine(const CCVector3 &start, const CCVector3 &end); 33 | extern void CCRenderCube(const bool outline); 34 | extern void CCRenderCubeMinMax(const CCVector3 min, const CCVector3 max, const bool outline); 35 | 36 | // Shader functions 37 | //----------------- 38 | extern void CCSetColour(const CCColour &colour); 39 | extern void CCSetColour(const float r, const float g, const float b, const float a); 40 | extern const CCColour& CCGetColour(); 41 | 42 | extern void CCSetTexCoords(const float *inUVs); 43 | extern void CCDefaultTexCoords(); 44 | extern void CCInverseTexCoords(); 45 | 46 | extern void CCRefreshRenderAttributes(); 47 | 48 | 49 | #endif // __CCRENDERTOOLS_H__ 50 | -------------------------------------------------------------------------------- /external/3dsloader/3dsloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ---------------- www.spacesimulator.net -------------- 3 | * ---- Space simulators and 3d engine tutorials ---- 4 | * 5 | * Author: Damiano Vitulli 6 | * 7 | * This program is released under the BSD licence 8 | * By using this program you agree to licence terms on spacesimulator.net copyright page 9 | * 10 | * 11 | * 3ds models loader 12 | * 13 | * File header: 3dsloader.h 14 | * 15 | */ 16 | 17 | /********************************************************** 18 | * 19 | * TYPES DECLARATION 20 | * 21 | *********************************************************/ 22 | 23 | // TODO: Optimize down vertices 24 | #define MAX_VERTICES 8000 // Max number of vertices (for each object) 25 | #define MAX_POLYGONS 12000 // Max number of polygons (for each object) 26 | 27 | // Our vertex type 28 | typedef struct{ 29 | float x,y,z; 30 | }vertex_type; 31 | 32 | // The polygon (triangle), 3 numbers that aim 3 vertices 33 | typedef struct{ 34 | int a,b,c; 35 | }polygon_type; 36 | 37 | // The mapcoord type, 2 texture coordinates for each vertex 38 | typedef struct{ 39 | float u,v; 40 | }mapcoord_type; 41 | 42 | // The object type 43 | typedef struct { 44 | char name[20]; 45 | 46 | int vertices_qty; 47 | int polygons_qty; 48 | 49 | vertex_type vertex[MAX_VERTICES]; 50 | vertex_type normal[MAX_VERTICES]; 51 | polygon_type polygon[MAX_POLYGONS]; 52 | mapcoord_type mapcoord[MAX_VERTICES]; 53 | } obj3ds_type; 54 | 55 | 56 | /********************************************************** 57 | * 58 | * FUNCTION Load3DS (obj_type_ptr, char *) 59 | * 60 | * This function loads a mesh from a 3ds file. 61 | * Please note that we are loading only the vertices, polygons and mapping lists. 62 | * If you need to load meshes with advanced features as for example: 63 | * multi objects, materials, lights and so on, you must insert other chunk parsers. 64 | * 65 | *********************************************************/ 66 | 67 | extern int Load3DS(obj3ds_type *p_object, const char *p_filename); 68 | 69 | extern void Calc3DSNormals(obj3ds_type *p_object); 70 | 71 | -------------------------------------------------------------------------------- /engine/source/tools/CCTools.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTools.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include 12 | #include "CCFileManager.h" 13 | 14 | 15 | #ifdef DEBUGON 16 | 17 | 18 | #ifdef ALLOW_DEBUGLOG 19 | #if defined WP8 || defined WIN8 20 | #include 21 | void DEBUGLOG(const char *text, ...) 22 | { 23 | CCText output = text; 24 | 25 | va_list argp; 26 | va_start(argp, text); 27 | char *next = va_arg(argp, char *); 28 | va_end(argp); 29 | 30 | OutputDebugStringA( output.buffer ); 31 | } 32 | #endif 33 | #endif 34 | 35 | void CCDebugAssert(const bool condition, const char *file, const int line, const char *message) 36 | { 37 | if( !condition ) 38 | { 39 | DEBUGLOG( "%s %i \n", file, line ); 40 | fflush( stdout ); 41 | if( message ) 42 | { 43 | DEBUGLOG( "ASSERT: %s \n", message ); 44 | } 45 | 46 | // Root call to Java on Android for ease of debugging 47 | #ifdef ANDROID 48 | CCJNI::Assert( file, line, message ); 49 | #endif 50 | assert( condition ); 51 | } 52 | } 53 | 54 | #endif 55 | 56 | 57 | 58 | bool CCSaveData(const char *id, const char *data) 59 | { 60 | if( id != NULL && data != NULL ) 61 | { 62 | CCText file = "cache/"; 63 | file += id; 64 | CCFileManager::SaveCachedFile( file.buffer, data, strlen( data ) ); 65 | return true; 66 | } 67 | return false; 68 | } 69 | 70 | 71 | bool CCLoadData(const char *id, CCText &result) 72 | { 73 | CCText file = "cache/"; 74 | file += id; 75 | 76 | if( CCFileManager::DoesFileExist( file.buffer, Resource_Cached ) ) 77 | { 78 | const int fileSize = CCFileManager::GetFile( file.buffer, result, Resource_Cached, false, NULL ); 79 | if( fileSize > 0 ) 80 | { 81 | return true; 82 | } 83 | } 84 | 85 | return false; 86 | } 87 | -------------------------------------------------------------------------------- /external/zlib-1.2.3/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | This function can be used to decompress a whole file at once if the 20 | input file is mmap'ed. 21 | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 23 | enough memory, Z_BUF_ERROR if there was not enough room in the output 24 | buffer, or Z_DATA_ERROR if the input data was corrupted. 25 | */ 26 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 27 | Bytef *dest; 28 | uLongf *destLen; 29 | const Bytef *source; 30 | uLong sourceLen; 31 | { 32 | z_stream stream; 33 | int err; 34 | 35 | stream.next_in = (Bytef*)source; 36 | stream.avail_in = (uInt)sourceLen; 37 | /* Check for source > 64K on 16-bit machine: */ 38 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 39 | 40 | stream.next_out = dest; 41 | stream.avail_out = (uInt)*destLen; 42 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 43 | 44 | stream.zalloc = (alloc_func)0; 45 | stream.zfree = (free_func)0; 46 | 47 | err = inflateInit(&stream); 48 | if (err != Z_OK) return err; 49 | 50 | err = inflate(&stream, Z_FINISH); 51 | if (err != Z_STREAM_END) { 52 | inflateEnd(&stream); 53 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 54 | return Z_DATA_ERROR; 55 | return err; 56 | } 57 | *destLen = stream.total_out; 58 | 59 | err = inflateEnd(&stream); 60 | return err; 61 | } 62 | -------------------------------------------------------------------------------- /engine/source/objects/CCMoveable.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCMoveable.h 7 | * Description : A scene managed moveable object. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | class CCMoveable : public CCCollideable 15 | { 16 | public: 17 | typedef CCCollideable super; 18 | 19 | CCMoveable(); 20 | 21 | // CCObject 22 | virtual bool update(const CCTime &time); 23 | 24 | // CCCollideable 25 | virtual CCCollideable* requestCollisionWith(CCCollideable *collidedWith); 26 | virtual bool isMoveable() { return true; } 27 | 28 | virtual void updateMovement(const float delta); 29 | virtual float applyMovementDirection(const float delta); 30 | 31 | virtual void applyVelocity(const float delta, const float movementMagnitude); 32 | float getCollisionPosition(const float thisObjectPosition, const float thisObjectBounds, const float collidedObjectPosition, const float collidedObjectBounds); 33 | CCCollideable* applyHorizontalVelocity(const float velocityX, const float velocityZ); 34 | CCCollideable* applyVerticalVelocity(const float increment); 35 | 36 | virtual void reportVerticalCollision(const CCCollideable *collidedWith); 37 | 38 | static void setGravityForce(const float force) { gravityForce = force; } 39 | 40 | inline void setVelocity(const float x, const float y, const float z) { movementVelocity.x = x; movementVelocity.y = y; movementVelocity.z = z; } 41 | inline void setAdditionalVelocity(const float x, const float y, const float z) { additionalVelocity.x = x; additionalVelocity.y = y; additionalVelocity.z = z; } 42 | inline void incrementAdditionalVelocity(const float x, const float y, const float z) { additionalVelocity.x += x; additionalVelocity.y += y; additionalVelocity.z += z; } 43 | 44 | bool moveable; 45 | float movementSpeed; 46 | CCVector3 movementDirection; 47 | 48 | protected: 49 | CCVector3 velocity; 50 | CCVector3 movementVelocity; 51 | CCVector3 additionalVelocity; 52 | float decelerationSpeed; 53 | 54 | bool gravity; 55 | static float gravityForce; 56 | }; 57 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureBase.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureBase.h 7 | * Description : Represents a texture. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCTEXTUREBASE_H__ 15 | #define __CCTEXTUREBASE_H__ 16 | 17 | 18 | struct CCTextureLoadOptions; 19 | 20 | 21 | class CCTextureName 22 | { 23 | public: 24 | CCTextureName() 25 | { 26 | glName = 0; 27 | } 28 | 29 | GLuint name() const { return glName; } 30 | 31 | protected: 32 | GLuint glName; 33 | }; 34 | 35 | 36 | class CCTextureBase : public CCTextureName, public virtual CCActiveAllocation 37 | { 38 | protected: 39 | uint32_t imageWidth, imageHeight; 40 | uint32_t allocatedWidth, allocatedHeight; 41 | uint32_t allocatedBytes; 42 | 43 | 44 | 45 | public: 46 | CCTextureBase(); 47 | virtual ~CCTextureBase(); 48 | 49 | void loadAndCreateAsync(const char *path, const CCResourceType resourceType, const CCTextureLoadOptions options, CCLambdaSafeCallback *callback); 50 | 51 | bool loadAndCreateSync(const char *path, const CCResourceType resourceType, const CCTextureLoadOptions options); 52 | 53 | #ifndef QT 54 | protected: 55 | #else 56 | virtual bool loadData(const char *data, const int length) = 0; 57 | #endif 58 | virtual bool load(const char *path, const CCResourceType resourceType) = 0; 59 | virtual void createGLTexture(const CCTextureLoadOptions options) = 0; 60 | 61 | public: 62 | float getImageWidth() const { return (float)imageWidth; } 63 | float getImageHeight() const { return (float)imageHeight; } 64 | 65 | virtual float getRawWidth() const { return (float)imageWidth; } 66 | virtual float getRawHeight() const { return (float)imageHeight; } 67 | 68 | float getAllocatedWidth() const { return (float)allocatedWidth; } 69 | float getAllocatedHeight() const { return (float)allocatedHeight; } 70 | int getBytes() { return allocatedBytes; } 71 | 72 | static bool ExtensionSupported(const char* extension); 73 | }; 74 | 75 | 76 | #endif // __CCTEXTUREBASE_H__ 77 | -------------------------------------------------------------------------------- /external/libjpeg-8d/jcinit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcinit.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains initialization logic for the JPEG compressor. 9 | * This routine is in charge of selecting the modules to be executed and 10 | * making an initialization call to each one. 11 | * 12 | * Logically, this code belongs in jcmaster.c. It's split out because 13 | * linking this routine implies linking the entire compression library. 14 | * For a transcoding-only application, we want to be able to use jcmaster.c 15 | * without linking in the whole library. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | 22 | 23 | /* 24 | * Master selection of compression modules. 25 | * This is done once at the start of processing an image. We determine 26 | * which modules will be used and give them appropriate initialization calls. 27 | */ 28 | 29 | GLOBAL(void) 30 | jinit_compress_master (j_compress_ptr cinfo) 31 | { 32 | /* Initialize master control (includes parameter checking/processing) */ 33 | jinit_c_master_control(cinfo, FALSE /* full compression */); 34 | 35 | /* Preprocessing */ 36 | if (! cinfo->raw_data_in) { 37 | jinit_color_converter(cinfo); 38 | jinit_downsampler(cinfo); 39 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); 40 | } 41 | /* Forward DCT */ 42 | jinit_forward_dct(cinfo); 43 | /* Entropy encoding: either Huffman or arithmetic coding. */ 44 | if (cinfo->arith_code) 45 | jinit_arith_encoder(cinfo); 46 | else { 47 | jinit_huff_encoder(cinfo); 48 | } 49 | 50 | /* Need a full-image coefficient buffer in any multi-pass mode. */ 51 | jinit_c_coef_controller(cinfo, 52 | (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); 53 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); 54 | 55 | jinit_marker_writer(cinfo); 56 | 57 | /* We can now tell the memory manager to allocate virtual arrays. */ 58 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 59 | 60 | /* Write the datastream header (SOI) immediately. 61 | * Frame and scan headers are postponed till later. 62 | * This lets application insert special markers after the SOI. 63 | */ 64 | (*cinfo->marker->write_file_header) (cinfo); 65 | } 66 | -------------------------------------------------------------------------------- /engine/source/objects/CCTile3DFrameBuffer.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTile3DFrameBuffer.h 7 | * Description : A tile which displays the contents of a frame buffer 8 | * 9 | * Created : 07/02/12 10 | *----------------------------------------------------------- 11 | */ 12 | 13 | #ifndef __CCTILE3DFRAMEBUFFER_H__ 14 | #define __CCTILE3DFRAMEBUFFER_H__ 15 | 16 | 17 | class CCTile3DFrameBuffer : public CCTile3DButton 18 | { 19 | public: 20 | typedef CCTile3DButton super; 21 | 22 | CCTile3DFrameBuffer(CCSceneBase *scene); 23 | virtual void destruct(); 24 | 25 | // CCObject 26 | virtual bool update(const CCTime &time); 27 | 28 | virtual void renderModel(const bool alpha); 29 | 30 | public: 31 | // Touchable 32 | virtual bool handleProjectedTouch(const CCCameraProjectionResults &cameraProjectionResults, 33 | const CCCollideable *hitObject, 34 | const CCVector3 &hitPosition, 35 | const CCScreenTouches &touch, 36 | const CCTouchAction touchAction); 37 | 38 | virtual bool handleSceneTouch(const CCCameraProjectionResults &cameraProjectionResults, 39 | const CCCollideable *hitObject, 40 | const CCVector3 &hitPosition, 41 | const CCScreenTouches &screenTouch, 42 | const CCTouchAction touchAction); 43 | 44 | void setFrameBufferID(const int frameBufferID); 45 | void linkScene(CCSceneBase *scene) 46 | { 47 | linkedScenes.add( scene ); 48 | scene->enabled = false; 49 | } 50 | 51 | static void ResetRenderFlag() 52 | { 53 | renderedThisFrame = 0; 54 | } 55 | 56 | protected: 57 | int frameBufferID; 58 | CCPtrList linkedScenes; 59 | 60 | bool sceneControlsActive; 61 | CCScreenTouches touches[CCControls::max_touches]; 62 | 63 | bool firstRender; 64 | static CCPtrList frameBuffers; 65 | static uint renderedThisFrame; 66 | }; 67 | 68 | 69 | #endif // __CCTILE3DFRAMEBUFFER_H__ 70 | -------------------------------------------------------------------------------- /external/zlib-1.2.3/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of dynamic tree. The maximum found in a long but non- 39 | exhaustive search was 1444 code structures (852 for length/literals 40 | and 592 for distances, the latter actually the result of an 41 | exhaustive search). The true maximum is not known, but the value 42 | below is more than safe. */ 43 | #define ENOUGH 2048 44 | #define MAXD 592 45 | 46 | /* Type of code to build for inftable() */ 47 | typedef enum { 48 | CODES, 49 | LENS, 50 | DISTS 51 | } codetype; 52 | 53 | extern int inflate_table OF((codetype type, unsigned short FAR *lens, 54 | unsigned codes, code FAR * FAR *table, 55 | unsigned FAR *bits, unsigned short FAR *work)); 56 | -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitiveBase.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPrimitiveBase.h 7 | * Description : Base drawable component. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCPRIMITIVEBASE_H__ 15 | #define __CCPRIMITIVEBASE_H__ 16 | 17 | 18 | class CCPrimitiveBase : public CCBaseType, public virtual CCActiveAllocation 19 | { 20 | typedef CCBaseType super; 21 | 22 | protected: 23 | long primitiveID; 24 | 25 | float *vertices; 26 | float *normals; 27 | 28 | struct TextureInfo 29 | { 30 | TextureInfo() 31 | { 32 | primaryIndex = secondaryIndex = 0; 33 | } 34 | int primaryIndex; 35 | int secondaryIndex; 36 | 37 | }; 38 | TextureInfo *textureInfo; 39 | int frameBufferID; 40 | 41 | 42 | 43 | public: 44 | CCPrimitiveBase(const long primitiveID=-1); 45 | 46 | // CCBaseType 47 | virtual void destruct(); 48 | 49 | long getPrimitiveID() const 50 | { 51 | return primitiveID; 52 | } 53 | 54 | // name specifies local path to the texture 55 | // resourceType specifies is the data is generated during runtime or part of the install package 56 | // alpha specifies if the image should function through the transparency pipe 57 | void setTexture(const char *file, CCResourceType resourceType, CCLambdaCallback *onDownloadCallback=NULL, 58 | const CCTextureLoadOptions options=CCTextureLoadOptions()); 59 | virtual void setTextureHandleIndex(const int index); 60 | inline int getTextureHandleIndex() 61 | { 62 | if( textureInfo != NULL ) 63 | { 64 | return textureInfo->primaryIndex; 65 | } 66 | return -1; 67 | } 68 | void removeTexture(); 69 | 70 | void setFrameBufferID(const int frameBufferID) { this->frameBufferID = frameBufferID; } 71 | 72 | // Adjust the model's UVs to match the loaded texture, 73 | // as non-square textures load into a square texture which means the mapping requires adjustment 74 | virtual void adjustTextureUVs() {}; 75 | 76 | virtual void render(); 77 | virtual void renderVertices(const bool textured) = 0; 78 | virtual void renderOutline() {}; 79 | }; 80 | 81 | 82 | #endif // __CCPRIMITIVEBASE_H__ 83 | -------------------------------------------------------------------------------- /engine/source/tools/CCCallbacks.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCCallbacks.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | 12 | 13 | // CCActiveAllocation 14 | CCPtrList CCActiveAllocation::ActiveAllocations; 15 | long CCActiveAllocation::NextAllocationID = 0; 16 | 17 | 18 | CCActiveAllocation::CCActiveAllocation() 19 | { 20 | CCNativeThreadLock(); 21 | 22 | #ifdef DEBUGON 23 | for( int i=0; ilazyID == pendingID ) 73 | { 74 | CCNativeThreadUnlock(); 75 | return true; 76 | } 77 | 78 | #ifdef DEBUGON 79 | 80 | else 81 | { 82 | //DEBUGLOG( "Detected that the callback has been deleted and the memory has been replaced by another callback\n" ); 83 | } 84 | 85 | #else 86 | 87 | break; 88 | 89 | #endif 90 | } 91 | } 92 | CCNativeThreadUnlock(); 93 | return false; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /engine/source/rendering/CCModelBase.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCModelBase.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCPrimitives.h" 12 | 13 | 14 | CCModelBase::CCModelBase(const long jsID) 15 | { 16 | if( jsID != -1 ) 17 | { 18 | this->jsID = jsID; 19 | } 20 | 21 | shader = "basic"; 22 | } 23 | 24 | 25 | void CCModelBase::destruct() 26 | { 27 | models.deleteObjectsAndList(); 28 | primitives.deleteObjectsAndList(); 29 | 30 | super::destruct(); 31 | } 32 | 33 | 34 | void CCModelBase::render(const bool alpha) 35 | { 36 | #if defined PROFILEON 37 | CCProfiler profile( "CCModelBase::render()" ); 38 | #endif 39 | 40 | if( renderable ) 41 | { 42 | GLPushMatrix(); 43 | { 44 | refreshModelMatrix(); 45 | GLMultMatrixf( modelMatrix ); 46 | 47 | gRenderer->setShader( shader ); 48 | 49 | if( colour != NULL ) 50 | { 51 | CCSetColour( *colour ); 52 | } 53 | 54 | if( alpha == false || CCGetColour().alpha > 0.0f ) 55 | { 56 | for( int i=0; irender(); 60 | } 61 | } 62 | 63 | for( int i=0; irender( alpha ); 67 | if( colour != NULL ) 68 | { 69 | CCSetColour( *colour ); 70 | } 71 | } 72 | } 73 | GLPopMatrix(); 74 | } 75 | } 76 | 77 | 78 | void CCModelBase::addModel(CCModelBase *model, const int index) 79 | { 80 | CCASSERT( model != this ); 81 | models.add( model ); 82 | 83 | if( index != -1 ) 84 | { 85 | models.reinsert( model, index ); 86 | } 87 | } 88 | 89 | 90 | void CCModelBase::removeModel(CCModelBase *model) 91 | { 92 | CCASSERT( model != this ); 93 | models.remove( model ); 94 | } 95 | 96 | 97 | void CCModelBase::addPrimitive(CCPrimitiveBase *primitive) 98 | { 99 | primitives.add( primitive ); 100 | } 101 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureFontPageFile.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureFontPageFile.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCTextureFontPageFile.h" 12 | #include "CCFileManager.h" 13 | 14 | 15 | CCTextureFontPageFile::CCTextureFontPageFile(const char *name) 16 | { 17 | this->name = name; 18 | } 19 | 20 | 21 | CCTextureFontPageFile::~CCTextureFontPageFile() 22 | { 23 | } 24 | 25 | 26 | bool CCTextureFontPageFile::load(const int textureIndex, const char *csv) 27 | { 28 | this->textureIndex = textureIndex; 29 | this->csv = csv; 30 | 31 | CCResourceType resourceType = CCFileManager::FindFile( csv ); 32 | if( resourceType != Resource_Unknown ) 33 | { 34 | 35 | // Load the descriptor file 36 | CCText textData; 37 | CCFileManager::GetFile( csv, textData, resourceType ); 38 | 39 | CCPtrList lettersSplit; 40 | textData.split( lettersSplit, "\n" ); 41 | 42 | CCText rawLetterData; 43 | CCPtrList letterDataSplit; 44 | for( int i=0; itextureManager->setTextureIndex( textureIndex ); 80 | } 81 | -------------------------------------------------------------------------------- /external/zlib-1.2.3/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; 79 | } 80 | -------------------------------------------------------------------------------- /external/libpng/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the header file. */ 5 | #define HAVE_DLFCN_H 0 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_INTTYPES_H 0 9 | 10 | /* Define to 1 if you have the `m' library (-lm). */ 11 | #define HAVE_LIBM 1 12 | 13 | /* Define to 1 if you have the `z' library (-lz). */ 14 | #define HAVE_LIBZ 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_MALLOC_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_MEMORY_H 0 21 | 22 | /* Define to 1 if you have the `memset' function. */ 23 | #define HAVE_MEMSET 1 24 | 25 | /* Define to 1 if you have the `pow' function. */ 26 | /* #undef HAVE_POW */ 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_STDINT_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_STDLIB_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_STRINGS_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_STRING_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_SYS_STAT_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_SYS_TYPES_H 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_UNISTD_H 1 48 | 49 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 50 | */ 51 | #define LT_OBJDIR ".libs/" 52 | 53 | /* Name of package */ 54 | #define PACKAGE "libpng" 55 | 56 | /* Define to the address where bug reports for this package should be sent. */ 57 | #define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net" 58 | 59 | /* Define to the full name of this package. */ 60 | #define PACKAGE_NAME "libpng" 61 | 62 | /* Define to the full name and version of this package. */ 63 | #define PACKAGE_STRING "libpng 1.4.1" 64 | 65 | /* Define to the one symbol short name of this package. */ 66 | #define PACKAGE_TARNAME "libpng" 67 | 68 | /* Define to the home page for this package. */ 69 | #define PACKAGE_URL "" 70 | 71 | /* Define to the version of this package. */ 72 | #define PACKAGE_VERSION "1.4.1" 73 | 74 | /* Define to 1 if you have the ANSI C header files. */ 75 | #define STDC_HEADERS 1 76 | 77 | /* Define to 1 if your declares `struct tm'. */ 78 | /* #undef TM_IN_SYS_TIME */ 79 | 80 | /* Version number of package */ 81 | #define VERSION "1.4.1" 82 | 83 | /* Define to empty if `const' does not conform to ANSI C. */ 84 | /* #undef const */ 85 | 86 | /* Define to `unsigned int' if does not define. */ 87 | /* #undef size_t */ 88 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/jansson_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef JANSSON_PRIVATE_H 9 | #define JANSSON_PRIVATE_H 10 | 11 | #include 12 | #include "jansson.h" 13 | #include "hashtable.h" 14 | #include "strbuffer.h" 15 | 16 | #define container_of(ptr_, type_, member_) \ 17 | ((type_ *)((char *)ptr_ - offsetof(type_, member_))) 18 | 19 | /* On some platforms, max() may already be defined */ 20 | #ifndef max 21 | #define max(a, b) ((a) > (b) ? (a) : (b)) 22 | #endif 23 | 24 | /* va_copy is a C99 feature. In C89 implementations, it's sometimes 25 | available as __va_copy. If not, memcpy() should do the trick. */ 26 | #ifndef va_copy 27 | #ifdef __va_copy 28 | #define va_copy __va_copy 29 | #else 30 | #define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) 31 | #endif 32 | #endif 33 | 34 | typedef struct { 35 | json_t json; 36 | hashtable_t hashtable; 37 | size_t serial; 38 | int visited; 39 | } json_object_t; 40 | 41 | typedef struct { 42 | json_t json; 43 | size_t size; 44 | size_t entries; 45 | json_t **table; 46 | int visited; 47 | } json_array_t; 48 | 49 | typedef struct { 50 | json_t json; 51 | char *value; 52 | } json_string_t; 53 | 54 | typedef struct { 55 | json_t json; 56 | double value; 57 | } json_real_t; 58 | 59 | typedef struct { 60 | json_t json; 61 | json_int_t value; 62 | } json_integer_t; 63 | 64 | #define json_to_object(json_) container_of(json_, json_object_t, json) 65 | #define json_to_array(json_) container_of(json_, json_array_t, json) 66 | #define json_to_string(json_) container_of(json_, json_string_t, json) 67 | #define json_to_real(json_) container_of(json_, json_real_t, json) 68 | #define json_to_integer(json_) container_of(json_, json_integer_t, json) 69 | 70 | void jsonp_error_init(json_error_t *error, const char *source); 71 | void jsonp_error_set_source(json_error_t *error, const char *source); 72 | void jsonp_error_set(json_error_t *error, int line, int column, 73 | size_t position, const char *msg, ...); 74 | void jsonp_error_vset(json_error_t *error, int line, int column, 75 | size_t position, const char *msg, va_list ap); 76 | 77 | /* Locale independent string<->double conversions */ 78 | int jsonp_strtod(strbuffer_t *strbuffer, double *out); 79 | int jsonp_dtostr(char *buffer, size_t size, double value); 80 | 81 | /* Wrappers for custom memory functions */ 82 | void* jsonp_malloc(size_t size); 83 | void jsonp_free(void *ptr); 84 | char *jsonp_strndup(const char *str, size_t length); 85 | char *jsonp_strdup(const char *str); 86 | 87 | /* Windows compatibility */ 88 | #ifdef _WIN32 89 | #define snprintf _snprintf 90 | #define vsnprintf _vsnprintf 91 | #endif 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /engine/source/tools/CCTypes.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTypes.h 7 | * Description : Contains base structures. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCTYPES_H__ 15 | #define __CCTYPES_H__ 16 | 17 | 18 | #include "CCTools.h" 19 | 20 | 21 | typedef unsigned short ushort; 22 | 23 | 24 | enum CCResourceType 25 | { 26 | Resource_Unknown, 27 | Resource_Cached, 28 | #ifdef IOS 29 | Resource_Temp, 30 | #else 31 | Resource_Temp = Resource_Cached, 32 | #endif 33 | Resource_Packaged 34 | }; 35 | 36 | 37 | class CCBaseType 38 | { 39 | public: 40 | virtual ~CCBaseType(); 41 | virtual void destruct() = 0; 42 | }; 43 | 44 | 45 | class CCUpdater : public CCBaseType 46 | { 47 | public: 48 | typedef CCBaseType super; 49 | 50 | CCUpdater() 51 | { 52 | #ifdef DEBUGON 53 | destructCalled = false; 54 | #endif 55 | } 56 | 57 | virtual ~CCUpdater() 58 | { 59 | #ifdef DEBUGON 60 | CCASSERT( destructCalled ); 61 | #endif 62 | } 63 | 64 | virtual void destruct() 65 | { 66 | #ifdef DEBUGON 67 | destructCalled = true; 68 | #endif 69 | } 70 | 71 | virtual bool update(const float delta) = 0; 72 | virtual void finish() {} 73 | 74 | #ifdef DEBUGON 75 | protected: 76 | bool destructCalled; 77 | #endif 78 | }; 79 | 80 | 81 | #include "CCArray.h" 82 | 83 | 84 | struct CCData 85 | { 86 | CCData(); 87 | ~CCData(); 88 | 89 | void setSize(const uint inLength); 90 | void ensureLength(const uint minLength, const bool keepData=false); 91 | void set(const char *data, const uint inLength); 92 | void append(const char *data, const uint inLength); 93 | 94 | CCData& operator=(const CCData &other); 95 | 96 | CCData& operator+=(const CCText &other); 97 | CCData& operator+=(const char *other); 98 | CCData& operator+=(const char other); 99 | CCData& operator+=(const int value); 100 | CCData& operator+=(const uint value); 101 | CCData& operator+=(const long value); 102 | CCData& operator+=(const long long value); 103 | CCData& operator+=(const unsigned long long value); 104 | CCData& operator+=(const float value); 105 | CCData& operator+=(const double value); 106 | 107 | protected: 108 | void zero(); 109 | 110 | public: 111 | uint length; 112 | char *buffer; 113 | uint bufferSize; 114 | }; 115 | 116 | 117 | #include "CCString.h" 118 | 119 | 120 | #endif // __CCBASETYPES_H__ 121 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureFontPage.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureFontPage.h 7 | * Description : Handles rendering text. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCTEXTUREFONTPAGE_H__ 15 | #define __CCTEXTUREFONTPAGE_H__ 16 | 17 | 18 | #include "CCTextureBase.h" 19 | 20 | class CCTextureFontPage 21 | { 22 | protected: 23 | bool loaded; 24 | CCText name; 25 | 26 | typedef struct 27 | { 28 | CCPoint start, end; 29 | CCSize size; 30 | } Letter; 31 | enum { num_letters = 256 }; 32 | Letter letters[num_letters]; 33 | 34 | class CachedTextMesh 35 | { 36 | public: 37 | CachedTextMesh() 38 | { 39 | textHeight = 0.0f; 40 | centeredX = false; 41 | totalLineHeight = 0.0f; 42 | vertices = NULL; 43 | uvs = NULL; 44 | vertexCount = 0; 45 | lastDrawTime = 0.0f; 46 | } 47 | 48 | ~CachedTextMesh() 49 | { 50 | if( vertices != NULL ) 51 | { 52 | gRenderer->derefVertexPointer( ATTRIB_VERTEX, vertices ); 53 | free( vertices ); 54 | } 55 | 56 | if( uvs != NULL ) 57 | { 58 | free( uvs ); 59 | } 60 | } 61 | 62 | // input 63 | CCText text; 64 | float textHeight; 65 | bool centeredX; 66 | 67 | // calculated 68 | float totalLineHeight; 69 | 70 | // render 71 | float *vertices; 72 | float *uvs; 73 | uint vertexCount; 74 | 75 | // life management 76 | float lastDrawTime; 77 | }; 78 | CCPtrList cachedMeshes; 79 | 80 | 81 | 82 | public: 83 | CCTextureFontPage(); 84 | virtual ~CCTextureFontPage() {} 85 | 86 | inline const char* getName() const { return name.buffer; } 87 | float getCharacterWidth(const char character, const float size) const; 88 | float getWidth(const char *text, const uint length, const float size) const; 89 | float getHeight(const char *text, const uint length, const float size) const; 90 | 91 | void renderText(const char *text, const uint length, const float height=1.0f, const bool centeredX=true); 92 | 93 | protected: 94 | const CachedTextMesh* getTextMesh(const char *text, const uint length, const float height, const bool centeredX); 95 | CachedTextMesh* buildTextMesh(const char *text, const uint length, const float height, const bool centeredX); 96 | 97 | public: 98 | void renderOutline(CCVector3 start, CCVector3 end, const float multiple) const; 99 | void view() const; 100 | const Letter* getLetter(const char character) const; 101 | 102 | protected: 103 | virtual void bindTexturePage() const = 0; 104 | }; 105 | 106 | 107 | #endif // __TEXTUREFONTPAGE_H__ 108 | -------------------------------------------------------------------------------- /engine/source/objects/CCRenderable.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCRenerable.h 7 | * Description : A renderable component. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCRENDERABLE_H__ 15 | #define __CCRENDERABLE_H__ 16 | 17 | 18 | class CCRenderable : public CCBaseType 19 | { 20 | protected: 21 | long jsID; // Used for js communication 22 | // Note: If we create 300 objects a second we'll run out of ids after 82 days (2147483647/300)/60/60/24 23 | 24 | bool renderable; 25 | 26 | CCVector3 position; 27 | 28 | CCMatrix modelMatrix; 29 | bool updateModelMatrix; 30 | 31 | CCMatrix worldMatrix; 32 | bool updateWorldMatrix; 33 | 34 | CCColour *colour; 35 | 36 | public: 37 | CCVector3 rotation; 38 | CCVector3 *scale; 39 | 40 | 41 | public: 42 | typedef CCBaseType super; 43 | 44 | CCRenderable(); 45 | 46 | // CCBaseType 47 | virtual void destruct(); 48 | 49 | long getJSID() const 50 | { 51 | return jsID; 52 | } 53 | 54 | virtual void dirtyModelMatrix(); 55 | virtual void dirtyWorldMatrix(); 56 | 57 | bool shouldRender() 58 | { 59 | return renderable; 60 | } 61 | 62 | void setRenderable(const bool toggle) 63 | { 64 | renderable = toggle; 65 | } 66 | 67 | virtual void refreshModelMatrix(); 68 | void refreshWorldMatrix(const CCMatrix *parentMatrix); 69 | 70 | CCMatrix& getModelMatrix() { return modelMatrix; } 71 | 72 | inline const CCVector3& getConstPosition() const { return position; } 73 | inline CCVector3& getPosition() { return position; } 74 | void setPosition(const CCVector3 &vector); 75 | virtual void setPositionXYZ(const float x, const float y, const float z); 76 | void setPositionX(const float x); 77 | void setPositionY(const float y); 78 | void setPositionZ(const float z); 79 | void setPositionXY(const float x, const float z); 80 | void setPositionXZ(const float x, const float z); 81 | void setPositionYZ(const float y, const float z); 82 | 83 | void translate(CCVector3 *vector); 84 | virtual void translate(const float x, const float y, const float z); 85 | 86 | virtual void rotationUpdated(); 87 | void setRotation(const CCVector3 &vector); 88 | void setRotationY(const float y); 89 | void rotateX(const float x); 90 | void rotateY(const float y); 91 | void rotateZ(const float z); 92 | 93 | void setScale(const float value); 94 | void setScale(const float x, const float y, const float z); 95 | 96 | inline CCColour* getColour() { return colour; } 97 | }; 98 | 99 | 100 | #endif // __CCRENDERABLE_H__ 101 | -------------------------------------------------------------------------------- /engine/source/ai/CCPathFinderNetwork.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPathFinderNetwork 7 | * Description : Network of nodes used for path finding 8 | * 9 | * Created : 03/05/10 10 | *----------------------------------------------------------- 11 | */ 12 | 13 | #ifndef __CCPATHFINDERNETWORK_H__ 14 | #define __CCPATHFINDERNETWORK_H__ 15 | 16 | 17 | class CCPathFinderNetwork 18 | { 19 | public: 20 | CCPathFinderNetwork(); 21 | ~CCPathFinderNetwork(); 22 | 23 | void view(); 24 | 25 | void addNode(const CCVector3 point, CCCollideable *parent=NULL); 26 | void addCollideable(CCCollideable *collideable, const CCVector3 &extents); 27 | void linkDistantNodes(); 28 | void removeCollideable(CCCollideable *collideable); 29 | void addFillerNodes(CCCollideable *collideable); 30 | void removeFillerNodes(); 31 | 32 | void clear(); 33 | 34 | // Connect our nodes 35 | void connect(); 36 | 37 | uint findClosestNodes(const CCVector3 &position, const float &radius, const CCVector3 **vectors, const uint &length); 38 | 39 | struct PathNode 40 | { 41 | PathNode() 42 | { 43 | parent = NULL; 44 | } 45 | 46 | CCVector3 point; 47 | 48 | struct PathConnection 49 | { 50 | float distance; 51 | float angle; 52 | const PathNode *node; 53 | }; 54 | 55 | CCCollideable *parent; 56 | CCPtrList connections; 57 | }; 58 | const PathNode* findClosestNodeToPathTarget(CCCollideable *objectToPath, const CCVector3 &position, const bool withConnections); 59 | const PathNode* findClosestNode(const CCVector3 &position); 60 | 61 | struct Path 62 | { 63 | Path() 64 | { 65 | endDirection = 0; 66 | distance = 0.0f; 67 | } 68 | 69 | int directions[50]; 70 | int endDirection; 71 | float distance; 72 | }; 73 | bool findPath(CCCollideable *objectToPath, Path &pathResult, const PathNode *fromNode, const PathNode *toNode); 74 | 75 | protected: 76 | template struct NodesList : public CCPtrList 77 | { 78 | NodesList() 79 | { 80 | this->allocate( TLENGTH ); 81 | } 82 | 83 | bool add(T *node) 84 | { 85 | CCPtrList::add( node ); 86 | if( this->length < this->allocated ) 87 | { 88 | return true; 89 | } 90 | return false; 91 | } 92 | }; 93 | 94 | // Used for path finding 95 | Path path; 96 | const PathNode *pathingFrom; 97 | bool followPath(CCCollideable *objectToPath, 98 | Path &path, const int currentDirection, 99 | const float currentDistance, 100 | NodesList &previousNode, 101 | const PathNode *fromNode, const PathNode *toNode); 102 | 103 | NodesList nodes; 104 | bool connectingNodes; 105 | }; 106 | 107 | 108 | #endif // __CCPATHFINDERNETWORK_H__ 109 | -------------------------------------------------------------------------------- /engine/source/tools/CCFileManager.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCFileManager.h 7 | * Description : Handles loading files between platforms. 8 | * 9 | * Created : 11/05/11 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCFILEMANAGER_H__ 15 | #define __CCFILEMANAGER_H__ 16 | 17 | 18 | #include "CCTypes.h" 19 | #include "CCCallbacks.h" 20 | #include 21 | 22 | class CCIOCallback : public CCLambdaCallback 23 | { 24 | public: 25 | CCIOCallback(const int inPriority) 26 | { 27 | priority = inPriority; 28 | exists = false; 29 | } 30 | 31 | // Run this before IO is performed to verify the lambda of the call is still active 32 | virtual bool isCallbackActive() = 0; 33 | 34 | CCText filePath; 35 | int priority; 36 | bool exists; 37 | }; 38 | 39 | 40 | class CCFileManager 41 | { 42 | public: 43 | virtual ~CCFileManager() {} 44 | 45 | static CCFileManager* File(CCResourceType resourceType); 46 | virtual bool open(const char *filePath) = 0; 47 | virtual void close() = 0; 48 | 49 | virtual uint read(void *dest, const uint size) = 0; 50 | 51 | virtual void seek(const uint size) = 0; 52 | virtual bool endOfFile() = 0; 53 | virtual uint size() = 0; 54 | 55 | protected: 56 | // data pointer must be freed with a call to FREE_POINTER 57 | static int GetFileData(const char *fullFilePath, char **data, CCResourceType resourceType, const bool assertOnFail=true); 58 | static int GetFileSize(const char *fullFilePath, CCResourceType resourceType, const bool assertOnFail=true); 59 | 60 | public: 61 | static void GetFilePath(CCText &fullFilePath, const char *filePath, CCResourceType resourceType); 62 | 63 | static int GetFile(const char *filePath, CCData &fileData, CCResourceType resourceType=Resource_Unknown, const bool assertOnFail=true, struct stat *info=NULL); 64 | 65 | static int GetFileInfo(const char *filePath, CCResourceType resourceType=Resource_Unknown, const bool assertOnFail=true, struct stat *info=NULL); 66 | 67 | static bool SaveCachedFile(const char *filePath, const char *data, const int length); 68 | static bool DeleteCachedFile(const char *filePath, const bool checkIfExists=true); 69 | static bool RenameCachedFile(const char *oldFile, CCResourceType resourceType, const char *newFile); 70 | 71 | static bool DeleteFile(const char *filePath, CCResourceType resourceType, const bool checkIfExists=true); 72 | 73 | static void ReadyIO(); 74 | static void DoesCachedFileExistAsync(const char *filePath, CCIOCallback *inCallback); 75 | static bool DoesFileExist(const char *filePath, CCResourceType resourceType=Resource_Cached); 76 | 77 | static CCResourceType FindFile(const char *filePath); 78 | 79 | static const char* GetAppStorageFolder(); 80 | }; 81 | 82 | 83 | #endif // __CCFILEMANAGER_H__ 84 | -------------------------------------------------------------------------------- /engine/source/objects/CCObject.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCObject.h 7 | * Description : A scene managed object. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | class CCObject : public CCRenderable 15 | { 16 | typedef CCRenderable super; 17 | 18 | protected: 19 | CCText objectID; // Used for serverside communication 20 | 21 | public: 22 | CCSceneBase *inScene; 23 | uint deleteMe; 24 | 25 | CCObject *parent; 26 | 27 | CCRenderPass renderPass; 28 | bool octreeRender; 29 | 30 | protected: 31 | CCModelBase *model; 32 | bool readDepth, writeDepth; 33 | bool disableCulling, frontCulling; 34 | 35 | bool transparent, transparentParent; 36 | CCInterpolatorLinearColour *colourInterpolator; 37 | 38 | // If I have children, they will be offset from my position 39 | CCObjectPtrList children; 40 | CCObjectPtrList updaters; 41 | 42 | 43 | 44 | public: 45 | CCObject(const long jsID=-1); 46 | virtual void destruct(); 47 | 48 | const char* getServerObjectID() const 49 | { 50 | return objectID.buffer; 51 | } 52 | 53 | // CCRenderable 54 | virtual void dirtyWorldMatrix(); 55 | 56 | virtual void setScene(CCSceneBase *scene); 57 | virtual void removeFromScene(); 58 | 59 | // Delete the object in 2 frames. 60 | void deleteLater(); 61 | 62 | inline bool isActive() { return deleteMe == 0; } 63 | virtual void deactivate() {}; 64 | 65 | void addChild(CCObject *object, const int index=-1); 66 | bool removeChild(CCObject *object); 67 | 68 | // Remove an object from our child list and add it into the scene 69 | void moveChildToScene(CCObject *object, CCSceneBase *scene); 70 | 71 | void addUpdater(CCUpdater *updater); 72 | void removeUpdater(CCUpdater *updater); 73 | 74 | virtual bool shouldCollide(CCCollideable *collideWith, const bool initialCall); 75 | 76 | virtual bool update(const CCTime &time); 77 | virtual void renderObject(const CCCameraBase *camera, const bool alpha); 78 | 79 | virtual void renderModel(const bool alpha); 80 | 81 | public: 82 | bool isTransparent() { return transparent; } 83 | void setTransparent(const bool toggle=true); 84 | void setTransparentParent(const bool toggle=true); 85 | 86 | CCInterpolatorLinearColour& getColourInterpolator(); 87 | virtual void setColour(const CCColour &inColour, const bool interpolate=false, CCLambdaCallback *inCallback=NULL); 88 | void setColourAlpha(const float inAlpha, const bool interpolate=false, CCLambdaCallback *inCallback=NULL); 89 | 90 | CCModelBase* getModel() { return model; } 91 | 92 | void setModel(CCModelBase *model); 93 | void setReadDepth(const bool toggle); 94 | void setWriteDepth(const bool toggle); 95 | void setCulling(const bool toggle); 96 | void setFrontCulling(const bool toggle); 97 | }; 98 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/strbuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2013 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef _GNU_SOURCE 9 | #define _GNU_SOURCE 10 | #endif 11 | 12 | #include 13 | #include 14 | #include "jansson_private.h" 15 | #include "strbuffer.h" 16 | 17 | #define STRBUFFER_MIN_SIZE 16 18 | #define STRBUFFER_FACTOR 2 19 | #define STRBUFFER_SIZE_MAX ((size_t)-1) 20 | 21 | int strbuffer_init(strbuffer_t *strbuff) 22 | { 23 | strbuff->size = STRBUFFER_MIN_SIZE; 24 | strbuff->length = 0; 25 | 26 | strbuff->value = jsonp_malloc(strbuff->size); 27 | if(!strbuff->value) 28 | return -1; 29 | 30 | /* initialize to empty */ 31 | strbuff->value[0] = '\0'; 32 | return 0; 33 | } 34 | 35 | void strbuffer_close(strbuffer_t *strbuff) 36 | { 37 | if(strbuff->value) 38 | jsonp_free(strbuff->value); 39 | 40 | strbuff->size = 0; 41 | strbuff->length = 0; 42 | strbuff->value = NULL; 43 | } 44 | 45 | void strbuffer_clear(strbuffer_t *strbuff) 46 | { 47 | strbuff->length = 0; 48 | strbuff->value[0] = '\0'; 49 | } 50 | 51 | const char *strbuffer_value(const strbuffer_t *strbuff) 52 | { 53 | return strbuff->value; 54 | } 55 | 56 | char *strbuffer_steal_value(strbuffer_t *strbuff) 57 | { 58 | char *result = strbuff->value; 59 | strbuff->value = NULL; 60 | return result; 61 | } 62 | 63 | int strbuffer_append(strbuffer_t *strbuff, const char *string) 64 | { 65 | return strbuffer_append_bytes(strbuff, string, strlen(string)); 66 | } 67 | 68 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte) 69 | { 70 | return strbuffer_append_bytes(strbuff, &byte, 1); 71 | } 72 | 73 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) 74 | { 75 | if(size >= strbuff->size - strbuff->length) 76 | { 77 | size_t new_size; 78 | char *new_value; 79 | 80 | /* avoid integer overflow */ 81 | if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR 82 | || size > STRBUFFER_SIZE_MAX - 1 83 | || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size) 84 | return -1; 85 | 86 | new_size = max(strbuff->size * STRBUFFER_FACTOR, 87 | strbuff->length + size + 1); 88 | 89 | new_value = jsonp_malloc(new_size); 90 | if(!new_value) 91 | return -1; 92 | 93 | memcpy(new_value, strbuff->value, strbuff->length); 94 | 95 | jsonp_free(strbuff->value); 96 | strbuff->value = new_value; 97 | strbuff->size = new_size; 98 | } 99 | 100 | memcpy(strbuff->value + strbuff->length, data, size); 101 | strbuff->length += size; 102 | strbuff->value[strbuff->length] = '\0'; 103 | 104 | return 0; 105 | } 106 | 107 | char strbuffer_pop(strbuffer_t *strbuff) 108 | { 109 | if(strbuff->length > 0) { 110 | char c = strbuff->value[--strbuff->length]; 111 | strbuff->value[strbuff->length] = '\0'; 112 | return c; 113 | } 114 | else 115 | return '\0'; 116 | } 117 | -------------------------------------------------------------------------------- /engine/source/ai/CCMovementInterpolator.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCMovementInterpolator.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCObjects.h" 12 | #include "CCMovementInterpolator.h" 13 | 14 | 15 | CCMovementInterpolator::CCMovementInterpolator(CCCollideable *inObject, const bool updateCollisions) 16 | { 17 | object = inObject; 18 | object->addUpdater( this ); 19 | 20 | updating = false; 21 | this->updateCollisions = updateCollisions; 22 | } 23 | 24 | 25 | 26 | bool CCMovementInterpolator::update(const float delta) 27 | { 28 | if( updating ) 29 | { 30 | if( movementInterpolator.update( delta ) ) 31 | { 32 | if( updateCollisions ) 33 | { 34 | object->updateCollisions = true; 35 | CCOctreeRefreshObject( object ); 36 | } 37 | object->dirtyModelMatrix(); 38 | return true; 39 | } 40 | else 41 | { 42 | updating = false; 43 | } 44 | } 45 | return false; 46 | } 47 | 48 | 49 | void CCMovementInterpolator::clear() 50 | { 51 | if( updating ) 52 | { 53 | updating = false; 54 | movementInterpolator.clear(); 55 | } 56 | } 57 | 58 | 59 | void CCMovementInterpolator::setMovement(const CCVector3 target, CCLambdaCallback *inCallback) 60 | { 61 | updating = true; 62 | movementInterpolator.pushV3( &object->getPosition(), target, true, inCallback ); 63 | } 64 | 65 | 66 | void CCMovementInterpolator::setMovementX(const float x) 67 | { 68 | setMovement( CCVector3( x, object->getConstPosition().y, object->getConstPosition().z ) ); 69 | } 70 | 71 | 72 | void CCMovementInterpolator::translateMovementX(const float x) 73 | { 74 | setMovementX( object->getConstPosition().x + x ); 75 | } 76 | 77 | 78 | void CCMovementInterpolator::setMovementY(const float y, CCLambdaCallback *inCallback) 79 | { 80 | setMovement( CCVector3( object->getConstPosition().x, y, object->getConstPosition().z ), inCallback ); 81 | } 82 | 83 | 84 | void CCMovementInterpolator::setMovementXY(const float x,const float y, CCLambdaCallback *inCallback) 85 | { 86 | setMovement( CCVector3( x, y, object->getConstPosition().z ), inCallback ); 87 | } 88 | 89 | 90 | void CCMovementInterpolator::setMovementYZ(const float y,const float z, CCLambdaCallback *inCallback) 91 | { 92 | setMovement( CCVector3( object->getConstPosition().x, y, z ), inCallback ); 93 | } 94 | 95 | 96 | const CCVector3 CCMovementInterpolator::getMovementTarget() const 97 | { 98 | if( updating && movementInterpolator.interpolators.length > 0 ) 99 | { 100 | return movementInterpolator.getTarget(); 101 | } 102 | return object->getConstPosition(); 103 | } 104 | 105 | 106 | void CCMovementInterpolator::setDuration(const float duration) 107 | { 108 | movementInterpolator.setDuration( duration ); 109 | } -------------------------------------------------------------------------------- /external/libjpeg-8d/jmemnobs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jmemnobs.c 3 | * 4 | * Copyright (C) 1992-1996, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file provides a really simple implementation of the system- 9 | * dependent portion of the JPEG memory manager. This implementation 10 | * assumes that no backing-store files are needed: all required space 11 | * can be obtained from malloc(). 12 | * This is very portable in the sense that it'll compile on almost anything, 13 | * but you'd better have lots of main memory (or virtual memory) if you want 14 | * to process big images. 15 | * Note that the max_memory_to_use option is ignored by this implementation. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | #include "jmemsys.h" /* import the system-dependent declarations */ 22 | 23 | #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ 24 | extern void * malloc JPP((size_t size)); 25 | extern void free JPP((void *ptr)); 26 | #endif 27 | 28 | 29 | /* 30 | * Memory allocation and freeing are controlled by the regular library 31 | * routines malloc() and free(). 32 | */ 33 | 34 | GLOBAL(void *) 35 | jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) 36 | { 37 | return (void *) malloc(sizeofobject); 38 | } 39 | 40 | GLOBAL(void) 41 | jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) 42 | { 43 | free(object); 44 | } 45 | 46 | 47 | /* 48 | * "Large" objects are treated the same as "small" ones. 49 | * NB: although we include FAR keywords in the routine declarations, 50 | * this file won't actually work in 80x86 small/medium model; at least, 51 | * you probably won't be able to process useful-size images in only 64KB. 52 | */ 53 | 54 | GLOBAL(void FAR *) 55 | jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) 56 | { 57 | return (void FAR *) malloc(sizeofobject); 58 | } 59 | 60 | GLOBAL(void) 61 | jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) 62 | { 63 | free(object); 64 | } 65 | 66 | 67 | /* 68 | * This routine computes the total memory space available for allocation. 69 | * Here we always say, "we got all you want bud!" 70 | */ 71 | 72 | GLOBAL(long) 73 | jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, 74 | long max_bytes_needed, long already_allocated) 75 | { 76 | return max_bytes_needed; 77 | } 78 | 79 | 80 | /* 81 | * Backing store (temporary file) management. 82 | * Since jpeg_mem_available always promised the moon, 83 | * this should never be called and we can just error out. 84 | */ 85 | 86 | GLOBAL(void) 87 | jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, 88 | long total_bytes_needed) 89 | { 90 | ERREXIT(cinfo, JERR_NO_BACKING_STORE); 91 | } 92 | 93 | 94 | /* 95 | * These routines take care of any system-dependent initialization and 96 | * cleanup required. Here, there isn't any. 97 | */ 98 | 99 | GLOBAL(long) 100 | jpeg_mem_init (j_common_ptr cinfo) 101 | { 102 | return 0; /* just set max_memory_to_use to 0 */ 103 | } 104 | 105 | GLOBAL(void) 106 | jpeg_mem_term (j_common_ptr cinfo) 107 | { 108 | /* no work */ 109 | } 110 | -------------------------------------------------------------------------------- /engine/resources/shaders/phong.fx: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : phong.fx 7 | * Description : Basic phong lighting. 8 | * 9 | * Created : 08/09/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | precision mediump float; 15 | 16 | // ------- 17 | // Globals 18 | // ------- 19 | uniform highp mat4 u_projectionMatrix; 20 | uniform highp mat4 u_viewMatrix; 21 | uniform highp mat4 u_modelMatrix; 22 | uniform vec4 u_modelColour; 23 | 24 | //#ifdef LIGHTING_ENABLED 25 | uniform mat4 u_modelNormalMatrix; 26 | uniform vec3 u_lightPosition; 27 | uniform vec4 u_lightDiffuse; 28 | //#endif 29 | 30 | 31 | // ------------------ 32 | // VS Output/PS Input 33 | // ------------------ 34 | varying vec2 ps_texCoord; 35 | 36 | //#ifdef LIGHTING_ENABLED 37 | varying highp vec3 ps_worldPosition; 38 | varying vec3 ps_worldNormal; 39 | //#endif 40 | 41 | 42 | // ----------------- 43 | #ifdef VERTEX_SHADER 44 | // ----------------- 45 | // VS Input 46 | attribute highp vec3 vs_position; 47 | attribute vec2 vs_texCoord; 48 | 49 | //#ifdef LIGHTING_ENABLED 50 | attribute vec3 vs_normal; 51 | //#endif 52 | 53 | void main() 54 | { 55 | mat4 modelViewMatrix = u_viewMatrix * u_modelMatrix; 56 | 57 | gl_Position = u_projectionMatrix * modelViewMatrix * vec4( vs_position, 1.0 ); 58 | ps_texCoord = vs_texCoord; 59 | 60 | //#ifdef LIGHTING_ENABLED 61 | ps_worldPosition = vec3( modelViewMatrix * vec4( vs_position, 1.0 ) ); 62 | 63 | #ifdef QT 64 | ps_worldNormal = vs_normal; 65 | ps_worldNormal = vec3( 1, 1, 1 ); 66 | #else 67 | // Works for uniform scaled models 68 | // normal.w must be 0.0 to kill off translation 69 | vec3 fakeNormal = vs_normal; 70 | fakeNormal = vec3( 1, 1, 1 ); 71 | vec3 transformedNormal = vec3( modelViewMatrix * vec4( fakeNormal, 0.0 ) ); 72 | ps_worldNormal = normalize( transformedNormal ); 73 | #endif 74 | // Normal matrix is required for non-uniform scaled models 75 | // vec3 transformedNormal = ( u_modelNormalMatrix * vec4( vs_normal, 1.0 ) ).xyz; 76 | // ps_worldNormal = normalize( transformedNormal ); 77 | //#endif 78 | } 79 | 80 | #endif 81 | 82 | 83 | 84 | // ---------------- 85 | #ifdef PIXEL_SHADER 86 | // ---------------- 87 | 88 | uniform sampler2D s_diffuseTexture; 89 | 90 | void main() 91 | { 92 | vec4 textureColour = texture2D( s_diffuseTexture, ps_texCoord ).rgba; 93 | 94 | //#ifdef LIGHTING_ENABLED 95 | 96 | vec3 u_lightPosition = vec3( -100.0, 100.0, 100.0 ); 97 | vec4 u_lightDiffuse = vec4( 1.0, 1.0, 1.0, 1.0 ); 98 | 99 | vec3 L = normalize( u_lightPosition - ps_worldPosition ); 100 | vec4 Idiff = u_lightDiffuse * max( dot( ps_worldNormal, L ), 0.0 ); 101 | Idiff = clamp( Idiff, 0.5, 1.0 ); 102 | Idiff.a = 1.0; 103 | 104 | gl_FragColor = Idiff * u_modelColour * textureColour; 105 | 106 | //#else 107 | // 108 | // gl_FragColor = u_modelColour * textureColour; 109 | // 110 | //#endif 111 | } 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitiveSphere.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPrimitiveSphere.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCPrimitives.h" 12 | 13 | static const uint space = 10; 14 | 15 | 16 | void CCPrimitiveSphere::renderVertices(const bool textured) 17 | { 18 | CCRenderer::CCSetRenderStates( true ); 19 | 20 | GLVertexPointer( 3, GL_FLOAT, 0, vertices, vertexCount ) ; 21 | gRenderer->GLDrawArrays( GL_TRIANGLE_STRIP, 0, vertexCount ); 22 | } 23 | 24 | 25 | static void appendNormals(CCVector3 *normal, const float *vertices, float *normals, const uint n, const float z) 26 | { 27 | normal->set( vertices[n-3], vertices[n-2], vertices[n-1] * z ); 28 | CCVector3Normalize( *normal ); 29 | normals[n-3] = normal->x; 30 | normals[n-2] = normal->y; 31 | normals[n-1] = normal->z; 32 | } 33 | 34 | 35 | void CCPrimitiveSphere::setup(const float radius) 36 | { 37 | vertexCount = ( 90 / space ) * ( 360 / space ) * 4; 38 | const size_t sizeOfMalloc = sizeof( float ) * vertexCount * 3; 39 | vertices = (float*)malloc( sizeOfMalloc ); 40 | normals = (float*)malloc( sizeOfMalloc ); 41 | 42 | float depth = -1.0f; 43 | float r = radius; 44 | int n = 0; 45 | 46 | CCVector3 normalVector; 47 | //for( float z = 1.0f; z >= -1.0f; z -= 2.0f ) 48 | float z = 1.0f; 49 | { 50 | for( float b = 0.0f; b <= 90.0f - space; b+=space) 51 | { 52 | for( float a = 0.0f; a <= 360.0f - space; a+=space) 53 | { 54 | vertices[n++] = r * sinf((a) / 180.0f * CC_PI) * sinf((b) / 180.0f * CC_PI); 55 | vertices[n++] = r * cosf((a) / 180.0f * CC_PI) * sinf((b) / 180.0f * CC_PI); 56 | vertices[n++] = z * r * cosf((b) / 180.0f * CC_PI); 57 | //VERTEX[n].V = (2 * b) / 360; 58 | //VERTEX[n].U = (a) / 360; 59 | appendNormals( &normalVector, vertices, normals, n, depth ); 60 | 61 | vertices[n++] = r * sinf((a) / 180.0f * CC_PI) * sinf((b + space) / 180.0f * CC_PI); 62 | vertices[n++] = r * cosf((a) / 180.0f * CC_PI) * sinf((b + space) / 180.0f * CC_PI); 63 | vertices[n++] = z * r * cosf((b + space) / 180.0f * CC_PI); 64 | //VERTEX[n].V = (2 * (b + space)) / 360; 65 | //VERTEX[n].U = (a) / 360; 66 | appendNormals( &normalVector, vertices, normals, n, depth ); 67 | 68 | vertices[n++] = r * sinf((a + space) / 180.0f * CC_PI) * sinf((b) / 180.0f * CC_PI); 69 | vertices[n++] = r * cosf((a + space) / 180.0f * CC_PI) * sinf((b) / 180.0f * CC_PI); 70 | vertices[n++] = z * r * cosf((b) / 180.0f * CC_PI); 71 | //VERTEX[n].V = (2 * b) / 360; 72 | //VERTEX[n].U = (a + space) / 360; 73 | appendNormals( &normalVector, vertices, normals, n, depth ); 74 | 75 | vertices[n++] = r * sinf((a + space) / 180.0f * CC_PI) * sinf((b + space) / 180.0f * CC_PI); 76 | vertices[n++] = r * cosf((a + space) / 180.0f * CC_PI) * sinf((b + space) / 180.0f * CC_PI); 77 | vertices[n++] = z * r * cosf((b + space) / 180.0f * CC_PI); 78 | //VERTEX[n].V = (2 * (b + space)) / 360; 79 | //VERTEX[n].U = (a + space) / 360; 80 | appendNormals( &normalVector, vertices, normals, n, depth ); 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /engine/source/tools/CCOctree.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCOctree.h 7 | * Description : Octree container used for collisions and rendering 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCOCTREE_H__ 15 | #define __CCOCTREE_H__ 16 | 17 | 18 | #define MAX_TREE_OBJECTS 64 19 | 20 | #ifdef DEBUGON 21 | extern int maxOctreesPerObject; 22 | extern int maxLeafsPerScan; 23 | extern int maxCollideablesPerScan; 24 | #endif 25 | 26 | enum CCOctreeLeafs 27 | { 28 | leaf_bottom_front_left, 29 | leaf_bottom_front_right, 30 | leaf_bottom_back_left, 31 | leaf_bottom_back_right, 32 | 33 | leaf_top_front_left, 34 | leaf_top_front_right, 35 | leaf_top_back_left, 36 | leaf_top_back_right, 37 | }; 38 | 39 | struct CCOctree 40 | { 41 | CCOctree *parent; 42 | CCOctree **leafs; 43 | CCPtrList objects; 44 | 45 | float hSize; 46 | CCVector3 min, max; 47 | 48 | CCOctree(CCOctree *inParent, const CCVector3 position, const float size); 49 | }; 50 | 51 | // Delete the octree and all it's leafs 52 | extern void CCOctreeDeleteLeafs(CCOctree *tree); 53 | 54 | // Add an object into the octree and create leafs if necessary 55 | extern void CCOctreeAddObject(CCOctree *tree, CCCollideable *collideable); 56 | 57 | // Remove an object from an octree and delete the octree if necessary 58 | extern void CCOctreeRemoveObject(CCOctree *tree, CCCollideable *collideable); 59 | extern void CCOctreeRemoveObject(CCCollideable *collideable); 60 | 61 | // Remove and add octree 62 | extern void CCOctreeRefreshObject(CCCollideable *collideable); 63 | 64 | // Remove unused leafs 65 | extern void CCOctreePruneTree(CCOctree *tree); 66 | 67 | // See if the range is in the tree 68 | extern bool CCOctreeIsInLeaf(const CCOctree *leaf, const CCVector3 &targetMin, const CCVector3 &targetMax); 69 | 70 | // Traverse the tree 71 | extern bool CCOctreeHasObjects(CCOctree *tree); 72 | 73 | // Traverse the tree and find the leafs nodes, from the bottom up so we don't end up with all the leafs 74 | extern void CCOctreeListLeafs(const CCOctree *tree, const CCVector3 &targetMin, const CCVector3 &targetMax, const CCOctree **leafsList, int *numberOfLeafs); 75 | 76 | // List all the collideables in the tree 77 | extern void CCOctreeListCollideables(CCCollideable **collideables, int *numberOfCollideables, const CCOctree **leafs, const int numberOfLeafs); 78 | extern void CCOctreeListVisibles(CCPtrList &leafs, CCPtrList &collideables); 79 | 80 | // Render the octrees 81 | extern void CCOctreeRender(CCOctree *tree); 82 | 83 | // Render the objects in the trees 84 | extern CCCollideable* CCOctreeGetVisibleCollideables(const int i); 85 | extern void CCOctreeScanVisibleCollideables(const float frustum[6][4], 86 | CCPtrList &visibleCollideables); 87 | extern void CCScanVisibleCollideables(const float frustum[6][4], 88 | const CCPtrList &collideables, 89 | CCPtrList &visibleCollideables); 90 | extern void CCRenderVisibleObjects(CCCameraBase *camera, const CCRenderPass pass, const bool alpha); 91 | 92 | 93 | #endif // __CCOCTREE_H__ 94 | -------------------------------------------------------------------------------- /external/jansson-2.5/src/strconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "jansson_private.h" 6 | #include "strbuffer.h" 7 | 8 | /* need config.h to get the correct snprintf */ 9 | #ifdef HAVE_CONFIG_H 10 | #include 11 | #endif 12 | 13 | #if JSON_HAVE_LOCALECONV 14 | #include 15 | 16 | /* 17 | - This code assumes that the decimal separator is exactly one 18 | character. 19 | 20 | - If setlocale() is called by another thread between the call to 21 | localeconv() and the call to sprintf() or strtod(), the result may 22 | be wrong. setlocale() is not thread-safe and should not be used 23 | this way. Multi-threaded programs should use uselocale() instead. 24 | */ 25 | 26 | static void to_locale(strbuffer_t *strbuffer) 27 | { 28 | const char *point; 29 | char *pos; 30 | 31 | point = localeconv()->decimal_point; 32 | if(*point == '.') { 33 | /* No conversion needed */ 34 | return; 35 | } 36 | 37 | pos = strchr(strbuffer->value, '.'); 38 | if(pos) 39 | *pos = *point; 40 | } 41 | 42 | static void from_locale(char *buffer) 43 | { 44 | const char *point; 45 | char *pos; 46 | 47 | point = localeconv()->decimal_point; 48 | if(*point == '.') { 49 | /* No conversion needed */ 50 | return; 51 | } 52 | 53 | pos = strchr(buffer, *point); 54 | if(pos) 55 | *pos = '.'; 56 | } 57 | #endif 58 | 59 | int jsonp_strtod(strbuffer_t *strbuffer, double *out) 60 | { 61 | double value; 62 | char *end; 63 | 64 | #if JSON_HAVE_LOCALECONV 65 | to_locale(strbuffer); 66 | #endif 67 | 68 | errno = 0; 69 | value = strtod(strbuffer->value, &end); 70 | assert(end == strbuffer->value + strbuffer->length); 71 | 72 | if(errno == ERANGE && value != 0) { 73 | /* Overflow */ 74 | return -1; 75 | } 76 | 77 | *out = value; 78 | return 0; 79 | } 80 | 81 | int jsonp_dtostr(char *buffer, size_t size, double value) 82 | { 83 | int ret; 84 | char *start, *end; 85 | size_t length; 86 | 87 | ret = snprintf(buffer, size, "%.17g", value); 88 | if(ret < 0) 89 | return -1; 90 | 91 | length = (size_t)ret; 92 | if(length >= size) 93 | return -1; 94 | 95 | #if JSON_HAVE_LOCALECONV 96 | from_locale(buffer); 97 | #endif 98 | 99 | /* Make sure there's a dot or 'e' in the output. Otherwise 100 | a real is converted to an integer when decoding */ 101 | if(strchr(buffer, '.') == NULL && 102 | strchr(buffer, 'e') == NULL) 103 | { 104 | if(length + 3 >= size) { 105 | /* No space to append ".0" */ 106 | return -1; 107 | } 108 | buffer[length] = '.'; 109 | buffer[length + 1] = '0'; 110 | buffer[length + 2] = '\0'; 111 | length += 2; 112 | } 113 | 114 | /* Remove leading '+' from positive exponent. Also remove leading 115 | zeros from exponents (added by some printf() implementations) */ 116 | start = strchr(buffer, 'e'); 117 | if(start) { 118 | start++; 119 | end = start + 1; 120 | 121 | if(*start == '-') 122 | start++; 123 | 124 | while(*end == '0') 125 | end++; 126 | 127 | if(end != start) { 128 | memmove(start, end, length - (size_t)(end - buffer)); 129 | length -= (size_t)(end - start); 130 | } 131 | } 132 | 133 | return (int)length; 134 | } 135 | -------------------------------------------------------------------------------- /external/libjpeg-8d/jinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jinclude.h 3 | * 4 | * Copyright (C) 1991-1994, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file exists to provide a single place to fix any problems with 9 | * including the wrong system include files. (Common problems are taken 10 | * care of by the standard jconfig symbols, but on really weird systems 11 | * you may have to edit this file.) 12 | * 13 | * NOTE: this file is NOT intended to be included by applications using the 14 | * JPEG library. Most applications need only include jpeglib.h. 15 | */ 16 | 17 | 18 | /* Include auto-config file to find out which system include files we need. */ 19 | 20 | #include "jconfig.h" /* auto configuration options */ 21 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 22 | 23 | /* 24 | * We need the NULL macro and size_t typedef. 25 | * On an ANSI-conforming system it is sufficient to include . 26 | * Otherwise, we get them from or ; we may have to 27 | * pull in as well. 28 | * Note that the core JPEG library does not require ; 29 | * only the default error handler and data source/destination modules do. 30 | * But we must pull it in because of the references to FILE in jpeglib.h. 31 | * You can remove those references if you want to compile without . 32 | */ 33 | 34 | #ifdef HAVE_STDDEF_H 35 | #include 36 | #endif 37 | 38 | #ifdef HAVE_STDLIB_H 39 | #include 40 | #endif 41 | 42 | #ifdef NEED_SYS_TYPES_H 43 | #include 44 | #endif 45 | 46 | #include 47 | 48 | /* 49 | * We need memory copying and zeroing functions, plus strncpy(). 50 | * ANSI and System V implementations declare these in . 51 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 52 | * Some systems may declare memset and memcpy in . 53 | * 54 | * NOTE: we assume the size parameters to these functions are of type size_t. 55 | * Change the casts in these macros if not! 56 | */ 57 | 58 | #ifdef NEED_BSD_STRINGS 59 | 60 | #include 61 | #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 62 | #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 63 | 64 | #else /* not BSD, assume ANSI/SysV string lib */ 65 | 66 | #include 67 | #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 68 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 69 | 70 | #endif 71 | 72 | /* 73 | * In ANSI C, and indeed any rational implementation, size_t is also the 74 | * type returned by sizeof(). However, it seems there are some irrational 75 | * implementations out there, in which sizeof() returns an int even though 76 | * size_t is defined as long or unsigned long. To ensure consistent results 77 | * we always use this SIZEOF() macro in place of using sizeof() directly. 78 | */ 79 | 80 | #define SIZEOF(object) ((size_t) sizeof(object)) 81 | 82 | /* 83 | * The modules that use fread() and fwrite() always invoke them through 84 | * these macros. On some systems you may need to twiddle the argument casts. 85 | * CAUTION: argument order is different from underlying functions! 86 | */ 87 | 88 | #define JFREAD(file,buf,sizeofbuf) \ 89 | ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 90 | #define JFWRITE(file,buf,sizeofbuf) \ 91 | ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 92 | -------------------------------------------------------------------------------- /external/libjpeg-8d/jcomapi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcomapi.c 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains application interface routines that are used for both 9 | * compression and decompression. 10 | */ 11 | 12 | #define JPEG_INTERNALS 13 | #include "jinclude.h" 14 | #include "jpeglib.h" 15 | 16 | 17 | /* 18 | * Abort processing of a JPEG compression or decompression operation, 19 | * but don't destroy the object itself. 20 | * 21 | * For this, we merely clean up all the nonpermanent memory pools. 22 | * Note that temp files (virtual arrays) are not allowed to belong to 23 | * the permanent pool, so we will be able to close all temp files here. 24 | * Closing a data source or destination, if necessary, is the application's 25 | * responsibility. 26 | */ 27 | 28 | GLOBAL(void) 29 | jpeg_abort (j_common_ptr cinfo) 30 | { 31 | int pool; 32 | 33 | /* Do nothing if called on a not-initialized or destroyed JPEG object. */ 34 | if (cinfo->mem == NULL) 35 | return; 36 | 37 | /* Releasing pools in reverse order might help avoid fragmentation 38 | * with some (brain-damaged) malloc libraries. 39 | */ 40 | for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { 41 | (*cinfo->mem->free_pool) (cinfo, pool); 42 | } 43 | 44 | /* Reset overall state for possible reuse of object */ 45 | if (cinfo->is_decompressor) { 46 | cinfo->global_state = DSTATE_START; 47 | /* Try to keep application from accessing now-deleted marker list. 48 | * A bit kludgy to do it here, but this is the most central place. 49 | */ 50 | ((j_decompress_ptr) cinfo)->marker_list = NULL; 51 | } else { 52 | cinfo->global_state = CSTATE_START; 53 | } 54 | } 55 | 56 | 57 | /* 58 | * Destruction of a JPEG object. 59 | * 60 | * Everything gets deallocated except the master jpeg_compress_struct itself 61 | * and the error manager struct. Both of these are supplied by the application 62 | * and must be freed, if necessary, by the application. (Often they are on 63 | * the stack and so don't need to be freed anyway.) 64 | * Closing a data source or destination, if necessary, is the application's 65 | * responsibility. 66 | */ 67 | 68 | GLOBAL(void) 69 | jpeg_destroy (j_common_ptr cinfo) 70 | { 71 | /* We need only tell the memory manager to release everything. */ 72 | /* NB: mem pointer is NULL if memory mgr failed to initialize. */ 73 | if (cinfo->mem != NULL) 74 | (*cinfo->mem->self_destruct) (cinfo); 75 | cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ 76 | cinfo->global_state = 0; /* mark it destroyed */ 77 | } 78 | 79 | 80 | /* 81 | * Convenience routines for allocating quantization and Huffman tables. 82 | * (Would jutils.c be a more reasonable place to put these?) 83 | */ 84 | 85 | GLOBAL(JQUANT_TBL *) 86 | jpeg_alloc_quant_table (j_common_ptr cinfo) 87 | { 88 | JQUANT_TBL *tbl; 89 | 90 | tbl = (JQUANT_TBL *) 91 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); 92 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 93 | return tbl; 94 | } 95 | 96 | 97 | GLOBAL(JHUFF_TBL *) 98 | jpeg_alloc_huff_table (j_common_ptr cinfo) 99 | { 100 | JHUFF_TBL *tbl; 101 | 102 | tbl = (JHUFF_TBL *) 103 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); 104 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 105 | return tbl; 106 | } 107 | -------------------------------------------------------------------------------- /engine/source/rendering/CCFrameBufferManager.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCFrameBufferManager.h 7 | * Description : Manages the creating and switching of frame buffers. 8 | * 9 | * Created : 01/08/11 10 | * Author(s) : Chris Wilson, Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCFRAMEBUFFERMANAGER_H__ 15 | #define __CCFRAMEBUFFERMANAGER_H__ 16 | 17 | 18 | #ifdef QT 19 | #include 20 | #define FBOType QGLFramebufferObject* 21 | #else 22 | #define FBOType GLuint 23 | #endif 24 | 25 | #include "CCTextureBase.h" 26 | 27 | 28 | class CCFrameBufferObject : public CCTextureName 29 | { 30 | public: 31 | CCFrameBufferObject(); 32 | CCFrameBufferObject(const char *inName, const int inWidth, const int inHeight); 33 | 34 | void setFrameBuffer(FBOType fbo) { frameBuffer = fbo; } 35 | FBOType getFrameBuffer() { return frameBuffer; } 36 | 37 | GLuint getRenderTexture() { return glName; } 38 | void setRenderTexture(GLuint inTexture) { glName = inTexture; } 39 | void bindRenderTexture(); 40 | 41 | const CCText& getName() { return name; } 42 | GLuint getFrameBufferHandle(); 43 | 44 | #ifndef QT 45 | GLuint renderBuffer, depthBuffer, stencilBuffer; 46 | #endif 47 | 48 | int width; 49 | int height; 50 | 51 | private: 52 | CCText name; 53 | 54 | FBOType frameBuffer; 55 | }; 56 | 57 | 58 | 59 | class CCFrameBufferManager 60 | { 61 | friend class CCRenderer; 62 | friend class CCDeviceRenderer; 63 | 64 | public: 65 | CCFrameBufferManager(); 66 | ~CCFrameBufferManager(); 67 | 68 | void setup(); 69 | 70 | float getWidth(const int fboIndex); 71 | float getHeight(const int fboIndex); 72 | int getNumberOfFBOs() { return fbos.length; } 73 | 74 | // Creates framebuffer and returns index of frame buffer object to be used with other calls 75 | int findFrameBuffer(const char *name); 76 | int newFrameBuffer(const char *name, const int size, const bool depthBuffer, const bool stencilBuffer); 77 | void deleteFrameBuffer(const int fboIndex); 78 | 79 | protected: 80 | void createFrameBuffer(CCFrameBufferObject &fbo, const bool useDepthBuffer, const bool useStencilBuffer); 81 | void destroyFrameBuffer(CCFrameBufferObject &fbo); 82 | void destoryAllFrameBuffers(); 83 | 84 | public: 85 | // Sets the currently active framebuffer 86 | void bindFrameBuffer(const int fboIndex); 87 | void bindDefaultFrameBuffer(); 88 | 89 | // Sets the active texture to the texture bound to the given frame buffer 90 | void bindFrameBufferTexture(const int fboIndex); 91 | 92 | #ifndef QT 93 | // Returns the renderbuffer attached to the default framebuffer 94 | GLuint getDefaultRenderBuffer() { return defaultFBO.renderBuffer; } 95 | #endif 96 | 97 | // Returns the OpenGL handle of the texture attached to the given frame buffer 98 | GLuint getFrameBufferTexture(const int fboIndex); 99 | 100 | // Returns the OpenGL handle for given frame buffer 101 | GLuint getFrameBufferHandle(const int fboIndex); 102 | 103 | private: 104 | CCFrameBufferObject defaultFBO; 105 | int currentFBOIndex; 106 | CCPtrList fbos; 107 | }; 108 | 109 | 110 | #endif // __CCFRAMEBUFFERMANAGER_H__ 111 | -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitiveSquare.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPrimitiveSquare.h 7 | * Description : Square drawable component. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCPRIMITIVESQUARE_H__ 15 | #define __CCPRIMITIVESQUARE_H__ 16 | 17 | 18 | struct CCPrimitiveSquareUVs 19 | { 20 | static void Setup(CCPrimitiveSquareUVs **uvs, const float x1, const float y1, const float x2, const float y2) 21 | { 22 | if( *uvs == NULL ) 23 | { 24 | *uvs = new CCPrimitiveSquareUVs( x1, y1, x2, y2 ); 25 | } 26 | else 27 | { 28 | (*uvs)->set( x1, y1, x2, y2 ); 29 | } 30 | } 31 | 32 | CCPrimitiveSquareUVs(const float x1, const float y1, const float x2, const float y2) 33 | { 34 | set( x1, y1, x2, y2 ); 35 | } 36 | 37 | void set(const float x1, const float y1, const float x2, const float y2) 38 | { 39 | uvs[0] = x2; // Bottom right 40 | uvs[1] = y1; 41 | uvs[2] = x1; // Bottom left 42 | uvs[3] = y1; 43 | uvs[4] = x2; // Top right 44 | uvs[5] = y2; 45 | uvs[6] = x1; // Top left 46 | uvs[7] = y2; 47 | } 48 | 49 | void scroll(const float x, const float y) 50 | { 51 | uvs[0] += x; 52 | uvs[1] += y; 53 | uvs[2] += x; 54 | uvs[3] += y; 55 | uvs[4] += x; 56 | uvs[5] += y; 57 | uvs[6] += x; 58 | uvs[7] += y; 59 | 60 | if( uvs[0] > 1.0f ) 61 | { 62 | for( uint i=0; i<8; ++i ) 63 | { 64 | uvs[i] -= 1.0f; 65 | } 66 | } 67 | } 68 | 69 | void flipY() 70 | { 71 | const float x1 = uvs[0]; 72 | const float x2 = uvs[2]; 73 | uvs[0] = x2; 74 | uvs[2] = x1; 75 | uvs[4] = x2; 76 | uvs[6] = x1; 77 | } 78 | 79 | float uvs[8]; 80 | }; 81 | 82 | class CCPrimitiveSquare : public CCPrimitiveBase 83 | { 84 | typedef CCPrimitiveBase super; 85 | 86 | public: 87 | CCPrimitiveSquareUVs *customUVs; // Custom UV coordinates 88 | CCPrimitiveSquareUVs *adjustedUVs; // Adjusted UV coordinates from our custom UVs based on texture allocation size 89 | 90 | CCVector3 *scale; 91 | CCVector3 *position; 92 | 93 | 94 | protected: 95 | float *customVertexPositionBuffer; 96 | 97 | 98 | public: 99 | CCPrimitiveSquare(const long primitiveID=-1); 100 | 101 | // CCBaseType 102 | virtual void destruct(); 103 | 104 | // Adjust the model's UVs to match the loaded texture, 105 | // as non-square textures load into a square texture which means the mapping requires adjustment 106 | virtual void adjustTextureUVs(); 107 | 108 | public: 109 | void setTextureUVs(const float x1, const float y1, const float x2, const float y2); 110 | 111 | virtual void renderVertices(const bool textured); 112 | virtual void renderOutline(); 113 | 114 | void setScale(const float width, const float height, const float depth=1.0f) 115 | { 116 | CCVector3FillPtr( &scale, width, height, depth ); 117 | }; 118 | 119 | void setPosition(const float x, const float y, const float z) 120 | { 121 | CCVector3FillPtr( &position, x, y, z ); 122 | }; 123 | 124 | void setCustomVertexPositionBuffer(float *buffer); 125 | 126 | void flipY(); 127 | }; 128 | 129 | 130 | #endif // __CCPRIMITIVESQUARE_H__ 131 | -------------------------------------------------------------------------------- /engine/source/tools/CCTools.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTools.h 7 | * Description : Contains base functions. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCTOOLS_H__ 15 | #define __CCTOOLS_H__ 16 | 17 | 18 | #include "CCPlatform.h" 19 | 20 | 21 | // add GCC_PREPROCESSOR_DEFINITIONS DEBUGON in Project Settings 22 | #define ALLOW_DEBUGLOG 23 | #if defined DEBUGON && defined ALLOW_DEBUGLOG 24 | 25 | #define LOG_FPS 1 26 | #if defined WP8 || defined WIN8 27 | extern void DEBUGLOG(const char *text, ...); 28 | #else 29 | #define DEBUGLOG printf 30 | #endif 31 | #define DEBUGFLUSH fflush( stdout ); 32 | 33 | #define LOG_NEWMAX(string, currentMax, newMax) \ 34 | if( currentMax < newMax ) { currentMax = newMax; printf( "%s - %i \n", string, currentMax ); } 35 | 36 | #else 37 | 38 | #define DEBUGLOG 39 | #define DEBUGFLUSH 40 | #define LOG_NEWMAX(string, currentMax, newMax) 41 | 42 | #endif 43 | 44 | 45 | #ifdef DEBUGON 46 | 47 | extern void CCDebugAssert(const bool condition, const char *file, const int line, const char *message=NULL); 48 | 49 | #define CCASSERT(condition) CCDebugAssert( condition, __FILE__, __LINE__ ); 50 | 51 | #define CCASSERT_MESSAGE(condition, message) CCDebugAssert( condition, __FILE__, __LINE__, message ); 52 | 53 | #ifdef DXRENDERER 54 | #define DEBUG_OPENGL() {} 55 | #else 56 | #define DEBUG_OPENGL() \ 57 | { \ 58 | GLenum error = glGetError(); \ 59 | CCASSERT( error == 0 ); \ 60 | } 61 | #endif 62 | 63 | #else // DEBUGON 64 | 65 | inline void DebugAssert(const bool condition, const char *message=NULL) {} 66 | #define CCASSERT(cond) {}; 67 | #define CCASSERT_MESSAGE(cond,str) {} 68 | 69 | #define DEBUG_OPENGL() {} 70 | 71 | #endif 72 | 73 | 74 | #define DELETE_OBJECT(object) \ 75 | if( object != NULL ) \ 76 | { \ 77 | object->destruct(); \ 78 | delete object; \ 79 | object = NULL; \ 80 | } 81 | 82 | 83 | #define DELETE_POINTER(pointer) \ 84 | if( pointer != NULL ) \ 85 | { \ 86 | delete pointer; \ 87 | pointer = NULL; \ 88 | } 89 | 90 | 91 | #define FREE_POINTER(pointer) \ 92 | if( pointer != NULL ) \ 93 | { \ 94 | free( pointer ); \ 95 | pointer = NULL; \ 96 | } 97 | 98 | 99 | 100 | inline bool CCHasFlag(const uint source, const uint flag) 101 | { 102 | const uint result = source & flag; 103 | if( result != 0 ) 104 | { 105 | return true; 106 | } 107 | 108 | return false; 109 | } 110 | 111 | inline void CCAddFlag(uint &source, const uint flag) 112 | { 113 | if( CCHasFlag( source, flag ) == false ) 114 | { 115 | source |= flag; 116 | } 117 | } 118 | 119 | inline void CCRemoveFlag(uint &source, const uint flag) 120 | { 121 | if( CCHasFlag( source, flag ) ) 122 | { 123 | source ^= flag; 124 | } 125 | } 126 | 127 | 128 | bool CCSaveData(const char *id, const char *data); 129 | bool CCLoadData(const char *id, struct CCText &result); 130 | 131 | 132 | #endif // __CCTOOLS_H__ 133 | -------------------------------------------------------------------------------- /engine/source/tools/CCControls.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCControls.h 7 | * Description : Cross platform controls interface. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCCONTROLS_H__ 15 | #define __CCCONTROLS_H__ 16 | 17 | 18 | #define CC_DOUBLE_TAP_THRESHOLD 0.2f 19 | 20 | 21 | #ifdef IOS 22 | #ifdef __OBJC__ 23 | #include "CCGLView.h" 24 | #else 25 | #define UITouch void 26 | #endif 27 | #else 28 | struct UITouch; 29 | #endif 30 | 31 | 32 | enum CCTouchAction 33 | { 34 | touch_pressed, 35 | touch_movingHorizontal, 36 | touch_movingVertical, 37 | touch_moving, 38 | touch_released, 39 | touch_lost 40 | }; 41 | 42 | 43 | enum CCTwoTouchAction 44 | { 45 | twotouch_unassigned, 46 | twotouch_zooming, 47 | twotouch_rotating 48 | }; 49 | 50 | 51 | struct CCScreenTouches 52 | { 53 | CCScreenTouches() 54 | { 55 | lastTouch = usingTouch = NULL; 56 | timeHeld = lastTimeReleased = 0.0f; 57 | } 58 | 59 | const CCPoint averageLastDeltas() const; 60 | 61 | UITouch *usingTouch, *lastTouch; 62 | CCPoint startPosition, position, delta, totalDelta, lastTotalDelta; 63 | float timeHeld, lastTimeReleased; 64 | 65 | enum { max_last_deltas = 50 }; 66 | struct TimedDelta 67 | { 68 | TimedDelta() 69 | { 70 | time = 0.0f; 71 | } 72 | 73 | void clear() 74 | { 75 | time = 0.0f; 76 | delta = CCPoint(); 77 | } 78 | 79 | float time; 80 | CCPoint delta; 81 | }; 82 | TimedDelta lastDeltas[max_last_deltas]; 83 | }; 84 | 85 | 86 | 87 | struct CCSensorInclinometer 88 | { 89 | CCSensorInclinometer() 90 | { 91 | updated = false; 92 | } 93 | 94 | bool updated; 95 | CCVector3 prevIncline; 96 | CCVector3 currIncline; 97 | CCVector3 newIncline; 98 | 99 | CCVector3 change; 100 | }; 101 | 102 | 103 | 104 | class CCControls 105 | { 106 | public: 107 | CCControls(); 108 | 109 | void render(); 110 | 111 | // Synchronizes the controls 112 | void update(const CCTime &time); 113 | 114 | // Update our touch logic 115 | static void UpdateTouch(CCScreenTouches &touch, const CCTime &time); 116 | 117 | protected: 118 | void unTouch(UITouch *touch); 119 | 120 | public: 121 | static bool DetectZoomGesture(const CCScreenTouches &touch1, const CCScreenTouches &touch2); 122 | static bool DetectRotateGesture(const CCScreenTouches &touch1, const CCScreenTouches &touch2); 123 | static bool TouchActionMoving(const CCTouchAction touchAction); 124 | 125 | static const CCPoint& GetTouchMovementThreashold() { return TouchMovementThreashold; } 126 | static void RefreshTouchMovementThreashold(); 127 | static void SetDPI(const float x, const float y); 128 | 129 | const CCScreenTouches* getScreenTouches() { return screenTouches; } 130 | const CCSensorInclinometer& getInclinometer() { return inclinometer; } 131 | 132 | public: 133 | enum { max_touches = 2 }; 134 | 135 | protected: 136 | bool inUse; 137 | CCScreenTouches screenTouches[max_touches]; 138 | static CCPoint TouchMovementPixels; 139 | static CCPoint TouchMovementThreashold; 140 | 141 | CCSensorInclinometer inclinometer; 142 | }; 143 | 144 | 145 | #endif // __CONTROLS_H_ 146 | -------------------------------------------------------------------------------- /engine/source/tools/CCMathTools.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCMathTools.h 7 | * Description : Collection of math tools. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #include "CCVectors.h" 15 | 16 | #define CC_SMALLFLOAT 0.01f 17 | #define CC_PI (float)M_PI 18 | const float CC_PI2 = CC_PI*CC_PI; 19 | const float CC_HPI = CC_PI * 0.5f; 20 | 21 | #define CC_DEGREES_TO_RADIANS(__ANGLE__) ( CC_PI * (__ANGLE__) / 180.0f ) 22 | #define CC_RADIANS_TO_DEGREES(__ANGLE__) ( 180.0f * (__ANGLE__) / CC_PI ) 23 | 24 | #define CC_SWAP(x,y) x^=y^=x^=y 25 | 26 | #define CC_SQUARE(x) x*x 27 | 28 | extern bool CCEqualFloat(const float a, const float b); 29 | extern float CCSignFloat(const float value); 30 | 31 | extern int CCRandomDualInt(); 32 | 33 | // Float operations 34 | extern float CCFloatRandom(); 35 | extern float CCFloatRandomDualSided(); 36 | extern void CCFloatSwap(float &a, float &b); 37 | extern void CCFloatClamp(float &value, const float min, const float max); 38 | 39 | extern void CCClampInt(int &value, const int min, const int max); 40 | inline bool CCToTarget(float &value, const float target, const float amount) 41 | { 42 | if( value != target ) 43 | { 44 | if( value > target ) 45 | { 46 | value = MAX( target, value - amount ); 47 | } 48 | else 49 | { 50 | value = MIN( target, value + amount ); 51 | } 52 | 53 | return true; 54 | } 55 | 56 | return false; 57 | } 58 | 59 | extern bool CCToRotation(float ¤t, float target, const float amount); 60 | extern float CCLengthSquared(const float a, const float b); 61 | extern uint CCPowerOf2(const uint value); 62 | extern uint CCNextPowerOf2(uint x); 63 | 64 | extern float CCDistance(const float first, const float second); 65 | extern void CCClampDistance(float ¤t, const float target, const float offset); 66 | 67 | extern float CCDistanceBetweenPoints(const CCPoint &first, const CCPoint &second); 68 | extern float CCDistanceBetweenAngles(const float first, const float second); 69 | extern float CCDirectionBetweenAngles(const float first, const float second); 70 | extern float CCAngleBetweenPoints(const CCPoint &first, const CCPoint &second); 71 | extern float CCAngleBetweenLines(const CCPoint &line1Start, const CCPoint &line1End, const CCPoint &line2Start, const CCPoint &line2End); 72 | 73 | extern void CCClampRotation(float &rotation); 74 | 75 | extern void CCRotateAboutX(CCVector3 &rotatedPosition, const float rotation, const CCVector3 &from, const CCVector3 &about); 76 | extern void CCRotateAboutY(CCVector3 &rotatedPosition, const float rotation, const CCVector3 &from, const CCVector3 &about); 77 | 78 | extern float CCRotateXAboutY(const float x, const float z, const float cosAngle, const float sinAngle); 79 | extern float CCRotateZAboutY(const float x, const float z, const float cosAngle, const float sinAngle); 80 | 81 | extern void CCRotateAboutXY(CCVector3 &rotatedPosition, const float rotationX, const float rotationY, const CCVector3 &from, const CCVector3 &about); 82 | 83 | extern void CCRotatePoint(CCPoint &position, const float rotation); 84 | 85 | extern bool CCOppositePoints(const CCPoint &pointA, const CCPoint &pointB); 86 | 87 | extern float CCAngleTowards(const float fromX, const float fromZ, const float toX, const float toZ); 88 | extern float CCAngleTowards(const CCVector3 &from, const CCVector3 &to); 89 | 90 | // Clamp the rotation down to movements of an angle (i.e. only allow right angles 90degrees) 91 | extern void CCLockRotation(float *rotation, const float angle); 92 | -------------------------------------------------------------------------------- /engine/source/scenes/CCSceneBase.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCSceneBase.h 7 | * Description : Handles the drawing and updating of objects. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCSCENEBASE_H__ 15 | #define __CCSCENEBASE_H__ 16 | 17 | 18 | class CCObject; 19 | class CCCameraAppUI; 20 | 21 | class CCSceneBase : public CCBaseType 22 | { 23 | public: 24 | CCSceneBase(); 25 | virtual void destruct(); 26 | virtual void deleteLater(); 27 | 28 | virtual void setup() {}; 29 | virtual void restart() {} 30 | 31 | void deleteLinkedScenesLater(); 32 | inline bool shouldDelete() { return deleteMe; } 33 | 34 | // Called by the Engine to let the scene fetch and handle the controls 35 | virtual bool updateControls(const CCTime &time); 36 | 37 | // Called by updateControls or a user object perhaps rendering the scene in a frame buffer with specific touches to handle the controls with 38 | virtual bool handleTouches(const CCScreenTouches &touch1, const CCScreenTouches &touch2, const CCTime &time) { return false; } 39 | 40 | virtual bool shouldHandleBackButton() { return false; } 41 | virtual void handleBackButton() {} 42 | 43 | bool update(const CCTime &time); 44 | bool updateTask(const CCTime &time); 45 | 46 | protected: 47 | virtual bool updateScene(const CCTime &time); 48 | virtual bool updateCamera(const CCTime &time); 49 | 50 | public: 51 | virtual const CCCameraBase* getCamera() { return NULL; } 52 | virtual void resize() {} 53 | virtual void resized() {} 54 | 55 | public: 56 | virtual bool render(const CCCameraBase *inCamera, const CCRenderPass pass, const bool alpha); 57 | 58 | protected: 59 | virtual void renderObjects(const CCCameraBase *inCamera, const CCRenderPass pass, const bool alpha); 60 | 61 | public: 62 | // For sorted objects, we get passed the object to draw here 63 | virtual void renderVisibleObject(CCObject *object, const CCCameraBase *inCamera, const CCRenderPass pass, const bool alpha); 64 | 65 | virtual bool postRender(const CCCameraBase *inCamera, const CCRenderPass pass, const bool alpha) { return false; } 66 | 67 | // Add object to the scene and place in the created list 68 | void addObject(CCObject *object); 69 | void removeObject(CCObject* object); 70 | 71 | void addCollideable(CCCollideable *collideable); 72 | void removeCollideable(CCCollideable *collideable); 73 | 74 | virtual void removeTile(class CCTile3DButton *tile) {} 75 | 76 | // Tells the scene to inform on deletes 77 | void setParent(CCSceneBase *inParent); 78 | virtual void deletingChild(CCSceneBase *inScene) {} 79 | 80 | public: 81 | // Passes on renders and controls to child scenes 82 | void addChildScene(CCSceneBase *inScene); 83 | void removeChildScene(CCSceneBase *inScene); 84 | 85 | // Linked scenes are deleted along with this scene 86 | void linkScene(CCSceneBase *inScene); 87 | void unlinkScene(CCSceneBase *inScene); 88 | 89 | // Runs on native thread 90 | virtual void appPaused() {} 91 | virtual void appResumed() {} 92 | 93 | public: 94 | bool enabled; 95 | 96 | protected: 97 | bool deleteMe; 98 | 99 | protected: 100 | CCPtrList objects; 101 | CCPtrList collideables; 102 | 103 | CCSceneBase *parentScene; 104 | CCPtrList childScenes; 105 | CCPtrList linkedScenes; 106 | 107 | float lifetime; 108 | }; 109 | 110 | 111 | #endif // __CCSCENEBASE_H__ 112 | -------------------------------------------------------------------------------- /engine/source/tools/CCExternalAccessoryManager.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCExternalAccessoryManager.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCAppManager.h" 12 | 13 | #ifdef IOS 14 | static CCDeviceExternalAccessoryManager *gEAManager = NULL; 15 | #endif 16 | 17 | CCPtrList CCExternalAccessoryManager::accessoryList; 18 | CCAccessoryReader *CCExternalAccessoryManager::accessoryReader; 19 | 20 | 21 | void CCExternalAccessoryManager::Reset() 22 | { 23 | CCNativeThreadLock(); 24 | 25 | accessoryList.deleteObjects(); 26 | 27 | #ifdef IOS 28 | if( gEAManager == NULL ) 29 | { 30 | gEAManager = [[CCDeviceExternalAccessoryManager alloc] init]; 31 | } 32 | [gEAManager resetAccessories]; 33 | #endif 34 | 35 | accessoryReader = NULL; 36 | 37 | CCNativeThreadUnlock(); 38 | } 39 | 40 | 41 | void CCExternalAccessoryManager::Stop() 42 | { 43 | #ifdef IOS 44 | if( gEAManager != NULL ) 45 | { 46 | [gEAManager release]; 47 | gEAManager = NULL; 48 | } 49 | #endif 50 | } 51 | 52 | 53 | bool CCExternalAccessoryManager::openSession() 54 | { 55 | #ifdef IOS 56 | return [gEAManager openSession]; 57 | #endif 58 | 59 | return false; 60 | } 61 | 62 | 63 | void CCExternalAccessoryManager::closeSession() 64 | { 65 | #ifdef IOS 66 | [gEAManager closeSession]; 67 | #endif 68 | } 69 | 70 | 71 | void CCExternalAccessoryManager::setupControllerForAccessory(CCExternalAccessory *accessory, const char *protocol) 72 | { 73 | #ifdef IOS 74 | [gEAManager setupControllerForAccessory:accessory->accessory withProtocolString:protocol]; 75 | #endif 76 | } 77 | 78 | 79 | void CCExternalAccessoryManager::addAccessory(EAAccessory *inAccessory) 80 | { 81 | #ifdef IOS 82 | CCNativeThreadLock(); 83 | 84 | EAAccessory *eaAccessory = inAccessory; 85 | const uint connectionID = [eaAccessory connectionID]; 86 | 87 | for( int i=0; iconnectionID == connectionID ) 91 | { 92 | CCNativeThreadUnlock(); 93 | return; 94 | } 95 | } 96 | 97 | CCExternalAccessory *accessory = new CCExternalAccessory(); 98 | accessory->accessory = inAccessory; 99 | accessory->connectionID = connectionID; 100 | 101 | NSArray *protocols = [eaAccessory protocolStrings]; 102 | const int protocolsLength = [protocols count]; 103 | for( int i=0; iprotocolStrings.add( new CCText( [protocol UTF8String] ) ); 107 | } 108 | 109 | accessoryList.add( accessory ); 110 | 111 | CCNativeThreadUnlock(); 112 | #endif 113 | } 114 | 115 | 116 | void CCExternalAccessoryManager::removeAccessory(EAAccessory *inAccessory) 117 | { 118 | CCNativeThreadLock(); 119 | 120 | uint connectionID = 0; 121 | 122 | #ifdef IOS 123 | EAAccessory *eaAccessory = inAccessory; 124 | connectionID = [eaAccessory connectionID]; 125 | #endif 126 | 127 | for( int i=0; iconnectionID == connectionID ) 131 | { 132 | accessoryList.remove( accessory ); 133 | delete accessory; 134 | break; 135 | } 136 | } 137 | 138 | CCNativeThreadUnlock(); 139 | } 140 | -------------------------------------------------------------------------------- /engine/source/objects/CCTile3D.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTile3D.h 7 | * Description : Base class for our Tile widgets. 8 | * 9 | * Created : 14/09/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCTILE3D_H__ 15 | #define __CCTILE3D_H__ 16 | 17 | 18 | class CCTouchable 19 | { 20 | public: 21 | CCTouchable() 22 | { 23 | touching = false; 24 | touchReleased = false; 25 | } 26 | 27 | inline float getTouchingTime() { return touchingTime; } 28 | 29 | virtual bool handleProjectedTouch(const CCCameraProjectionResults &cameraProjectionResults, 30 | const CCCollideable *hitObject, 31 | const CCVector3 &hitPosition, 32 | const CCScreenTouches &touch, 33 | const CCTouchAction touchAction) = 0; 34 | 35 | // Called when the tile is touched 36 | virtual void touchActionPressed(const float x, const float y, const CCScreenTouches &touch, const CCTouchAction touchAction) = 0; 37 | 38 | // Called when a touch is moved over this tile 39 | virtual void touchActionMoved(const float x, const float y, const CCScreenTouches &touch, const CCTouchAction touchAction) = 0; 40 | 41 | // Called when the tile is released 42 | virtual void touchActionRelease(const CCTouchAction touchAction) = 0; 43 | 44 | protected: 45 | // Callbacks 46 | virtual void handleTouchRelease() = 0; 47 | virtual void onTouchPress() 48 | { 49 | CCLAMBDA_EMIT( onPress ); 50 | } 51 | 52 | virtual void onTouchMove() 53 | { 54 | CCLAMBDA_EMIT( onMove ); 55 | } 56 | 57 | virtual void onTouchRelease() 58 | { 59 | CCLAMBDA_EMIT( onRelease ); 60 | } 61 | 62 | virtual void onTouchLoss() 63 | { 64 | CCLAMBDA_EMIT( onLoss ); 65 | } 66 | 67 | protected: 68 | bool touching; 69 | float touchingTime; 70 | bool touchReleased; 71 | 72 | public: 73 | CCLAMBDA_SIGNAL onPress; 74 | CCLAMBDA_SIGNAL onMove; 75 | CCLAMBDA_SIGNAL onRelease; 76 | CCLAMBDA_SIGNAL onLoss; 77 | }; 78 | 79 | 80 | 81 | class CCTile3D : public CCCollideable, public CCTouchable, public virtual CCActiveAllocation 82 | { 83 | public: 84 | typedef CCCollideable super; 85 | 86 | CCTile3D(); 87 | virtual void destruct(); 88 | 89 | // CCRenderable 90 | virtual void dirtyModelMatrix(); 91 | virtual void setPositionXYZ(const float x, const float y, const float z); 92 | virtual void translate(const float x, const float y, const float z); 93 | 94 | // Positioning Tiles 95 | void positionTileY(float &y); 96 | virtual void positionTileBelow(CCTile3D *fromTile); 97 | void positionTileAbove(CCTile3D *fromTile); 98 | void positionTileRight(CCTile3D *fromTile); 99 | void positionTileLeft(CCTile3D *fromTile); 100 | 101 | void setTileMovement(const CCVector3 target); 102 | void setTileMovementX(const float x); 103 | void translateTileMovementX(const float x); 104 | void setTileMovementY(const float y); 105 | void setTileMovementXY(const float x, const float y); 106 | void setTileMovementYZ(const float y, const float z); 107 | void setTileMovementBelow(const CCTile3D *fromTile); 108 | const CCVector3 getTileMovementTarget() const; 109 | 110 | // Objects which move along with this tile, but contain handle their own collisions 111 | CCPtrList attachments; 112 | }; 113 | 114 | 115 | #endif // __CCTILE3D_H__ 116 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureBase.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureBase.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCTextureBase.h" 12 | 13 | #ifdef WP8 14 | #include 15 | #include 16 | #endif 17 | 18 | 19 | CCTextureBase::CCTextureBase() 20 | { 21 | allocatedBytes = 0; 22 | } 23 | 24 | 25 | CCTextureBase::~CCTextureBase() 26 | { 27 | if( glName != 0 ) 28 | { 29 | #ifndef DXRENDERER 30 | glDeleteTextures( 1, &glName ); 31 | #endif 32 | } 33 | } 34 | 35 | 36 | void CCTextureBase::loadAndCreateAsync(const char *path, const CCResourceType resourceType, const CCTextureLoadOptions options, CCLambdaSafeCallback *callback) 37 | { 38 | CCLAMBDA_4( CreateFunction, CCTextureBase, that, bool, loaded, CCTextureLoadOptions, options, CCLambdaSafeCallback*, callback, { 39 | 40 | if( gEngine->paused ) 41 | { 42 | loaded = false; 43 | } 44 | 45 | if( loaded ) 46 | { 47 | that->createGLTexture( options ); 48 | } 49 | 50 | if( callback != NULL ) 51 | { 52 | callback->runParameters = (void*)loaded; 53 | callback->safeRun(); 54 | delete callback; 55 | } 56 | 57 | }); 58 | 59 | CCLAMBDA_FINISH_6( LoadFunction, CCTextureBase, that, CCText, path, CCResourceType, resourceType, CCTextureLoadOptions, options, CCLambdaSafeCallback*, callback, bool, loaded, 60 | 61 | // Run on a random thread 62 | { 63 | if( gEngine->paused ) 64 | { 65 | loaded = false; 66 | } 67 | else 68 | { 69 | loaded = that->load( path.buffer, resourceType ); 70 | } 71 | }, 72 | 73 | // Finish on the jobs thread 74 | { 75 | if( gEngine != NULL ) 76 | { 77 | gEngine->jobsToEngineThread( new CreateFunction( that, loaded, options, callback ) ); 78 | } 79 | }); 80 | 81 | gEngine->engineToJobsThread( new LoadFunction( this, path, resourceType, options, callback, false ) ); 82 | } 83 | 84 | 85 | bool CCTextureBase::loadAndCreateSync(const char *path, const CCResourceType resourceType, const CCTextureLoadOptions options) 86 | { 87 | if( gEngine->paused ) 88 | { 89 | return false; 90 | } 91 | 92 | const bool loaded = load( path, resourceType ); 93 | if( loaded ) 94 | { 95 | createGLTexture( options ); 96 | } 97 | return loaded; 98 | } 99 | 100 | 101 | bool CCTextureBase::ExtensionSupported(const char *extension) 102 | { 103 | #ifdef DXRENDERER 104 | #else 105 | const GLubyte *extensions = NULL; 106 | const GLubyte *start; 107 | GLubyte *where, *terminator; 108 | 109 | // Extension names should not have spaces 110 | where = (GLubyte*)strchr( extension, ' ' ); 111 | if( where || *extension == '\0' ) return 0; 112 | 113 | // It takes a bit of care to be fool-proof about parsing the OpenGL extensions string. Don't be fooled by sub-strings, etc. 114 | extensions = glGetString( GL_EXTENSIONS ); 115 | start = extensions; 116 | for(;;) 117 | { 118 | where = (GLubyte*)strstr( (const char*)start, extension ); 119 | if( !where ) 120 | { 121 | break; 122 | } 123 | terminator = where + strlen( extension ); 124 | if( where == start || *( where - 1 ) == ' ' ) 125 | { 126 | if( *terminator == ' ' || *terminator == '\0' ) 127 | { 128 | return true; 129 | } 130 | } 131 | start = terminator; 132 | } 133 | #endif 134 | return false; 135 | } 136 | -------------------------------------------------------------------------------- /external/3dsloader/3dsvect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ---------------- www.spacesimulator.net -------------- 3 | * ---- Space simulators and 3d engine tutorials ---- 4 | * 5 | * Author: Damiano Vitulli 6 | * 7 | * This program is released under the BSD licence 8 | * By using this program you agree to licence terms on spacesimulator.net copyright page 9 | * 10 | * 11 | * Maths library for vectors management 12 | * 13 | */ 14 | 15 | #include 16 | #include "3dsvect.h" 17 | 18 | 19 | /********************************************************** 20 | * 21 | * SUBROUTINE VectCreate (p3d_ptr_type p_start, p3d_ptr_type p_end, p3d_ptr_type p_vector) 22 | * 23 | * This function creates a vector from two points 24 | * 25 | * Parameters: p_start = 3d point 1 26 | * p_end = 3d point 2 27 | * p_vector = final vector 28 | * 29 | *********************************************************/ 30 | 31 | void VectCreate(p3d_type *p_start, p3d_type *p_end, p3d_type *p_vector ) 32 | { 33 | p_vector->x = p_end->x - p_start->x; 34 | p_vector->y = p_end->y - p_start->y; 35 | p_vector->z = p_end->z - p_start->z; 36 | VectNormalize(p_vector); 37 | } 38 | 39 | 40 | 41 | /********************************************************** 42 | * 43 | * FUNCTION VectLength (p3d_ptr_type p_vector) 44 | * 45 | * Returns the length of the vector 46 | * 47 | * Parameters: p_vector = vector 48 | * 49 | * Return value: (float) Length of the vector 50 | * 51 | *********************************************************/ 52 | 53 | float VectLength(p3d_type *p_vector) 54 | { 55 | return (float)(sqrt(p_vector->x*p_vector->x + p_vector->y*p_vector->y + p_vector->z*p_vector->z)); 56 | } 57 | 58 | 59 | 60 | /********************************************************** 61 | * 62 | * SUBROUTINE VectNormalize (p3d_ptr_type p_vector) 63 | * 64 | * This function Normalize a vector: all the three components x,y,z are scaled to 1 65 | * 66 | * Parameters: p_vector = vector 67 | * 68 | *********************************************************/ 69 | 70 | void VectNormalize(p3d_type *p_vector) 71 | { 72 | float l_length; 73 | 74 | l_length = VectLength(p_vector); 75 | if (l_length==0) l_length=1; 76 | p_vector->x /= l_length; 77 | p_vector->y /= l_length; 78 | p_vector->z /= l_length; 79 | } 80 | 81 | 82 | 83 | /********************************************************** 84 | * 85 | * FUNCTION VectScalarProduct (p3d_ptr_type p_vector1,p3d_ptr_type p_vector2) 86 | * 87 | * Scalar product between two vectors 88 | * 89 | * Parameters: p_vector1 = vector1 90 | * p_vector2 = vector2 91 | * 92 | * Return value: (float) scalar product = vector1 x vector2 93 | * 94 | *********************************************************/ 95 | 96 | float VectScalarProduct(p3d_type *p_vector1, p3d_type *p_vector2) 97 | { 98 | return (p_vector1->x*p_vector2->x + p_vector1->y*p_vector2->y + p_vector1->z*p_vector2->z); 99 | } 100 | 101 | 102 | 103 | /********************************************************** 104 | * 105 | * SUBROUTINE VectDotProduct (p3d_ptr_type p_vector1,p3d_ptr_type p_vector2,p3d_ptr_type p_normal) 106 | * 107 | * Calculate the dot product between p_vector1 and p_vector2 and stores the result in p_normal 108 | * 109 | * Parameters: p_vector1 = vector1 110 | * p_vector2 = vector2 111 | * p_normal = dot product = vector1 dot vector2 112 | * 113 | *********************************************************/ 114 | 115 | void VectDotProduct(p3d_type *p_vector1, p3d_type *p_vector2, p3d_type *p_normal) 116 | { 117 | p_normal->x=(p_vector1->y * p_vector2->z) - (p_vector1->z * p_vector2->y); 118 | p_normal->y=(p_vector1->z * p_vector2->x) - (p_vector1->x * p_vector2->z); 119 | p_normal->z=(p_vector1->x * p_vector2->y) - (p_vector1->y * p_vector2->x); 120 | } 121 | -------------------------------------------------------------------------------- /engine/source/tools/CCString.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCString.h 7 | * Description : Contains base structures. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCSTRING_H__ 15 | #define __CCSTRING_H__ 16 | 17 | 18 | struct CCText : CCData 19 | { 20 | CCText() {} 21 | explicit CCText(const int inLength); 22 | CCText(const char *text); 23 | CCText(const CCText &other); 24 | 25 | bool operator==(const char *other) const; 26 | bool operator!=(const char *other) const; 27 | CCText& operator=(const char *text); 28 | CCText& operator=(const CCText &other); 29 | 30 | void set(const char *text); 31 | void set(const char *text, const uint inLength); 32 | void clear(); 33 | void trimLength(const uint maxLength); 34 | 35 | inline static bool Equals(const CCText &text, const CCText &token) 36 | { 37 | return Equals( text.buffer, token.buffer ); 38 | } 39 | 40 | inline static bool Equals(const CCText &text, const char *token) 41 | { 42 | return Equals( text.buffer, token ); 43 | } 44 | 45 | inline static bool Equals(const char *buffer, const char *token) 46 | { 47 | if( buffer == NULL && token == NULL ) 48 | { 49 | return true; 50 | } 51 | if( buffer != NULL && token != NULL ) 52 | { 53 | return strcmp( buffer, token ) == 0; 54 | } 55 | return false; 56 | } 57 | 58 | inline static bool Contains(const CCText &text, const CCText &token) 59 | { 60 | return Contains( text.buffer, token.buffer ); 61 | } 62 | 63 | inline static bool Contains(const CCText &text, const char *token) 64 | { 65 | return Contains( text.buffer, token); 66 | } 67 | 68 | inline static bool Contains(const char *buffer, const char *token) 69 | { 70 | if( buffer != NULL && token != NULL ) 71 | { 72 | return strstr( buffer, token ) != NULL; 73 | } 74 | return false; 75 | } 76 | 77 | static bool StartsWith(const char *buffer, const char *token); 78 | void stripExtension(); 79 | void stripFile(); 80 | void stripDirectory(const bool windowsDirectories=false); 81 | void strip(const char *token); 82 | void toLowerCase(); 83 | static void SetLastWord(const char *inBuffer, CCText &outText); 84 | 85 | const char* getExtension() 86 | { 87 | if( length > 4 ) 88 | { 89 | return buffer+length-4; 90 | } 91 | return NULL; 92 | } 93 | 94 | void replaceChar(const char search, const char replace); 95 | void replaceChars(const char *token, const char *replace); 96 | void replaceChars(const char *token, const CCText &replace); 97 | void replaceChars(const char *token, const char replace); 98 | 99 | // Set the text to be the value between the split tokens 100 | void split(CCPtrList &splitList, const char *token, const bool first=false); 101 | void splitBetween(CCText source, const char *from, const char *to); 102 | void splitBefore(CCText source, const char *before); 103 | void splitBeforeLast(CCText source, const char *before); 104 | void splitAfter(CCText source, const char *after); 105 | void splitAfterLast(CCText source, const char *after); 106 | void removeBetween(const char *from, const char *to); 107 | void removeBetweenIncluding(const char *from, const char *to); 108 | 109 | void encodeForWeb(); 110 | void removeNewLines(); 111 | }; 112 | 113 | 114 | #endif // __CCSTRING_H__ 115 | -------------------------------------------------------------------------------- /engine/source/tools/CCVectors.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCVectors.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | 12 | 13 | void CCVector3::set(const char *text) 14 | { 15 | CCText data = text; 16 | CCPtrList split; 17 | data.split( split, "," ); 18 | CCASSERT( split.length == 3 ); 19 | 20 | if( split.length == 3 ) 21 | { 22 | x = (float)atof( split.list[0] ); 23 | y = (float)atof( split.list[1] ); 24 | z = (float)atof( split.list[2] ); 25 | 26 | if( x != x ) 27 | { 28 | CCASSERT( false ); 29 | x = 0.0f; 30 | } 31 | 32 | if( y != y ) 33 | { 34 | y = 0.0f; 35 | } 36 | 37 | if( z != z ) 38 | { 39 | z = 0.0f; 40 | } 41 | } 42 | } 43 | 44 | 45 | float& CCVector3::operator[](int idx) 46 | { 47 | switch(idx) 48 | { 49 | case 0: return x; 50 | case 1: return y; 51 | case 2: return z; 52 | } 53 | CCASSERT( true ); 54 | return x; 55 | } 56 | 57 | 58 | const float& CCVector3::operator[](int idx) const 59 | { 60 | switch(idx) 61 | { 62 | case 0: return x; 63 | case 1: return y; 64 | case 2: return z; 65 | } 66 | CCASSERT( true ); 67 | return x; 68 | } 69 | 70 | 71 | bool CCVector3::toTarget(const float target, const float speed) 72 | { 73 | bool updating = CCToTarget( x, target, speed ); 74 | updating |= CCToTarget( y, target, speed ); 75 | updating |= CCToTarget( z, target, speed ); 76 | return updating; 77 | } 78 | 79 | 80 | bool CCVector3::toTarget(const CCVector3 &target, const float speed) 81 | { 82 | bool updating = CCToTarget( x, target.x, speed ); 83 | updating |= CCToTarget( y, target.y, speed ); 84 | updating |= CCToTarget( z, target.z, speed ); 85 | return updating; 86 | } 87 | 88 | 89 | bool CCVector3::toTarget(const CCVector3 &target, const float speedX, const float speedY, const float speedZ) 90 | { 91 | bool updating = CCToTarget( x, target.x, speedX ); 92 | updating |= CCToTarget( y, target.y, speedY ); 93 | updating |= CCToTarget( z, target.z, speedZ ); 94 | return updating; 95 | } 96 | 97 | 98 | void CCVector3Transform(const CCVector3 *translation, const float m[16], CCVector3 *out) 99 | { 100 | #define M(row, col) m[row*4+col] 101 | out->x = translation->x * M(0,0) + translation->y * M(1,0) + translation->z * M(2,0) + 1.0f * M(3,0); 102 | out->y = translation->x * M(0,1) + translation->y * M(1,1) + translation->z * M(2,1) + 1.0f * M(3,1); 103 | out->z = translation->x * M(0,2) + translation->y * M(1,2) + translation->z * M(2,2) + 1.0f * M(3,2); 104 | #undef M 105 | } 106 | 107 | 108 | 109 | void CCVector3::clamp(const CCVector3 &min, const CCVector3 &max) 110 | { 111 | CCFloatClamp( x, min.x, max.x ); 112 | CCFloatClamp( y, min.y, max.y ); 113 | CCFloatClamp( z, min.z, max.z ); 114 | } 115 | 116 | 117 | void CCVector3::clamp(const float min, const float max) 118 | { 119 | CCFloatClamp( x, min, max ); 120 | CCFloatClamp( y, min, max ); 121 | CCFloatClamp( z, min, max ); 122 | } 123 | 124 | 125 | void CCVector3::clampDistance(const CCVector3 &target, const float offset) 126 | { 127 | CCClampDistance( x, target.x, offset ); 128 | CCClampDistance( y, target.y, offset ); 129 | CCClampDistance( z, target.z, offset ); 130 | } 131 | 132 | 133 | bool CCColour::toTarget(const CCColour &target, const float amount) 134 | { 135 | bool interpolating = CCToTarget( red, target.red, amount ); 136 | interpolating |= CCToTarget( green, target.green, amount ); 137 | interpolating |= CCToTarget( blue, target.blue, amount ); 138 | interpolating |= CCToTarget( alpha, target.alpha, amount ); 139 | return interpolating; 140 | } 141 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureSprites.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureSprites.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCTextureSprites.h" 12 | #include "CCTextureBase.h" 13 | #include "CCPrimitives.h" 14 | 15 | 16 | CCSpriteInfo* CCTextureSprites::getSpriteInfo(const char *pageName, const CCResourceType resourceType, 17 | const char *spriteName) 18 | { 19 | CCSpritesPage *page = NULL; 20 | for( int i=0; iname == pageName ) 24 | { 25 | page = itr; 26 | break; 27 | } 28 | } 29 | 30 | if( page == NULL ) 31 | { 32 | page = new CCSpritesPage(); 33 | page->name = pageName; 34 | page->loadData( resourceType ); 35 | } 36 | 37 | return page->getSpriteInfo( spriteName ); 38 | } 39 | 40 | 41 | void CCTextureSprites::setUVs(struct CCPrimitiveSquareUVs **uvs, 42 | const char *pageName, const CCResourceType resourceType, 43 | const char *spriteName) 44 | { 45 | CCSpriteInfo *sprite = getSpriteInfo( pageName, resourceType, spriteName ); 46 | sprite->setUVs( uvs ); 47 | } 48 | 49 | 50 | 51 | void CCSpritesPage::loadData(const CCResourceType resourceType) 52 | { 53 | // textureIndex = gEngine->textureManager->assignTextureIndex( name.buffer, resourceType, false, false, false ); 54 | // const CCTextureBase *texture = gEngine->textureManager->getTextureIndex( textureIndex ); 55 | // CCASSERT( texture != NULL ); 56 | // const float textureWidth = texture->getImageWidth(); 57 | // const float textureHeight = texture->getImageHeight(); 58 | // 59 | // CCText xmlFilename = name; 60 | // xmlFilename.stripExtension(); 61 | // xmlFilename += ".xml"; 62 | // XMLDocument *xml = new XMLDocument(); 63 | // XMLNode *xmlRoot = xml->loadRootNode( xmlFilename.buffer ); 64 | // while( xmlRoot != NULL ) 65 | // { 66 | // CCSpriteInfo *sprite = new CCSpriteInfo(); 67 | // sprites.add( sprite ); 68 | // sprite->name = xmlRoot->tag(); 69 | // 70 | // XMLNode *internals = xmlRoot->getRoot(); 71 | // while( internals != NULL ) 72 | // { 73 | // if( internals->tagIs( "frame" ) ) 74 | // { 75 | // sprite->x1 = internals->attributeFloat( "x1", 0.0f, true ); 76 | // sprite->y1 = internals->attributeFloat( "y1", 0.0f, true ); 77 | // sprite->x2 = internals->attributeFloat( "x2", 0.0f, true ); 78 | // sprite->y2 = internals->attributeFloat( "y2", 0.0f, true ); 79 | // 80 | // const float width = sprite->x2 - sprite->x1; 81 | // const float height = sprite->y2 - sprite->y1; 82 | // sprite->width = width * textureWidth; 83 | // sprite->height = height * textureHeight; 84 | // sprite->aspectRatio = width / height; 85 | // break; 86 | // } 87 | // internals = internals->next(); 88 | // } 89 | // xmlRoot = xmlRoot->next(); 90 | // } 91 | // delete xml; 92 | } 93 | 94 | 95 | CCSpriteInfo* CCSpritesPage::getSpriteInfo(const char *spriteName) 96 | { 97 | CCSpriteInfo *sprite = NULL; 98 | for( int i=0; iname == spriteName ) 102 | { 103 | sprite = itr; 104 | break; 105 | } 106 | } 107 | CCASSERT( sprite != NULL ); 108 | return sprite; 109 | } 110 | 111 | 112 | void CCSpritesPage::setUVs(CCPrimitiveSquareUVs **uvs, const char *spriteName) 113 | { 114 | CCSpriteInfo *sprite = getSpriteInfo( spriteName ); 115 | sprite->setUVs( uvs ); 116 | } 117 | 118 | 119 | void CCSpriteInfo::setUVs(CCPrimitiveSquareUVs **uvs) 120 | { 121 | CCPrimitiveSquareUVs::Setup( uvs, x1, y1, x2, y2 ); 122 | } 123 | -------------------------------------------------------------------------------- /external/base64/base64.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | base64.cpp and base64.h 3 | 4 | Copyright (C) 2004-2008 René Nyffenegger 5 | 6 | This source code is provided 'as-is', without any express or implied 7 | warranty. In no event will the author be held liable for any damages 8 | arising from the use of this software. 9 | 10 | Permission is granted to anyone to use this software for any purpose, 11 | including commercial applications, and to alter it and redistribute it 12 | freely, subject to the following restrictions: 13 | 14 | 1. The origin of this source code must not be misrepresented; you must not 15 | claim that you wrote the original source code. If you use this source code 16 | in a product, an acknowledgment in the product documentation would be 17 | appreciated but is not required. 18 | 19 | 2. Altered source versions must be plainly marked as such, and must not be 20 | misrepresented as being the original source code. 21 | 22 | 3. This notice may not be removed or altered from any source distribution. 23 | 24 | René Nyffenegger rene.nyffenegger@adp-gmbh.ch 25 | 26 | */ 27 | 28 | #include "base64.h" 29 | #include 30 | 31 | static const std::string base64_chars = 32 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 33 | "abcdefghijklmnopqrstuvwxyz" 34 | "0123456789+/"; 35 | 36 | 37 | static inline bool is_base64(unsigned char c) { 38 | return (isalnum(c) || (c == '+') || (c == '/')); 39 | } 40 | 41 | std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) { 42 | std::string ret; 43 | int i = 0; 44 | int j = 0; 45 | unsigned char char_array_3[3]; 46 | unsigned char char_array_4[4]; 47 | 48 | while (in_len--) { 49 | char_array_3[i++] = *(bytes_to_encode++); 50 | if (i == 3) { 51 | char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 52 | char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); 53 | char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); 54 | char_array_4[3] = char_array_3[2] & 0x3f; 55 | 56 | for(i = 0; (i <4) ; i++) 57 | ret += base64_chars[char_array_4[i]]; 58 | i = 0; 59 | } 60 | } 61 | 62 | if (i) 63 | { 64 | for(j = i; j < 3; j++) 65 | char_array_3[j] = '\0'; 66 | 67 | char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 68 | char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); 69 | char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); 70 | char_array_4[3] = char_array_3[2] & 0x3f; 71 | 72 | for (j = 0; (j < i + 1); j++) 73 | ret += base64_chars[char_array_4[j]]; 74 | 75 | while((i++ < 3)) 76 | ret += '='; 77 | 78 | } 79 | 80 | return ret; 81 | 82 | } 83 | 84 | std::string base64_decode(std::string const& encoded_string) { 85 | int in_len = encoded_string.size(); 86 | int i = 0; 87 | int j = 0; 88 | int in_ = 0; 89 | unsigned char char_array_4[4], char_array_3[3]; 90 | std::string ret; 91 | 92 | while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { 93 | char_array_4[i++] = encoded_string[in_]; in_++; 94 | if (i ==4) { 95 | for (i = 0; i <4; i++) 96 | char_array_4[i] = base64_chars.find(char_array_4[i]); 97 | 98 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); 99 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); 100 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; 101 | 102 | for (i = 0; (i < 3); i++) 103 | ret += char_array_3[i]; 104 | i = 0; 105 | } 106 | } 107 | 108 | if (i) { 109 | for (j = i; j <4; j++) 110 | char_array_4[j] = 0; 111 | 112 | for (j = 0; j <4; j++) 113 | char_array_4[j] = base64_chars.find(char_array_4[j]); 114 | 115 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); 116 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); 117 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; 118 | 119 | for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; 120 | } 121 | 122 | return ret; 123 | } 124 | -------------------------------------------------------------------------------- /engine/source/rendering/CCTextureManager.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTextureManager.h 7 | * Description : Manages the loading and setting of textures. 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | #ifndef __CCTEXTUREMANAGER_H__ 15 | #define __CCTEXTUREMANAGER_H__ 16 | 17 | 18 | #include "CCTextureBase.h" 19 | class CCTextureFontPage; 20 | struct CCTextureSprites; 21 | 22 | 23 | struct CCTextureLoadOptions 24 | { 25 | CCTextureLoadOptions(const bool asyncLoad=true, const bool alwaysResident=false) 26 | { 27 | filter = GL_LINEAR; 28 | disableMipMapping = false; 29 | this->asyncLoad = asyncLoad; 30 | this->alwaysResident = alwaysResident; 31 | } 32 | int filter; 33 | bool disableMipMapping; 34 | bool asyncLoad; 35 | bool alwaysResident; 36 | 37 | bool equals(const CCTextureLoadOptions &options) const 38 | { 39 | return filter == options.filter && 40 | disableMipMapping == options.disableMipMapping; 41 | } 42 | }; 43 | 44 | struct CCTextureHandle 45 | { 46 | CCText filePath; 47 | CCResourceType resourceType; 48 | CCTextureBase *texture; 49 | 50 | bool loading; 51 | bool loadable; 52 | 53 | CCTextureLoadOptions options; 54 | 55 | float lastTimeUsed; 56 | CCLAMBDA_SIGNAL onLoad; 57 | 58 | CCTextureHandle(const char *inFilePath, const CCResourceType inResourceType) 59 | { 60 | filePath = inFilePath; 61 | resourceType = inResourceType; 62 | texture = NULL; 63 | loading = false; 64 | loadable = true; 65 | lastTimeUsed = 0.0f; 66 | } 67 | 68 | ~CCTextureHandle(); 69 | 70 | void deleteTexture(const bool reduceMemory=true); 71 | }; 72 | 73 | 74 | class CCTextureManager : public virtual CCActiveAllocation 75 | { 76 | friend class CCTextureHandle; 77 | 78 | protected: 79 | const CCTextureName *currentGLTexture; 80 | int totalTexturesLoaded; 81 | int totalUsedTextureSpace; 82 | 83 | CCPtrList textureHandles; 84 | CCPtrList recreatingTextureHandles; 85 | 86 | 87 | 88 | public: 89 | CCTextureManager(); 90 | ~CCTextureManager(); 91 | 92 | void invalidateAllTextureHandles(); // Deletes OpenGL handles (usually done after a context reset) 93 | protected: 94 | void recreatedTexture(CCTextureHandle *handle); 95 | public: 96 | bool isReady(); 97 | 98 | void loadFont(const char *name, const uint textureIndex, const char *csv); 99 | 100 | uint assignTextureIndex(const char *filePath, const CCResourceType resourceType, 101 | const CCTextureLoadOptions options=CCTextureLoadOptions()); 102 | 103 | CCTextureHandle* getTextureHandle(const char *filePath, const CCResourceType resourceType, const CCTextureLoadOptions options=CCTextureLoadOptions()); 104 | CCTextureHandle* getTextureHandle(const int handleIndex); 105 | void deleteTextureHandle(const char *filePath); 106 | void invalidateTextureHandle(const char *filePath); 107 | 108 | void loadTextureAsync(CCTextureHandle &textureHandle, CCLambdaSafeCallback *callback=NULL); 109 | void loadTextureSync(CCTextureHandle &textureHandle, CCLambdaSafeCallback *callback=NULL); 110 | void loadTextureFailed(CCTextureHandle &textureHandle, CCTextureBase **texture); 111 | void loadedTexture(CCTextureHandle &textureHandle, CCTextureBase *texture); 112 | 113 | void trim(); 114 | 115 | // Used for direct OpenGL access binding 116 | void bindTexture(const CCTextureName *texture); 117 | const CCTextureName* getCurrentGLTexture() { return currentGLTexture; } 118 | 119 | // Used for assignging textures 120 | bool setTextureIndex(const int textureIndex); 121 | 122 | CCTextureBase* getTexture(const int handleIndex, CCLambdaSafeCallback *callback, const bool async=true); 123 | 124 | CCPtrList fontPages; 125 | CCTextureSprites *textureSprites; 126 | }; 127 | 128 | 129 | #endif // __CCTEXTUREMANAGER_H__ 130 | -------------------------------------------------------------------------------- /engine/resources/shaders/phongenv.fx: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : phongenv.fx 7 | * Description : Uses multitexturing for env mapping. 8 | * 9 | * Created : 10/10/11 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | precision mediump float; 15 | 16 | // ------- 17 | // Globals 18 | // ------- 19 | uniform highp mat4 u_modelViewProjectionMatrix; 20 | uniform highp mat4 u_modelViewMatrix; 21 | uniform vec4 u_modelColour; 22 | 23 | uniform mat4 u_modelNormalMatrix; 24 | uniform vec3 u_lightPosition; 25 | uniform vec4 u_lightDiffuse; 26 | 27 | uniform vec3 u_cameraPosition; 28 | 29 | 30 | // ------------------ 31 | // VS Output/PS Input 32 | // ------------------ 33 | varying vec2 ps_texCoord; 34 | 35 | varying highp vec3 ps_worldPosition; 36 | varying vec3 ps_worldNormal; 37 | 38 | varying vec3 ps_reflectionVector; 39 | 40 | 41 | // ----------------- 42 | #ifdef VERTEX_SHADER 43 | // ----------------- 44 | // VS Input 45 | attribute highp vec3 vs_position; 46 | attribute vec2 vs_texCoord; 47 | 48 | attribute vec3 vs_normal; 49 | 50 | mat3 GetLinearPart(mat4 m) 51 | { 52 | mat3 result; 53 | 54 | result[0][0] = m[0][0]; 55 | result[0][1] = m[0][1]; 56 | result[0][2] = m[0][2]; 57 | 58 | result[1][0] = m[1][0]; 59 | result[1][1] = m[1][1]; 60 | result[1][2] = m[1][2]; 61 | 62 | result[2][0] = m[2][0]; 63 | result[2][1] = m[2][1]; 64 | result[2][2] = m[2][2]; 65 | 66 | return result; 67 | } 68 | 69 | void main() 70 | { 71 | gl_Position = u_modelViewProjectionMatrix * vec4( vs_position, 1.0 ); 72 | ps_texCoord = vs_texCoord; 73 | 74 | ps_worldPosition = vec3( u_modelViewMatrix * vec4( vs_position, 1.0 ) ); 75 | 76 | #ifdef QT 77 | ps_worldNormal = vec3( 1, 1, 1 ); 78 | #else 79 | 80 | // Works for uniform scaled models 81 | // normal.w must be 0.0 to kill off translation 82 | vec3 transformedNormal = vec3( u_modelViewMatrix * vec4( vs_normal, 0.0 ) ); 83 | ps_worldNormal = normalize( transformedNormal ); 84 | 85 | // Normal matrix is required for non-uniform scaled models 86 | //vec3 transformedNormal = ( u_modelNormalMatrix * vec4( vs_normal, 1.0 ) ).xyz; 87 | //ps_worldNormal = normalize( transformedNormal ); 88 | 89 | #endif 90 | 91 | mat3 modelView3x3 = GetLinearPart( u_modelViewMatrix ); 92 | 93 | // find world space normal. 94 | vec3 N = normalize( modelView3x3 * ps_worldNormal ); 95 | 96 | // find world space eye vector. 97 | vec3 E = normalize( ps_worldPosition - u_cameraPosition ); 98 | 99 | ps_reflectionVector = reflect( E, N ); 100 | } 101 | 102 | #endif 103 | 104 | 105 | 106 | // ---------------- 107 | #ifdef PIXEL_SHADER 108 | // ---------------- 109 | 110 | uniform sampler2D s_diffuseTexture; 111 | uniform sampler2D s_envTexture; 112 | 113 | void main() 114 | { 115 | // Environment map 116 | vec4 envColour; 117 | vec3 vR = normalize( ps_reflectionVector ); 118 | 119 | // Select the front or back env map according to the sign of vR.z. 120 | if( vR.z > 0.0 ) 121 | { 122 | // calculate the forward paraboloid map texture coordinates 123 | vec2 frontUV; 124 | frontUV = ( vR.xy / (2.0 * ( 1.0 + vR.z ) ) ) + 0.5; 125 | envColour = texture2D( s_envTexture, frontUV ); 126 | } 127 | else 128 | { 129 | // calculate the backward paraboloid map texture coordinates 130 | vec2 backUV; 131 | backUV = ( vR.xy / ( 2.0 * ( 1.0 - vR.z ) ) ) + 0.5; 132 | envColour = texture2D( s_envTexture, backUV ); 133 | } 134 | 135 | vec4 diffColour = texture2D( s_diffuseTexture, ps_texCoord ).rgba; 136 | vec4 textureColour = diffColour + envColour * 0.2; 137 | textureColour = clamp( textureColour, 0.0, 1.0 ); 138 | 139 | vec3 L = normalize( u_lightPosition - ps_worldPosition ); 140 | vec4 Idiff = u_lightDiffuse * max( dot( ps_worldNormal, L ), 0.0 ); 141 | Idiff = clamp( Idiff, 0.5, 1.0 ); 142 | Idiff.a = 1.0; 143 | 144 | gl_FragColor = Idiff * u_modelColour * textureColour; 145 | } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /engine/source/objects/CCCollideable.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCCollideable.h 7 | * Description : A scene managed collideable object 8 | * 9 | * Created : 01/03/10 10 | * Author(s) : Ashraf Samy Hegab 11 | *----------------------------------------------------------- 12 | */ 13 | 14 | class CCMovementInterpolator; 15 | 16 | class CCCollideable : public CCObject 17 | { 18 | typedef CCObject super; 19 | 20 | protected: 21 | uint drawOrder; 22 | bool collisionsEnabled; 23 | 24 | public: 25 | uint collideableType; 26 | CCVector3 collisionBounds; 27 | CCSize collisionSize; 28 | CCSize inverseCollisionSize; 29 | 30 | CCVector3 aabbMin, aabbMax; 31 | bool updateCollisions; 32 | 33 | CCPtrList octrees; 34 | 35 | bool visible; 36 | 37 | protected: 38 | // The owner system allows us tie object to our lifespan, without modifying their collision or position 39 | CCCollideable *owner; 40 | CCPtrList owns; 41 | 42 | #ifdef DEBUGON 43 | CCText debugName; 44 | #endif 45 | 46 | CCMovementInterpolator *movementInterpolator; 47 | 48 | 49 | 50 | public: 51 | CCCollideable(const char *objectID=NULL); 52 | virtual void destruct(); 53 | 54 | // CCRenderable 55 | virtual void setPositionXYZ(const float x, const float y, const float z); 56 | virtual void translate(const float x, const float y, const float z); 57 | 58 | // CCObject 59 | virtual void setScene(CCSceneBase *scene); 60 | virtual void removeFromScene(); 61 | virtual void deactivate(); 62 | virtual bool shouldCollide(CCCollideable *collideWith, const bool initialCall); 63 | 64 | inline int getDrawOrder() const { return drawOrder; } 65 | void setDrawOrder(const int drawOrder) 66 | { 67 | this->drawOrder = drawOrder; 68 | } 69 | 70 | virtual void renderModel(const bool alpha); 71 | protected: 72 | virtual void renderCollisionBox(); 73 | 74 | public: 75 | virtual const char* getType() const { return NULL; } 76 | 77 | void setSquareCollisionBounds(const float size); 78 | void setSquareCollisionBounds(const float width, const float heigth); 79 | void setHSquareCollisionBounds(const float hSize); 80 | void setHSquareCollisionBounds(const float hWidth, const float hHeight); 81 | 82 | void setCollisionBounds(const float width, const float height, const float depth); 83 | void setHCollisionBounds(const float hWidth, const float hHeight, const float hDepth); 84 | 85 | // Ask to report a collision to the collidedWith object 86 | virtual CCCollideable* requestCollisionWith(CCCollideable *collidedWith); 87 | 88 | // Ask the collidedWith object if we've collided 89 | virtual CCCollideable* recieveCollisionFrom(CCCollideable *collisionSource, const float x, const float y, const float z); 90 | 91 | virtual bool reportAttack(CCObject *attackedBy, const float force, const float damage, const float x, const float y, const float z); 92 | 93 | virtual bool isCollideable() { return collisionsEnabled; } 94 | virtual void setCollideable(const bool toggle) { collisionsEnabled = toggle; } 95 | virtual bool isMoveable() { return false; } 96 | 97 | virtual void ownObject(CCCollideable *object); 98 | virtual void unOwnObject(CCCollideable *object); 99 | 100 | protected: 101 | void setOwner(CCCollideable *newOwner); 102 | 103 | // Called when parent object is removed from scene or deactivated 104 | virtual void removeOwner(CCCollideable *currentOwner); 105 | 106 | public: 107 | inline const char* getDebugName() 108 | { 109 | #ifdef DEBUGON 110 | return debugName.buffer; 111 | #endif 112 | return ""; 113 | } 114 | 115 | inline void setDebugName(const char *name) 116 | { 117 | #ifdef DEBUGON 118 | debugName = name; 119 | #endif 120 | } 121 | 122 | void createMovementInterpolator(const bool updateCollisions); 123 | 124 | CCMovementInterpolator* getMovementInterpolator() 125 | { 126 | return movementInterpolator; 127 | } 128 | 129 | float width() 130 | { 131 | return collisionSize.width; 132 | } 133 | 134 | float height() 135 | { 136 | return collisionSize.height; 137 | } 138 | }; 139 | -------------------------------------------------------------------------------- /engine/source/objects/CCObjectText.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCObjectText.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCObjects.h" 12 | #include "CCTextureManager.h" 13 | #include "CCTextureFontPage.h" 14 | 15 | 16 | CCObjectText::CCObjectText(CCCollideable *inParent) 17 | { 18 | colour = new CCColour(); 19 | setTransparent( true ); 20 | readDepth = false; 21 | 22 | shader = "alphacolour"; 23 | centered = true; 24 | endMarker = false; 25 | 26 | setFont( "HelveticaNeueLight" ); 27 | 28 | parent = inParent; 29 | if( inParent ) 30 | { 31 | inParent->addChild( this ); 32 | } 33 | } 34 | 35 | 36 | CCObjectText::CCObjectText(const long jsID) 37 | { 38 | if( jsID != -1 ) 39 | { 40 | this->jsID = jsID; 41 | } 42 | 43 | colour = NULL; // Colour handled in JS 44 | setTransparent( true ); 45 | readDepth = false; 46 | 47 | shader = NULL; // No shaders yet 48 | centered = true; 49 | endMarker = false; 50 | 51 | parent = NULL; 52 | } 53 | 54 | 55 | void CCObjectText::destruct() 56 | { 57 | super::destruct(); 58 | } 59 | 60 | 61 | void CCObjectText::renderObject(const CCCameraBase *camera, const bool alpha) 62 | { 63 | #if defined PROFILEON 64 | CCProfiler profile( "CCObjectText::renderObject()" ); 65 | #endif 66 | 67 | if( renderable ) 68 | { 69 | GLPushMatrix(); 70 | { 71 | refreshModelMatrix(); 72 | GLMultMatrixf( modelMatrix ); 73 | 74 | if( shader != NULL ) 75 | { 76 | gRenderer->setShader( shader ); 77 | } 78 | 79 | if( colour != NULL ) 80 | { 81 | CCSetColour( *colour ); 82 | } 83 | 84 | if( alpha == false || CCGetColour().alpha > 0.0f ) 85 | { 86 | fontPage->renderText( text.buffer, text.length, height, centered ); 87 | 88 | if( endMarker ) 89 | { 90 | gEngine->textureManager->setTextureIndex( 1 ); 91 | const float x = ( fontPage->getWidth( text.buffer, text.length, height ) + fontPage->getCharacterWidth( ' ', height ) ) * 0.5f; 92 | const float y = height * 0.45f; 93 | const CCVector3 start = CCVector3( x, -y, 0.0f ); 94 | const CCVector3 end = CCVector3( x, y, 0.0f ); 95 | CCRenderLine( start, end ); 96 | } 97 | } 98 | } 99 | GLPopMatrix(); 100 | } 101 | } 102 | 103 | 104 | void CCObjectText::setText(const char *text, const float height, const char *font) 105 | { 106 | this->text = text; 107 | 108 | if( height != -1.0f ) 109 | { 110 | setHeight( height ); 111 | } 112 | 113 | if( font != NULL ) 114 | { 115 | setFont( font ); 116 | } 117 | } 118 | 119 | 120 | float CCObjectText::getWidth() 121 | { 122 | return fontPage->getWidth( text.buffer, text.length, height ); 123 | } 124 | 125 | 126 | float CCObjectText::getHeight() 127 | { 128 | return fontPage->getHeight( text.buffer, text.length, height ); 129 | } 130 | 131 | 132 | void CCObjectText::setHeight(const float height) 133 | { 134 | this->height = height; 135 | } 136 | 137 | 138 | void CCObjectText::setCentered(const bool centered) 139 | { 140 | if( centered ) 141 | { 142 | setPositionX( 0.0f ); 143 | } 144 | else if( parent != NULL ) 145 | { 146 | setPositionX( -parent->collisionBounds.x ); 147 | } 148 | 149 | this->centered = centered; 150 | } 151 | 152 | 153 | void CCObjectText::setFont(const char *font) 154 | { 155 | for( int i=0; itextureManager->fontPages.length; ++i ) 156 | { 157 | CCTextureFontPage *page = gEngine->textureManager->fontPages.list[i]; 158 | const char *name = page->getName(); 159 | if( CCText::Equals( font, name ) ) 160 | { 161 | fontPage = page; 162 | return; 163 | } 164 | } 165 | 166 | //CCASSERT( false ); 167 | fontPage = gEngine->textureManager->fontPages.list[0]; 168 | } 169 | -------------------------------------------------------------------------------- /engine/source/objects/CCTile3D.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCTile3D.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCObjects.h" 12 | #include "CCTextureFontPage.h" 13 | #include "CCMovementInterpolator.h" 14 | 15 | 16 | CCTile3D::CCTile3D() 17 | { 18 | setDebugName( "Tile3D" ); 19 | } 20 | 21 | 22 | void CCTile3D::destruct() 23 | { 24 | // Delete objects from CCTouchable 25 | onPress.deleteObjectsAndList(); 26 | onMove.deleteObjectsAndList(); 27 | onRelease.deleteObjectsAndList(); 28 | onLoss.deleteObjectsAndList(); 29 | 30 | super::destruct(); 31 | } 32 | 33 | 34 | // CCRenderable 35 | void CCTile3D::dirtyModelMatrix() 36 | { 37 | super::dirtyModelMatrix(); 38 | for( int i=0; idirtyModelMatrix(); 42 | } 43 | } 44 | 45 | 46 | void CCTile3D::setPositionXYZ(const float x, const float y, const float z) 47 | { 48 | if( position.x != x || position.y != y || position.z != z ) 49 | { 50 | CCVector3 distance = position; 51 | super::setPositionXYZ( x, y, z ); 52 | distance.sub( position ); 53 | 54 | for( int i=0; itranslate( -distance.x, -distance.y, -distance.z ); 58 | } 59 | 60 | CCOctreeRefreshObject( this ); 61 | 62 | if( movementInterpolator != NULL ) 63 | { 64 | movementInterpolator->clear(); 65 | } 66 | } 67 | } 68 | 69 | 70 | void CCTile3D::translate(const float x, const float y, const float z) 71 | { 72 | super::translate( x, y, z ); 73 | 74 | for( int i=0; itranslate( x, y, z ); 78 | } 79 | 80 | CCOctreeRefreshObject( this ); 81 | } 82 | 83 | 84 | // Positioning Tiles 85 | void CCTile3D::positionTileY(float &y) 86 | { 87 | y -= collisionBounds.y; 88 | translate( 0.0f, y, 0.0f ); 89 | y -= collisionBounds.y; 90 | } 91 | 92 | 93 | void CCTile3D::positionTileBelow(CCTile3D *fromTile) 94 | { 95 | setPosition( fromTile->getConstPosition() ); 96 | translate( 0.0f, -( fromTile->collisionBounds.y + collisionBounds.y ), 0.0f ); 97 | } 98 | 99 | 100 | void CCTile3D::positionTileAbove(CCTile3D *fromTile) 101 | { 102 | setPosition( fromTile->getConstPosition() ); 103 | translate( 0.0f, fromTile->collisionBounds.y + collisionBounds.y, 0.0f ); 104 | } 105 | 106 | 107 | void CCTile3D::positionTileRight(CCTile3D *fromTile) 108 | { 109 | setPosition( fromTile->getConstPosition() ); 110 | translate( fromTile->collisionBounds.x + collisionBounds.x, 0.0f, 0.0f ); 111 | } 112 | 113 | 114 | void CCTile3D::positionTileLeft(CCTile3D *fromTile) 115 | { 116 | setPosition( fromTile->getConstPosition() ); 117 | translate( -( fromTile->collisionBounds.x + collisionBounds.x ), 0.0f, 0.0f ); 118 | } 119 | 120 | 121 | void CCTile3D::setTileMovement(const CCVector3 target) 122 | { 123 | movementInterpolator->setMovement( target ); 124 | } 125 | 126 | 127 | void CCTile3D::setTileMovementX(const float x) 128 | { 129 | movementInterpolator->setMovementX( x ); 130 | } 131 | 132 | 133 | void CCTile3D::translateTileMovementX(const float x) 134 | { 135 | movementInterpolator->translateMovementX( x ); 136 | } 137 | 138 | 139 | void CCTile3D::setTileMovementY(const float y) 140 | { 141 | movementInterpolator->setMovementY( y ); 142 | } 143 | 144 | 145 | void CCTile3D::setTileMovementXY(const float x, const float y) 146 | { 147 | movementInterpolator->setMovementXY( x, y ); 148 | } 149 | 150 | 151 | void CCTile3D::setTileMovementYZ(const float y, const float z) 152 | { 153 | movementInterpolator->setMovementYZ( y, z ); 154 | } 155 | 156 | 157 | void CCTile3D::setTileMovementBelow(const CCTile3D *fromTile) 158 | { 159 | CCVector3 target = fromTile->getTileMovementTarget(); 160 | target.y -= ( fromTile->collisionBounds.y + collisionBounds.y ); 161 | movementInterpolator->setMovement( target ); 162 | } 163 | 164 | 165 | const CCVector3 CCTile3D::getTileMovementTarget() const 166 | { 167 | return movementInterpolator->getMovementTarget(); 168 | } -------------------------------------------------------------------------------- /engine/source/rendering/CCPrimitiveBase.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------- 2 | * http://softwareispoetry.com 3 | *----------------------------------------------------------- 4 | * This software is distributed under the Apache 2.0 license. 5 | *----------------------------------------------------------- 6 | * File Name : CCPrimitiveBase.cpp 7 | *----------------------------------------------------------- 8 | */ 9 | 10 | #include "CCDefines.h" 11 | #include "CCPrimitives.h" 12 | #include "CCFileManager.h" 13 | #include "CCJS.h" 14 | 15 | 16 | CCPrimitiveBase::CCPrimitiveBase(const long primitiveID) 17 | { 18 | if( primitiveID != -1 ) 19 | { 20 | this->primitiveID = primitiveID; 21 | } 22 | 23 | vertices = NULL; 24 | normals = NULL; 25 | textureInfo = NULL; 26 | frameBufferID = -1; 27 | } 28 | 29 | 30 | void CCPrimitiveBase::destruct() 31 | { 32 | if( vertices != NULL ) 33 | { 34 | gRenderer->derefVertexPointer( ATTRIB_VERTEX, vertices ); 35 | free( vertices ); 36 | } 37 | 38 | if( normals != NULL ) 39 | { 40 | free( normals ); 41 | } 42 | 43 | removeTexture(); 44 | } 45 | 46 | void CCPrimitiveBase::setTexture(const char *file, CCResourceType resourceType, CCLambdaCallback *onDownloadCallback, 47 | const CCTextureLoadOptions options) 48 | { 49 | if( resourceType == Resource_Unknown ) 50 | { 51 | resourceType = CCFileManager::FindFile( file ); 52 | } 53 | 54 | if( resourceType != Resource_Unknown ) 55 | { 56 | const int textureIndex = gEngine->textureManager->assignTextureIndex( file, resourceType, options ); 57 | setTextureHandleIndex( textureIndex ); 58 | 59 | if( onDownloadCallback != NULL ) 60 | { 61 | onDownloadCallback->safeRun(); 62 | delete onDownloadCallback; 63 | } 64 | } 65 | else 66 | { 67 | CCLAMBDA_4( DownloadedCallback, CCPrimitiveBase, primitive, CCText, file, CCLambdaCallback*, nextCallback, CCTextureLoadOptions, options, 68 | { 69 | primitive->setTexture( file.buffer, Resource_Cached, nextCallback, options ); 70 | }); 71 | CCJSEngine::GetAsset( file, NULL, new DownloadedCallback( this, file, onDownloadCallback, options ) ); 72 | } 73 | } 74 | 75 | 76 | void CCPrimitiveBase::setTextureHandleIndex(const int index) 77 | { 78 | if( textureInfo == NULL ) 79 | { 80 | textureInfo = new TextureInfo(); 81 | } 82 | 83 | textureInfo->primaryIndex = index; 84 | 85 | const int textureHandleIndex = textureInfo->primaryIndex; 86 | CCTextureHandle *textureHandle = gEngine->textureManager->getTextureHandle( textureHandleIndex ); 87 | if( textureHandle->texture != NULL ) 88 | { 89 | adjustTextureUVs(); 90 | } 91 | else 92 | { 93 | CCLAMBDA_CONNECT_THIS( textureHandle->onLoad, CCPrimitiveBase, adjustTextureUVs() ); 94 | } 95 | } 96 | 97 | 98 | void CCPrimitiveBase::removeTexture() 99 | { 100 | if( textureInfo != NULL ) 101 | { 102 | DELETE_POINTER( textureInfo ); 103 | } 104 | } 105 | 106 | 107 | void CCPrimitiveBase::render() 108 | { 109 | #if defined PROFILEON 110 | CCProfiler profile( "CCPrimitiveBase::render()" ); 111 | #endif 112 | 113 | bool usingTexture = false; 114 | if( textureInfo != NULL && textureInfo->primaryIndex > 0 ) 115 | { 116 | //DEBUGLOG( "CCPrimitiveBase::render usingTexture %i", textureInfo->primaryIndex ); 117 | 118 | if( gEngine->textureManager->setTextureIndex( textureInfo->primaryIndex ) ) 119 | { 120 | usingTexture = true; 121 | 122 | #if defined PROFILEON 123 | CCTextureHandle *textureHandle = gEngine->textureManager->getTextureHandle( textureInfo->primaryIndex ); 124 | if( textureHandle != NULL ) 125 | { 126 | profile.append( textureHandle->filePath.buffer ); 127 | } 128 | #endif 129 | 130 | if( textureInfo->secondaryIndex > 0 ) 131 | { 132 | // Why would you want to use the same texture twice? you wouldn't.. bad! 133 | CCASSERT( textureInfo->primaryIndex != textureInfo->secondaryIndex ); 134 | 135 | #ifndef DXRENDERER 136 | #ifndef QT 137 | glActiveTexture( GL_TEXTURE1 ); 138 | gEngine->textureManager->setTextureIndex( textureInfo->secondaryIndex ); 139 | glActiveTexture( GL_TEXTURE0 ); 140 | #endif 141 | #endif 142 | } 143 | } 144 | } 145 | else if( frameBufferID >= 0 ) 146 | { 147 | gRenderer->frameBufferManager.bindFrameBufferTexture( frameBufferID ); 148 | } 149 | else 150 | { 151 | //DEBUGLOG( "CCPrimitiveBase::render !usingTexture" ); 152 | gEngine->textureManager->setTextureIndex( 0 ); 153 | } 154 | 155 | renderVertices( usingTexture ); 156 | } 157 | --------------------------------------------------------------------------------