├── .gitignore ├── .gitattributes ├── SDL ├── SDL_revision.h ├── SDL_revision.h.orig ├── SDL_name.h ├── SDL_copying.h ├── COPYING ├── SDL_types.h ├── SDL_opengles.h ├── SDL_opengles2.h ├── close_code.h ├── SDL_config.h ├── SDL_blendmode.h ├── SDL_clipboard.h ├── SDL_quit.h ├── SDL_error.h ├── SDL_gesture.h ├── SDL_config_minimal.h ├── SDL_main.h ├── SDL_power.h ├── SDL_touch.h ├── SDL_input.h ├── SDL_loadso.h ├── SDL_rotozoom.h ├── SDL_config_wiz.h ├── SDL_timer.h ├── SDL_config_pandora.h ├── SDL_config_android.h ├── SDL_config_nintendods.h ├── SDL_cpuinfo.h ├── begin_code.h ├── SDL_platform.h ├── SDL_config_iphoneos.h ├── SDL_rect.h ├── SDL_config_macosx.h ├── SDL_keyboard.h ├── SDL.h ├── SDL_version.h ├── SDL_image.h ├── SDL_config_windows.h ├── SDL_shape.h ├── SDL_thread.h ├── SDL_log.h ├── SDL_joystick.h ├── SDL_syswm.h ├── SDL_endian.h ├── SDL_rwops.h ├── SDL_mutex.h └── SDL_hints.h ├── .gitmodules ├── src ├── dtCrowdWrap.hpp ├── dtNavMeshWrap.hpp ├── addon.cc ├── dtNavMeshQueryWrap.hpp ├── BuildContextWrap.hpp ├── InputGeomWrap.hpp ├── dtCrowdWrap.cpp ├── dtNavMeshWrap.cpp ├── BuildContextWrap.cpp ├── dtNavMeshQueryWrap.cpp ├── Sample_TempObstaclesWrap.hpp ├── InputGeomWrap.cpp ├── Sample_TempObstaclesExt.hpp └── Sample_TempObstaclesExt.cpp ├── package.json ├── LICENSE ├── README.md ├── test └── test.js ├── binding.gyp └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | SDL/* linguist-vendored 2 | -------------------------------------------------------------------------------- /SDL/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-5605:9269bf952041" 2 | #define SDL_REVISION_NUMBER 5605 3 | -------------------------------------------------------------------------------- /SDL/SDL_revision.h.orig: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-5603:e1ca92e7f2ff" 2 | #define SDL_REVISION_NUMBER 5603 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "recastnavigation"] 2 | path = recastnavigation 3 | url = https://github.com/flyriver/recastnavigation.git 4 | -------------------------------------------------------------------------------- /SDL/SDL_name.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SDLname_h_ 3 | #define _SDLname_h_ 4 | 5 | #if defined(__STDC__) || defined(__cplusplus) 6 | #define NeedFunctionPrototypes 1 7 | #endif 8 | 9 | #define SDL_NAME(X) SDL_##X 10 | 11 | #endif /* _SDLname_h_ */ 12 | -------------------------------------------------------------------------------- /src/dtCrowdWrap.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // dtCrowdWrap.hpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #ifndef dtCrowdWrap_hpp 10 | #define dtCrowdWrap_hpp 11 | 12 | #include 13 | #include 14 | 15 | using namespace v8; 16 | 17 | class dtCrowd; 18 | class dtCrowdWrap : public Nan::ObjectWrap { 19 | 20 | public: 21 | static Nan::Persistent constructor_template; 22 | static NAN_MODULE_INIT(Init); 23 | static NAN_METHOD(New); 24 | 25 | private: 26 | dtCrowd *m_dtCrowd; 27 | }; 28 | 29 | #endif /* dtCrowdWrap_hpp */ 30 | -------------------------------------------------------------------------------- /src/dtNavMeshWrap.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // dtNavMeshWrap.hpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #ifndef dtNavMeshWrap_hpp 10 | #define dtNavMeshWrap_hpp 11 | 12 | #include 13 | #include 14 | 15 | using namespace v8; 16 | 17 | class dtNavMesh; 18 | class dtNavMeshWrap : public Nan::ObjectWrap { 19 | 20 | public: 21 | static Nan::Persistent constructor_template; 22 | static NAN_MODULE_INIT(Init); 23 | static NAN_METHOD(New); 24 | 25 | private: 26 | dtNavMesh *m_dtNavMesh; 27 | }; 28 | 29 | 30 | #endif /* dtNavMeshWrap_hpp */ 31 | -------------------------------------------------------------------------------- /src/addon.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "BuildContextWrap.hpp" 5 | #include "InputGeomWrap.hpp" 6 | #include "dtCrowdWrap.hpp" 7 | #include "dtNavMeshWrap.hpp" 8 | #include "dtNavMeshQueryWrap.hpp" 9 | #include "Sample_TempObstaclesWrap.hpp" 10 | 11 | using namespace v8; 12 | 13 | void InitAll(Handle exports) { 14 | 15 | BuildContextWrap::Init(exports); 16 | InputGeomWrap::Init(exports); 17 | Sample_TempObstaclesWrap::Init(exports); 18 | dtCrowdWrap::Init(exports); 19 | dtNavMeshWrap::Init(exports); 20 | dtNavMeshQueryWrap::Init(exports); 21 | } 22 | 23 | NODE_MODULE(addon, InitAll) 24 | -------------------------------------------------------------------------------- /src/dtNavMeshQueryWrap.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // dtNavMeshQueryWrap.hpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #ifndef dtNavMeshQueryWrap_hpp 10 | #define dtNavMeshQueryWrap_hpp 11 | 12 | #include 13 | #include 14 | 15 | using namespace v8; 16 | 17 | class dtNavMeshQuery; 18 | class dtNavMeshQueryWrap : public Nan::ObjectWrap { 19 | 20 | public: 21 | static Nan::Persistent constructor_template; 22 | static NAN_MODULE_INIT(Init); 23 | static NAN_METHOD(New); 24 | 25 | private: 26 | dtNavMeshQuery *m_dtNavMeshQuery; 27 | }; 28 | 29 | #endif /* dtNavMeshQueryWrap_hpp */ 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node_recast", 3 | "version": "1.0.11", 4 | "description": "recast navigation for node.js addon", 5 | "main": "index.js", 6 | "scripts": { 7 | "install": "node-gyp rebuild", 8 | "test": "node test/test.js" 9 | }, 10 | "private": false, 11 | "gypfile": true, 12 | "dependencies": { 13 | "bindings": "^1.5.0", 14 | "nan": "^2.13.2" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/liuhaochuan1/node_recast.git" 19 | }, 20 | "keywords": [ 21 | "recast", 22 | "navigation", 23 | "node", 24 | "pathfind", 25 | "mesh" 26 | ], 27 | "author": "liuhaochuan & zhangyu", 28 | "license": "MIT" 29 | } 30 | -------------------------------------------------------------------------------- /src/BuildContextWrap.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // BuildContextWrap.hpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #ifndef BuildContextWrap_hpp 10 | #define BuildContextWrap_hpp 11 | 12 | #include 13 | #include 14 | 15 | using namespace v8; 16 | 17 | class BuildContext; 18 | class BuildContextWrap : public Nan::ObjectWrap { 19 | 20 | public: 21 | static Nan::Persistent constructor_template; 22 | static NAN_MODULE_INIT(Init); 23 | static NAN_METHOD(New); 24 | 25 | public: 26 | BuildContext* getBuildContext() { return m_buildContext; }; 27 | 28 | private: 29 | BuildContext *m_buildContext; 30 | }; 31 | 32 | #endif /* BuildContextWrap_hpp */ 33 | -------------------------------------------------------------------------------- /src/InputGeomWrap.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // InputGeomWarp.hpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #ifndef InputGeomWrap_hpp 10 | #define InputGeomWrap_hpp 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace v8; 17 | 18 | class InputGeomNode : public InputGeom { 19 | 20 | }; 21 | 22 | class InputGeomWrap : public Nan::ObjectWrap { 23 | 24 | public: 25 | static Nan::Persistent constructor_template; 26 | static NAN_MODULE_INIT(Init); 27 | static NAN_METHOD(New); 28 | static NAN_METHOD(Load); 29 | 30 | public: 31 | InputGeom* getInputGeom() { return m_inputGeom; }; 32 | 33 | private: 34 | InputGeom *m_inputGeom; 35 | }; 36 | 37 | 38 | #endif /* InputGeomWarp_hpp */ 39 | -------------------------------------------------------------------------------- /SDL/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /src/dtCrowdWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // dtCrowdWrap.cpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #include "dtCrowdWrap.hpp" 10 | #include 11 | 12 | Nan::Persistent dtCrowdWrap::constructor_template; 13 | 14 | NAN_MODULE_INIT(dtCrowdWrap::Init) { 15 | Nan::HandleScope scope; 16 | Local t = Nan::New(New); 17 | t->InstanceTemplate()->SetInternalFieldCount(1); 18 | t->SetClassName(Nan::New("dtCrowd").ToLocalChecked()); 19 | constructor_template.Reset(t); 20 | Nan::Set(target, Nan::New("dtCrowd").ToLocalChecked(), 21 | Nan::GetFunction(t).ToLocalChecked()); 22 | } 23 | 24 | NAN_METHOD(dtCrowdWrap::New) { 25 | if (!info.IsConstructCall()) { 26 | return Nan::ThrowTypeError("Use the new operator to create new objects"); 27 | } 28 | dtCrowdWrap *obj = new dtCrowdWrap(); 29 | obj->m_dtCrowd = new dtCrowd(); 30 | obj->Wrap(info.This()); 31 | info.GetReturnValue().Set(info.This()); 32 | } -------------------------------------------------------------------------------- /src/dtNavMeshWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // dtNavMeshWrap.cpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #include "dtNavMeshWrap.hpp" 10 | #include 11 | 12 | Nan::Persistent dtNavMeshWrap::constructor_template; 13 | 14 | 15 | NAN_MODULE_INIT(dtNavMeshWrap::Init) { 16 | Nan::HandleScope scope; 17 | Local t = Nan::New(New); 18 | t->InstanceTemplate()->SetInternalFieldCount(1); 19 | t->SetClassName(Nan::New("dtNavMeshQuery").ToLocalChecked()); 20 | constructor_template.Reset(t); 21 | Nan::Set(target, Nan::New("dtNavMeshQuery").ToLocalChecked(), 22 | Nan::GetFunction(t).ToLocalChecked()); 23 | } 24 | 25 | NAN_METHOD(dtNavMeshWrap::New) { 26 | if (!info.IsConstructCall()) { 27 | return Nan::ThrowTypeError("Use the new operator to create new objects"); 28 | } 29 | dtNavMeshWrap *obj = new dtNavMeshWrap(); 30 | obj->m_dtNavMesh = new dtNavMesh(); 31 | obj->Wrap(info.This()); 32 | info.GetReturnValue().Set(info.This()); 33 | } 34 | -------------------------------------------------------------------------------- /src/BuildContextWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // BuildContextWrap.cpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #include "BuildContextWrap.hpp" 10 | #include 11 | 12 | Nan::Persistent BuildContextWrap::constructor_template; 13 | 14 | NAN_MODULE_INIT(BuildContextWrap::Init) { 15 | Nan::HandleScope scope; 16 | Local t = Nan::New(New); 17 | t->InstanceTemplate()->SetInternalFieldCount(1); 18 | t->SetClassName(Nan::New("BuildContext").ToLocalChecked()); 19 | 20 | constructor_template.Reset(t); 21 | Nan::Set(target, Nan::New("BuildContext").ToLocalChecked(), 22 | Nan::GetFunction(t).ToLocalChecked()); 23 | } 24 | 25 | NAN_METHOD(BuildContextWrap::New) { 26 | if (!info.IsConstructCall()) { 27 | return Nan::ThrowTypeError("Use the new operator to create new objects"); 28 | } 29 | BuildContextWrap *obj = new BuildContextWrap(); 30 | obj->m_buildContext = new BuildContext(); 31 | obj->Wrap(info.This()); 32 | info.GetReturnValue().Set(info.This()); 33 | } -------------------------------------------------------------------------------- /SDL/COPYING: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | --- 22 | 23 | Portions of these headers taken from SDL2 (where noted) 24 | Copyright (C) 1997-2013 Sam Lantinga 25 | -------------------------------------------------------------------------------- /src/dtNavMeshQueryWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // dtNavMeshQueryWrap.cpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #include "dtNavMeshQueryWrap.hpp" 10 | #include 11 | 12 | Nan::Persistent dtNavMeshQueryWrap::constructor_template; 13 | 14 | NAN_MODULE_INIT(dtNavMeshQueryWrap::Init) { 15 | Nan::HandleScope scope; 16 | Local t = Nan::New(New); 17 | t->InstanceTemplate()->SetInternalFieldCount(1); 18 | t->SetClassName(Nan::New("dtNavMeshQuery").ToLocalChecked()); 19 | constructor_template.Reset(t); 20 | Nan::Set(target, Nan::New("dtNavMeshQuery").ToLocalChecked(), 21 | Nan::GetFunction(t).ToLocalChecked()); 22 | } 23 | 24 | NAN_METHOD(dtNavMeshQueryWrap::New) { 25 | if (!info.IsConstructCall()) { 26 | return Nan::ThrowTypeError("Use the new operator to create new objects"); 27 | } 28 | dtNavMeshQueryWrap *obj = new dtNavMeshQueryWrap(); 29 | obj->m_dtNavMeshQuery = new dtNavMeshQuery(); 30 | obj->Wrap(info.This()); 31 | info.GetReturnValue().Set(info.This()); 32 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 liuhaochuan1 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SDL/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /SDL/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /SDL/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /SDL/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #undef _begin_code_h 30 | 31 | /* Reset structure packing at previous byte alignment */ 32 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) 33 | #ifdef __BORLANDC__ 34 | #pragma nopackwarning 35 | #endif 36 | #pragma pack(pop) 37 | #endif /* Compiler needs structure packing set */ 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | A JavaScript library to handle 3D navigation meshes pathfind, in nodejs. 3 | 4 | It node.js addon bundle of the [RecastDetour navigation c++ library](https://github.com/memononen/recastnavigation) 5 | 6 | # Install 7 | npm install node_recast 8 | 9 | # Usage 10 | 11 | ``` js 12 | var node_recast = require('node_recast'); 13 | var recast = new node_recast(); 14 | recast.setCellSize(0.1); 15 | recast.setCellHeight(0.2); 16 | recast.setAgentHeight(2.0); 17 | recast.setAgentRadius(0.0); 18 | recast.setAgentMaxClimb(0.9); 19 | recast.setAgentMaxSlope(45.0); 20 | recast.setRegionMinSize(8); 21 | recast.setRegionMergeSize(20.0); 22 | recast.setEdgeMaxLen(12.0); 23 | recast.setEdgeMaxError(1.3); 24 | recast.setVertsPerPoly(6); 25 | recast.setDetailSampleDist(6.0); 26 | recast.setDetailSampleMaxError(1.0); 27 | recast.setPartitionType(0); 28 | 29 | recast.load('/path/objfile.obj'); 30 | 31 | recast.build(); 32 | 33 | var nPt = recast.findNearestPoint(0,0,0,2.0,2.0,2.0); 34 | console.log('FindNearestPoint result:'); 35 | console.dir(nPt); 36 | 37 | var ref = recast.addTempObstacle(0.1,0.2,0.3,radius,height); 38 | recast.update(0); 39 | 40 | recast.removeTempObstacle(ref); 41 | recast.update(0); 42 | 43 | recast.clearAllTempObstacles(); 44 | recast.update(0); 45 | 46 | var ranPt1 = recast.findRandomPoint(); 47 | 48 | var ranPt2 = recast.findRandomPoint(); 49 | 50 | var path1 = recast.findPath(ranPt1.x,ranPt1.y,ranPt1.z,ranPt2.x,ranPt2.y,ranPt2.z,1000); 51 | console.dir(path1); 52 | ``` 53 | 54 | # Testing 55 | 56 | node ./node_modules/node_recast/test/test.js 57 | 58 | # Author 59 | 60 | liuhaochuan & zhangyu 61 | 62 | # Mail 63 | liuhaochuan@hotmail.com -------------------------------------------------------------------------------- /SDL/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_h 23 | #define _SDL_config_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /** 28 | * \file SDL_config.h 29 | * 30 | * SDL_config.h for any platform that doesn't build using the configure system. 31 | */ 32 | 33 | /* Add any platform that doesn't build using the configure system. */ 34 | #if defined(__WIN32__) 35 | #include "SDL_config_windows.h" 36 | #elif defined(__MACOSX__) 37 | #include "SDL_config_macosx.h" 38 | #elif defined(__IPHONEOS__) 39 | #include "SDL_config_iphoneos.h" 40 | #elif defined(__ANDROID__) 41 | #include "SDL_config_android.h" 42 | #elif defined(__NINTENDODS__) 43 | #include "SDL_config_nintendods.h" 44 | #else 45 | #include "SDL_config_minimal.h" 46 | #endif /* platform config */ 47 | 48 | #endif /* _SDL_config_h */ 49 | -------------------------------------------------------------------------------- /src/Sample_TempObstaclesWrap.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Sample_TempObstaclesWrap.hpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | #ifndef Sample_TempObstaclesWrap_hpp 10 | #define Sample_TempObstaclesWrap_hpp 11 | 12 | #include 13 | #include 14 | 15 | using namespace v8; 16 | 17 | class Sample_TempObstaclesExt; 18 | class Sample_TempObstaclesWrap : public Nan::ObjectWrap { 19 | public: 20 | static Nan::Persistent constructor_template; 21 | static NAN_MODULE_INIT(Init); 22 | static NAN_METHOD(New); 23 | static NAN_METHOD(SetContext); 24 | static NAN_METHOD(SetInputGeom); 25 | static NAN_METHOD(Build); 26 | static NAN_METHOD(SetCellSize); 27 | static NAN_METHOD(SetCellHeight); 28 | static NAN_METHOD(SetAgentHeight); 29 | static NAN_METHOD(SetAgentRadius); 30 | static NAN_METHOD(SetAgentMaxClimb); 31 | static NAN_METHOD(SetAgentMaxSlope); 32 | static NAN_METHOD(SetRegionMinSize); 33 | static NAN_METHOD(SetRegionMergeSize); 34 | static NAN_METHOD(SetEdgeMaxLen); 35 | static NAN_METHOD(SetEdgeMaxError); 36 | static NAN_METHOD(SetVertsPerPoly); 37 | static NAN_METHOD(SetDetailSampleDist); 38 | static NAN_METHOD(SetDetailSampleMaxError); 39 | static NAN_METHOD(SetPartitionType); 40 | static NAN_METHOD(SetTileSize); 41 | static NAN_METHOD(Update); 42 | static NAN_METHOD(AddTempObstacle); 43 | static NAN_METHOD(RemoveTempObstacle); 44 | static NAN_METHOD(ClearAllTempObstacles); 45 | static NAN_METHOD(FindNearestPoint); 46 | static NAN_METHOD(FindRandomPoint); 47 | static NAN_METHOD(FindPath); 48 | 49 | public: 50 | Sample_TempObstaclesExt* getSample_TempObstacles() { return m_sample_TempObstacles; }; 51 | 52 | private: 53 | Sample_TempObstaclesExt *m_sample_TempObstacles; 54 | }; 55 | 56 | 57 | #endif /* Sample_TempObstaclesWrap_hpp */ 58 | -------------------------------------------------------------------------------- /src/InputGeomWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // InputGeomWarp.cpp 3 | // binding 4 | // 5 | // Created by pop on 16/5/13. 6 | // 7 | // 8 | 9 | 10 | #include "InputGeomWrap.hpp" 11 | #include "macros.h" 12 | #include "BuildContextWrap.hpp" 13 | #include 14 | 15 | Nan::Persistent InputGeomWrap::constructor_template; 16 | 17 | NAN_MODULE_INIT(InputGeomWrap::Init) { 18 | Nan::HandleScope scope; 19 | Local t = Nan::New(New); 20 | t->InstanceTemplate()->SetInternalFieldCount(1); 21 | t->SetClassName(Nan::New("InputGeom").ToLocalChecked()); 22 | Nan::SetPrototypeMethod(t, "load", Load); 23 | constructor_template.Reset(t); 24 | Nan::Set(target, Nan::New("InputGeom").ToLocalChecked(), 25 | Nan::GetFunction(t).ToLocalChecked()); 26 | } 27 | 28 | NAN_METHOD(InputGeomWrap::New) { 29 | if (!info.IsConstructCall()) { 30 | return Nan::ThrowTypeError("Use the new operator to create new objects"); 31 | } 32 | InputGeomWrap *obj = new InputGeomWrap(); 33 | obj->m_inputGeom = new InputGeom(); 34 | obj->Wrap(info.This()); 35 | info.GetReturnValue().Set(info.This()); 36 | } 37 | 38 | NAN_METHOD(InputGeomWrap::Load) { 39 | InputGeomWrap* thisobj = Nan::ObjectWrap::Unwrap(info.This()); 40 | BuildContextWrap *buildContext = Nan::ObjectWrap::Unwrap(info[0]->ToObject()); 41 | REQUIRE_ARGUMENT_STRING(1, filename); 42 | rcContext *ctx = buildContext->getBuildContext(); 43 | bool result = thisobj->getInputGeom()->load(ctx,*filename); 44 | //info.This()->ForceSet(Nan::New("filename").ToLocalChecked(), info[0].As(), ReadOnly); 45 | info.GetReturnValue().Set(result); 46 | } 47 | 48 | /* 49 | NAN_METHOD(CalculatePrimes) { 50 | int under = To(info[0]).FromJust(); 51 | Callback *callback = new Callback(info[1].As()); 52 | 53 | AsyncQueueWorker(new PrimeWorker(callback, under)); 54 | } 55 | */ -------------------------------------------------------------------------------- /src/Sample_TempObstaclesExt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef Sample_TempObstaclesExt_hpp 2 | #define Sample_TempObstaclesExt_hpp 3 | 4 | #include 5 | 6 | struct vertex3 { 7 | float x; 8 | float y; 9 | float z; 10 | }; 11 | 12 | struct vpath { 13 | int nlen; 14 | vertex3 *datas; 15 | }; 16 | 17 | class Sample_TempObstaclesExt : public Sample_TempObstacles { 18 | 19 | public: 20 | Sample_TempObstaclesExt(); 21 | void SetCellSize(float val) { m_cellSize = val; } 22 | void SetCellHeight(float val) { m_cellHeight = val; } 23 | void SetAgentHeight(float val) { m_agentHeight = val; } 24 | void SetAgentRadius(float val) { m_agentRadius = val; } 25 | void SetAgentMaxClimb(float val) { m_agentMaxClimb = val; } 26 | void SetAgentMaxSlope(float val) { m_agentMaxSlope = val; } 27 | void SetRegionMinSize(float val) { m_regionMinSize = val; } 28 | void SetRegionMergeSize(float val) { m_regionMergeSize = val; } 29 | void SetEdgeMaxLen(float val) { m_edgeMaxLen = val; } 30 | void SetEdgeMaxError(float val) { m_edgeMaxError = val; } 31 | void SetVertsPerPoly(float val) { m_vertsPerPoly = val; } 32 | void SetDetailSampleDist(float val) { m_detailSampleDist = val; } 33 | void SetDetailSampleMaxError(float val) { m_detailSampleMaxError = val; } 34 | void SetPartitionType(int val) { m_partitionType = val; } 35 | void SetTileSize(float val) { m_tileSize = val; } 36 | unsigned int addTempObstacle(const float posX,const float posY,const float posZ,const float radius, const float height); 37 | unsigned int removeTempObstacle(const unsigned int ref); 38 | unsigned int findNearestPoint(float cx, float cy, float cz,float extx, float exty, float extz,float *nearestPos,dtPolyRef *ref); 39 | unsigned int findRandomPoint(float *randomPt,dtPolyRef *ref); 40 | unsigned int findPath(float startPosX, float startPosY, float startPosZ,float endPosX, float endPosY, float endPosZ, int maxPath,vpath *ret); 41 | bool Build(); 42 | }; 43 | 44 | #endif -------------------------------------------------------------------------------- /SDL/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_blendmode.h 24 | * 25 | * Header file declaring the SDL_BlendMode enumeration 26 | */ 27 | 28 | #ifndef _SDL_blendmode_h 29 | #define _SDL_blendmode_h 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | /* *INDENT-OFF* */ 35 | extern "C" { 36 | /* *INDENT-ON* */ 37 | #endif 38 | 39 | /** 40 | * \brief The blend mode used in SDL_RenderCopy() and drawing operations. 41 | */ 42 | typedef enum 43 | { 44 | SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */ 45 | SDL_BLENDMODE_BLEND = 0x00000001, /**< dst = (src * A) + (dst * (1-A)) */ 46 | SDL_BLENDMODE_ADD = 0x00000002, /**< dst = (src * A) + dst */ 47 | SDL_BLENDMODE_MOD = 0x00000004 /**< dst = src * dst */ 48 | } SDL_BlendMode; 49 | 50 | /* Ends C function definitions when using C++ */ 51 | #ifdef __cplusplus 52 | /* *INDENT-OFF* */ 53 | } 54 | /* *INDENT-ON* */ 55 | #endif 56 | #include "close_code.h" 57 | 58 | #endif /* _SDL_video_h */ 59 | 60 | /* vi: set ts=4 sw=4 expandtab: */ 61 | -------------------------------------------------------------------------------- /SDL/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef _SDL_clipboard_h 29 | #define _SDL_clipboard_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | /* *INDENT-OFF* */ 37 | extern "C" { 38 | /* *INDENT-ON* */ 39 | #endif 40 | 41 | /* Function prototypes */ 42 | 43 | /** 44 | * \brief Put UTF-8 text into the clipboard 45 | * 46 | * \sa SDL_GetClipboardText() 47 | */ 48 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 49 | 50 | /** 51 | * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() 52 | * 53 | * \sa SDL_SetClipboardText() 54 | */ 55 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 56 | 57 | /** 58 | * \brief Returns whether the clipboard has text 59 | * 60 | * \sa SDL_GetClipboardText() 61 | */ 62 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 63 | 64 | 65 | /* Ends C function definitions when using C++ */ 66 | #ifdef __cplusplus 67 | /* *INDENT-OFF* */ 68 | } 69 | /* *INDENT-ON* */ 70 | #endif 71 | #include "close_code.h" 72 | 73 | #endif /* _SDL_clipboard_h */ 74 | 75 | /* vi: set ts=4 sw=4 expandtab: */ 76 | -------------------------------------------------------------------------------- /SDL/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef _SDL_quit_h 29 | #define _SDL_quit_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* _SDL_quit_h */ 59 | -------------------------------------------------------------------------------- /SDL/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_error.h 24 | * 25 | * Simple error message routines for SDL. 26 | */ 27 | 28 | #ifndef _SDL_error_h 29 | #define _SDL_error_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | /* *INDENT-OFF* */ 37 | extern "C" { 38 | /* *INDENT-ON* */ 39 | #endif 40 | 41 | /* Public functions */ 42 | extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); 43 | extern DECLSPEC const char *SDLCALL SDL_GetError(void); 44 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 45 | 46 | /** 47 | * \name Internal error functions 48 | * 49 | * \internal 50 | * Private error reporting function - used internally. 51 | */ 52 | /*@{*/ 53 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 54 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 55 | typedef enum 56 | { 57 | SDL_ENOMEM, 58 | SDL_EFREAD, 59 | SDL_EFWRITE, 60 | SDL_EFSEEK, 61 | SDL_UNSUPPORTED, 62 | SDL_LASTERROR 63 | } SDL_errorcode; 64 | extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); 65 | /*@}*//*Internal error functions*/ 66 | 67 | /* Ends C function definitions when using C++ */ 68 | #ifdef __cplusplus 69 | /* *INDENT-OFF* */ 70 | } 71 | /* *INDENT-ON* */ 72 | #endif 73 | #include "close_code.h" 74 | 75 | #endif /* _SDL_error_h */ 76 | 77 | /* vi: set ts=4 sw=4 expandtab: */ 78 | -------------------------------------------------------------------------------- /SDL/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef _SDL_gesture_h 29 | #define _SDL_gesture_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | /* *INDENT-OFF* */ 42 | extern "C" { 43 | /* *INDENT-ON* */ 44 | #endif 45 | 46 | typedef Sint64 SDL_GestureID; 47 | 48 | /* Function prototypes */ 49 | 50 | /** 51 | * \brief Begin Recording a gesture on the specified touch, or all touches (-1) 52 | * 53 | * 54 | */ 55 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 56 | 57 | 58 | /** 59 | * \brief Save all currently loaded Dollar Gesture templates 60 | * 61 | * 62 | */ 63 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src); 64 | 65 | /** 66 | * \brief Save a currently loaded Dollar Gesture template 67 | * 68 | * 69 | */ 70 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src); 71 | 72 | 73 | /** 74 | * \brief Load Dollar Gesture templates from a file 75 | * 76 | * 77 | */ 78 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 79 | 80 | 81 | /* Ends C function definitions when using C++ */ 82 | #ifdef __cplusplus 83 | /* *INDENT-OFF* */ 84 | } 85 | /* *INDENT-ON* */ 86 | #endif 87 | #include "close_code.h" 88 | 89 | #endif /* _SDL_gesture_h */ 90 | 91 | /* vi: set ts=4 sw=4 expandtab: */ 92 | -------------------------------------------------------------------------------- /SDL/SDL_config_minimal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_minimal_h 23 | #define _SDL_config_minimal_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /** 28 | * \file SDL_config_minimal.h 29 | * 30 | * This is the minimal configuration that can be used to build SDL. 31 | */ 32 | 33 | #include 34 | #include 35 | 36 | #if !defined(__EMSCRIPTEN__) && !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 37 | typedef unsigned int size_t; 38 | typedef signed char int8_t; 39 | typedef unsigned char uint8_t; 40 | typedef signed short int16_t; 41 | typedef unsigned short uint16_t; 42 | typedef signed int int32_t; 43 | typedef unsigned int uint32_t; 44 | typedef signed long long int64_t; 45 | typedef unsigned long long uint64_t; 46 | typedef unsigned long uintptr_t; 47 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 48 | 49 | #ifdef __GNUC__ 50 | #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 51 | #endif 52 | 53 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 54 | #define SDL_AUDIO_DRIVER_DUMMY 1 55 | 56 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 57 | #define SDL_JOYSTICK_DISABLED 1 58 | 59 | /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ 60 | #define SDL_HAPTIC_DISABLED 1 61 | 62 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 63 | #define SDL_LOADSO_DISABLED 1 64 | 65 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 66 | #define SDL_THREADS_DISABLED 1 67 | 68 | /* Enable the stub timer support (src/timer/dummy/\*.c) */ 69 | #define SDL_TIMERS_DISABLED 1 70 | 71 | /* Enable the dummy video driver (src/video/dummy/\*.c) */ 72 | #define SDL_VIDEO_DRIVER_DUMMY 1 73 | 74 | #endif /* _SDL_config_minimal_h */ 75 | -------------------------------------------------------------------------------- /SDL/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_main_h 23 | #define _SDL_main_h 24 | 25 | #include "SDL_stdinc.h" 26 | 27 | /** 28 | * \file SDL_main.h 29 | * 30 | * Redefine main() on some platforms so that it is called by SDL. 31 | */ 32 | 33 | #if defined(__WIN32__) || defined(__IPHONEOS__) || defined(__ANDROID__) 34 | #ifndef SDL_MAIN_HANDLED 35 | #define SDL_MAIN_NEEDED 36 | #endif 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | #define C_LINKAGE "C" 41 | #else 42 | #define C_LINKAGE 43 | #endif /* __cplusplus */ 44 | 45 | /** 46 | * \file SDL_main.h 47 | * 48 | * The application's main() function must be called with C linkage, 49 | * and should be declared like this: 50 | * \code 51 | * #ifdef __cplusplus 52 | * extern "C" 53 | * #endif 54 | * int main(int argc, char *argv[]) 55 | * { 56 | * } 57 | * \endcode 58 | */ 59 | 60 | #ifdef SDL_MAIN_NEEDED 61 | #define main SDL_main 62 | #endif 63 | 64 | /** 65 | * The prototype for the application's main() function 66 | */ 67 | extern C_LINKAGE int SDL_main(int argc, char *argv[]); 68 | 69 | 70 | #include "begin_code.h" 71 | #ifdef __cplusplus 72 | /* *INDENT-OFF* */ 73 | extern "C" { 74 | /* *INDENT-ON* */ 75 | #endif 76 | 77 | #ifdef __WIN32__ 78 | 79 | /** 80 | * This can be called to set the application class at startup 81 | */ 82 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, 83 | void *hInst); 84 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); 85 | 86 | #endif /* __WIN32__ */ 87 | 88 | 89 | #ifdef __cplusplus 90 | /* *INDENT-OFF* */ 91 | } 92 | /* *INDENT-ON* */ 93 | #endif 94 | #include "close_code.h" 95 | 96 | #endif /* _SDL_main_h */ 97 | 98 | /* vi: set ts=4 sw=4 expandtab: */ 99 | -------------------------------------------------------------------------------- /SDL/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_power_h 23 | #define _SDL_power_h 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | /* *INDENT-OFF* */ 37 | extern "C" { 38 | /* *INDENT-ON* */ 39 | #endif 40 | 41 | /** 42 | * \brief The basic state for the system's power supply. 43 | */ 44 | typedef enum 45 | { 46 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 47 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 48 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 49 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 50 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 51 | } SDL_PowerState; 52 | 53 | 54 | /** 55 | * \brief Get the current power supply details. 56 | * 57 | * \param secs Seconds of battery life left. You can pass a NULL here if 58 | * you don't care. Will return -1 if we can't determine a 59 | * value, or we're not running on a battery. 60 | * 61 | * \param pct Percentage of battery life left, between 0 and 100. You can 62 | * pass a NULL here if you don't care. Will return -1 if we 63 | * can't determine a value, or we're not running on a battery. 64 | * 65 | * \return The state of the battery (if any). 66 | */ 67 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); 68 | 69 | /* Ends C function definitions when using C++ */ 70 | #ifdef __cplusplus 71 | /* *INDENT-OFF* */ 72 | } 73 | /* *INDENT-ON* */ 74 | #endif 75 | #include "close_code.h" 76 | 77 | #endif /* _SDL_power_h */ 78 | 79 | /* vi: set ts=4 sw=4 expandtab: */ 80 | -------------------------------------------------------------------------------- /SDL/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2013 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* 23 | ================================= IMPORTANT ================================ 24 | This header taken from SDL2 25 | ============================================================================ 26 | */ 27 | 28 | /** 29 | * \file SDL_touch.h 30 | * 31 | * Include file for SDL touch event handling. 32 | */ 33 | 34 | #ifndef _SDL_touch_h 35 | #define _SDL_touch_h 36 | 37 | #include "SDL_stdinc.h" 38 | #include "SDL_error.h" 39 | #include "SDL_video.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | typedef Sint64 SDL_TouchID; 48 | typedef Sint64 SDL_FingerID; 49 | 50 | typedef struct SDL_Finger 51 | { 52 | SDL_FingerID id; 53 | float x; 54 | float y; 55 | float pressure; 56 | } SDL_Finger; 57 | 58 | /* Used as the device ID for mouse events simulated with touch input */ 59 | #define SDL_TOUCH_MOUSEID ((Uint32)-1) 60 | 61 | 62 | /* Function prototypes */ 63 | 64 | /** 65 | * \brief Get the number of registered touch devices. 66 | */ 67 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); 68 | 69 | /** 70 | * \brief Get the touch ID with the given index, or 0 if the index is invalid. 71 | */ 72 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); 73 | 74 | /** 75 | * \brief Get the number of active fingers for a given touch device. 76 | */ 77 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); 78 | 79 | /** 80 | * \brief Get the finger object of the given touch, with the given index. 81 | */ 82 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); 83 | 84 | /* Ends C function definitions when using C++ */ 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #include "close_code.h" 89 | 90 | #endif /* _SDL_touch_h */ 91 | 92 | /* vi: set ts=4 sw=4 expandtab: */ 93 | -------------------------------------------------------------------------------- /SDL/SDL_input.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_input.h 24 | * 25 | * Include file for lowlevel SDL input device handling. 26 | * 27 | * This talks about individual devices, and not the system cursor. If you 28 | * just want to know when the user moves the pointer somewhere in your 29 | * window, this is NOT the API you want. This one handles things like 30 | * multi-touch, drawing tablets, and multiple, separate mice. 31 | * 32 | * The other API is in SDL_mouse.h 33 | */ 34 | 35 | #ifndef _SDL_input_h 36 | #define _SDL_input_h 37 | 38 | #include "SDL_stdinc.h" 39 | #include "SDL_error.h" 40 | #include "SDL_video.h" 41 | 42 | #include "begin_code.h" 43 | /* Set up for C function definitions, even when using C++ */ 44 | #ifdef __cplusplus 45 | /* *INDENT-OFF* */ 46 | extern "C" { 47 | /* *INDENT-ON* */ 48 | #endif 49 | 50 | 51 | /* Function prototypes */ 52 | 53 | /* !!! FIXME: real documentation 54 | * - Redetect devices 55 | * - This invalidates all existing device information from previous queries! 56 | * - There is an implicit (re)detect upon SDL_Init(). 57 | */ 58 | extern DECLSPEC int SDLCALL SDL_RedetectInputDevices(void); 59 | 60 | /** 61 | * \brief Get the number of mouse input devices available. 62 | */ 63 | extern DECLSPEC int SDLCALL SDL_GetNumInputDevices(void); 64 | 65 | /** 66 | * \brief Gets the name of a device with the given index. 67 | * 68 | * \param index is the index of the device, whose name is to be returned. 69 | * 70 | * \return the name of the device with the specified index 71 | */ 72 | extern DECLSPEC const char *SDLCALL SDL_GetInputDeviceName(int index); 73 | 74 | 75 | extern DECLSPEC int SDLCALL SDL_IsDeviceDisconnected(int index); 76 | 77 | /* Ends C function definitions when using C++ */ 78 | #ifdef __cplusplus 79 | /* *INDENT-OFF* */ 80 | } 81 | /* *INDENT-ON* */ 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* _SDL_mouse_h */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /SDL/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_loadso.h 24 | * 25 | * System dependent library loading routines 26 | * 27 | * Some things to keep in mind: 28 | * \li These functions only work on C function names. Other languages may 29 | * have name mangling and intrinsic language support that varies from 30 | * compiler to compiler. 31 | * \li Make sure you declare your function pointers with the same calling 32 | * convention as the actual library function. Your code will crash 33 | * mysteriously if you do not do this. 34 | * \li Avoid namespace collisions. If you load a symbol from the library, 35 | * it is not defined whether or not it goes into the global symbol 36 | * namespace for the application. If it does and it conflicts with 37 | * symbols in your code or other shared libraries, you will not get 38 | * the results you expect. :) 39 | */ 40 | 41 | #ifndef _SDL_loadso_h 42 | #define _SDL_loadso_h 43 | 44 | #include "SDL_stdinc.h" 45 | #include "SDL_error.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | /* *INDENT-OFF* */ 51 | extern "C" { 52 | /* *INDENT-ON* */ 53 | #endif 54 | 55 | /** 56 | * This function dynamically loads a shared object and returns a pointer 57 | * to the object handle (or NULL if there was an error). 58 | * The 'sofile' parameter is a system dependent name of the object file. 59 | */ 60 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); 61 | 62 | /** 63 | * Given an object handle, this function looks up the address of the 64 | * named function in the shared object and returns it. This address 65 | * is no longer valid after calling SDL_UnloadObject(). 66 | */ 67 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, 68 | const char *name); 69 | 70 | /** 71 | * Unload a shared object from memory. 72 | */ 73 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 74 | 75 | /* Ends C function definitions when using C++ */ 76 | #ifdef __cplusplus 77 | /* *INDENT-OFF* */ 78 | } 79 | /* *INDENT-ON* */ 80 | #endif 81 | #include "close_code.h" 82 | 83 | #endif /* _SDL_loadso_h */ 84 | 85 | /* vi: set ts=4 sw=4 expandtab: */ 86 | -------------------------------------------------------------------------------- /SDL/SDL_rotozoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SDL_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces 4 | 5 | Copyright (C) 2001-2011 Andreas Schiffler 6 | 7 | This software is provided 'as-is', without any express or implied 8 | warranty. In no event will the authors be held liable for any damages 9 | arising from the use of this software. 10 | 11 | Permission is granted to anyone to use this software for any purpose, 12 | including commercial applications, and to alter it and redistribute it 13 | freely, subject to the following restrictions: 14 | 15 | 1. The origin of this software must not be misrepresented; you must not 16 | claim that you wrote the original software. If you use this software 17 | in a product, an acknowledgment in the product documentation would be 18 | appreciated but is not required. 19 | 20 | 2. Altered source versions must be plainly marked as such, and must not be 21 | misrepresented as being the original software. 22 | 23 | 3. This notice may not be removed or altered from any source 24 | distribution. 25 | 26 | Andreas Schiffler -- aschiffler at ferzkopp dot net 27 | 28 | */ 29 | 30 | #ifndef _SDL_rotozoom_h 31 | #define _SDL_rotozoom_h 32 | 33 | #include 34 | 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #ifndef M_PI 41 | #define M_PI 3.141592654 42 | #endif 43 | 44 | #include "SDL.h" 45 | 46 | /* ---- Defines */ 47 | 48 | /*! 49 | \brief Disable anti-aliasing (no smoothing). 50 | */ 51 | #define SMOOTHING_OFF 0 52 | 53 | /*! 54 | \brief Enable anti-aliasing (smoothing). 55 | */ 56 | #define SMOOTHING_ON 1 57 | 58 | /* ---- Function Prototypes */ 59 | 60 | #ifdef _MSC_VER 61 | # if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT) 62 | # define SDL_ROTOZOOM_SCOPE __declspec(dllexport) 63 | # else 64 | # ifdef LIBSDL_GFX_DLL_IMPORT 65 | # define SDL_ROTOZOOM_SCOPE __declspec(dllimport) 66 | # endif 67 | # endif 68 | #endif 69 | #ifndef SDL_ROTOZOOM_SCOPE 70 | # define SDL_ROTOZOOM_SCOPE extern 71 | #endif 72 | 73 | /* 74 | 75 | Rotozoom functions 76 | 77 | */ 78 | 79 | SDL_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth); 80 | 81 | SDL_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY 82 | (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth); 83 | 84 | 85 | SDL_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth, 86 | int *dstheight); 87 | 88 | SDL_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY 89 | (int width, int height, double angle, double zoomx, double zoomy, 90 | int *dstwidth, int *dstheight); 91 | 92 | /* 93 | 94 | Zooming functions 95 | 96 | */ 97 | 98 | SDL_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth); 99 | 100 | SDL_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight); 101 | 102 | /* 103 | 104 | Shrinking functions 105 | 106 | */ 107 | 108 | SDL_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory); 109 | 110 | /* 111 | 112 | Specialized rotation functions 113 | 114 | */ 115 | 116 | SDL_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns); 117 | 118 | /* Ends C function definitions when using C++ */ 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif /* _SDL_rotozoom_h */ 124 | -------------------------------------------------------------------------------- /SDL/SDL_config_wiz.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_h 23 | #define _SDL_config_h 24 | 25 | /* This is a set of defines to configure the SDL features */ 26 | 27 | /* General platform specific identifiers */ 28 | #include "SDL_platform.h" 29 | 30 | #define SDL_BYTEORDER 1234 31 | 32 | #define HAVE_ALLOCA_H 1 33 | #define HAVE_SYS_TYPES_H 1 34 | #define HAVE_STDIO_H 1 35 | #define STDC_HEADERS 1 36 | #define HAVE_STDLIB_H 1 37 | #define HAVE_STDARG_H 1 38 | #define HAVE_MALLOC_H 1 39 | #define HAVE_MEMORY_H 1 40 | #define HAVE_STRING_H 1 41 | #define HAVE_STRINGS_H 1 42 | #define HAVE_INTTYPES_H 1 43 | #define HAVE_STDINT_H 1 44 | #define HAVE_CTYPE_H 1 45 | #define HAVE_MATH_H 1 46 | #define HAVE_ICONV_H 1 47 | #define HAVE_SIGNAL_H 1 48 | #define HAVE_MALLOC 1 49 | #define HAVE_CALLOC 1 50 | #define HAVE_REALLOC 1 51 | #define HAVE_FREE 1 52 | #define HAVE_ALLOCA 1 53 | #define HAVE_GETENV 1 54 | #define HAVE_SETENV 1 55 | #define HAVE_PUTENV 1 56 | #define HAVE_UNSETENV 1 57 | #define HAVE_QSORT 1 58 | #define HAVE_ABS 1 59 | #define HAVE_BCOPY 1 60 | #define HAVE_MEMSET 1 61 | #define HAVE_MEMCPY 1 62 | #define HAVE_MEMMOVE 1 63 | #define HAVE_STRLEN 1 64 | #define HAVE_STRDUP 1 65 | #define HAVE_STRCHR 1 66 | #define HAVE_STRRCHR 1 67 | #define HAVE_STRSTR 1 68 | #define HAVE_STRTOL 1 69 | #define HAVE_STRTOUL 1 70 | #define HAVE_STRTOLL 1 71 | #define HAVE_STRTOULL 1 72 | #define HAVE_ATOI 1 73 | #define HAVE_ATOF 1 74 | #define HAVE_STRCMP 1 75 | #define HAVE_STRNCMP 1 76 | #define HAVE_STRCASECMP 1 77 | #define HAVE_STRNCASECMP 1 78 | #define HAVE_SSCANF 1 79 | #define HAVE_SNPRINTF 1 80 | #define HAVE_VSNPRINTF 1 81 | #define HAVE_M_PI 1 82 | #define HAVE_CEIL 1 83 | #define HAVE_COPYSIGN 1 84 | #define HAVE_COS 1 85 | #define HAVE_COSF 1 86 | #define HAVE_FABS 1 87 | #define HAVE_FLOOR 1 88 | #define HAVE_LOG 1 89 | #define HAVE_SCALBN 1 90 | #define HAVE_SIN 1 91 | #define HAVE_SINF 1 92 | #define HAVE_SQRT 1 93 | #define HAVE_SIGACTION 1 94 | #define HAVE_SETJMP 1 95 | #define HAVE_NANOSLEEP 1 96 | #define HAVE_POW 1 97 | 98 | #define SDL_CDROM_DISABLED 1 99 | #define SDL_AUDIO_DRIVER_DUMMY 1 100 | #define SDL_AUDIO_DRIVER_OSS 1 101 | 102 | #define SDL_INPUT_LINUXEV 1 103 | #define SDL_INPUT_TSLIB 1 104 | #define SDL_JOYSTICK_LINUX 1 105 | #define SDL_HAPTIC_LINUX 1 106 | 107 | #define SDL_LOADSO_DLOPEN 1 108 | 109 | #define SDL_THREAD_PTHREAD 1 110 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 111 | 112 | #define SDL_TIMER_UNIX 1 113 | 114 | #define SDL_VIDEO_DRIVER_DUMMY 1 115 | #define SDL_VIDEO_DRIVER_PANDORA 1 116 | #define SDL_VIDEO_RENDER_OGL_ES 1 117 | #define SDL_VIDEO_OPENGL_ES 1 118 | 119 | #endif /* _SDL_config_h */ 120 | -------------------------------------------------------------------------------- /SDL/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_timer_h 23 | #define _SDL_timer_h 24 | 25 | /** 26 | * \file SDL_timer.h 27 | * 28 | * Header for the SDL time management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | /* *INDENT-OFF* */ 38 | extern "C" { 39 | /* *INDENT-ON* */ 40 | #endif 41 | 42 | /** 43 | * \brief Get the number of milliseconds since the SDL library initialization. 44 | * 45 | * \note This value wraps if the program runs for more than ~49 days. 46 | */ 47 | extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); 48 | 49 | /** 50 | * \brief Get the current value of the high resolution counter 51 | */ 52 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); 53 | 54 | /** 55 | * \brief Get the count per second of the high resolution counter 56 | */ 57 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); 58 | 59 | /** 60 | * \brief Wait a specified number of milliseconds before returning. 61 | */ 62 | extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); 63 | 64 | /** 65 | * Function prototype for the timer callback function. 66 | * 67 | * The callback function is passed the current timer interval and returns 68 | * the next timer interval. If the returned value is the same as the one 69 | * passed in, the periodic alarm continues, otherwise a new alarm is 70 | * scheduled. If the callback returns 0, the periodic alarm is cancelled. 71 | */ 72 | typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); 73 | 74 | /** 75 | * Definition of the timer ID type. 76 | */ 77 | typedef int SDL_TimerID; 78 | 79 | /** 80 | * \brief Add a new timer to the pool of timers already running. 81 | * 82 | * \return A timer ID, or NULL when an error occurs. 83 | */ 84 | extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, 85 | SDL_TimerCallback callback, 86 | void *param); 87 | 88 | /** 89 | * \brief Remove a timer knowing its ID. 90 | * 91 | * \return A boolean value indicating success or failure. 92 | * 93 | * \warning It is not safe to remove a timer multiple times. 94 | */ 95 | extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); 96 | 97 | 98 | /* Ends C function definitions when using C++ */ 99 | #ifdef __cplusplus 100 | /* *INDENT-OFF* */ 101 | } 102 | /* *INDENT-ON* */ 103 | #endif 104 | #include "close_code.h" 105 | 106 | #endif /* _SDL_timer_h */ 107 | 108 | /* vi: set ts=4 sw=4 expandtab: */ 109 | -------------------------------------------------------------------------------- /SDL/SDL_config_pandora.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_h 23 | #define _SDL_config_h 24 | 25 | /* This is a set of defines to configure the SDL features */ 26 | 27 | /* General platform specific identifiers */ 28 | #include "SDL_platform.h" 29 | 30 | #ifdef __LP64__ 31 | #define SIZEOF_VOIDP 8 32 | #else 33 | #define SIZEOF_VOIDP 4 34 | #endif 35 | 36 | #define SDL_BYTEORDER 1234 37 | 38 | #define HAVE_ALLOCA_H 1 39 | #define HAVE_SYS_TYPES_H 1 40 | #define HAVE_STDIO_H 1 41 | #define STDC_HEADERS 1 42 | #define HAVE_STDLIB_H 1 43 | #define HAVE_STDARG_H 1 44 | #define HAVE_MALLOC_H 1 45 | #define HAVE_MEMORY_H 1 46 | #define HAVE_STRING_H 1 47 | #define HAVE_STRINGS_H 1 48 | #define HAVE_INTTYPES_H 1 49 | #define HAVE_STDINT_H 1 50 | #define HAVE_CTYPE_H 1 51 | #define HAVE_MATH_H 1 52 | #define HAVE_ICONV_H 1 53 | #define HAVE_SIGNAL_H 1 54 | #define HAVE_MALLOC 1 55 | #define HAVE_CALLOC 1 56 | #define HAVE_REALLOC 1 57 | #define HAVE_FREE 1 58 | #define HAVE_ALLOCA 1 59 | #define HAVE_GETENV 1 60 | #define HAVE_SETENV 1 61 | #define HAVE_PUTENV 1 62 | #define HAVE_UNSETENV 1 63 | #define HAVE_QSORT 1 64 | #define HAVE_ABS 1 65 | #define HAVE_BCOPY 1 66 | #define HAVE_MEMSET 1 67 | #define HAVE_MEMCPY 1 68 | #define HAVE_MEMMOVE 1 69 | #define HAVE_STRLEN 1 70 | #define HAVE_STRDUP 1 71 | #define HAVE_STRCHR 1 72 | #define HAVE_STRRCHR 1 73 | #define HAVE_STRSTR 1 74 | #define HAVE_STRTOL 1 75 | #define HAVE_STRTOUL 1 76 | #define HAVE_STRTOLL 1 77 | #define HAVE_STRTOULL 1 78 | #define HAVE_ATOI 1 79 | #define HAVE_ATOF 1 80 | #define HAVE_STRCMP 1 81 | #define HAVE_STRNCMP 1 82 | #define HAVE_STRCASECMP 1 83 | #define HAVE_STRNCASECMP 1 84 | #define HAVE_SSCANF 1 85 | #define HAVE_SNPRINTF 1 86 | #define HAVE_VSNPRINTF 1 87 | #define HAVE_M_PI 1 88 | #define HAVE_CEIL 1 89 | #define HAVE_COPYSIGN 1 90 | #define HAVE_COS 1 91 | #define HAVE_COSF 1 92 | #define HAVE_FABS 1 93 | #define HAVE_FLOOR 1 94 | #define HAVE_LOG 1 95 | #define HAVE_SCALBN 1 96 | #define HAVE_SIN 1 97 | #define HAVE_SINF 1 98 | #define HAVE_SQRT 1 99 | #define HAVE_SIGACTION 1 100 | #define HAVE_SETJMP 1 101 | #define HAVE_NANOSLEEP 1 102 | 103 | #define SDL_AUDIO_DRIVER_DUMMY 1 104 | #define SDL_AUDIO_DRIVER_OSS 1 105 | 106 | #define SDL_INPUT_LINUXEV 1 107 | #define SDL_INPUT_TSLIB 1 108 | #define SDL_JOYSTICK_LINUX 1 109 | #define SDL_HAPTIC_LINUX 1 110 | 111 | #define SDL_LOADSO_DLOPEN 1 112 | 113 | #define SDL_THREAD_PTHREAD 1 114 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 115 | 116 | #define SDL_TIMER_UNIX 1 117 | 118 | #define SDL_VIDEO_DRIVER_DUMMY 1 119 | #define SDL_VIDEO_DRIVER_X11 1 120 | #define SDL_VIDEO_DRIVER_X11_XINPUT 1 121 | #define SDL_VIDEO_DRIVER_PANDORA 1 122 | #define SDL_VIDEO_RENDER_OGL_ES 1 123 | #define SDL_VIDEO_OPENGL_ES 1 124 | 125 | #endif /* _SDL_config_h */ 126 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | var addon = require('bindings')('addon'); 2 | 3 | var startTime = 0; 4 | var endTime = 0; 5 | var costTime = 0; 6 | //上下文 7 | var buildContext = new addon.BuildContext(); 8 | 9 | //输入网格 10 | startTime = new Date().getTime(); 11 | var inputGeom = new addon.InputGeom(); 12 | var error = inputGeom.load(buildContext, __dirname + '/maz0001.obj'); 13 | if( !error) { 14 | console.log('加载网格文件失败!'); 15 | process.exit(0); 16 | } 17 | else { 18 | console.log('加载网格文件成功'); 19 | } 20 | endTime = new Date().getTime(); 21 | costTime = endTime - startTime; 22 | console.log('加载网格文件消耗时间:' + costTime + 'ms'); 23 | 24 | var sample_TempObstacles = new addon.Sample_TempObstacles(); 25 | 26 | //设置参数 27 | sample_TempObstacles.setCellSize(0.1); 28 | sample_TempObstacles.setCellHeight(0.2); 29 | sample_TempObstacles.setAgentHeight(2.0); 30 | //这个参数如果设置太大,可能会截断某些很狭窄的地形 31 | //recast.set_agentRadius(0.6); 32 | sample_TempObstacles.setAgentRadius(0.0); 33 | //这个参数可以定义多边形大小,越小,多边形越多 34 | sample_TempObstacles.setAgentMaxClimb(0.9); 35 | sample_TempObstacles.setAgentMaxSlope(45.0); 36 | sample_TempObstacles.setRegionMinSize(8); 37 | sample_TempObstacles.setRegionMergeSize(20.0); 38 | sample_TempObstacles.setEdgeMaxLen(12.0); 39 | sample_TempObstacles.setEdgeMaxError(1.3); 40 | sample_TempObstacles.setVertsPerPoly(6); 41 | sample_TempObstacles.setDetailSampleDist(6.0); 42 | sample_TempObstacles.setDetailSampleMaxError(1.0); 43 | sample_TempObstacles.setPartitionType(0); 44 | 45 | //设置上下文 46 | sample_TempObstacles.setContext(buildContext); 47 | //设置输入网格 48 | sample_TempObstacles.setInputGeom(inputGeom); 49 | 50 | //建立导航网格 51 | startTime = new Date().getTime(); 52 | error = sample_TempObstacles.build(); 53 | if( !error) { 54 | console.log('建立导航网格失败!'); 55 | process.exit(0); 56 | } 57 | else { 58 | console.log('建立导航网格成功'); 59 | } 60 | endTime = new Date().getTime(); 61 | costTime = endTime - startTime; 62 | console.log('建立导航网格消耗时间:' + costTime + 'ms'); 63 | 64 | //添加临时障碍 65 | //坐标,半径,高度 66 | var x = 1.0; 67 | var y = 1.0; 68 | var z = 1.0; 69 | var radius = 1.0; 70 | var height = 2.0; 71 | var ref1 = sample_TempObstacles.addTempObstacle(x,y,z,radius,height); 72 | sample_TempObstacles.update(0); 73 | console.log('addTempObstacle result ref1:' + ref1); 74 | var ref2 = sample_TempObstacles.addTempObstacle(x,y,z,radius,height); 75 | sample_TempObstacles.update(0); 76 | console.log('addTempObstacle result ref2:' + ref2); 77 | 78 | //删除零食障碍 79 | var status = sample_TempObstacles.removeTempObstacle(ref1); 80 | sample_TempObstacles.update(0); 81 | console.log('removeTempObstacle status:' + status); 82 | 83 | ref1 = sample_TempObstacles.addTempObstacle(x,y,z,radius,height); 84 | sample_TempObstacles.update(0); 85 | console.log('addTempObstacle result ref1:' + ref1); 86 | 87 | var nPt = sample_TempObstacles.findNearestPoint(0,0,0,2.0,2.0,2.0); 88 | console.log('FindNearestPoint result:'); 89 | console.dir(nPt); 90 | 91 | 92 | //删除所有临时障碍 93 | sample_TempObstacles.clearAllTempObstacles(); 94 | sample_TempObstacles.update(0); 95 | 96 | //测试随机寻路1000次消耗时间毫秒 97 | startTime = new Date().getTime(); 98 | for(var i = 0; i < 1000; i++) { 99 | //随机得到一个合法的点 100 | var ranPt1 = sample_TempObstacles.findRandomPoint(); 101 | //console.log(ranPt1); 102 | 103 | var ranPt2 = sample_TempObstacles.findRandomPoint(); 104 | //console.log(ranPt2); 105 | 106 | //寻路 107 | var path1 = sample_TempObstacles.findPath(ranPt1.x,ranPt1.y,ranPt1.z,ranPt2.x,ranPt2.y,ranPt2.z,1000); 108 | //console.log('findPath result1:'); 109 | //console.dir(path1); 110 | 111 | //var path2 = sample_TempObstacles.findPath(ranPt2.x,ranPt2.y,ranPt2.z,ranPt1.x,ranPt1.y,ranPt1.z,1000); 112 | //console.log('findPath result2:'); 113 | //console.dir(path2); 114 | } 115 | 116 | endTime = new Date().getTime(); 117 | costTime = endTime - startTime; 118 | console.log('测试随机寻路1000次消耗时间:' + costTime + 'ms'); 119 | 120 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": 'addon', 5 | 6 | 'include_dirs': [ 7 | './recastnavigation/DebugUtils/Include', 8 | './recastnavigation/Detour/Include', 9 | './recastnavigation/DetourCrowd/Include', 10 | './recastnavigation/DetourTileCache/Include', 11 | './recastnavigation/Recast/Include/', 12 | './recastnavigation/RecastDemo/Include', 13 | './SDL', 14 | './recastnavigation/RecastDemo/Contrib/fastlz', 15 | " 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_android_h 23 | #define _SDL_config_android_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /** 28 | * \file SDL_config_android.h 29 | * 30 | * This is a configuration that can be used to build SDL for Android 31 | */ 32 | 33 | #include 34 | 35 | #define HAVE_ALLOCA_H 1 36 | #define HAVE_SYS_TYPES_H 1 37 | #define HAVE_STDIO_H 1 38 | #define STDC_HEADERS 1 39 | #define HAVE_STRING_H 1 40 | #define HAVE_INTTYPES_H 1 41 | #define HAVE_STDINT_H 1 42 | #define HAVE_CTYPE_H 1 43 | #define HAVE_MATH_H 1 44 | #define HAVE_SIGNAL_H 1 45 | 46 | /* C library functions */ 47 | #define HAVE_MALLOC 1 48 | #define HAVE_CALLOC 1 49 | #define HAVE_REALLOC 1 50 | #define HAVE_FREE 1 51 | #define HAVE_ALLOCA 1 52 | #define HAVE_GETENV 1 53 | #define HAVE_SETENV 1 54 | #define HAVE_PUTENV 1 55 | #define HAVE_SETENV 1 56 | #define HAVE_UNSETENV 1 57 | #define HAVE_QSORT 1 58 | #define HAVE_ABS 1 59 | #define HAVE_BCOPY 1 60 | #define HAVE_MEMSET 1 61 | #define HAVE_MEMCPY 1 62 | #define HAVE_MEMMOVE 1 63 | #define HAVE_MEMCMP 1 64 | #define HAVE_STRLEN 1 65 | #define HAVE_STRLCPY 1 66 | #define HAVE_STRLCAT 1 67 | #define HAVE_STRDUP 1 68 | #define HAVE_STRCHR 1 69 | #define HAVE_STRRCHR 1 70 | #define HAVE_STRSTR 1 71 | #define HAVE_STRTOL 1 72 | #define HAVE_STRTOUL 1 73 | #define HAVE_STRTOLL 1 74 | #define HAVE_STRTOULL 1 75 | #define HAVE_STRTOD 1 76 | #define HAVE_ATOI 1 77 | #define HAVE_ATOF 1 78 | #define HAVE_STRCMP 1 79 | #define HAVE_STRNCMP 1 80 | #define HAVE_STRCASECMP 1 81 | #define HAVE_STRNCASECMP 1 82 | #define HAVE_SSCANF 1 83 | #define HAVE_SNPRINTF 1 84 | #define HAVE_VSNPRINTF 1 85 | #define HAVE_M_PI 1 86 | #define HAVE_ATAN 1 87 | #define HAVE_ATAN2 1 88 | #define HAVE_CEIL 1 89 | #define HAVE_COPYSIGN 1 90 | #define HAVE_COS 1 91 | #define HAVE_COSF 1 92 | #define HAVE_FABS 1 93 | #define HAVE_FLOOR 1 94 | #define HAVE_LOG 1 95 | #define HAVE_POW 1 96 | #define HAVE_SCALBN 1 97 | #define HAVE_SIN 1 98 | #define HAVE_SINF 1 99 | #define HAVE_SQRT 1 100 | #define HAVE_SIGACTION 1 101 | #define HAVE_SETJMP 1 102 | #define HAVE_NANOSLEEP 1 103 | #define HAVE_SYSCONF 1 104 | 105 | #define SIZEOF_VOIDP 4 106 | 107 | /* Enable various audio drivers */ 108 | #define SDL_AUDIO_DRIVER_ANDROID 1 109 | #define SDL_AUDIO_DRIVER_DUMMY 1 110 | 111 | /* Enable various input drivers */ 112 | #define SDL_JOYSTICK_ANDROID 1 113 | #define SDL_HAPTIC_DUMMY 1 114 | 115 | /* Enable various shared object loading systems */ 116 | #define SDL_LOADSO_DLOPEN 1 117 | 118 | /* Enable various threading systems */ 119 | #define SDL_THREAD_PTHREAD 1 120 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 121 | 122 | /* Enable various timer systems */ 123 | #define SDL_TIMER_UNIX 1 124 | 125 | /* Enable various video drivers */ 126 | #define SDL_VIDEO_DRIVER_ANDROID 1 127 | 128 | /* Enable OpenGL ES */ 129 | #define SDL_VIDEO_OPENGL_ES 1 130 | #define SDL_VIDEO_RENDER_OGL_ES 1 131 | #define SDL_VIDEO_RENDER_OGL_ES2 1 132 | 133 | #endif /* _SDL_config_minimal_h */ 134 | -------------------------------------------------------------------------------- /SDL/SDL_config_nintendods.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_nintendods_h 23 | #define _SDL_config_nintendods_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* This is a set of defines to configure the SDL features */ 28 | 29 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 30 | typedef signed char int8_t; 31 | typedef unsigned char uint8_t; 32 | typedef signed short int16_t; 33 | typedef unsigned short uint16_t; 34 | typedef signed int int32_t; 35 | typedef unsigned int uint32_t; 36 | typedef signed long long int64_t; 37 | typedef unsigned long long uint64_t; 38 | 39 | /* LiF: __PTRDIFF_TYPE__ was causing errors of conflicting typedefs with the 40 | shipping with devkitARM. copied a similar ifdef from it. */ 41 | #ifndef __PTRDIFF_TYPE__ 42 | typedef unsigned long uintptr_t; 43 | #else 44 | typedef unsigned __PTRDIFF_TYPE__ uintptr_t; 45 | #endif 46 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 47 | 48 | #define SIZEOF_VOIDP 4 49 | 50 | /* Useful headers */ 51 | #define HAVE_SYS_TYPES_H 1 52 | #define HAVE_STDIO_H 1 53 | #define STDC_HEADERS 1 54 | #define HAVE_STRING_H 1 55 | #define HAVE_CTYPE_H 1 56 | 57 | /* C library functions */ 58 | #define HAVE_MALLOC 1 59 | #define HAVE_CALLOC 1 60 | #define HAVE_REALLOC 1 61 | #define HAVE_FREE 1 62 | #define HAVE_ALLOCA 1 63 | #define HAVE_GETENV 1 64 | #define HAVE_SETENV 1 65 | #define HAVE_PUTENV 1 66 | #define HAVE_QSORT 1 67 | #define HAVE_ABS 1 68 | #define HAVE_BCOPY 1 69 | #define HAVE_MEMSET 1 70 | #define HAVE_MEMCPY 1 71 | #define HAVE_MEMMOVE 1 72 | #define HAVE_MEMCMP 1 73 | #define HAVE_STRLEN 1 74 | #define HAVE_STRDUP 1 75 | #define HAVE_INDEX 1 76 | #define HAVE_RINDEX 1 77 | #define HAVE_STRCHR 1 78 | #define HAVE_STRRCHR 1 79 | #define HAVE_STRSTR 1 80 | #define HAVE_STRTOL 1 81 | #define HAVE_STRTOD 1 82 | #define HAVE_ATOI 1 83 | #define HAVE_ATOF 1 84 | #define HAVE_STRCMP 1 85 | #define HAVE_STRNCMP 1 86 | #define HAVE_STRICMP 1 87 | #define HAVE_STRCASECMP 1 88 | #define HAVE_SSCANF 1 89 | #define HAVE_SNPRINTF 1 90 | #define HAVE_VSNPRINTF 1 91 | 92 | /* DS isn't that sophisticated */ 93 | #define LACKS_SYS_MMAN_H 1 94 | 95 | /* Enable various audio drivers */ 96 | #define SDL_AUDIO_DRIVER_NDS 1 97 | /*#define SDL_AUDIO_DRIVER_DUMMY 1 TODO: uncomment this later*/ 98 | 99 | /* Enable various input drivers */ 100 | #define SDL_JOYSTICK_NDS 1 101 | /*#define SDL_JOYSTICK_DUMMY 1 TODO: uncomment this later*/ 102 | 103 | /* DS has no dynamic linking afaik */ 104 | #define SDL_LOADSO_DISABLED 1 105 | 106 | /* Enable various threading systems */ 107 | /*#define SDL_THREAD_NDS 1*/ 108 | #define SDL_THREADS_DISABLED 1 109 | 110 | /* Enable various timer systems */ 111 | #define SDL_TIMER_NDS 1 112 | 113 | /* Enable various video drivers */ 114 | #define SDL_VIDEO_DRIVER_NDS 1 115 | #ifdef USE_HW_RENDERER 116 | #define SDL_VIDEO_RENDER_NDS 1 117 | #else 118 | #define SDL_VIDEO_RENDER_NDS 0 119 | #endif 120 | 121 | /* Enable system power support */ 122 | #define SDL_POWER_NINTENDODS 1 123 | 124 | /* Enable haptic support */ 125 | #define SDL_HAPTIC_NDS 1 126 | 127 | #define SDL_BYTEORDER SDL_LIL_ENDIAN 128 | 129 | #endif /* _SDL_config_nintendods_h */ 130 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: pop 3 | * @Date: 2016-05-15 15:25:15 4 | * @Last Modified by: pop 5 | * @Last Modified time: 2016-05-16 18:27:47 6 | */ 7 | 8 | 'use strict'; 9 | 10 | function Recast() { 11 | this.addon = require('bindings')('addon'); 12 | this.buildContext = new this.addon.BuildContext(); 13 | this.inputGeom = new this.addon.InputGeom(); 14 | this.sample_TempObstacles = new this.addon.Sample_TempObstacles(); 15 | //设置上下文 16 | this.sample_TempObstacles.setContext(this.buildContext); 17 | //设置输入网格 18 | this.sample_TempObstacles.setInputGeom(this.inputGeom); 19 | } 20 | 21 | Recast.prototype.setCellSize = function(val) { 22 | this.sample_TempObstacles.setCellSize(val); 23 | }; 24 | 25 | Recast.prototype.setCellHeight = function(val) { 26 | this.sample_TempObstacles.setCellHeight(val); 27 | }; 28 | 29 | Recast.prototype.setAgentHeight = function(val) { 30 | this.sample_TempObstacles.setAgentHeight(val); 31 | }; 32 | 33 | Recast.prototype.setAgentRadius = function(val) { 34 | this.sample_TempObstacles.setAgentRadius(val); 35 | }; 36 | 37 | Recast.prototype.setAgentMaxClimb = function(val) { 38 | this.sample_TempObstacles.setAgentMaxClimb(val); 39 | }; 40 | 41 | Recast.prototype.setAgentMaxSlope = function(val) { 42 | this.sample_TempObstacles.setAgentMaxSlope(val); 43 | }; 44 | 45 | Recast.prototype.setRegionMinSize = function(val) { 46 | this.sample_TempObstacles.setRegionMinSize(val); 47 | }; 48 | 49 | Recast.prototype.setRegionMergeSize = function(val) { 50 | this.sample_TempObstacles.setRegionMergeSize(val); 51 | }; 52 | 53 | Recast.prototype.setEdgeMaxLen = function(val) { 54 | this.sample_TempObstacles.setEdgeMaxLen(val); 55 | }; 56 | 57 | Recast.prototype.setEdgeMaxError = function(val) { 58 | this.sample_TempObstacles.setEdgeMaxError(val); 59 | }; 60 | 61 | Recast.prototype.setVertsPerPoly = function(val) { 62 | this.sample_TempObstacles.setVertsPerPoly(val); 63 | }; 64 | 65 | Recast.prototype.setDetailSampleDist = function(val) { 66 | this.sample_TempObstacles.setDetailSampleDist(val); 67 | }; 68 | 69 | Recast.prototype.setDetailSampleMaxError = function(val) { 70 | this.sample_TempObstacles.setDetailSampleMaxError(val); 71 | }; 72 | 73 | Recast.prototype.setPartitionType = function(val) { 74 | this.sample_TempObstacles.setPartitionType(val); 75 | }; 76 | 77 | Recast.prototype.setDefault = function() { 78 | //设置参数 79 | this.setCellSize(0.1); 80 | this.setCellHeight(0.2); 81 | this.setAgentHeight(2.0); 82 | //直径如果设置太大,会截断狭窄的地形 83 | //this.setAgentRadius(0.6); 84 | this.setAgentRadius(0.0); 85 | this.setAgentMaxClimb(0.9); 86 | this.setAgentMaxSlope(45.0); 87 | this.setRegionMinSize(8); 88 | this.setRegionMergeSize(20.0); 89 | this.setEdgeMaxLen(12.0); 90 | this.setEdgeMaxError(1.3); 91 | this.setVertsPerPoly(6); 92 | this.setDetailSampleDist(6.0); 93 | this.setDetailSampleMaxError(1.0); 94 | this.setPartitionType(0); 95 | }; 96 | 97 | Recast.prototype.load = function(fileName) { 98 | return this.inputGeom.load(this.buildContext, fileName); 99 | }; 100 | 101 | Recast.prototype.build = function() { 102 | return this.sample_TempObstacles.build(); 103 | }; 104 | 105 | Recast.prototype.addTempObstacle = function(x,y,z,radius,height) { 106 | return this.sample_TempObstacles.addTempObstacle(x,y,z,radius,height); 107 | }; 108 | 109 | Recast.prototype.removeTempObstacle = function(ref) { 110 | return this.sample_TempObstacles.removeTempObstacle(ref); 111 | }; 112 | 113 | Recast.prototype.clearAllTempObstacles = function() { 114 | return this.sample_TempObstacles.clearAllTempObstacles(); 115 | }; 116 | 117 | Recast.prototype.update = function(dt) { 118 | this.sample_TempObstacles.update(dt); 119 | }; 120 | 121 | Recast.prototype.findNearestPoint = function(x,y,z,rx,ry,rz) { 122 | return this.sample_TempObstacles.findNearestPoint(x,y,z,rx,ry,rz); 123 | }; 124 | 125 | Recast.prototype.findRandomPoint = function() { 126 | return this.sample_TempObstacles.findRandomPoint(); 127 | }; 128 | 129 | Recast.prototype.findPath = function(x1,y1,z1,x2,y2,z2,maxPath) { 130 | return this.sample_TempObstacles.findPath(x1,y1,z1,x2,y2,z2,maxPath); 131 | }; 132 | 133 | 134 | module.exports = Recast; 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /SDL/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_cpuinfo.h 24 | * 25 | * CPU feature detection for SDL. 26 | */ 27 | 28 | #ifndef _SDL_cpuinfo_h 29 | #define _SDL_cpuinfo_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | /* Need to do this here because intrin.h has C++ code in it */ 34 | /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ 35 | #if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE) 36 | #include 37 | #ifndef _WIN64 38 | #define __MMX__ 39 | #define __3dNOW__ 40 | #endif 41 | #define __SSE__ 42 | #define __SSE2__ 43 | #elif defined(__MINGW64_VERSION_MAJOR) 44 | #include 45 | #else 46 | #ifdef __ALTIVEC__ 47 | #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) 48 | #include 49 | #undef pixel 50 | #endif 51 | #endif 52 | #ifdef __MMX__ 53 | #include 54 | #endif 55 | #ifdef __3dNOW__ 56 | #include 57 | #endif 58 | #ifdef __SSE__ 59 | #include 60 | #endif 61 | #ifdef __SSE2__ 62 | #include 63 | #endif 64 | #endif 65 | 66 | #include "begin_code.h" 67 | /* Set up for C function definitions, even when using C++ */ 68 | #ifdef __cplusplus 69 | /* *INDENT-OFF* */ 70 | extern "C" { 71 | /* *INDENT-ON* */ 72 | #endif 73 | 74 | /* This is a guess for the cacheline size used for padding. 75 | * Most x86 processors have a 64 byte cache line. 76 | * The 64-bit PowerPC processors have a 128 byte cache line. 77 | * We'll use the larger value to be generally safe. 78 | */ 79 | #define SDL_CACHELINE_SIZE 128 80 | 81 | /** 82 | * This function returns the number of CPU cores available. 83 | */ 84 | extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); 85 | 86 | /** 87 | * This function returns the L1 cache line size of the CPU 88 | * 89 | * This is useful for determining multi-threaded structure padding 90 | * or SIMD prefetch sizes. 91 | */ 92 | extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); 93 | 94 | /** 95 | * This function returns true if the CPU has the RDTSC instruction. 96 | */ 97 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 98 | 99 | /** 100 | * This function returns true if the CPU has AltiVec features. 101 | */ 102 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 103 | 104 | /** 105 | * This function returns true if the CPU has MMX features. 106 | */ 107 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 108 | 109 | /** 110 | * This function returns true if the CPU has 3DNow! features. 111 | */ 112 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 113 | 114 | /** 115 | * This function returns true if the CPU has SSE features. 116 | */ 117 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 118 | 119 | /** 120 | * This function returns true if the CPU has SSE2 features. 121 | */ 122 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 123 | 124 | /** 125 | * This function returns true if the CPU has SSE3 features. 126 | */ 127 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); 128 | 129 | /** 130 | * This function returns true if the CPU has SSE4.1 features. 131 | */ 132 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); 133 | 134 | /** 135 | * This function returns true if the CPU has SSE4.2 features. 136 | */ 137 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); 138 | 139 | 140 | /* Ends C function definitions when using C++ */ 141 | #ifdef __cplusplus 142 | /* *INDENT-OFF* */ 143 | } 144 | /* *INDENT-ON* */ 145 | #endif 146 | #include "close_code.h" 147 | 148 | #endif /* _SDL_cpuinfo_h */ 149 | 150 | /* vi: set ts=4 sw=4 expandtab: */ 151 | -------------------------------------------------------------------------------- /SDL/begin_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file begin_code.h 24 | * 25 | * This file sets things up for C dynamic library function definitions, 26 | * static inlined functions, and structures aligned at 4-byte alignment. 27 | * If you don't like ugly C preprocessor code, don't look at this file. :) 28 | */ 29 | 30 | /* This shouldn't be nested -- included it around code only. */ 31 | #ifdef _begin_code_h 32 | #error Nested inclusion of begin_code.h 33 | #endif 34 | #define _begin_code_h 35 | 36 | /* Some compilers use a special export keyword */ 37 | #ifndef DECLSPEC 38 | # if defined(__BEOS__) || defined(__HAIKU__) 39 | # if defined(__GNUC__) 40 | # define DECLSPEC __declspec(dllexport) 41 | # else 42 | # define DECLSPEC __declspec(export) 43 | # endif 44 | # elif defined(__WIN32__) 45 | # ifdef __BORLANDC__ 46 | # ifdef BUILD_SDL 47 | # define DECLSPEC 48 | # else 49 | # define DECLSPEC __declspec(dllimport) 50 | # endif 51 | # else 52 | # define DECLSPEC __declspec(dllexport) 53 | # endif 54 | # else 55 | # if defined(__GNUC__) && __GNUC__ >= 4 56 | # define DECLSPEC __attribute__ ((visibility("default"))) 57 | # else 58 | # define DECLSPEC 59 | # endif 60 | # endif 61 | #endif 62 | 63 | /* By default SDL uses the C calling convention */ 64 | #ifndef SDLCALL 65 | #if defined(__WIN32__) && !defined(__GNUC__) 66 | #define SDLCALL __cdecl 67 | #else 68 | #define SDLCALL 69 | #endif 70 | #endif /* SDLCALL */ 71 | 72 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ 73 | #ifdef __SYMBIAN32__ 74 | #undef DECLSPEC 75 | #define DECLSPEC 76 | #endif /* __SYMBIAN32__ */ 77 | 78 | /* Force structure packing at 4 byte alignment. 79 | This is necessary if the header is included in code which has structure 80 | packing set to an alternate value, say for loading structures from disk. 81 | The packing is reset to the previous value in close_code.h 82 | */ 83 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 84 | #ifdef _MSC_VER 85 | #pragma warning(disable: 4103) 86 | #endif 87 | #ifdef __BORLANDC__ 88 | #pragma nopackwarning 89 | #endif 90 | #pragma pack(push,4) 91 | #endif /* Compiler needs structure packing set */ 92 | 93 | /* Set up compiler-specific options for inlining functions */ 94 | #ifndef SDL_INLINE_OKAY 95 | #ifdef __GNUC__ 96 | #define SDL_INLINE_OKAY 97 | #else 98 | /* Add any special compiler-specific cases here */ 99 | #if defined(_MSC_VER) || defined(__BORLANDC__) || \ 100 | defined(__DMC__) || defined(__SC__) || \ 101 | defined(__WATCOMC__) || defined(__LCC__) || \ 102 | defined(__DECC) 103 | #ifndef __inline__ 104 | #define __inline__ __inline 105 | #endif 106 | #define SDL_INLINE_OKAY 107 | #else 108 | #if !defined(__MRC__) && !defined(_SGI_SOURCE) 109 | #ifndef __inline__ 110 | #define __inline__ inline 111 | #endif 112 | #define SDL_INLINE_OKAY 113 | #endif /* Not a funky compiler */ 114 | #endif /* Visual C++ */ 115 | #endif /* GNU C */ 116 | #endif /* SDL_INLINE_OKAY */ 117 | 118 | /* If inlining isn't supported, remove "__inline__", turning static 119 | inlined functions into static functions (resulting in code bloat 120 | in all files which include the offending header files) 121 | */ 122 | #ifndef SDL_INLINE_OKAY 123 | #define __inline__ 124 | #endif 125 | 126 | /* Apparently this is needed by several Windows compilers */ 127 | #if !defined(__MACH__) 128 | #ifndef NULL 129 | #ifdef __cplusplus 130 | #define NULL 0 131 | #else 132 | #define NULL ((void *)0) 133 | #endif 134 | #endif /* NULL */ 135 | #endif /* ! Mac OS X - breaks precompiled headers */ 136 | -------------------------------------------------------------------------------- /SDL/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_platform.h 24 | * 25 | * Try to get a standard set of platform defines. 26 | */ 27 | 28 | #ifndef _SDL_platform_h 29 | #define _SDL_platform_h 30 | 31 | #if defined(_AIX) 32 | #undef __AIX__ 33 | #define __AIX__ 1 34 | #endif 35 | #if defined(__BEOS__) 36 | #undef __BEOS__ 37 | #define __BEOS__ 1 38 | #endif 39 | #if defined(__HAIKU__) 40 | #undef __HAIKU__ 41 | #define __HAIKU__ 1 42 | #endif 43 | #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) 44 | #undef __BSDI__ 45 | #define __BSDI__ 1 46 | #endif 47 | #if defined(_arch_dreamcast) 48 | #undef __DREAMCAST__ 49 | #define __DREAMCAST__ 1 50 | #endif 51 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 52 | #undef __FREEBSD__ 53 | #define __FREEBSD__ 1 54 | #endif 55 | #if defined(hpux) || defined(__hpux) || defined(__hpux__) 56 | #undef __HPUX__ 57 | #define __HPUX__ 1 58 | #endif 59 | #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) 60 | #undef __IRIX__ 61 | #define __IRIX__ 1 62 | #endif 63 | #if defined(linux) || defined(__linux) || defined(__linux__) 64 | #undef __LINUX__ 65 | #define __LINUX__ 1 66 | #endif 67 | #if defined(ANDROID) 68 | #undef __ANDROID__ 69 | #undef __LINUX__ /*do we need to do this?*/ 70 | #define __ANDROID__ 1 71 | #endif 72 | 73 | #if defined(__APPLE__) 74 | /* lets us know what version of Mac OS X we're compiling on */ 75 | #include "AvailabilityMacros.h" 76 | #include "TargetConditionals.h" 77 | #ifndef MAC_OS_X_VERSION_10_4 78 | #define MAC_OS_X_VERSION_10_4 1040 79 | #endif 80 | #ifndef MAC_OS_X_VERSION_10_5 81 | #define MAC_OS_X_VERSION_10_5 1050 82 | #endif 83 | #ifndef MAC_OS_X_VERSION_10_6 84 | #define MAC_OS_X_VERSION_10_6 1060 85 | #endif 86 | #if TARGET_OS_IPHONE 87 | /* if compiling for iPhone */ 88 | #undef __IPHONEOS__ 89 | #define __IPHONEOS__ 1 90 | #undef __MACOSX__ 91 | #else 92 | /* if not compiling for iPhone */ 93 | #undef __MACOSX__ 94 | #define __MACOSX__ 1 95 | #endif /* TARGET_OS_IPHONE */ 96 | #endif /* defined(__APPLE__) */ 97 | 98 | #if defined(__NetBSD__) 99 | #undef __NETBSD__ 100 | #define __NETBSD__ 1 101 | #endif 102 | #if defined(__OpenBSD__) 103 | #undef __OPENBSD__ 104 | #define __OPENBSD__ 1 105 | #endif 106 | #if defined(__OS2__) 107 | #undef __OS2__ 108 | #define __OS2__ 1 109 | #endif 110 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 111 | #undef __OSF__ 112 | #define __OSF__ 1 113 | #endif 114 | #if defined(__QNXNTO__) 115 | #undef __QNXNTO__ 116 | #define __QNXNTO__ 1 117 | #endif 118 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 119 | #undef __RISCOS__ 120 | #define __RISCOS__ 1 121 | #endif 122 | #if defined(__SVR4) 123 | #undef __SOLARIS__ 124 | #define __SOLARIS__ 1 125 | #endif 126 | #if defined(WIN32) || defined(_WIN32) 127 | #undef __WIN32__ 128 | #define __WIN32__ 1 129 | #endif 130 | 131 | #if defined(__NDS__) 132 | #undef __NINTENDODS__ 133 | #define __NINTENDODS__ 1 134 | #endif 135 | 136 | 137 | #include "begin_code.h" 138 | /* Set up for C function definitions, even when using C++ */ 139 | #ifdef __cplusplus 140 | /* *INDENT-OFF* */ 141 | extern "C" { 142 | /* *INDENT-ON* */ 143 | #endif 144 | 145 | /** 146 | * \brief Gets the name of the platform. 147 | */ 148 | extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); 149 | 150 | /* Ends C function definitions when using C++ */ 151 | #ifdef __cplusplus 152 | /* *INDENT-OFF* */ 153 | } 154 | /* *INDENT-ON* */ 155 | #endif 156 | #include "close_code.h" 157 | 158 | #endif /* _SDL_platform_h */ 159 | 160 | /* vi: set ts=4 sw=4 expandtab: */ 161 | -------------------------------------------------------------------------------- /SDL/SDL_config_iphoneos.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_iphoneos_h 23 | #define _SDL_config_iphoneos_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | #ifdef __LP64__ 28 | #define SIZEOF_VOIDP 8 29 | #else 30 | #define SIZEOF_VOIDP 4 31 | #endif 32 | 33 | #define HAVE_GCC_ATOMICS 1 34 | 35 | #define HAVE_ALLOCA_H 1 36 | #define HAVE_SYS_TYPES_H 1 37 | #define HAVE_STDIO_H 1 38 | #define STDC_HEADERS 1 39 | #define HAVE_STRING_H 1 40 | #define HAVE_INTTYPES_H 1 41 | #define HAVE_STDINT_H 1 42 | #define HAVE_CTYPE_H 1 43 | #define HAVE_MATH_H 1 44 | #define HAVE_SIGNAL_H 1 45 | 46 | /* C library functions */ 47 | #define HAVE_MALLOC 1 48 | #define HAVE_CALLOC 1 49 | #define HAVE_REALLOC 1 50 | #define HAVE_FREE 1 51 | #define HAVE_ALLOCA 1 52 | #define HAVE_GETENV 1 53 | #define HAVE_SETENV 1 54 | #define HAVE_PUTENV 1 55 | #define HAVE_SETENV 1 56 | #define HAVE_UNSETENV 1 57 | #define HAVE_QSORT 1 58 | #define HAVE_ABS 1 59 | #define HAVE_BCOPY 1 60 | #define HAVE_MEMSET 1 61 | #define HAVE_MEMCPY 1 62 | #define HAVE_MEMMOVE 1 63 | #define HAVE_MEMCMP 1 64 | #define HAVE_STRLEN 1 65 | #define HAVE_STRLCPY 1 66 | #define HAVE_STRLCAT 1 67 | #define HAVE_STRDUP 1 68 | #define HAVE_STRCHR 1 69 | #define HAVE_STRRCHR 1 70 | #define HAVE_STRSTR 1 71 | #define HAVE_STRTOL 1 72 | #define HAVE_STRTOUL 1 73 | #define HAVE_STRTOLL 1 74 | #define HAVE_STRTOULL 1 75 | #define HAVE_STRTOD 1 76 | #define HAVE_ATOI 1 77 | #define HAVE_ATOF 1 78 | #define HAVE_STRCMP 1 79 | #define HAVE_STRNCMP 1 80 | #define HAVE_STRCASECMP 1 81 | #define HAVE_STRNCASECMP 1 82 | #define HAVE_SSCANF 1 83 | #define HAVE_SNPRINTF 1 84 | #define HAVE_VSNPRINTF 1 85 | #define HAVE_M_PI 1 86 | #define HAVE_ATAN 1 87 | #define HAVE_ATAN2 1 88 | #define HAVE_CEIL 1 89 | #define HAVE_COPYSIGN 1 90 | #define HAVE_COS 1 91 | #define HAVE_COSF 1 92 | #define HAVE_FABS 1 93 | #define HAVE_FLOOR 1 94 | #define HAVE_LOG 1 95 | #define HAVE_POW 1 96 | #define HAVE_SCALBN 1 97 | #define HAVE_SIN 1 98 | #define HAVE_SINF 1 99 | #define HAVE_SQRT 1 100 | #define HAVE_SIGACTION 1 101 | #define HAVE_SETJMP 1 102 | #define HAVE_NANOSLEEP 1 103 | #define HAVE_SYSCONF 1 104 | #define HAVE_SYSCTLBYNAME 1 105 | 106 | /* enable iPhone version of Core Audio driver */ 107 | #define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1 108 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 109 | #define SDL_AUDIO_DRIVER_DUMMY 1 110 | 111 | /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ 112 | #define SDL_HAPTIC_DISABLED 1 113 | 114 | /* Enable Unix style SO loading */ 115 | /* Technically this works, but it violates the iPhone developer agreement */ 116 | /* #define SDL_LOADSO_DLOPEN 1 */ 117 | 118 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 119 | #define SDL_LOADSO_DISABLED 1 120 | 121 | /* Enable various threading systems */ 122 | #define SDL_THREAD_PTHREAD 1 123 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 124 | 125 | /* Enable various timer systems */ 126 | #define SDL_TIMER_UNIX 1 127 | 128 | /* Supported video drivers */ 129 | #define SDL_VIDEO_DRIVER_UIKIT 1 130 | #define SDL_VIDEO_DRIVER_DUMMY 1 131 | 132 | /* enable OpenGL ES */ 133 | #define SDL_VIDEO_OPENGL_ES 1 134 | #define SDL_VIDEO_RENDER_OGL_ES 1 135 | #define SDL_VIDEO_RENDER_OGL_ES2 1 136 | 137 | /* Enable system power support */ 138 | #define SDL_POWER_UIKIT 1 139 | 140 | /* enable iPhone keyboard support */ 141 | #define SDL_IPHONE_KEYBOARD 1 142 | 143 | /* Set max recognized G-force from accelerometer 144 | See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed 145 | */ 146 | #define SDL_IPHONE_MAX_GFORCE 5.0 147 | 148 | #endif /* _SDL_config_iphoneos_h */ 149 | -------------------------------------------------------------------------------- /SDL/SDL_rect.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_rect.h 24 | * 25 | * Header file for SDL_rect definition and management functions. 26 | */ 27 | 28 | #ifndef _SDL_rect_h 29 | #define _SDL_rect_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_pixels.h" 34 | #include "SDL_rwops.h" 35 | 36 | #include "begin_code.h" 37 | /* Set up for C function definitions, even when using C++ */ 38 | #ifdef __cplusplus 39 | /* *INDENT-OFF* */ 40 | extern "C" { 41 | /* *INDENT-ON* */ 42 | #endif 43 | 44 | /** 45 | * \brief The structure that defines a point 46 | * 47 | * \sa SDL_EnclosePoints 48 | */ 49 | typedef struct 50 | { 51 | int x; 52 | int y; 53 | } SDL_Point; 54 | 55 | /** 56 | * \brief A rectangle, with the origin at the upper left. 57 | * 58 | * \sa SDL_RectEmpty 59 | * \sa SDL_RectEquals 60 | * \sa SDL_HasIntersection 61 | * \sa SDL_IntersectRect 62 | * \sa SDL_UnionRect 63 | * \sa SDL_EnclosePoints 64 | */ 65 | typedef struct SDL_Rect 66 | { 67 | int x, y; 68 | int w, h; 69 | } SDL_Rect; 70 | 71 | /** 72 | * \brief Returns true if the rectangle has no area. 73 | */ 74 | #define SDL_RectEmpty(X) (((X)->w <= 0) || ((X)->h <= 0)) 75 | 76 | /** 77 | * \brief Returns true if the two rectangles are equal. 78 | */ 79 | #define SDL_RectEquals(A, B) (((A)->x == (B)->x) && ((A)->y == (B)->y) && \ 80 | ((A)->w == (B)->w) && ((A)->h == (B)->h)) 81 | 82 | /** 83 | * \brief Determine whether two rectangles intersect. 84 | * 85 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 86 | */ 87 | extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, 88 | const SDL_Rect * B); 89 | 90 | /** 91 | * \brief Calculate the intersection of two rectangles. 92 | * 93 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 94 | */ 95 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, 96 | const SDL_Rect * B, 97 | SDL_Rect * result); 98 | 99 | /** 100 | * \brief Calculate the union of two rectangles. 101 | */ 102 | extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, 103 | const SDL_Rect * B, 104 | SDL_Rect * result); 105 | 106 | /** 107 | * \brief Calculate a minimal rectangle enclosing a set of points 108 | * 109 | * \return SDL_TRUE if any points were within the clipping rect 110 | */ 111 | extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, 112 | int count, 113 | const SDL_Rect * clip, 114 | SDL_Rect * result); 115 | 116 | /** 117 | * \brief Calculate the intersection of a rectangle and line segment. 118 | * 119 | * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. 120 | */ 121 | extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * 122 | rect, int *X1, 123 | int *Y1, int *X2, 124 | int *Y2); 125 | 126 | /* Ends C function definitions when using C++ */ 127 | #ifdef __cplusplus 128 | /* *INDENT-OFF* */ 129 | } 130 | /* *INDENT-ON* */ 131 | #endif 132 | #include "close_code.h" 133 | 134 | #endif /* _SDL_rect_h */ 135 | 136 | /* vi: set ts=4 sw=4 expandtab: */ 137 | -------------------------------------------------------------------------------- /SDL/SDL_config_macosx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_macosx_h 23 | #define _SDL_config_macosx_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ 28 | #include 29 | 30 | /* This is a set of defines to configure the SDL features */ 31 | 32 | #ifdef __LP64__ 33 | #define SIZEOF_VOIDP 8 34 | #else 35 | #define SIZEOF_VOIDP 4 36 | #endif 37 | 38 | /* Useful headers */ 39 | /* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ 40 | #if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) 41 | #define HAVE_ALLOCA_H 1 42 | #endif 43 | #define HAVE_SYS_TYPES_H 1 44 | #define HAVE_STDIO_H 1 45 | #define STDC_HEADERS 1 46 | #define HAVE_STRING_H 1 47 | #define HAVE_INTTYPES_H 1 48 | #define HAVE_STDINT_H 1 49 | #define HAVE_CTYPE_H 1 50 | #define HAVE_MATH_H 1 51 | #define HAVE_SIGNAL_H 1 52 | 53 | /* C library functions */ 54 | #define HAVE_MALLOC 1 55 | #define HAVE_CALLOC 1 56 | #define HAVE_REALLOC 1 57 | #define HAVE_FREE 1 58 | #define HAVE_ALLOCA 1 59 | #define HAVE_GETENV 1 60 | #define HAVE_SETENV 1 61 | #define HAVE_PUTENV 1 62 | #define HAVE_UNSETENV 1 63 | #define HAVE_QSORT 1 64 | #define HAVE_ABS 1 65 | #define HAVE_BCOPY 1 66 | #define HAVE_MEMSET 1 67 | #define HAVE_MEMCPY 1 68 | #define HAVE_MEMMOVE 1 69 | #define HAVE_MEMCMP 1 70 | #define HAVE_STRLEN 1 71 | #define HAVE_STRLCPY 1 72 | #define HAVE_STRLCAT 1 73 | #define HAVE_STRDUP 1 74 | #define HAVE_STRCHR 1 75 | #define HAVE_STRRCHR 1 76 | #define HAVE_STRSTR 1 77 | #define HAVE_STRTOL 1 78 | #define HAVE_STRTOUL 1 79 | #define HAVE_STRTOLL 1 80 | #define HAVE_STRTOULL 1 81 | #define HAVE_STRTOD 1 82 | #define HAVE_ATOI 1 83 | #define HAVE_ATOF 1 84 | #define HAVE_STRCMP 1 85 | #define HAVE_STRNCMP 1 86 | #define HAVE_STRCASECMP 1 87 | #define HAVE_STRNCASECMP 1 88 | #define HAVE_SSCANF 1 89 | #define HAVE_SNPRINTF 1 90 | #define HAVE_VSNPRINTF 1 91 | #define HAVE_CEIL 1 92 | #define HAVE_COPYSIGN 1 93 | #define HAVE_COS 1 94 | #define HAVE_COSF 1 95 | #define HAVE_FABS 1 96 | #define HAVE_FLOOR 1 97 | #define HAVE_LOG 1 98 | #define HAVE_POW 1 99 | #define HAVE_SCALBN 1 100 | #define HAVE_SIN 1 101 | #define HAVE_SINF 1 102 | #define HAVE_SQRT 1 103 | #define HAVE_SIGACTION 1 104 | #define HAVE_SETJMP 1 105 | #define HAVE_NANOSLEEP 1 106 | #define HAVE_SYSCONF 1 107 | #define HAVE_SYSCTLBYNAME 1 108 | #define HAVE_ATAN 1 109 | #define HAVE_ATAN2 1 110 | 111 | /* Enable various audio drivers */ 112 | #define SDL_AUDIO_DRIVER_COREAUDIO 1 113 | #define SDL_AUDIO_DRIVER_DISK 1 114 | #define SDL_AUDIO_DRIVER_DUMMY 1 115 | 116 | /* Enable various input drivers */ 117 | #define SDL_JOYSTICK_IOKIT 1 118 | #define SDL_HAPTIC_IOKIT 1 119 | 120 | /* Enable various shared object loading systems */ 121 | #define SDL_LOADSO_DLOPEN 1 122 | 123 | /* Enable various threading systems */ 124 | #define SDL_THREAD_PTHREAD 1 125 | #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 126 | 127 | /* Enable various timer systems */ 128 | #define SDL_TIMER_UNIX 1 129 | 130 | /* Enable various video drivers */ 131 | #define SDL_VIDEO_DRIVER_COCOA 1 132 | #define SDL_VIDEO_DRIVER_DUMMY 1 133 | #define SDL_VIDEO_DRIVER_X11 1 134 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" 135 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" 136 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" 137 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT "/usr/X11R6/lib/libXi.6.dylib" 138 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" 139 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" 140 | #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" 141 | #define SDL_VIDEO_DRIVER_X11_XINERAMA 1 142 | #define SDL_VIDEO_DRIVER_X11_XINPUT 1 143 | #define SDL_VIDEO_DRIVER_X11_XRANDR 1 144 | #define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 145 | #define SDL_VIDEO_DRIVER_X11_XSHAPE 1 146 | #define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 147 | 148 | #ifndef SDL_VIDEO_RENDER_OGL 149 | #define SDL_VIDEO_RENDER_OGL 1 150 | #endif 151 | 152 | /* Enable OpenGL support */ 153 | #ifndef SDL_VIDEO_OPENGL 154 | #define SDL_VIDEO_OPENGL 1 155 | #endif 156 | #ifndef SDL_VIDEO_OPENGL_CGL 157 | #define SDL_VIDEO_OPENGL_CGL 1 158 | #endif 159 | #ifndef SDL_VIDEO_OPENGL_GLX 160 | #define SDL_VIDEO_OPENGL_GLX 1 161 | #endif 162 | 163 | /* Enable system power support */ 164 | #define SDL_POWER_MACOSX 1 165 | 166 | /* Enable assembly routines */ 167 | #define SDL_ASSEMBLY_ROUTINES 1 168 | #ifdef __ppc__ 169 | #define SDL_ALTIVEC_BLITTERS 1 170 | #endif 171 | 172 | #endif /* _SDL_config_macosx_h */ 173 | -------------------------------------------------------------------------------- /SDL/SDL_keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_keyboard.h 24 | * 25 | * Include file for SDL keyboard event handling 26 | */ 27 | 28 | #ifndef _SDL_keyboard_h 29 | #define _SDL_keyboard_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_keycode.h" 34 | #include "SDL_video.h" 35 | 36 | #include "begin_code.h" 37 | /* Set up for C function definitions, even when using C++ */ 38 | #ifdef __cplusplus 39 | /* *INDENT-OFF* */ 40 | extern "C" { 41 | /* *INDENT-ON* */ 42 | #endif 43 | 44 | /** 45 | * \brief The SDL keysym structure, used in key events. 46 | */ 47 | typedef struct SDL_Keysym 48 | { 49 | SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ 50 | SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ 51 | Uint16 mod; /**< current key modifiers */ 52 | Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */ 53 | } SDL_Keysym; 54 | 55 | /* Function prototypes */ 56 | 57 | /** 58 | * \brief Get the window which currently has keyboard focus. 59 | */ 60 | extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); 61 | 62 | /** 63 | * \brief Get a snapshot of the current state of the keyboard. 64 | * 65 | * \param numkeys if non-NULL, receives the length of the returned array. 66 | * 67 | * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. 68 | * 69 | * \b Example: 70 | * \code 71 | * Uint8 *state = SDL_GetKeyboardState(NULL); 72 | * if ( state[SDL_SCANCODE_RETURN] ) { 73 | * printf(" is pressed.\n"); 74 | * } 75 | * \endcode 76 | */ 77 | extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); 78 | 79 | /** 80 | * \brief Get the current key modifier state for the keyboard. 81 | */ 82 | extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); 83 | 84 | /** 85 | * \brief Set the current key modifier state for the keyboard. 86 | * 87 | * \note This does not change the keyboard state, only the key modifier flags. 88 | */ 89 | extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); 90 | 91 | /** 92 | * \brief Get the key code corresponding to the given scancode according 93 | * to the current keyboard layout. 94 | * 95 | * See ::SDL_Keycode for details. 96 | * 97 | * \sa SDL_GetKeyName() 98 | */ 99 | extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); 100 | 101 | /** 102 | * \brief Get the scancode corresponding to the given key code according to the 103 | * current keyboard layout. 104 | * 105 | * See ::SDL_Scancode for details. 106 | * 107 | * \sa SDL_GetScancodeName() 108 | */ 109 | extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); 110 | 111 | /** 112 | * \brief Get a human-readable name for a scancode. 113 | * 114 | * \return A pointer to a UTF-8 string that stays valid at least until the next 115 | * call to this function. If you need it around any longer, you must 116 | * copy it. If the scancode doesn't have a name, this function returns 117 | * an empty string (""). 118 | * 119 | * \sa SDL_Scancode 120 | */ 121 | extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode 122 | scancode); 123 | 124 | /** 125 | * \brief Get a human-readable name for a key. 126 | * 127 | * \return A pointer to a UTF-8 string that stays valid at least until the next 128 | * call to this function. If you need it around any longer, you must 129 | * copy it. If the key doesn't have a name, this function returns an 130 | * empty string (""). 131 | * 132 | * \sa SDL_Key 133 | */ 134 | extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); 135 | 136 | /** 137 | * \brief Start accepting Unicode text input events. 138 | * 139 | * \sa SDL_StopTextInput() 140 | * \sa SDL_SetTextInputRect() 141 | */ 142 | extern DECLSPEC void SDLCALL SDL_StartTextInput(void); 143 | 144 | /** 145 | * \brief Stop receiving any text input events. 146 | * 147 | * \sa SDL_StartTextInput() 148 | */ 149 | extern DECLSPEC void SDLCALL SDL_StopTextInput(void); 150 | 151 | /** 152 | * \brief Set the rectangle used to type Unicode text inputs. 153 | * 154 | * \sa SDL_StartTextInput() 155 | */ 156 | extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); 157 | 158 | 159 | /* Ends C function definitions when using C++ */ 160 | #ifdef __cplusplus 161 | /* *INDENT-OFF* */ 162 | } 163 | /* *INDENT-ON* */ 164 | #endif 165 | #include "close_code.h" 166 | 167 | #endif /* _SDL_keyboard_h */ 168 | 169 | /* vi: set ts=4 sw=4 expandtab: */ 170 | -------------------------------------------------------------------------------- /SDL/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL.h 24 | * 25 | * Main include header for the SDL library 26 | */ 27 | 28 | /** 29 | * \mainpage Simple DirectMedia Layer (SDL) 30 | * 31 | * http://www.libsdl.org/ 32 | * 33 | * \section intro_sec Introduction 34 | * 35 | * This is the Simple DirectMedia Layer, a general API that provides low 36 | * level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, 37 | * and 2D framebuffer across multiple platforms. 38 | * 39 | * SDL is written in C, but works with C++ natively, and has bindings to 40 | * several other languages, including Ada, C#, Eiffel, Erlang, Euphoria, 41 | * Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, 42 | * Pike, Pliant, Python, Ruby, and Smalltalk. 43 | * 44 | * This library is distributed under GNU LGPL version 2, which can be 45 | * found in the file "COPYING". This license allows you to use SDL 46 | * freely in commercial programs as long as you link with the dynamic 47 | * library. 48 | * 49 | * The best way to learn how to use SDL is to check out the header files in 50 | * the "include" subdirectory and the programs in the "test" subdirectory. 51 | * The header files and test programs are well commented and always up to date. 52 | * More documentation is available in HTML format in "docs/index.html", and 53 | * a documentation wiki is available online at: 54 | * http://www.libsdl.org/cgi/docwiki.cgi 55 | * 56 | * The test programs in the "test" subdirectory are in the public domain. 57 | * 58 | * Frequently asked questions are answered online: 59 | * http://www.libsdl.org/faq.php 60 | * 61 | * If you need help with the library, or just want to discuss SDL related 62 | * issues, you can join the developers mailing list: 63 | * http://www.libsdl.org/mailing-list.php 64 | * 65 | * Enjoy! 66 | * Sam Lantinga (slouken@libsdl.org) 67 | */ 68 | 69 | #ifndef _SDL_H 70 | #define _SDL_H 71 | 72 | #include "SDL_main.h" 73 | #include "SDL_stdinc.h" 74 | #include "SDL_assert.h" 75 | #include "SDL_atomic.h" 76 | #include "SDL_audio.h" 77 | #include "SDL_clipboard.h" 78 | #include "SDL_cpuinfo.h" 79 | #include "SDL_endian.h" 80 | #include "SDL_error.h" 81 | #include "SDL_events.h" 82 | #include "SDL_hints.h" 83 | #include "SDL_loadso.h" 84 | #include "SDL_log.h" 85 | #include "SDL_mutex.h" 86 | #include "SDL_power.h" 87 | #include "SDL_render.h" 88 | #include "SDL_rwops.h" 89 | #include "SDL_thread.h" 90 | #include "SDL_timer.h" 91 | #include "SDL_version.h" 92 | #include "SDL_video.h" 93 | #include "SDL_compat.h" 94 | 95 | #include "begin_code.h" 96 | /* Set up for C function definitions, even when using C++ */ 97 | #ifdef __cplusplus 98 | /* *INDENT-OFF* */ 99 | extern "C" { 100 | /* *INDENT-ON* */ 101 | #endif 102 | 103 | /* As of version 0.5, SDL is loaded dynamically into the application */ 104 | 105 | /** 106 | * \name SDL_INIT_* 107 | * 108 | * These are the flags which may be passed to SDL_Init(). You should 109 | * specify the subsystems which you will be using in your application. 110 | */ 111 | /*@{*/ 112 | #define SDL_INIT_TIMER 0x00000001 113 | #define SDL_INIT_AUDIO 0x00000010 114 | #define SDL_INIT_VIDEO 0x00000020 115 | #define SDL_INIT_JOYSTICK 0x00000200 116 | #define SDL_INIT_HAPTIC 0x00001000 117 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ 118 | #define SDL_INIT_EVERYTHING 0x0000FFFF 119 | /*@}*/ 120 | 121 | /** 122 | * This function initializes the subsystems specified by \c flags 123 | * Unless the ::SDL_INIT_NOPARACHUTE flag is set, it will install cleanup 124 | * signal handlers for some commonly ignored fatal signals (like SIGSEGV). 125 | */ 126 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 127 | 128 | /** 129 | * This function initializes specific SDL subsystems 130 | */ 131 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 132 | 133 | /** 134 | * This function cleans up specific SDL subsystems 135 | */ 136 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 137 | 138 | /** 139 | * This function returns a mask of the specified subsystems which have 140 | * previously been initialized. 141 | * 142 | * If \c flags is 0, it returns a mask of all initialized subsystems. 143 | */ 144 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 145 | 146 | /** 147 | * This function cleans up all initialized subsystems. You should 148 | * call it upon all exit conditions. 149 | */ 150 | extern DECLSPEC void SDLCALL SDL_Quit(void); 151 | 152 | /* Ends C function definitions when using C++ */ 153 | #ifdef __cplusplus 154 | /* *INDENT-OFF* */ 155 | } 156 | /* *INDENT-ON* */ 157 | #endif 158 | #include "close_code.h" 159 | 160 | #endif /* _SDL_H */ 161 | 162 | /* vi: set ts=4 sw=4 expandtab: */ 163 | -------------------------------------------------------------------------------- /SDL/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_version.h 24 | * 25 | * This header defines the current SDL version. 26 | */ 27 | 28 | #ifndef _SDL_version_h 29 | #define _SDL_version_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | /* *INDENT-OFF* */ 37 | extern "C" { 38 | /* *INDENT-ON* */ 39 | #endif 40 | 41 | /** 42 | * \brief Information the version of SDL in use. 43 | * 44 | * Represents the library's version as three levels: major revision 45 | * (increments with massive changes, additions, and enhancements), 46 | * minor revision (increments with backwards-compatible changes to the 47 | * major revision), and patchlevel (increments with fixes to the minor 48 | * revision). 49 | * 50 | * \sa SDL_VERSION 51 | * \sa SDL_GetVersion 52 | */ 53 | typedef struct SDL_version 54 | { 55 | Uint8 major; /**< major version */ 56 | Uint8 minor; /**< minor version */ 57 | Uint8 patch; /**< update version */ 58 | } SDL_version; 59 | 60 | /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 61 | */ 62 | #define SDL_MAJOR_VERSION 1 63 | #define SDL_MINOR_VERSION 3 64 | #define SDL_PATCHLEVEL 0 65 | 66 | /** 67 | * \brief Macro to determine SDL version program was compiled against. 68 | * 69 | * This macro fills in a SDL_version structure with the version of the 70 | * library you compiled against. This is determined by what header the 71 | * compiler uses. Note that if you dynamically linked the library, you might 72 | * have a slightly newer or older version at runtime. That version can be 73 | * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), 74 | * is not a macro. 75 | * 76 | * \param x A pointer to a SDL_version struct to initialize. 77 | * 78 | * \sa SDL_version 79 | * \sa SDL_GetVersion 80 | */ 81 | #define SDL_VERSION(x) \ 82 | { \ 83 | (x)->major = SDL_MAJOR_VERSION; \ 84 | (x)->minor = SDL_MINOR_VERSION; \ 85 | (x)->patch = SDL_PATCHLEVEL; \ 86 | } 87 | 88 | /** 89 | * This macro turns the version numbers into a numeric value: 90 | * \verbatim 91 | (1,2,3) -> (1203) 92 | \endverbatim 93 | * 94 | * This assumes that there will never be more than 100 patchlevels. 95 | */ 96 | #define SDL_VERSIONNUM(X, Y, Z) \ 97 | ((X)*1000 + (Y)*100 + (Z)) 98 | 99 | /** 100 | * This is the version number macro for the current SDL version. 101 | */ 102 | #define SDL_COMPILEDVERSION \ 103 | SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) 104 | 105 | /** 106 | * This macro will evaluate to true if compiled with SDL at least X.Y.Z. 107 | */ 108 | #define SDL_VERSION_ATLEAST(X, Y, Z) \ 109 | (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) 110 | 111 | /** 112 | * \brief Get the version of SDL that is linked against your program. 113 | * 114 | * If you are linking to SDL dynamically, then it is possible that the 115 | * current version will be different than the version you compiled against. 116 | * This function returns the current version, while SDL_VERSION() is a 117 | * macro that tells you what version you compiled with. 118 | * 119 | * \code 120 | * SDL_version compiled; 121 | * SDL_version linked; 122 | * 123 | * SDL_VERSION(&compiled); 124 | * SDL_GetVersion(&linked); 125 | * printf("We compiled against SDL version %d.%d.%d ...\n", 126 | * compiled.major, compiled.minor, compiled.patch); 127 | * printf("But we linked against SDL version %d.%d.%d.\n", 128 | * linked.major, linked.minor, linked.patch); 129 | * \endcode 130 | * 131 | * This function may be called safely at any time, even before SDL_Init(). 132 | * 133 | * \sa SDL_VERSION 134 | */ 135 | extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); 136 | 137 | /** 138 | * \brief Get the code revision of SDL that is linked against your program. 139 | * 140 | * Returns an arbitrary string (a hash value) uniquely identifying the 141 | * exact revision of the SDL library in use, and is only useful in comparing 142 | * against other revisions. It is NOT an incrementing number. 143 | */ 144 | extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); 145 | 146 | /** 147 | * \brief Get the revision number of SDL that is linked against your program. 148 | * 149 | * Returns a number uniquely identifying the exact revision of the SDL 150 | * library in use. It is an incrementing number based on commits to 151 | * hg.libsdl.org. 152 | */ 153 | extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); 154 | 155 | 156 | /* Ends C function definitions when using C++ */ 157 | #ifdef __cplusplus 158 | /* *INDENT-OFF* */ 159 | } 160 | /* *INDENT-ON* */ 161 | #endif 162 | #include "close_code.h" 163 | 164 | #endif /* _SDL_version_h */ 165 | 166 | /* vi: set ts=4 sw=4 expandtab: */ 167 | -------------------------------------------------------------------------------- /src/Sample_TempObstaclesExt.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "Sample_TempObstaclesExt.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // This value specifies how many layers (or "floors") each navmesh tile is expected to have. 16 | static const int EXPECTED_LAYERS_PER_TILE = 4; 17 | 18 | Sample_TempObstaclesExt::Sample_TempObstaclesExt() { 19 | srand(time(NULL)); 20 | } 21 | 22 | bool Sample_TempObstaclesExt::Build() 23 | { 24 | // Init cache 25 | const float* bmin = m_geom->getNavMeshBoundsMin(); 26 | const float* bmax = m_geom->getNavMeshBoundsMax(); 27 | printf("handleBuild bmin:%f bmax:%f",*bmin,*bmax); 28 | int gw = 0, gh = 0; 29 | rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh); 30 | 31 | const int ts = (int)m_tileSize; 32 | const int tw = (gw + ts-1) / ts; 33 | const int th = (gh + ts-1) / ts; 34 | 35 | int tileBits = rcMin((int)dtIlog2(dtNextPow2(tw*th*EXPECTED_LAYERS_PER_TILE)), 14); 36 | if (tileBits > 14) tileBits = 14; 37 | int polyBits = 22 - tileBits; 38 | m_maxTiles = 1 << tileBits; 39 | m_maxPolysPerTile = 1 << polyBits; 40 | 41 | return handleBuild(); 42 | } 43 | 44 | unsigned int Sample_TempObstaclesExt::addTempObstacle(const float posX,const float posY,const float posZ,const float radius, const float height) 45 | { 46 | float p[3]; 47 | p[0] = posX; 48 | p[1] = posY; 49 | p[2] = posZ; 50 | unsigned int ref; 51 | m_tileCache->addObstacle(p, radius, height, &ref); 52 | return ref; 53 | } 54 | 55 | unsigned int Sample_TempObstaclesExt::removeTempObstacle(const unsigned int ref) 56 | { 57 | dtStatus status = m_tileCache->removeObstacle(ref); 58 | return status; 59 | } 60 | 61 | unsigned int Sample_TempObstaclesExt::findNearestPoint(float cx, float cy, float cz,float extx, float exty, float extz,float *nearestPos,dtPolyRef *ref) 62 | { 63 | dtNavMeshQuery* m_navQuery = getNavMeshQuery(); 64 | const float p[3] = {cx,cy,cz}; 65 | const float ext[3] = {extx,exty,extz}; 66 | dtQueryFilter filter; 67 | filter.setIncludeFlags(3); 68 | filter.setExcludeFlags(0); 69 | dtStatus status = m_navQuery->findNearestPoly(p, ext, &filter, ref, nearestPos); 70 | return status; 71 | } 72 | 73 | // Returns a random number [0..1) 74 | static float frand() 75 | { 76 | // return ((float)(rand() & 0xffff)/(float)0xffff); 77 | return (float)rand()/(float)RAND_MAX; 78 | } 79 | 80 | unsigned int Sample_TempObstaclesExt::findRandomPoint(float *randomPt,dtPolyRef *ref) 81 | { 82 | dtQueryFilter filter; 83 | filter.setIncludeFlags(3); 84 | filter.setExcludeFlags(0); 85 | dtNavMeshQuery* m_navQuery = getNavMeshQuery(); 86 | dtStatus status = m_navQuery->findRandomPoint(&filter, frand, ref, randomPt); 87 | return status; 88 | } 89 | 90 | unsigned int Sample_TempObstaclesExt::findPath(float startPosX, float startPosY, float startPosZ, 91 | float endPosX, float endPosY, float endPosZ, int maxPath,vpath *ret) 92 | { 93 | dtNavMeshQuery* m_navQuery = getNavMeshQuery(); 94 | if( m_navQuery == NULL) { 95 | printf("NavMeshQuery is not ready"); 96 | return DT_FAILURE; 97 | } 98 | float startPos[3] = { startPosX, startPosY, startPosZ }; 99 | float endPos[3] = { endPosX, endPosY, endPosZ }; 100 | const float ext[3] = {2,4,2}; 101 | dtStatus status; 102 | dtPolyRef path[maxPath+1]; 103 | int pathCount; 104 | dtQueryFilter filter; 105 | filter.setIncludeFlags(3); 106 | filter.setExcludeFlags(0); 107 | // Change costs. 108 | filter.setAreaCost(SAMPLE_POLYAREA_GROUND, 1.0f); 109 | filter.setAreaCost(SAMPLE_POLYAREA_WATER, 10.0f); 110 | filter.setAreaCost(SAMPLE_POLYAREA_ROAD, 1.0f); 111 | filter.setAreaCost(SAMPLE_POLYAREA_DOOR, 1.0f); 112 | filter.setAreaCost(SAMPLE_POLYAREA_GRASS, 2.0f); 113 | filter.setAreaCost(SAMPLE_POLYAREA_JUMP, 1.5f); 114 | float nearestStartPos[3]; 115 | dtPolyRef startRef = 0; 116 | m_navQuery->findNearestPoly(startPos, ext, &filter, &startRef, nearestStartPos); 117 | float nearestEndPos[3]; 118 | dtPolyRef endRef = 0; 119 | m_navQuery->findNearestPoly(endPos, ext, &filter, &endRef, nearestEndPos); 120 | //printf("Use %u , %u as start / end polyRefs \n", startRef, endRef); 121 | status = m_navQuery->findPath(startRef, endRef, nearestStartPos, nearestEndPos, &filter, path, &pathCount, maxPath); 122 | if (dtStatusFailed(status)) { 123 | printf("Cannot find a path: %u\n", status); 124 | return status; 125 | } 126 | 127 | //printf("Found a %u polysteps path \n", pathCount); 128 | float straightPath[maxPath*3]; 129 | unsigned char straightPathFlags[maxPath]; 130 | dtPolyRef straightPathRefs[maxPath]; 131 | int straightPathCount = 0; 132 | int maxStraightPath = maxPath; 133 | int options = 0; 134 | status = m_navQuery->findStraightPath(nearestStartPos, nearestEndPos, path, pathCount, straightPath, 135 | straightPathFlags, straightPathRefs, &straightPathCount, maxStraightPath, options); 136 | 137 | if (dtStatusFailed(status)) { 138 | printf("Cannot find a straight path: %u\n", status); 139 | return status; 140 | } 141 | //printf("Found a %u steps path \n", straightPathCount); 142 | ret->nlen = straightPathCount; 143 | ret->datas = new vertex3[straightPathCount]; 144 | for (int i = 0; i < straightPathCount; ++i) { 145 | const float* v = &straightPath[i*3]; 146 | ret->datas[i].x = v[0]; 147 | ret->datas[i].y = v[1]; 148 | ret->datas[i].z = v[2]; 149 | // why ? 150 | if (!(fabs(v[0]) < 0.0000001f && fabs(v[1]) < 0.0000001f && fabs(v[2]) < 0.0000001f)) { 151 | //sprintf(buff, "__tmp_recastjs_data.push({x:%f, y:%f, z:%f});", v[0], v[1], v[2]); 152 | //emscripten_run_script(buff); 153 | } else { 154 | //sprintf(buff, "ignore %f, %f, %f", v[0], v[1], v[2]); 155 | //emscripten_log(buff); 156 | } 157 | } 158 | return status; 159 | } -------------------------------------------------------------------------------- /SDL/SDL_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_image: An example image loading library for use with SDL 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* A simple library to load images of various formats as SDL surfaces */ 23 | 24 | #ifndef _SDL_IMAGE_H 25 | #define _SDL_IMAGE_H 26 | 27 | #include "SDL.h" 28 | #include "SDL_version.h" 29 | #include "begin_code.h" 30 | 31 | /* Set up for C function definitions, even when using C++ */ 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 37 | */ 38 | #define SDL_IMAGE_MAJOR_VERSION 1 39 | #define SDL_IMAGE_MINOR_VERSION 2 40 | #define SDL_IMAGE_PATCHLEVEL 12 41 | 42 | /* This macro can be used to fill a version structure with the compile-time 43 | * version of the SDL_image library. 44 | */ 45 | #define SDL_IMAGE_VERSION(X) \ 46 | { \ 47 | (X)->major = SDL_IMAGE_MAJOR_VERSION; \ 48 | (X)->minor = SDL_IMAGE_MINOR_VERSION; \ 49 | (X)->patch = SDL_IMAGE_PATCHLEVEL; \ 50 | } 51 | 52 | /* This function gets the version of the dynamically linked SDL_image library. 53 | it should NOT be used to fill a version structure, instead you should 54 | use the SDL_IMAGE_VERSION() macro. 55 | */ 56 | extern DECLSPEC const SDL_version * SDLCALL IMG_Linked_Version(void); 57 | 58 | typedef enum 59 | { 60 | IMG_INIT_JPG = 0x00000001, 61 | IMG_INIT_PNG = 0x00000002, 62 | IMG_INIT_TIF = 0x00000004, 63 | IMG_INIT_WEBP = 0x00000008 64 | } IMG_InitFlags; 65 | 66 | /* Loads dynamic libraries and prepares them for use. Flags should be 67 | one or more flags from IMG_InitFlags OR'd together. 68 | It returns the flags successfully initialized, or 0 on failure. 69 | */ 70 | extern DECLSPEC int SDLCALL IMG_Init(int flags); 71 | 72 | /* Unloads libraries loaded with IMG_Init */ 73 | extern DECLSPEC void SDLCALL IMG_Quit(void); 74 | 75 | /* Load an image from an SDL data source. 76 | The 'type' may be one of: "BMP", "GIF", "PNG", etc. 77 | 78 | If the image format supports a transparent pixel, SDL will set the 79 | colorkey for the surface. You can enable RLE acceleration on the 80 | surface afterwards by calling: 81 | SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey); 82 | */ 83 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type); 84 | /* Convenience functions */ 85 | extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file); 86 | extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, int freesrc); 87 | 88 | /* Invert the alpha of a surface for use with OpenGL 89 | This function is now a no-op, and only provided for backwards compatibility. 90 | */ 91 | extern DECLSPEC int SDLCALL IMG_InvertAlpha(int on); 92 | 93 | /* Functions to detect a file type, given a seekable source */ 94 | extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src); 95 | extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src); 96 | extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src); 97 | extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src); 98 | extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src); 99 | extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src); 100 | extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src); 101 | extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src); 102 | extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src); 103 | extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src); 104 | extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src); 105 | extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src); 106 | extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src); 107 | extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src); 108 | 109 | /* Individual loading functions */ 110 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src); 111 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src); 112 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src); 113 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src); 114 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src); 115 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src); 116 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src); 117 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src); 118 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src); 119 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src); 120 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src); 121 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src); 122 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src); 123 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src); 124 | extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src); 125 | 126 | extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm); 127 | 128 | /* We'll use SDL for reporting errors */ 129 | #define IMG_SetError SDL_SetError 130 | #define IMG_GetError SDL_GetError 131 | 132 | /* Ends C function definitions when using C++ */ 133 | #ifdef __cplusplus 134 | } 135 | #endif 136 | #include "close_code.h" 137 | 138 | #endif /* _SDL_IMAGE_H */ 139 | -------------------------------------------------------------------------------- /SDL/SDL_config_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_config_windows_h 23 | #define _SDL_config_windows_h 24 | 25 | #include "SDL_platform.h" 26 | 27 | /* This is a set of defines to configure the SDL features */ 28 | 29 | #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) 30 | #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) 31 | #define HAVE_STDINT_H 1 32 | #elif defined(_MSC_VER) 33 | typedef signed __int8 int8_t; 34 | typedef unsigned __int8 uint8_t; 35 | typedef signed __int16 int16_t; 36 | typedef unsigned __int16 uint16_t; 37 | typedef signed __int32 int32_t; 38 | typedef unsigned __int32 uint32_t; 39 | typedef signed __int64 int64_t; 40 | typedef unsigned __int64 uint64_t; 41 | #ifndef _UINTPTR_T_DEFINED 42 | #ifdef _WIN64 43 | typedef unsigned __int64 uintptr_t; 44 | #else 45 | typedef unsigned int uintptr_t; 46 | #endif 47 | #define _UINTPTR_T_DEFINED 48 | #endif 49 | /* Older Visual C++ headers don't have the Win64-compatible typedefs... */ 50 | #if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) 51 | #define DWORD_PTR DWORD 52 | #endif 53 | #if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) 54 | #define LONG_PTR LONG 55 | #endif 56 | #else /* !__GNUC__ && !_MSC_VER */ 57 | typedef signed char int8_t; 58 | typedef unsigned char uint8_t; 59 | typedef signed short int16_t; 60 | typedef unsigned short uint16_t; 61 | typedef signed int int32_t; 62 | typedef unsigned int uint32_t; 63 | typedef signed long long int64_t; 64 | typedef unsigned long long uint64_t; 65 | #ifndef _SIZE_T_DEFINED_ 66 | #define _SIZE_T_DEFINED_ 67 | typedef unsigned int size_t; 68 | #endif 69 | typedef unsigned int uintptr_t; 70 | #endif /* __GNUC__ || _MSC_VER */ 71 | #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ 72 | 73 | #ifdef _WIN64 74 | # define SIZEOF_VOIDP 8 75 | #else 76 | # define SIZEOF_VOIDP 4 77 | #endif 78 | 79 | /* Enabled for SDL 1.2 (binary compatibility) */ 80 | //#define HAVE_LIBC 1 81 | #ifdef HAVE_LIBC 82 | /* Useful headers */ 83 | #define HAVE_STDIO_H 1 84 | #define STDC_HEADERS 1 85 | #define HAVE_STRING_H 1 86 | #define HAVE_CTYPE_H 1 87 | #define HAVE_MATH_H 1 88 | #ifndef _WIN32_WCE 89 | #define HAVE_SIGNAL_H 1 90 | #endif 91 | 92 | /* C library functions */ 93 | #define HAVE_MALLOC 1 94 | #define HAVE_CALLOC 1 95 | #define HAVE_REALLOC 1 96 | #define HAVE_FREE 1 97 | #define HAVE_ALLOCA 1 98 | #define HAVE_QSORT 1 99 | #define HAVE_ABS 1 100 | #define HAVE_MEMSET 1 101 | #define HAVE_MEMCPY 1 102 | #define HAVE_MEMMOVE 1 103 | #define HAVE_MEMCMP 1 104 | #define HAVE_STRLEN 1 105 | #define HAVE__STRREV 1 106 | #define HAVE__STRUPR 1 107 | #define HAVE__STRLWR 1 108 | #define HAVE_STRCHR 1 109 | #define HAVE_STRRCHR 1 110 | #define HAVE_STRSTR 1 111 | #define HAVE_ITOA 1 112 | #define HAVE__LTOA 1 113 | #define HAVE__ULTOA 1 114 | #define HAVE_STRTOL 1 115 | #define HAVE_STRTOUL 1 116 | #define HAVE_STRTOLL 1 117 | #define HAVE_STRTOD 1 118 | #define HAVE_ATOI 1 119 | #define HAVE_ATOF 1 120 | #define HAVE_STRCMP 1 121 | #define HAVE_STRNCMP 1 122 | #define HAVE__STRICMP 1 123 | #define HAVE__STRNICMP 1 124 | #define HAVE_SSCANF 1 125 | #define HAVE_M_PI 1 126 | #define HAVE_ATAN 1 127 | #define HAVE_ATAN2 1 128 | #define HAVE_CEIL 1 129 | #define HAVE_COPYSIGN 1 130 | #define HAVE_COS 1 131 | #define HAVE_COSF 1 132 | #define HAVE_FABS 1 133 | #define HAVE_FLOOR 1 134 | #define HAVE_LOG 1 135 | #define HAVE_POW 1 136 | #define HAVE_SCALBN 1 137 | #define HAVE_SIN 1 138 | #define HAVE_SINF 1 139 | #define HAVE_SQRT 1 140 | #else 141 | #define HAVE_STDARG_H 1 142 | #define HAVE_STDDEF_H 1 143 | #endif 144 | 145 | /* Enable various audio drivers */ 146 | #ifndef _WIN32_WCE 147 | #define SDL_AUDIO_DRIVER_DSOUND 1 148 | #define SDL_AUDIO_DRIVER_XAUDIO2 1 149 | #endif 150 | #define SDL_AUDIO_DRIVER_WINMM 1 151 | #define SDL_AUDIO_DRIVER_DISK 1 152 | #define SDL_AUDIO_DRIVER_DUMMY 1 153 | 154 | /* Enable various input drivers */ 155 | #ifdef _WIN32_WCE 156 | #define SDL_JOYSTICK_DISABLED 1 157 | #define SDL_HAPTIC_DUMMY 1 158 | #else 159 | #define SDL_JOYSTICK_DINPUT 1 160 | #define SDL_HAPTIC_DINPUT 1 161 | #endif 162 | 163 | /* Enable various shared object loading systems */ 164 | #define SDL_LOADSO_WINDOWS 1 165 | 166 | /* Enable various threading systems */ 167 | #define SDL_THREAD_WINDOWS 1 168 | 169 | /* Enable various timer systems */ 170 | #ifdef _WIN32_WCE 171 | #define SDL_TIMER_WINCE 1 172 | #else 173 | #define SDL_TIMER_WINDOWS 1 174 | #endif 175 | 176 | /* Enable various video drivers */ 177 | #define SDL_VIDEO_DRIVER_DUMMY 1 178 | #define SDL_VIDEO_DRIVER_WINDOWS 1 179 | 180 | #ifndef _WIN32_WCE 181 | #ifndef SDL_VIDEO_RENDER_D3D 182 | #define SDL_VIDEO_RENDER_D3D 1 183 | #endif 184 | #endif 185 | 186 | /* Enable OpenGL support */ 187 | #ifndef _WIN32_WCE 188 | #ifndef SDL_VIDEO_OPENGL 189 | #define SDL_VIDEO_OPENGL 1 190 | #endif 191 | #ifndef SDL_VIDEO_OPENGL_WGL 192 | #define SDL_VIDEO_OPENGL_WGL 1 193 | #endif 194 | #ifndef SDL_VIDEO_RENDER_OGL 195 | #define SDL_VIDEO_RENDER_OGL 1 196 | #endif 197 | #endif 198 | 199 | /* Enable system power support */ 200 | #define SDL_POWER_WINDOWS 1 201 | 202 | /* Enable assembly routines (Win64 doesn't have inline asm) */ 203 | #ifndef _WIN64 204 | #define SDL_ASSEMBLY_ROUTINES 1 205 | #endif 206 | 207 | #endif /* _SDL_config_windows_h */ 208 | -------------------------------------------------------------------------------- /SDL/SDL_shape.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_shape_h 23 | #define _SDL_shape_h 24 | 25 | #include "SDL_stdinc.h" 26 | #include "SDL_pixels.h" 27 | #include "SDL_rect.h" 28 | #include "SDL_surface.h" 29 | #include "SDL_video.h" 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | /* *INDENT-OFF* */ 35 | extern "C" { 36 | /* *INDENT-ON* */ 37 | #endif 38 | 39 | /** \file SDL_shape.h 40 | * 41 | * Header file for the shaped window API. 42 | */ 43 | 44 | #define SDL_NONSHAPEABLE_WINDOW -1 45 | #define SDL_INVALID_SHAPE_ARGUMENT -2 46 | #define SDL_WINDOW_LACKS_SHAPE -3 47 | 48 | /** 49 | * \brief Create a window that can be shaped with the specified position, dimensions, and flags. 50 | * 51 | * \param title The title of the window, in UTF-8 encoding. 52 | * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or 53 | * ::SDL_WINDOWPOS_UNDEFINED. 54 | * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or 55 | * ::SDL_WINDOWPOS_UNDEFINED. 56 | * \param w The width of the window. 57 | * \param h The height of the window. 58 | * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: 59 | * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, 60 | * ::SDL_WINDOW_SHOWN, ::SDL_WINDOW_RESIZABLE, 61 | * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, 62 | * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. 63 | * 64 | * \return The window created, or NULL if window creation failed. 65 | * 66 | * \sa SDL_DestroyWindow() 67 | */ 68 | extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); 69 | 70 | /** 71 | * \brief Return whether the given window is a shaped window. 72 | * 73 | * \param window The window to query for being shaped. 74 | * 75 | * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. 76 | * \sa SDL_CreateShapedWindow 77 | */ 78 | extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); 79 | 80 | /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ 81 | typedef enum { 82 | /** \brief The default mode, a binarized alpha cutoff of 1. */ 83 | ShapeModeDefault, 84 | /** \brief A binarized alpha cutoff with a given integer value. */ 85 | ShapeModeBinarizeAlpha, 86 | /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ 87 | ShapeModeReverseBinarizeAlpha, 88 | /** \brief A color key is applied. */ 89 | ShapeModeColorKey 90 | } WindowShapeMode; 91 | 92 | #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) 93 | 94 | /** \brief A union containing parameters for shaped windows. */ 95 | typedef union { 96 | /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ 97 | Uint8 binarizationCutoff; 98 | SDL_Color colorKey; 99 | } SDL_WindowShapeParams; 100 | 101 | /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ 102 | typedef struct SDL_WindowShapeMode { 103 | /** \brief The mode of these window-shape parameters. */ 104 | WindowShapeMode mode; 105 | /** \brief Window-shape parameters. */ 106 | SDL_WindowShapeParams parameters; 107 | } SDL_WindowShapeMode; 108 | 109 | /** 110 | * \brief Set the shape and parameters of a shaped window. 111 | * 112 | * \param window The shaped window whose parameters should be set. 113 | * \param shape A surface encoding the desired shape for the window. 114 | * \param shape_mode The parameters to set for the shaped window. 115 | * 116 | * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW 117 | * if the SDL_Window* given does not reference a valid shaped window. 118 | * 119 | * \sa SDL_WindowShapeMode 120 | * \sa SDL_GetShapedWindowMode. 121 | */ 122 | extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); 123 | 124 | /** 125 | * \brief Get the shape parameters of a shaped window. 126 | * 127 | * \param window The shaped window whose parameters should be retrieved. 128 | * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. 129 | * 130 | * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode 131 | * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if 132 | * the SDL_Window* given is a shapeable window currently lacking a shape. 133 | * 134 | * \sa SDL_WindowShapeMode 135 | * \sa SDL_SetWindowShape 136 | */ 137 | extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); 138 | 139 | /* Ends C function definitions when using C++ */ 140 | #ifdef __cplusplus 141 | /* *INDENT-OFF* */ 142 | } 143 | /* *INDENT-ON* */ 144 | #endif 145 | #include "close_code.h" 146 | 147 | #endif /* _SDL_shape_h */ 148 | -------------------------------------------------------------------------------- /SDL/SDL_thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_thread_h 23 | #define _SDL_thread_h 24 | 25 | /** 26 | * \file SDL_thread.h 27 | * 28 | * Header for the SDL thread management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /* Thread synchronization primitives */ 35 | #include "SDL_mutex.h" 36 | 37 | #include "begin_code.h" 38 | /* Set up for C function definitions, even when using C++ */ 39 | #ifdef __cplusplus 40 | /* *INDENT-OFF* */ 41 | extern "C" { 42 | /* *INDENT-ON* */ 43 | #endif 44 | 45 | /* The SDL thread structure, defined in SDL_thread.c */ 46 | struct SDL_Thread; 47 | typedef struct SDL_Thread SDL_Thread; 48 | 49 | /* The SDL thread ID */ 50 | typedef unsigned long SDL_threadID; 51 | 52 | /* The SDL thread priority 53 | * 54 | * Note: On many systems you require special privileges to set high priority. 55 | */ 56 | typedef enum { 57 | SDL_THREAD_PRIORITY_LOW, 58 | SDL_THREAD_PRIORITY_NORMAL, 59 | SDL_THREAD_PRIORITY_HIGH 60 | } SDL_ThreadPriority; 61 | 62 | /* The function passed to SDL_CreateThread() 63 | It is passed a void* user context parameter and returns an int. 64 | */ 65 | typedef int (SDLCALL * SDL_ThreadFunction) (void *data); 66 | 67 | #if defined(__WIN32__) && !defined(HAVE_LIBC) 68 | /** 69 | * \file SDL_thread.h 70 | * 71 | * We compile SDL into a DLL. This means, that it's the DLL which 72 | * creates a new thread for the calling process with the SDL_CreateThread() 73 | * API. There is a problem with this, that only the RTL of the SDL.DLL will 74 | * be initialized for those threads, and not the RTL of the calling 75 | * application! 76 | * 77 | * To solve this, we make a little hack here. 78 | * 79 | * We'll always use the caller's _beginthread() and _endthread() APIs to 80 | * start a new thread. This way, if it's the SDL.DLL which uses this API, 81 | * then the RTL of SDL.DLL will be used to create the new thread, and if it's 82 | * the application, then the RTL of the application will be used. 83 | * 84 | * So, in short: 85 | * Always use the _beginthread() and _endthread() of the calling runtime 86 | * library! 87 | */ 88 | #define SDL_PASSED_BEGINTHREAD_ENDTHREAD 89 | #ifndef _WIN32_WCE 90 | #include /* This has _beginthread() and _endthread() defined! */ 91 | #endif 92 | 93 | #ifdef __GNUC__ 94 | typedef unsigned long (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, 95 | unsigned 96 | (__stdcall * 97 | func) (void *), 98 | void *arg, 99 | unsigned, 100 | unsigned 101 | *threadID); 102 | typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); 103 | #else 104 | typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, 105 | unsigned (__stdcall * 106 | func) (void 107 | *), 108 | void *arg, unsigned, 109 | unsigned *threadID); 110 | typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); 111 | #endif 112 | 113 | /** 114 | * Create a thread. 115 | */ 116 | extern DECLSPEC SDL_Thread *SDLCALL 117 | SDL_CreateThread(SDL_ThreadFunction fn, void *data, 118 | pfnSDL_CurrentBeginThread pfnBeginThread, 119 | pfnSDL_CurrentEndThread pfnEndThread); 120 | 121 | #if defined(_WIN32_WCE) 122 | 123 | /** 124 | * Create a thread. 125 | */ 126 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) 127 | 128 | #else 129 | 130 | /** 131 | * Create a thread. 132 | */ 133 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) 134 | 135 | #endif 136 | #else 137 | 138 | /** 139 | * Create a thread. 140 | */ 141 | extern DECLSPEC SDL_Thread *SDLCALL 142 | SDL_CreateThread(SDL_ThreadFunction fn, void *data); 143 | 144 | #endif 145 | 146 | /** 147 | * Get the thread identifier for the current thread. 148 | */ 149 | extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); 150 | 151 | /** 152 | * Get the thread identifier for the specified thread. 153 | * 154 | * Equivalent to SDL_ThreadID() if the specified thread is NULL. 155 | */ 156 | extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); 157 | 158 | /** 159 | * Set the priority for the current thread 160 | */ 161 | extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); 162 | 163 | /** 164 | * Wait for a thread to finish. 165 | * 166 | * The return code for the thread function is placed in the area 167 | * pointed to by \c status, if \c status is not NULL. 168 | */ 169 | extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); 170 | 171 | 172 | /* Ends C function definitions when using C++ */ 173 | #ifdef __cplusplus 174 | /* *INDENT-OFF* */ 175 | } 176 | /* *INDENT-ON* */ 177 | #endif 178 | #include "close_code.h" 179 | 180 | #endif /* _SDL_thread_h */ 181 | 182 | /* vi: set ts=4 sw=4 expandtab: */ 183 | -------------------------------------------------------------------------------- /SDL/SDL_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_log.h 24 | * 25 | * Simple log messages with categories and priorities. 26 | * 27 | * By default logs are quiet, but if you're debugging SDL you might want: 28 | * 29 | * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); 30 | * 31 | * Here's where the messages go on different platforms: 32 | * Windows: debug output stream 33 | * Android: log output 34 | * Others: standard error output (stderr) 35 | */ 36 | 37 | #ifndef _SDL_log_h 38 | #define _SDL_log_h 39 | 40 | #include "SDL_stdinc.h" 41 | 42 | #include "begin_code.h" 43 | /* Set up for C function definitions, even when using C++ */ 44 | #ifdef __cplusplus 45 | /* *INDENT-OFF* */ 46 | extern "C" { 47 | /* *INDENT-ON* */ 48 | #endif 49 | 50 | 51 | /** 52 | * \brief The maximum size of a log message 53 | * 54 | * Messages longer than the maximum size will be truncated 55 | */ 56 | #define SDL_MAX_LOG_MESSAGE 4096 57 | 58 | /** 59 | * \brief The predefined log categories 60 | * 61 | * By default the application category is enabled at the INFO level, 62 | * and all other categories are enabled at the CRITICAL level. 63 | */ 64 | enum 65 | { 66 | SDL_LOG_CATEGORY_APPLICATION, 67 | SDL_LOG_CATEGORY_ERROR, 68 | SDL_LOG_CATEGORY_SYSTEM, 69 | SDL_LOG_CATEGORY_AUDIO, 70 | SDL_LOG_CATEGORY_VIDEO, 71 | SDL_LOG_CATEGORY_RENDER, 72 | SDL_LOG_CATEGORY_INPUT, 73 | 74 | /* Reserved for future SDL library use */ 75 | SDL_LOG_CATEGORY_RESERVED1, 76 | SDL_LOG_CATEGORY_RESERVED2, 77 | SDL_LOG_CATEGORY_RESERVED3, 78 | SDL_LOG_CATEGORY_RESERVED4, 79 | SDL_LOG_CATEGORY_RESERVED5, 80 | SDL_LOG_CATEGORY_RESERVED6, 81 | SDL_LOG_CATEGORY_RESERVED7, 82 | SDL_LOG_CATEGORY_RESERVED8, 83 | SDL_LOG_CATEGORY_RESERVED9, 84 | SDL_LOG_CATEGORY_RESERVED10, 85 | 86 | /* Beyond this point is reserved for application use, e.g. 87 | enum { 88 | MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, 89 | MYAPP_CATEGORY_AWESOME2, 90 | MYAPP_CATEGORY_AWESOME3, 91 | ... 92 | }; 93 | */ 94 | SDL_LOG_CATEGORY_CUSTOM 95 | }; 96 | 97 | /** 98 | * \brief The predefined log priorities 99 | */ 100 | typedef enum 101 | { 102 | SDL_LOG_PRIORITY_VERBOSE = 1, 103 | SDL_LOG_PRIORITY_DEBUG, 104 | SDL_LOG_PRIORITY_INFO, 105 | SDL_LOG_PRIORITY_WARN, 106 | SDL_LOG_PRIORITY_ERROR, 107 | SDL_LOG_PRIORITY_CRITICAL, 108 | SDL_NUM_LOG_PRIORITIES 109 | } SDL_LogPriority; 110 | 111 | 112 | /** 113 | * \brief Set the priority of all log categories 114 | */ 115 | extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); 116 | 117 | /** 118 | * \brief Set the priority of a particular log category 119 | */ 120 | extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, 121 | SDL_LogPriority priority); 122 | 123 | /** 124 | * \brief Set the priority of a particular log category 125 | */ 126 | extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); 127 | 128 | /** 129 | * \brief Reset all priorities to default. 130 | * 131 | * \note This is called in SDL_Quit(). 132 | */ 133 | extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); 134 | 135 | /** 136 | * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO 137 | */ 138 | extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...); 139 | 140 | /** 141 | * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE 142 | */ 143 | extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...); 144 | 145 | /** 146 | * \brief Log a message with SDL_LOG_PRIORITY_DEBUG 147 | */ 148 | extern DECLSPEC void SDLCALL SDL_LogDebug(int category, const char *fmt, ...); 149 | 150 | /** 151 | * \brief Log a message with SDL_LOG_PRIORITY_INFO 152 | */ 153 | extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...); 154 | 155 | /** 156 | * \brief Log a message with SDL_LOG_PRIORITY_WARN 157 | */ 158 | extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...); 159 | 160 | /** 161 | * \brief Log a message with SDL_LOG_PRIORITY_ERROR 162 | */ 163 | extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...); 164 | 165 | /** 166 | * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL 167 | */ 168 | extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...); 169 | 170 | /** 171 | * \brief Log a message with the specified category and priority. 172 | */ 173 | extern DECLSPEC void SDLCALL SDL_LogMessage(int category, 174 | SDL_LogPriority priority, 175 | const char *fmt, ...); 176 | 177 | /** 178 | * \brief Log a message with the specified category and priority. 179 | */ 180 | extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, 181 | SDL_LogPriority priority, 182 | const char *fmt, va_list ap); 183 | 184 | /** 185 | * \brief The prototype for the log output function 186 | */ 187 | typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); 188 | 189 | /** 190 | * \brief Get the current log output function. 191 | */ 192 | extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); 193 | 194 | /** 195 | * \brief This function allows you to replace the default log output 196 | * function with one of your own. 197 | */ 198 | extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); 199 | 200 | 201 | /* Ends C function definitions when using C++ */ 202 | #ifdef __cplusplus 203 | /* *INDENT-OFF* */ 204 | } 205 | /* *INDENT-ON* */ 206 | #endif 207 | #include "close_code.h" 208 | 209 | #endif /* _SDL_log_h */ 210 | 211 | /* vi: set ts=4 sw=4 expandtab: */ 212 | -------------------------------------------------------------------------------- /SDL/SDL_joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_joystick.h 24 | * 25 | * Include file for SDL joystick event handling 26 | */ 27 | 28 | #ifndef _SDL_joystick_h 29 | #define _SDL_joystick_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | /* *INDENT-OFF* */ 38 | extern "C" { 39 | /* *INDENT-ON* */ 40 | #endif 41 | 42 | /** 43 | * \file SDL_joystick.h 44 | * 45 | * In order to use these functions, SDL_Init() must have been called 46 | * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system 47 | * for joysticks, and load appropriate drivers. 48 | */ 49 | 50 | /* The joystick structure used to identify an SDL joystick */ 51 | struct _SDL_Joystick; 52 | typedef struct _SDL_Joystick SDL_Joystick; 53 | 54 | 55 | /* Function prototypes */ 56 | /** 57 | * Count the number of joysticks attached to the system 58 | */ 59 | extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); 60 | 61 | /** 62 | * Get the implementation dependent name of a joystick. 63 | * This can be called before any joysticks are opened. 64 | * If no name can be found, this function returns NULL. 65 | */ 66 | extern DECLSPEC const char *SDLCALL SDL_JoystickName(int device_index); 67 | 68 | /** 69 | * Open a joystick for use. 70 | * The index passed as an argument refers tothe N'th joystick on the system. 71 | * This index is the value which will identify this joystick in future joystick 72 | * events. 73 | * 74 | * \return A joystick identifier, or NULL if an error occurred. 75 | */ 76 | extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); 77 | 78 | /** 79 | * Returns 1 if the joystick has been opened, or 0 if it has not. 80 | */ 81 | extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); 82 | 83 | /** 84 | * Get the device index of an opened joystick. 85 | */ 86 | extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick * joystick); 87 | 88 | /** 89 | * Get the number of general axis controls on a joystick. 90 | */ 91 | extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); 92 | 93 | /** 94 | * Get the number of trackballs on a joystick. 95 | * 96 | * Joystick trackballs have only relative motion events associated 97 | * with them and their state cannot be polled. 98 | */ 99 | extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); 100 | 101 | /** 102 | * Get the number of POV hats on a joystick. 103 | */ 104 | extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); 105 | 106 | /** 107 | * Get the number of buttons on a joystick. 108 | */ 109 | extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); 110 | 111 | /** 112 | * Update the current state of the open joysticks. 113 | * 114 | * This is called automatically by the event loop if any joystick 115 | * events are enabled. 116 | */ 117 | extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); 118 | 119 | /** 120 | * Enable/disable joystick event polling. 121 | * 122 | * If joystick events are disabled, you must call SDL_JoystickUpdate() 123 | * yourself and check the state of the joystick when you want joystick 124 | * information. 125 | * 126 | * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. 127 | */ 128 | extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); 129 | 130 | /** 131 | * Get the current state of an axis control on a joystick. 132 | * 133 | * The state is a value ranging from -32768 to 32767. 134 | * 135 | * The axis indices start at index 0. 136 | */ 137 | extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, 138 | int axis); 139 | 140 | /** 141 | * \name Hat positions 142 | */ 143 | /*@{*/ 144 | #define SDL_HAT_CENTERED 0x00 145 | #define SDL_HAT_UP 0x01 146 | #define SDL_HAT_RIGHT 0x02 147 | #define SDL_HAT_DOWN 0x04 148 | #define SDL_HAT_LEFT 0x08 149 | #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) 150 | #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) 151 | #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) 152 | #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) 153 | /*@}*/ 154 | 155 | /** 156 | * Get the current state of a POV hat on a joystick. 157 | * 158 | * The hat indices start at index 0. 159 | * 160 | * \return The return value is one of the following positions: 161 | * - ::SDL_HAT_CENTERED 162 | * - ::SDL_HAT_UP 163 | * - ::SDL_HAT_RIGHT 164 | * - ::SDL_HAT_DOWN 165 | * - ::SDL_HAT_LEFT 166 | * - ::SDL_HAT_RIGHTUP 167 | * - ::SDL_HAT_RIGHTDOWN 168 | * - ::SDL_HAT_LEFTUP 169 | * - ::SDL_HAT_LEFTDOWN 170 | */ 171 | extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, 172 | int hat); 173 | 174 | /** 175 | * Get the ball axis change since the last poll. 176 | * 177 | * \return 0, or -1 if you passed it invalid parameters. 178 | * 179 | * The ball indices start at index 0. 180 | */ 181 | extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, 182 | int ball, int *dx, int *dy); 183 | 184 | /** 185 | * Get the current state of a button on a joystick. 186 | * 187 | * The button indices start at index 0. 188 | */ 189 | extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, 190 | int button); 191 | 192 | /** 193 | * Close a joystick previously opened with SDL_JoystickOpen(). 194 | */ 195 | extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); 196 | 197 | 198 | /* Ends C function definitions when using C++ */ 199 | #ifdef __cplusplus 200 | /* *INDENT-OFF* */ 201 | } 202 | /* *INDENT-ON* */ 203 | #endif 204 | #include "close_code.h" 205 | 206 | #endif /* _SDL_joystick_h */ 207 | 208 | /* vi: set ts=4 sw=4 expandtab: */ 209 | -------------------------------------------------------------------------------- /SDL/SDL_syswm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_syswm.h 24 | * 25 | * Include file for SDL custom system window manager hooks. 26 | */ 27 | 28 | #ifndef _SDL_syswm_h 29 | #define _SDL_syswm_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | #include "SDL_version.h" 35 | 36 | #include "begin_code.h" 37 | /* Set up for C function definitions, even when using C++ */ 38 | #ifdef __cplusplus 39 | /* *INDENT-OFF* */ 40 | extern "C" { 41 | /* *INDENT-ON* */ 42 | #endif 43 | 44 | /** 45 | * \file SDL_syswm.h 46 | * 47 | * Your application has access to a special type of event ::SDL_SYSWMEVENT, 48 | * which contains window-manager specific information and arrives whenever 49 | * an unhandled window event occurs. This event is ignored by default, but 50 | * you can enable it with SDL_EventState(). 51 | */ 52 | #ifdef SDL_PROTOTYPES_ONLY 53 | struct SDL_SysWMinfo; 54 | #else 55 | 56 | #if defined(SDL_VIDEO_DRIVER_WINDOWS) 57 | #define WIN32_LEAN_AND_MEAN 58 | #include 59 | #endif 60 | 61 | /* This is the structure for custom window manager events */ 62 | #if defined(SDL_VIDEO_DRIVER_X11) 63 | #if defined(__APPLE__) && defined(__MACH__) 64 | /* conflicts with Quickdraw.h */ 65 | #define Cursor X11Cursor 66 | #endif 67 | 68 | #include 69 | #include 70 | 71 | #if defined(__APPLE__) && defined(__MACH__) 72 | /* matches the re-define above */ 73 | #undef Cursor 74 | #endif 75 | 76 | #endif /* defined(SDL_VIDEO_DRIVER_X11) */ 77 | 78 | #if defined(SDL_VIDEO_DRIVER_DIRECTFB) 79 | #include 80 | #endif 81 | 82 | #if defined(SDL_VIDEO_DRIVER_COCOA) 83 | #ifdef __OBJC__ 84 | #include 85 | #else 86 | typedef struct _NSWindow NSWindow; 87 | #endif 88 | #endif 89 | 90 | #if defined(SDL_VIDEO_DRIVER_UIKIT) 91 | #ifdef __OBJC__ 92 | #include 93 | #else 94 | typedef struct _UIWindow UIWindow; 95 | #endif 96 | #endif 97 | 98 | /** 99 | * These are the various supported windowing subsystems 100 | */ 101 | typedef enum 102 | { 103 | SDL_SYSWM_UNKNOWN, 104 | SDL_SYSWM_WINDOWS, 105 | SDL_SYSWM_X11, 106 | SDL_SYSWM_DIRECTFB, 107 | SDL_SYSWM_COCOA, 108 | SDL_SYSWM_UIKIT, 109 | } SDL_SYSWM_TYPE; 110 | 111 | /** 112 | * The custom event structure. 113 | */ 114 | struct SDL_SysWMmsg 115 | { 116 | SDL_version version; 117 | SDL_SYSWM_TYPE subsystem; 118 | union 119 | { 120 | #if defined(SDL_VIDEO_DRIVER_WINDOWS) 121 | struct { 122 | HWND hwnd; /**< The window for the message */ 123 | UINT msg; /**< The type of message */ 124 | WPARAM wParam; /**< WORD message parameter */ 125 | LPARAM lParam; /**< LONG message parameter */ 126 | } win; 127 | #endif 128 | #if defined(SDL_VIDEO_DRIVER_X11) 129 | struct { 130 | XEvent event; 131 | } x11; 132 | #endif 133 | #if defined(SDL_VIDEO_DRIVER_DIRECTFB) 134 | struct { 135 | DFBEvent event; 136 | } dfb; 137 | #endif 138 | #if defined(SDL_VIDEO_DRIVER_COCOA) 139 | struct 140 | { 141 | /* No Cocoa window events yet */ 142 | } cocoa; 143 | #endif 144 | #if defined(SDL_VIDEO_DRIVER_UIKIT) 145 | struct 146 | { 147 | /* No UIKit window events yet */ 148 | } uikit; 149 | #endif 150 | /* Can't have an empty union */ 151 | int dummy; 152 | } msg; 153 | }; 154 | 155 | /** 156 | * The custom window manager information structure. 157 | * 158 | * When this structure is returned, it holds information about which 159 | * low level system it is using, and will be one of SDL_SYSWM_TYPE. 160 | */ 161 | struct SDL_SysWMinfo 162 | { 163 | SDL_version version; 164 | SDL_SYSWM_TYPE subsystem; 165 | union 166 | { 167 | #if defined(SDL_VIDEO_DRIVER_WINDOWS) 168 | struct 169 | { 170 | HWND window; /**< The window handle */ 171 | } win; 172 | #endif 173 | #if defined(SDL_VIDEO_DRIVER_X11) 174 | struct 175 | { 176 | Display *display; /**< The X11 display */ 177 | Window window; /**< The X11 window */ 178 | } x11; 179 | #endif 180 | #if defined(SDL_VIDEO_DRIVER_DIRECTFB) 181 | struct 182 | { 183 | IDirectFB *dfb; /**< The directfb main interface */ 184 | IDirectFBWindow *window; /**< The directfb window handle */ 185 | IDirectFBSurface *surface; /**< The directfb client surface */ 186 | } dfb; 187 | #endif 188 | #if defined(SDL_VIDEO_DRIVER_COCOA) 189 | struct 190 | { 191 | NSWindow *window; /* The Cocoa window */ 192 | } cocoa; 193 | #endif 194 | #if defined(SDL_VIDEO_DRIVER_UIKIT) 195 | struct 196 | { 197 | UIWindow *window; /* The UIKit window */ 198 | } uikit; 199 | #endif 200 | /* Can't have an empty union */ 201 | int dummy; 202 | } info; 203 | }; 204 | 205 | #endif /* SDL_PROTOTYPES_ONLY */ 206 | 207 | typedef struct SDL_SysWMinfo SDL_SysWMinfo; 208 | 209 | /* Function prototypes */ 210 | /** 211 | * \brief This function allows access to driver-dependent window information. 212 | * 213 | * \param window The window about which information is being requested 214 | * \param info This structure must be initialized with the SDL version, and is 215 | * then filled in with information about the given window. 216 | * 217 | * \return SDL_TRUE if the function is implemented and the version member of 218 | * the \c info struct is valid, SDL_FALSE otherwise. 219 | * 220 | * You typically use this function like this: 221 | * \code 222 | * SDL_SysWMinfo info; 223 | * SDL_VERSION(&info.version); 224 | * if ( SDL_GetWindowWMInfo(&info) ) { ... } 225 | * \endcode 226 | */ 227 | extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, 228 | SDL_SysWMinfo * info); 229 | 230 | 231 | /* Ends C function definitions when using C++ */ 232 | #ifdef __cplusplus 233 | /* *INDENT-OFF* */ 234 | } 235 | /* *INDENT-ON* */ 236 | #endif 237 | #include "close_code.h" 238 | 239 | #endif /* _SDL_syswm_h */ 240 | 241 | /* vi: set ts=4 sw=4 expandtab: */ 242 | -------------------------------------------------------------------------------- /SDL/SDL_endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_endian.h 24 | * 25 | * Functions for reading and writing endian-specific values 26 | */ 27 | 28 | #ifndef _SDL_endian_h 29 | #define _SDL_endian_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | /** 34 | * \name The two types of endianness 35 | */ 36 | /*@{*/ 37 | #define SDL_LIL_ENDIAN 1234 38 | #define SDL_BIG_ENDIAN 4321 39 | /*@}*/ 40 | 41 | #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ 42 | #ifdef __linux__ 43 | #include 44 | #define SDL_BYTEORDER __BYTE_ORDER 45 | #else /* __linux __ */ 46 | #if defined(__hppa__) || \ 47 | defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 48 | (defined(__MIPS__) && defined(__MISPEB__)) || \ 49 | defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ 50 | defined(__sparc__) 51 | #define SDL_BYTEORDER SDL_BIG_ENDIAN 52 | #else 53 | #define SDL_BYTEORDER SDL_LIL_ENDIAN 54 | #endif 55 | #endif /* __linux __ */ 56 | #endif /* !SDL_BYTEORDER */ 57 | 58 | 59 | #include "begin_code.h" 60 | /* Set up for C function definitions, even when using C++ */ 61 | #ifdef __cplusplus 62 | /* *INDENT-OFF* */ 63 | extern "C" { 64 | /* *INDENT-ON* */ 65 | #endif 66 | 67 | /** 68 | * \file SDL_endian.h 69 | * 70 | * Uses inline functions for compilers that support them, and static 71 | * functions for those that do not. Because these functions become 72 | * static for compilers that do not support inline functions, this 73 | * header should only be included in files that actually use them. 74 | */ 75 | #if defined(__GNUC__) && defined(__i386__) && \ 76 | !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) 77 | static __inline__ Uint16 78 | SDL_Swap16(Uint16 x) 79 | { 80 | __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); 81 | return x; 82 | } 83 | #elif defined(__GNUC__) && defined(__x86_64__) 84 | static __inline__ Uint16 85 | SDL_Swap16(Uint16 x) 86 | { 87 | __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); 88 | return x; 89 | } 90 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 91 | static __inline__ Uint16 92 | SDL_Swap16(Uint16 x) 93 | { 94 | Uint16 result; 95 | 96 | __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); 97 | return result; 98 | } 99 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 100 | static __inline__ Uint16 101 | SDL_Swap16(Uint16 x) 102 | { 103 | __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); 104 | return x; 105 | } 106 | #else 107 | static __inline__ Uint16 108 | SDL_Swap16(Uint16 x) 109 | { 110 | return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); 111 | } 112 | #endif 113 | 114 | #if defined(__GNUC__) && defined(__i386__) 115 | static __inline__ Uint32 116 | SDL_Swap32(Uint32 x) 117 | { 118 | __asm__("bswap %0": "=r"(x):"0"(x)); 119 | return x; 120 | } 121 | #elif defined(__GNUC__) && defined(__x86_64__) 122 | static __inline__ Uint32 123 | SDL_Swap32(Uint32 x) 124 | { 125 | __asm__("bswapl %0": "=r"(x):"0"(x)); 126 | return x; 127 | } 128 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) 129 | static __inline__ Uint32 130 | SDL_Swap32(Uint32 x) 131 | { 132 | Uint32 result; 133 | 134 | __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); 135 | __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); 136 | __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); 137 | return result; 138 | } 139 | #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) 140 | static __inline__ Uint32 141 | SDL_Swap32(Uint32 x) 142 | { 143 | __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); 144 | return x; 145 | } 146 | #else 147 | static __inline__ Uint32 148 | SDL_Swap32(Uint32 x) 149 | { 150 | return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | 151 | ((x >> 8) & 0x0000FF00) | (x >> 24))); 152 | } 153 | #endif 154 | 155 | #if defined(__GNUC__) && defined(__i386__) 156 | static __inline__ Uint64 157 | SDL_Swap64(Uint64 x) 158 | { 159 | union 160 | { 161 | struct 162 | { 163 | Uint32 a, b; 164 | } s; 165 | Uint64 u; 166 | } v; 167 | v.u = x; 168 | __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), 169 | "1"(v.s. 170 | b)); 171 | return v.u; 172 | } 173 | #elif defined(__GNUC__) && defined(__x86_64__) 174 | static __inline__ Uint64 175 | SDL_Swap64(Uint64 x) 176 | { 177 | __asm__("bswapq %0": "=r"(x):"0"(x)); 178 | return x; 179 | } 180 | #else 181 | static __inline__ Uint64 182 | SDL_Swap64(Uint64 x) 183 | { 184 | Uint32 hi, lo; 185 | 186 | /* Separate into high and low 32-bit values and swap them */ 187 | lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 188 | x >>= 32; 189 | hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); 190 | x = SDL_Swap32(lo); 191 | x <<= 32; 192 | x |= SDL_Swap32(hi); 193 | return (x); 194 | } 195 | #endif 196 | 197 | 198 | static __inline__ float 199 | SDL_SwapFloat(float x) 200 | { 201 | union 202 | { 203 | float f; 204 | Uint32 ui32; 205 | } swapper; 206 | swapper.f = x; 207 | swapper.ui32 = SDL_Swap32(swapper.ui32); 208 | return swapper.f; 209 | } 210 | 211 | 212 | /** 213 | * \name Swap to native 214 | * Byteswap item from the specified endianness to the native endianness. 215 | */ 216 | /*@{*/ 217 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN 218 | #define SDL_SwapLE16(X) (X) 219 | #define SDL_SwapLE32(X) (X) 220 | #define SDL_SwapLE64(X) (X) 221 | #define SDL_SwapFloatLE(X) (X) 222 | #define SDL_SwapBE16(X) SDL_Swap16(X) 223 | #define SDL_SwapBE32(X) SDL_Swap32(X) 224 | #define SDL_SwapBE64(X) SDL_Swap64(X) 225 | #define SDL_SwapFloatBE(X) SDL_SwapFloat(X) 226 | #else 227 | #define SDL_SwapLE16(X) SDL_Swap16(X) 228 | #define SDL_SwapLE32(X) SDL_Swap32(X) 229 | #define SDL_SwapLE64(X) SDL_Swap64(X) 230 | #define SDL_SwapFloatLE(X) SDL_SwapFloat(X) 231 | #define SDL_SwapBE16(X) (X) 232 | #define SDL_SwapBE32(X) (X) 233 | #define SDL_SwapBE64(X) (X) 234 | #define SDL_SwapFloatBE(X) (X) 235 | #endif 236 | /*@}*//*Swap to native*/ 237 | 238 | /* Ends C function definitions when using C++ */ 239 | #ifdef __cplusplus 240 | /* *INDENT-OFF* */ 241 | } 242 | /* *INDENT-ON* */ 243 | #endif 244 | #include "close_code.h" 245 | 246 | #endif /* _SDL_endian_h */ 247 | 248 | /* vi: set ts=4 sw=4 expandtab: */ 249 | -------------------------------------------------------------------------------- /SDL/SDL_rwops.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_rwops.h 24 | * 25 | * This file provides a general interface for SDL to read and write 26 | * data streams. It can easily be extended to files, memory, etc. 27 | */ 28 | 29 | #ifndef _SDL_rwops_h 30 | #define _SDL_rwops_h 31 | 32 | #include "SDL_stdinc.h" 33 | #include "SDL_error.h" 34 | 35 | #include "begin_code.h" 36 | /* Set up for C function definitions, even when using C++ */ 37 | #ifdef __cplusplus 38 | /* *INDENT-OFF* */ 39 | extern "C" { 40 | /* *INDENT-ON* */ 41 | #endif 42 | 43 | /** 44 | * This is the read/write operation structure -- very basic. 45 | */ 46 | typedef struct SDL_RWops 47 | { 48 | /** 49 | * Seek to \c offset relative to \c whence, one of stdio's whence values: 50 | * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END 51 | * 52 | * \return the final offset in the data stream. 53 | */ 54 | long (SDLCALL * seek) (struct SDL_RWops * context, long offset, 55 | int whence); 56 | 57 | /** 58 | * Read up to \c maxnum objects each of size \c size from the data 59 | * stream to the area pointed at by \c ptr. 60 | * 61 | * \return the number of objects read, or 0 at error or end of file. 62 | */ 63 | size_t(SDLCALL * read) (struct SDL_RWops * context, void *ptr, 64 | size_t size, size_t maxnum); 65 | 66 | /** 67 | * Write exactly \c num objects each of size \c size from the area 68 | * pointed at by \c ptr to data stream. 69 | * 70 | * \return the number of objects written, or 0 at error or end of file. 71 | */ 72 | size_t(SDLCALL * write) (struct SDL_RWops * context, const void *ptr, 73 | size_t size, size_t num); 74 | 75 | /** 76 | * Close and free an allocated SDL_RWops structure. 77 | * 78 | * \return 0 if successful or -1 on write error when flushing data. 79 | */ 80 | int (SDLCALL * close) (struct SDL_RWops * context); 81 | 82 | Uint32 type; 83 | union 84 | { 85 | #if defined(ANDROID) 86 | struct 87 | { 88 | void *fileName; 89 | void *fileNameRef; 90 | void *inputStream; 91 | void *inputStreamRef; 92 | void *skipMethod; 93 | void *readableByteChannel; 94 | void *readableByteChannelRef; 95 | void *readMethod; 96 | long position; 97 | int size; 98 | } androidio; 99 | #elif defined(__WIN32__) 100 | struct 101 | { 102 | SDL_bool append; 103 | void *h; 104 | struct 105 | { 106 | void *data; 107 | size_t size; 108 | size_t left; 109 | } buffer; 110 | } windowsio; 111 | #endif 112 | 113 | #ifdef HAVE_STDIO_H 114 | struct 115 | { 116 | SDL_bool autoclose; 117 | FILE *fp; 118 | } stdio; 119 | #endif 120 | struct 121 | { 122 | Uint8 *base; 123 | Uint8 *here; 124 | Uint8 *stop; 125 | } mem; 126 | struct 127 | { 128 | void *data1; 129 | } unknown; 130 | } hidden; 131 | 132 | } SDL_RWops; 133 | 134 | 135 | /** 136 | * \name RWFrom functions 137 | * 138 | * Functions to create SDL_RWops structures from various data streams. 139 | */ 140 | /*@{*/ 141 | 142 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, 143 | const char *mode); 144 | 145 | #ifdef HAVE_STDIO_H 146 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, 147 | SDL_bool autoclose); 148 | #else 149 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, 150 | SDL_bool autoclose); 151 | #endif 152 | 153 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); 154 | extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, 155 | int size); 156 | 157 | /*@}*//*RWFrom functions*/ 158 | 159 | 160 | extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); 161 | extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); 162 | 163 | #define RW_SEEK_SET 0 /**< Seek from the beginning of data */ 164 | #define RW_SEEK_CUR 1 /**< Seek relative to current read point */ 165 | #define RW_SEEK_END 2 /**< Seek relative to the end of data */ 166 | 167 | /** 168 | * \name Read/write macros 169 | * 170 | * Macros to easily read and write from an SDL_RWops structure. 171 | */ 172 | /*@{*/ 173 | #define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) 174 | #define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) 175 | #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) 176 | #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) 177 | #define SDL_RWclose(ctx) (ctx)->close(ctx) 178 | /*@}*//*Read/write macros*/ 179 | 180 | 181 | /** 182 | * \name Read endian functions 183 | * 184 | * Read an item of the specified endianness and return in native format. 185 | */ 186 | /*@{*/ 187 | extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); 188 | extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); 189 | extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); 190 | extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); 191 | extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); 192 | extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); 193 | /*@}*//*Read endian functions*/ 194 | 195 | /** 196 | * \name Write endian functions 197 | * 198 | * Write an item of native format to the specified endianness. 199 | */ 200 | /*@{*/ 201 | extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); 202 | extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); 203 | extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); 204 | extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); 205 | extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); 206 | extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); 207 | /*@}*//*Write endian functions*/ 208 | 209 | 210 | /* Ends C function definitions when using C++ */ 211 | #ifdef __cplusplus 212 | /* *INDENT-OFF* */ 213 | } 214 | /* *INDENT-ON* */ 215 | #endif 216 | #include "close_code.h" 217 | 218 | #endif /* _SDL_rwops_h */ 219 | 220 | /* vi: set ts=4 sw=4 expandtab: */ 221 | -------------------------------------------------------------------------------- /SDL/SDL_mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_mutex_h 23 | #define _SDL_mutex_h 24 | 25 | /** 26 | * \file SDL_mutex.h 27 | * 28 | * Functions to provide thread synchronization primitives. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | /* *INDENT-OFF* */ 38 | extern "C" { 39 | /* *INDENT-ON* */ 40 | #endif 41 | 42 | /** 43 | * Synchronization functions which can time out return this value 44 | * if they time out. 45 | */ 46 | #define SDL_MUTEX_TIMEDOUT 1 47 | 48 | /** 49 | * This is the timeout value which corresponds to never time out. 50 | */ 51 | #define SDL_MUTEX_MAXWAIT (~(Uint32)0) 52 | 53 | 54 | /** 55 | * \name Mutex functions 56 | */ 57 | /*@{*/ 58 | 59 | /* The SDL mutex structure, defined in SDL_mutex.c */ 60 | struct SDL_mutex; 61 | typedef struct SDL_mutex SDL_mutex; 62 | 63 | /** 64 | * Create a mutex, initialized unlocked. 65 | */ 66 | extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); 67 | 68 | /** 69 | * Lock the mutex. 70 | * 71 | * \return 0, or -1 on error. 72 | */ 73 | #define SDL_LockMutex(m) SDL_mutexP(m) 74 | extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex * mutex); 75 | 76 | /** 77 | * Unlock the mutex. 78 | * 79 | * \return 0, or -1 on error. 80 | * 81 | * \warning It is an error to unlock a mutex that has not been locked by 82 | * the current thread, and doing so results in undefined behavior. 83 | */ 84 | #define SDL_UnlockMutex(m) SDL_mutexV(m) 85 | extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex * mutex); 86 | 87 | /** 88 | * Destroy a mutex. 89 | */ 90 | extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); 91 | 92 | /*@}*//*Mutex functions*/ 93 | 94 | 95 | /** 96 | * \name Semaphore functions 97 | */ 98 | /*@{*/ 99 | 100 | /* The SDL semaphore structure, defined in SDL_sem.c */ 101 | struct SDL_semaphore; 102 | typedef struct SDL_semaphore SDL_sem; 103 | 104 | /** 105 | * Create a semaphore, initialized with value, returns NULL on failure. 106 | */ 107 | extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); 108 | 109 | /** 110 | * Destroy a semaphore. 111 | */ 112 | extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); 113 | 114 | /** 115 | * This function suspends the calling thread until the semaphore pointed 116 | * to by \c sem has a positive count. It then atomically decreases the 117 | * semaphore count. 118 | */ 119 | extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); 120 | 121 | /** 122 | * Non-blocking variant of SDL_SemWait(). 123 | * 124 | * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would 125 | * block, and -1 on error. 126 | */ 127 | extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); 128 | 129 | /** 130 | * Variant of SDL_SemWait() with a timeout in milliseconds. 131 | * 132 | * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not 133 | * succeed in the allotted time, and -1 on error. 134 | * 135 | * \warning On some platforms this function is implemented by looping with a 136 | * delay of 1 ms, and so should be avoided if possible. 137 | */ 138 | extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); 139 | 140 | /** 141 | * Atomically increases the semaphore's count (not blocking). 142 | * 143 | * \return 0, or -1 on error. 144 | */ 145 | extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); 146 | 147 | /** 148 | * Returns the current count of the semaphore. 149 | */ 150 | extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); 151 | 152 | /*@}*//*Semaphore functions*/ 153 | 154 | 155 | /** 156 | * \name Condition variable functions 157 | */ 158 | /*@{*/ 159 | 160 | /* The SDL condition variable structure, defined in SDL_cond.c */ 161 | struct SDL_cond; 162 | typedef struct SDL_cond SDL_cond; 163 | 164 | /** 165 | * Create a condition variable. 166 | * 167 | * Typical use of condition variables: 168 | * 169 | * Thread A: 170 | * SDL_LockMutex(lock); 171 | * while ( ! condition ) { 172 | * SDL_CondWait(cond, lock); 173 | * } 174 | * SDL_UnlockMutex(lock); 175 | * 176 | * Thread B: 177 | * SDL_LockMutex(lock); 178 | * ... 179 | * condition = true; 180 | * ... 181 | * SDL_CondSignal(cond); 182 | * SDL_UnlockMutex(lock); 183 | * 184 | * There is some discussion whether to signal the condition variable 185 | * with the mutex locked or not. There is some potential performance 186 | * benefit to unlocking first on some platforms, but there are some 187 | * potential race conditions depending on how your code is structured. 188 | * 189 | * In general it's safer to signal the condition variable while the 190 | * mutex is locked. 191 | */ 192 | extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); 193 | 194 | /** 195 | * Destroy a condition variable. 196 | */ 197 | extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); 198 | 199 | /** 200 | * Restart one of the threads that are waiting on the condition variable. 201 | * 202 | * \return 0 or -1 on error. 203 | */ 204 | extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); 205 | 206 | /** 207 | * Restart all threads that are waiting on the condition variable. 208 | * 209 | * \return 0 or -1 on error. 210 | */ 211 | extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); 212 | 213 | /** 214 | * Wait on the condition variable, unlocking the provided mutex. 215 | * 216 | * \warning The mutex must be locked before entering this function! 217 | * 218 | * The mutex is re-locked once the condition variable is signaled. 219 | * 220 | * \return 0 when it is signaled, or -1 on error. 221 | */ 222 | extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); 223 | 224 | /** 225 | * Waits for at most \c ms milliseconds, and returns 0 if the condition 226 | * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not 227 | * signaled in the allotted time, and -1 on error. 228 | * 229 | * \warning On some platforms this function is implemented by looping with a 230 | * delay of 1 ms, and so should be avoided if possible. 231 | */ 232 | extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, 233 | SDL_mutex * mutex, Uint32 ms); 234 | 235 | /*@}*//*Condition variable functions*/ 236 | 237 | 238 | /* Ends C function definitions when using C++ */ 239 | #ifdef __cplusplus 240 | /* *INDENT-OFF* */ 241 | } 242 | /* *INDENT-ON* */ 243 | #endif 244 | #include "close_code.h" 245 | 246 | #endif /* _SDL_mutex_h */ 247 | 248 | /* vi: set ts=4 sw=4 expandtab: */ 249 | -------------------------------------------------------------------------------- /SDL/SDL_hints.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2011 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_hints.h 24 | * 25 | * Official documentation for SDL configuration variables 26 | * 27 | * This file contains functions to set and get configuration hints, 28 | * as well as listing each of them alphabetically. 29 | * 30 | * The convention for naming hints is SDL_HINT_X, where "SDL_X" is 31 | * the environment variable that can be used to override the default. 32 | * 33 | * In general these hints are just that - they may or may not be 34 | * supported or applicable on any given platform, but they provide 35 | * a way for an application or user to give the library a hint as 36 | * to how they would like the library to work. 37 | */ 38 | 39 | #ifndef _SDL_hints_h 40 | #define _SDL_hints_h 41 | 42 | #include "SDL_stdinc.h" 43 | 44 | #include "begin_code.h" 45 | /* Set up for C function definitions, even when using C++ */ 46 | #ifdef __cplusplus 47 | /* *INDENT-OFF* */ 48 | extern "C" { 49 | /* *INDENT-ON* */ 50 | #endif 51 | 52 | /** 53 | * \brief A variable controlling how 3D acceleration is used to accelerate the SDL 1.2 screen surface. 54 | * 55 | * SDL can try to accelerate the SDL 1.2 screen surface by using streaming 56 | * textures with a 3D rendering engine. This variable controls whether and 57 | * how this is done. 58 | * 59 | * This variable can be set to the following values: 60 | * "0" - Disable 3D acceleration 61 | * "1" - Enable 3D acceleration, using the default renderer. 62 | * "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.) 63 | * 64 | * By default SDL tries to make a best guess for each platform whether 65 | * to use acceleration or not. 66 | */ 67 | #define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" 68 | 69 | /** 70 | * \brief A variable specifying which render driver to use. 71 | * 72 | * If the application doesn't pick a specific renderer to use, this variable 73 | * specifies the name of the preferred renderer. If the preferred renderer 74 | * can't be initialized, the normal default renderer is used. 75 | * 76 | * This variable is case insensitive and can be set to the following values: 77 | * "direct3d" 78 | * "opengl" 79 | * "opengles2" 80 | * "opengles" 81 | * "software" 82 | * 83 | * The default varies by platform, but it's the first one in the list that 84 | * is available on the current platform. 85 | */ 86 | #define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" 87 | 88 | /** 89 | * \brief A variable controlling whether the OpenGL render driver uses shaders if they are available. 90 | * 91 | * This variable can be set to the following values: 92 | * "0" - Disable shaders 93 | * "1" - Enable shaders 94 | * 95 | * By default shaders are used if OpenGL supports them. 96 | */ 97 | #define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" 98 | 99 | /** 100 | * \brief A variable controlling the scaling quality 101 | * 102 | * This variable can be set to the following values: 103 | * "0" or "nearest" - Nearest pixel sampling 104 | * "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D) 105 | * "2" or "best" - Anisotropic filtering (supported by Direct3D) 106 | * 107 | * By default nearest pixel sampling is used 108 | */ 109 | #define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY" 110 | 111 | /** 112 | * \brief A variable controlling whether updates to the SDL 1.2 screen surface should be synchronized with the vertical refresh, to avoid tearing. 113 | * 114 | * This variable can be set to the following values: 115 | * "0" - Disable vsync 116 | * "1" - Enable vsync 117 | * 118 | * By default SDL does not sync screen surface updates with vertical refresh. 119 | */ 120 | #define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" 121 | 122 | /** 123 | * \brief A variable controlling whether the idle timer is disabled on iOS. 124 | * 125 | * When an iOS app does not receive touches for some time, the screen is 126 | * dimmed automatically. For games where the accelerometer is the only input 127 | * this is problematic. This functionality can be disabled by setting this 128 | * hint. 129 | * 130 | * This variable can be set to the following values: 131 | * "0" - Enable idle timer 132 | * "1" - Disable idle timer 133 | */ 134 | #define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" 135 | 136 | /** 137 | * \brief A variable controlling which orientations are allowed on iOS. 138 | * 139 | * In some circumstances it is necessary to be able to explicitly control 140 | * which UI orientations are allowed. 141 | * 142 | * This variable is a space delimited list of the following values: 143 | * "LandscapeLeft", "LandscapeRight", "Portrait" "PortraitUpsideDown" 144 | */ 145 | #define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" 146 | 147 | 148 | /** 149 | * \brief An enumeration of hint priorities 150 | */ 151 | typedef enum 152 | { 153 | SDL_HINT_DEFAULT, 154 | SDL_HINT_NORMAL, 155 | SDL_HINT_OVERRIDE 156 | } SDL_HintPriority; 157 | 158 | 159 | /** 160 | * \brief Set a hint with a specific priority 161 | * 162 | * The priority controls the behavior when setting a hint that already 163 | * has a value. Hints will replace existing hints of their priority and 164 | * lower. Environment variables are considered to have override priority. 165 | * 166 | * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise 167 | */ 168 | extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, 169 | const char *value, 170 | SDL_HintPriority priority); 171 | 172 | /** 173 | * \brief Set a hint with normal priority 174 | * 175 | * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise 176 | */ 177 | extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, 178 | const char *value); 179 | 180 | 181 | /** 182 | * \brief Get a hint 183 | * 184 | * \return The string value of a hint variable. 185 | */ 186 | extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); 187 | 188 | /** 189 | * \brief Clear all hints 190 | * 191 | * This function is called during SDL_Quit() to free stored hints. 192 | */ 193 | extern DECLSPEC void SDLCALL SDL_ClearHints(void); 194 | 195 | 196 | /* Ends C function definitions when using C++ */ 197 | #ifdef __cplusplus 198 | /* *INDENT-OFF* */ 199 | } 200 | /* *INDENT-ON* */ 201 | #endif 202 | #include "close_code.h" 203 | 204 | #endif /* _SDL_hints_h */ 205 | 206 | /* vi: set ts=4 sw=4 expandtab: */ 207 | --------------------------------------------------------------------------------