Implemented showing selected entity in editor with a specific colour

dev
Shariq Shah 7 years ago
parent c0e6e0bde2
commit 66b72cca73
  1. 44
      .dir-locals.el
  2. 8
      .gitignore
  3. 1354
      LICENSE
  4. 284
      README.md
  5. BIN
      assets/models/suzanne.symbres
  6. 256
      assets/shaders/blinn_phong.frag
  7. 260
      assets/shaders/blinn_phong.frag.orig
  8. 14
      assets/shaders/blinn_phong.vert
  9. 10
      assets/shaders/common.glsl
  10. 26
      assets/shaders/commonFrag.glsl
  11. 66
      assets/shaders/commonVert.glsl
  12. 20
      assets/shaders/debug.frag
  13. 20
      assets/shaders/debug.vert
  14. 236
      assets/shaders/deferred_light.frag
  15. 30
      assets/shaders/deferred_light.vert
  16. 32
      assets/shaders/fbo.frag
  17. 30
      assets/shaders/fbo.vert
  18. 82
      assets/shaders/fog.glsl
  19. 28
      assets/shaders/gui.frag
  20. 34
      assets/shaders/gui.vert
  21. 14
      assets/shaders/phong.frag
  22. 16
      assets/shaders/phong.vert
  23. 460
      assets/shaders/phongCommon.glsl
  24. 20
      assets/shaders/phongTextured.frag
  25. 26
      assets/shaders/quad.frag
  26. 28
      assets/shaders/quad.vert
  27. 26
      assets/shaders/simple.frag
  28. 24
      assets/shaders/simple.vert
  29. 20
      assets/shaders/unshaded.frag
  30. 14
      assets/shaders/unshaded.vert
  31. 18
      assets/shaders/unshaded_textured.frag
  32. 14
      assets/shaders/unshaded_textured.vert
  33. 242
      build/genie.lua
  34. 4362
      include/common/glad/glad.h
  35. 962
      include/common/soloud/soloud.h
  36. 626
      include/common/soloud/soloud_audiosource.h
  37. 124
      include/common/soloud/soloud_bassboostfilter.h
  38. 180
      include/common/soloud/soloud_biquadresonantfilter.h
  39. 170
      include/common/soloud/soloud_bus.h
  40. 980
      include/common/soloud/soloud_c.h
  41. 114
      include/common/soloud/soloud_dcremovalfilter.h
  42. 116
      include/common/soloud/soloud_echofilter.h
  43. 80
      include/common/soloud/soloud_error.h
  44. 124
      include/common/soloud/soloud_fader.h
  45. 88
      include/common/soloud/soloud_fft.h
  46. 112
      include/common/soloud/soloud_fftfilter.h
  47. 70
      include/common/soloud/soloud_file_hack_off.h
  48. 116
      include/common/soloud/soloud_file_hack_on.h
  49. 128
      include/common/soloud/soloud_filter.h
  50. 128
      include/common/soloud/soloud_flangerfilter.h
  51. 234
      include/common/soloud/soloud_internal.h
  52. 148
      include/common/soloud/soloud_lofifilter.h
  53. 230
      include/common/soloud/soloud_monotone.h
  54. 122
      include/common/soloud/soloud_openmpt.h
  55. 336
      include/common/soloud/soloud_sfxr.h
  56. 126
      include/common/soloud/soloud_speech.h
  57. 146
      include/common/soloud/soloud_tedsid.h
  58. 164
      include/common/soloud/soloud_thread.h
  59. 216
      include/common/soloud/soloud_vic.h
  60. 136
      include/common/soloud/soloud_wav.h
  61. 164
      include/common/soloud/soloud_wavstream.h
  62. 3052
      include/linux/ode/collision.h
  63. 364
      include/linux/ode/collision_space.h
  64. 632
      include/linux/ode/collision_trimesh.h
  65. 1136
      include/linux/ode/common.h
  66. 80
      include/linux/ode/compatibility.h
  67. 220
      include/linux/ode/contact.h
  68. 458
      include/linux/ode/cooperative.h
  69. 126
      include/linux/ode/error.h
  70. 80
      include/linux/ode/export-dif.h
  71. 288
      include/linux/ode/mass.h
  72. 400
      include/linux/ode/matrix.h
  73. 582
      include/linux/ode/matrix_coop.h
  74. 118
      include/linux/ode/memory.h
  75. 172
      include/linux/ode/misc.h
  76. 6792
      include/linux/ode/objects.h
  77. 112
      include/linux/ode/ode.h
  78. 430
      include/linux/ode/odeconfig.h
  79. 2710
      include/linux/ode/odecpp.h
  80. 934
      include/linux/ode/odecpp_collision.h
  81. 472
      include/linux/ode/odeinit.h
  82. 1090
      include/linux/ode/odemath.h
  83. 324
      include/linux/ode/odemath_legacy.h
  84. 32
      include/linux/ode/precision.h
  85. 140
      include/linux/ode/rotation.h
  86. 824
      include/linux/ode/threading.h
  87. 584
      include/linux/ode/threading_impl.h
  88. 152
      include/linux/ode/timer.h
  89. 12
      include/linux/ode/version.h
  90. 266
      include/linux/sdl2/SDL.h
  91. 582
      include/linux/sdl2/SDL_assert.h
  92. 548
      include/linux/sdl2/SDL_atomic.h
  93. 1380
      include/linux/sdl2/SDL_audio.h
  94. 224
      include/linux/sdl2/SDL_bits.h
  95. 240
      include/linux/sdl2/SDL_blendmode.h
  96. 142
      include/linux/sdl2/SDL_clipboard.h
  97. 786
      include/linux/sdl2/SDL_config.h
  98. 352
      include/linux/sdl2/SDL_cpuinfo.h
  99. 3346
      include/linux/sdl2/SDL_egl.h
  100. 520
      include/linux/sdl2/SDL_endian.h
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,22 +1,22 @@
(cond (cond
((string-equal system-type "windows-nt") ; Microsoft Windows ((string-equal system-type "windows-nt") ; Microsoft Windows
(progn (progn
((c-mode . ((c-mode .
((company-clang-arguments . ("-IW:/include")) ((company-clang-arguments . ("-IW:/include"))
(flycheck-clang-include-path . ("W:/include"))) (flycheck-clang-include-path . ("W:/include")))
) )
((c++-mode . ((mode . c)))) ((c++-mode . ((mode . c))))
) )
)) ))
((string-equal system-type "gnu/linux") ; linux ((string-equal system-type "gnu/linux") ; linux
(progn (progn
((c-mode . ((c-mode .
((company-clang-arguments . ("-I/mnt/Dev/Projects/symmetry/include")) ((company-clang-arguments . ("-I/mnt/Dev/Projects/symmetry/include"))
(flycheck-clang-include-path . ("/mnt/Dev/Projects/symmetry/include"))) (flycheck-clang-include-path . ("/mnt/Dev/Projects/symmetry/include")))
) )
((c++-mode . ((mode . c)))) ((c++-mode . ((mode . c))))
) )
))) )))

8
.gitignore vendored

@ -1,4 +1,4 @@
bin/* bin/*
build/* build/*
.vs/* .vs/*
.vscode .vscode

1354
LICENSE

File diff suppressed because it is too large Load Diff

@ -1,142 +1,142 @@
# Project Symmetry # Project Symmetry
## About ## About
A simple first person shooter that may or may not have anything to do with the concept of symmetry. A simple first person shooter that may or may not have anything to do with the concept of symmetry.
The game has a similar struct to older games like Quake where the objective is usually to survive and get to end of the level while killing monsters/demons. The game has a similar struct to older games like Quake where the objective is usually to survive and get to end of the level while killing monsters/demons.
The purpose of this project is to serve as an exercise in creating a game from the ground up using as few libraries as possible. The game uses the following The purpose of this project is to serve as an exercise in creating a game from the ground up using as few libraries as possible. The game uses the following
libraries: libraries:
| Library | Usage | | Library | Usage |
| ---------------------------------------------| --------------------------------------- | | ---------------------------------------------| --------------------------------------- |
| [SDL2](https://www.libsdl.org/) | Windowing, Input, Platform abstraction | | [SDL2](https://www.libsdl.org/) | Windowing, Input, Platform abstraction |
| [Soloud](http://sol.gfxile.net/soloud/) | 3d positional audio | | [Soloud](http://sol.gfxile.net/soloud/) | 3d positional audio |
| [ODE](http://ode.org/) | Physics | | [ODE](http://ode.org/) | Physics |
| [Nuklear](https://github.com/vurtun/nuklear) | In-game and editor UI | | [Nuklear](https://github.com/vurtun/nuklear) | In-game and editor UI |
| [GLAD](https://github.com/dav1dde/glad-web) | OpenGL Extension Loading | | [GLAD](https://github.com/dav1dde/glad-web) | OpenGL Extension Loading |
## Building ## Building
The game uses the [GENie](https://github.com/bkaradzic/GENie) build system. The game can be build by llowing steps: The game uses the [GENie](https://github.com/bkaradzic/GENie) build system. The game can be build by llowing steps:
-**Windows**: Execute the following command in the project's root directory by opening a visual studio veloper command prompt: -**Windows**: Execute the following command in the project's root directory by opening a visual studio veloper command prompt:
```shell ```shell
cd build cd build
..\tools\genie.exe vs2017 ..\tools\genie.exe vs2017
``` ```
This will generate a visual studio 2017 solution in the *build/vs2017* folder which can be opened in sual studio and built and run as ususal. This will generate a visual studio 2017 solution in the *build/vs2017* folder which can be opened in sual studio and built and run as ususal.
-**Linux(Ubuntu)**: Execute the following in the project's root directory -**Linux(Ubuntu)**: Execute the following in the project's root directory
```bash ```bash
cd build cd build
../tools/genie gmake ../tools/genie gmake
``` ```
This will generate makefiles in the *build/gmake* directory. Then, This will generate makefiles in the *build/gmake* directory. Then,
```bash ```bash
cd gmake cd gmake
make all make all
``` ```
This will build the debug configuration by default and it's output will be in *build/gmake/debug* folder. You can then run the game by, This will build the debug configuration by default and it's output will be in *build/gmake/debug* folder. You can then run the game by,
```bash ```bash
cd debug cd debug
./Symmetry ./Symmetry
``` ```
## License ## License
All the code in this repository is under GPLv3, see LICENSE for more information All the code in this repository is under GPLv3, see LICENSE for more information
## File format specifications ## File format specifications
- ### Entity - ### Entity
```bash ```bash
# Comment, Sample entity definition in file, paremeters left out are set to defaults # Comment, Sample entity definition in file, paremeters left out are set to defaults
# Empty line at the end specifies end of entity definition # Empty line at the end specifies end of entity definition
entity: "Something" entity: "Something"
position: 0 0 0 position: 0 0 0
scale: 1 1 1 scale: 1 1 1
rotation: 0 0 0 1 rotation: 0 0 0 1
model: "suzanne.pamesh" model: "suzanne.pamesh"
material: "blinn_phong" material: "blinn_phong"
diffuse_color: 1 0 0 1 diffuse_color: 1 0 0 1
diffuse_texture: "checkered.tga" diffuse_texture: "checkered.tga"
specular: 0.55 specular: 0.55
``` ```
- ### Configuration Variables a.k.a cfg-vars - ### Configuration Variables a.k.a cfg-vars
```bash ```bash
# Comment # Comment
render_width: 1024 render_width: 1024
render_height: 1024 render_height: 1024
debug_draw_enabled: true debug_draw_enabled: true
fog_color: 0.5 0.2 0.2 1 fog_color: 0.5 0.2 0.2 1
# There can be comments or empty newlines in between unlike entity definitions # There can be comments or empty newlines in between unlike entity definitions
ambient_light: 0.1 0.1 0.1 1 ambient_light: 0.1 0.1 0.1 1
msaa: true msaa: true
msaa_levels: 8 msaa_levels: 8
``` ```
- ### Keybindings - ### Keybindings
```bash ```bash
# All keys are parsed by comparing the output of SDL_GetKeyname # All keys are parsed by comparing the output of SDL_GetKeyname
# Each line represents a keybinding # Each line represents a keybinding
Move_Forward: W Move_Forward: W
# Multiple keys to a single binding are specified with commas # Multiple keys to a single binding are specified with commas
Move_Backward: S,Down Move_Backward: S,Down
# Combinations are specified with a hyphen/dash # Combinations are specified with a hyphen/dash
# When specifing combinations, modifiers(shift, alt, ctrl) always come before # When specifing combinations, modifiers(shift, alt, ctrl) always come before
# the hyphen and the actual key comes afterwards. At the moment modifier keys are # the hyphen and the actual key comes afterwards. At the moment modifier keys are
# forced to be on the left side i.e. Left Control, Left Shift and Left Alt. # forced to be on the left side i.e. Left Control, Left Shift and Left Alt.
Quit: Left Ctrl-Q Quit: Left Ctrl-Q
# Single modifier keys are allowed but multiple modifier keys without corresponding # Single modifier keys are allowed but multiple modifier keys without corresponding
# non-modifier key are not allowed # non-modifier key are not allowed
Sprint: Left Shift Sprint: Left Shift
``` ```
- ### Level/Scene - ### Level/Scene
- Binary format with header attached at the top - Binary format with header attached at the top
- Save child entities first - Save child entities first
- Copy paste all entites in the file one by one. Since the entites all look - Copy paste all entites in the file one by one. Since the entites all look
the same in memory and are made up of tagged unions, a simple memcpy approach the same in memory and are made up of tagged unions, a simple memcpy approach
should suffice. The problem is entity heirarchies. There are multiple approaches to should suffice. The problem is entity heirarchies. There are multiple approaches to
solve this problem. solve this problem.
- Save a sorted list of entites to file i.e. before saving create a new list that does - Save a sorted list of entites to file i.e. before saving create a new list that does
not have the empty array slots in the entity list and then just copy and paste. This not have the empty array slots in the entity list and then just copy and paste. This
is the simplest way to solve the problem as we don't have to worry about indexes of is the simplest way to solve the problem as we don't have to worry about indexes of
parent/child entites in heirarchy. We can take the whole array and paste it to the parent/child entites in heirarchy. We can take the whole array and paste it to the
file but creating a copy of entity list for this purpose only would be slow and consume a lot of memory. file but creating a copy of entity list for this purpose only would be slow and consume a lot of memory.
- Instead of creating a copy of the entity list for sorting and saving, sort the actual entity list - Instead of creating a copy of the entity list for sorting and saving, sort the actual entity list
and update all references as necessary then save the array to file. and update all references as necessary then save the array to file.
- Just write the name of the parent entity as parent. Make sure that all entity names are unique. - Just write the name of the parent entity as parent. Make sure that all entity names are unique.
- Use separate EntityDefinition file that serves as a blueprint/prefab for the entity - Use separate EntityDefinition file that serves as a blueprint/prefab for the entity
to load/save. When the entity is saved in a scene file, the scene file only needs to to load/save. When the entity is saved in a scene file, the scene file only needs to
refer to the entity's EntityDefinition file/asset along with it's parent and children refer to the entity's EntityDefinition file/asset along with it's parent and children
- This approach requires seperating a scene into mutable/immutable parts. - This approach requires seperating a scene into mutable/immutable parts.
Meaning, entities that can change their state during the duaration of the level are Meaning, entities that can change their state during the duaration of the level are
mutable and those that remain the same as they were defined in their EntityDefinition mutable and those that remain the same as they were defined in their EntityDefinition
file are immutable. file are immutable.
- In each level there going to be mutable entites i.e player and player's position/orientation, objectives - In each level there going to be mutable entites i.e player and player's position/orientation, objectives
cleared/remaining, doors opened and puzzles solved etc. Instead of handling all of these in the cleared/remaining, doors opened and puzzles solved etc. Instead of handling all of these in the
scene file, we save all the mutable state in the savegame files. When restoring game's state from a save name we will need scene file, we save all the mutable state in the savegame files. When restoring game's state from a save name we will need
to handle loading of a scene and then applying the mutable state to entites after loading. to handle loading of a scene and then applying the mutable state to entites after loading.
- Entities can have (a fixed number of?) properties. Each property has a name and a corresponding - Entities can have (a fixed number of?) properties. Each property has a name and a corresponding
variant value like, health or ammo etc. But, how to save/load all of that? variant value like, health or ammo etc. But, how to save/load all of that?
- ### Materials - ### Materials
*TODO* *TODO*
- ### Mesh/Geometry - ### Mesh/Geometry
*TODO* *TODO*

Binary file not shown.

@ -1,128 +1,128 @@
//include fog.glsl common.glsl commonFrag.glsl version.glsl //include fog.glsl common.glsl commonFrag.glsl version.glsl
struct Light struct Light
{ {
vec3 position; vec3 position;
vec3 direction; vec3 direction;
float outer_angle; float outer_angle;
float inner_angle; float inner_angle;
float falloff; float falloff;
float intensity; float intensity;
vec3 color; vec3 color;
uint pcf_enabled; uint pcf_enabled;
int type; int type;
int radius; int radius;
float depth_bias; float depth_bias;
}; };
const int LT_SPOT = 0; const int LT_SPOT = 0;
const int LT_DIR = 1; const int LT_DIR = 1;
const int LT_POINT = 2; const int LT_POINT = 2;
const int MAX_LIGHTS = 128; const int MAX_LIGHTS = 128;
uniform sampler2D diffuse_texture; uniform sampler2D diffuse_texture;
uniform Light lights[MAX_LIGHTS]; uniform Light lights[MAX_LIGHTS];
uniform int total_active_lights; uniform int total_active_lights;
uniform float specular; uniform float specular;
uniform float diffuse; uniform float diffuse;
uniform float specular_strength; uniform float specular_strength;
out vec4 frag_color; out vec4 frag_color;
vec3 calc_point_light(in Light light) vec3 calc_point_light(in Light light)
{ {
vec3 diffuse_comp = vec3(0.0); vec3 diffuse_comp = vec3(0.0);
vec3 specular_comp = vec3(0.0); vec3 specular_comp = vec3(0.0);
vec3 light_direction = vertex - light.position; vec3 light_direction = vertex - light.position;
float dist = abs(length(light_direction)); float dist = abs(length(light_direction));
if(dist <= light.radius) if(dist <= light.radius)
{ {
light_direction = normalize(light_direction); light_direction = normalize(light_direction);
vec3 normalized_normal = normalize(normal); vec3 normalized_normal = normalize(normal);
float cos_ang_incidence = dot(normalized_normal, -light_direction); float cos_ang_incidence = dot(normalized_normal, -light_direction);
cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); cos_ang_incidence = clamp(cos_ang_incidence, 0, 1);
if(cos_ang_incidence > 0) if(cos_ang_incidence > 0)
{ {
diffuse_comp = light.color * diffuse * cos_ang_incidence; diffuse_comp = light.color * diffuse * cos_ang_incidence;
vec3 vertex_to_eye = normalize(camera_pos - vertex); vec3 vertex_to_eye = normalize(camera_pos - vertex);
vec3 halfway = normalize(light.direction + vertex_to_eye); vec3 halfway = normalize(light.direction + vertex_to_eye);
float specular_factor = max(0.0, dot(normalized_normal, halfway)); float specular_factor = max(0.0, dot(normalized_normal, halfway));
specular_factor = pow(specular_factor, specular_strength); specular_factor = pow(specular_factor, specular_strength);
specular_comp = light.color * specular * specular_factor; specular_comp = light.color * specular * specular_factor;
} }
float attenuation = pow(max(0.0, (1.0 - (dist / light.radius))), light.falloff + 1.0f); float attenuation = pow(max(0.0, (1.0 - (dist / light.radius))), light.falloff + 1.0f);
return (((diffuse_comp + specular_comp) * attenuation) * light.intensity); return (((diffuse_comp + specular_comp) * attenuation) * light.intensity);
} }
else else
{ {
return vec3(0.0); return vec3(0.0);
} }
} }
vec3 calc_dir_light(in Light light) vec3 calc_dir_light(in Light light)
{ {
vec3 diffuse_comp = vec3(0.0); vec3 diffuse_comp = vec3(0.0);
vec3 specular_comp = vec3(0.0); vec3 specular_comp = vec3(0.0);
vec3 normalized_normal = normalize(normal); vec3 normalized_normal = normalize(normal);
float cos_ang_incidence = dot(normalized_normal, -light.direction); float cos_ang_incidence = dot(normalized_normal, -light.direction);
cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); cos_ang_incidence = clamp(cos_ang_incidence, 0, 1);
float shadow_factor = 1.0; float shadow_factor = 1.0;
if(cos_ang_incidence > 0) if(cos_ang_incidence > 0)
{ {
diffuse_comp = light.color * diffuse * cos_ang_incidence; diffuse_comp = light.color * diffuse * cos_ang_incidence;
vec3 vertex_to_eye = normalize(camera_pos - vertex); vec3 vertex_to_eye = normalize(camera_pos - vertex);
vec3 light_reflect = normalize(reflect(light.direction, normalized_normal)); vec3 light_reflect = normalize(reflect(light.direction, normalized_normal));
vec3 halfway = normalize(light.direction + vertex_to_eye); vec3 halfway = normalize(light.direction + vertex_to_eye);
float specular_factor = max(0.0, dot(normalized_normal, halfway)); float specular_factor = max(0.0, dot(normalized_normal, halfway));
specular_factor = pow(specular_factor, specular_strength); specular_factor = pow(specular_factor, specular_strength);
specular_comp = light.color * specular * specular_factor; specular_comp = light.color * specular * specular_factor;
// if(light.castShadow == 1) // if(light.castShadow == 1)
// { // {
// shadow_factor = calcShadowFactor(vertLightSpace.xyz); // shadow_factor = calcShadowFactor(vertLightSpace.xyz);
// } // }
} }
//return (light.intensity * (diffuse_comp + specular_comp)) * shadow_factor; //return (light.intensity * (diffuse_comp + specular_comp)) * shadow_factor;
return (light.intensity * (diffuse_comp + specular_comp)); return (light.intensity * (diffuse_comp + specular_comp));
} }
vec3 calc_spot_light(in Light light) vec3 calc_spot_light(in Light light)
{ {
vec3 color = vec3(0.0); vec3 color = vec3(0.0);
vec3 light_to_surface = vertex - light.position; vec3 light_to_surface = vertex - light.position;
float angle = dot(light.direction, normalize(light_to_surface)); float angle = dot(light.direction, normalize(light_to_surface));
if(acos(angle) < light.outer_angle) if(acos(angle) < light.outer_angle)
{ {
color = calc_point_light(light); color = calc_point_light(light);
color *= smoothstep(cos(light.outer_angle), cos(light.inner_angle), angle); color *= smoothstep(cos(light.outer_angle), cos(light.inner_angle), angle);
// if(light.cast_shadow != 0) // if(light.cast_shadow != 0)
// { // {
// float shadow_factor = calc_shadow_factor(vert_light_space.xyz / vert_light_space.w); // float shadow_factor = calc_shadow_factor(vert_light_space.xyz / vert_light_space.w);
// color *= shadow_factor; // color *= shadow_factor;
// } // }
} }
return color;// * shadowFactor; return color;// * shadowFactor;
} }
void main() void main()
{ {
vec4 albedo_color = diffuse_color * texture(diffuse_texture, uv); vec4 albedo_color = diffuse_color * texture(diffuse_texture, uv);
vec3 light_contribution = vec3(0.0, 0.0, 0.0); vec3 light_contribution = vec3(0.0, 0.0, 0.0);
for(int i = 0; i < total_active_lights; i++) for(int i = 0; i < total_active_lights; i++)
{ {
if(lights[i].type == LT_POINT) if(lights[i].type == LT_POINT)
light_contribution += calc_point_light(lights[i]); light_contribution += calc_point_light(lights[i]);
else if(lights[i].type == LT_DIR) else if(lights[i].type == LT_DIR)
light_contribution += calc_dir_light(lights[i]); light_contribution += calc_dir_light(lights[i]);
else else
light_contribution += calc_spot_light(lights[i]); light_contribution += calc_spot_light(lights[i]);
} }
frag_color = apply_fog((albedo_color * vec4(light_contribution + ambient_light, 1.0))); frag_color = apply_fog((albedo_color * vec4(light_contribution + ambient_light, 1.0)));
} }

@ -1,130 +1,130 @@
//include fog.glsl common.glsl commonFrag.glsl version.glsl //include fog.glsl common.glsl commonFrag.glsl version.glsl
struct Light struct Light
{ {
vec3 position; vec3 position;
vec3 direction; vec3 direction;
float outer_angle; float outer_angle;
float inner_angle; float inner_angle;
float falloff; float falloff;
float intensity; float intensity;
vec3 color; vec3 color;
uint pcf_enabled; uint pcf_enabled;
int type; int type;
int radius; int radius;
float depth_bias; float depth_bias;
}; };
const int LT_SPOT = 0; const int LT_SPOT = 0;
const int LT_DIR = 1; const int LT_DIR = 1;
const int LT_POINT = 2; const int LT_POINT = 2;
const int MAX_LIGHTS = 128; const int MAX_LIGHTS = 128;
uniform sampler2D diffuse_texture; uniform sampler2D diffuse_texture;
uniform Light lights[MAX_LIGHTS]; uniform Light lights[MAX_LIGHTS];
uniform int total_active_lights; uniform int total_active_lights;
uniform float specular; uniform float specular;
uniform float diffuse; uniform float diffuse;
uniform float specular_strength; uniform float specular_strength;
out vec4 frag_color; out vec4 frag_color;
vec3 calc_point_light(in Light light) vec3 calc_point_light(in Light light)
{ {
vec3 diffuse_comp = vec3(0.0); vec3 diffuse_comp = vec3(0.0);
vec3 specular_comp = vec3(0.0); vec3 specular_comp = vec3(0.0);
vec3 light_direction = vertex - light.position; vec3 light_direction = vertex - light.position;
float dist = abs(length(light_direction)); float dist = abs(length(light_direction));
if(dist <= light.radius) if(dist <= light.radius)
{ {
light_direction = normalize(light_direction); light_direction = normalize(light_direction);
vec3 normalized_normal = normalize(normal); vec3 normalized_normal = normalize(normal);
float cos_ang_incidence = dot(normalized_normal, -light_direction); float cos_ang_incidence = dot(normalized_normal, -light_direction);
cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); cos_ang_incidence = clamp(cos_ang_incidence, 0, 1);
if(cos_ang_incidence > 0) if(cos_ang_incidence > 0)
{ {
diffuse_comp = light.color * diffuse * cos_ang_incidence; diffuse_comp = light.color * diffuse * cos_ang_incidence;
vec3 vertex_to_eye = normalize(camera_pos - vertex); vec3 vertex_to_eye = normalize(camera_pos - vertex);
vec3 halfway = normalize(light.direction + vertex_to_eye); vec3 halfway = normalize(light.direction + vertex_to_eye);
float specular_factor = max(0.0, dot(normalized_normal, halfway)); float specular_factor = max(0.0, dot(normalized_normal, halfway));
specular_factor = pow(specular_factor, specular_strength); specular_factor = pow(specular_factor, specular_strength);
specular_comp = light.color * specular * specular_factor; specular_comp = light.color * specular * specular_factor;
} }
float attenuation = pow(max(0.0, (1.0 - (dist / light.radius))), light.falloff + 1.0f); float attenuation = pow(max(0.0, (1.0 - (dist / light.radius))), light.falloff + 1.0f);
return (((diffuse_comp + specular_comp) * attenuation) * light.intensity); return (((diffuse_comp + specular_comp) * attenuation) * light.intensity);
} }
else else
{ {
return vec3(0.0); return vec3(0.0);
} }
} }
vec3 calc_dir_light(in Light light) vec3 calc_dir_light(in Light light)
{ {
vec3 diffuse_comp = vec3(0.0); vec3 diffuse_comp = vec3(0.0);
vec3 specular_comp = vec3(0.0); vec3 specular_comp = vec3(0.0);
vec3 normalized_normal = normalize(normal); vec3 normalized_normal = normalize(normal);
float cos_ang_incidence = dot(normalized_normal, -light.direction); float cos_ang_incidence = dot(normalized_normal, -light.direction);
cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); cos_ang_incidence = clamp(cos_ang_incidence, 0, 1);
float shadow_factor = 1.0; float shadow_factor = 1.0;
if(cos_ang_incidence > 0) if(cos_ang_incidence > 0)
{ {
diffuse_comp = light.color * diffuse * cos_ang_incidence; diffuse_comp = light.color * diffuse * cos_ang_incidence;
vec3 vertex_to_eye = normalize(camera_pos - vertex); vec3 vertex_to_eye = normalize(camera_pos - vertex);
vec3 light_reflect = normalize(reflect(light.direction, normalized_normal)); vec3 light_reflect = normalize(reflect(light.direction, normalized_normal));
vec3 halfway = normalize(light.direction + vertex_to_eye); vec3 halfway = normalize(light.direction + vertex_to_eye);
float specular_factor = max(0.0, dot(normalized_normal, halfway)); float specular_factor = max(0.0, dot(normalized_normal, halfway));
specular_factor = pow(specular_factor, specular_strength); specular_factor = pow(specular_factor, specular_strength);
specular_comp = light.color * specular * specular_factor; specular_comp = light.color * specular * specular_factor;
// if(light.castShadow == 1) // if(light.castShadow == 1)
// { // {
// shadow_factor = calcShadowFactor(vertLightSpace.xyz); // shadow_factor = calcShadowFactor(vertLightSpace.xyz);
// } // }
} }
//return (light.intensity * (diffuse_comp + specular_comp)) * shadow_factor; //return (light.intensity * (diffuse_comp + specular_comp)) * shadow_factor;
return (light.intensity * (diffuse_comp + specular_comp)); return (light.intensity * (diffuse_comp + specular_comp));
} }
vec3 calc_spot_light(in Light light) vec3 calc_spot_light(in Light light)
{ {
vec3 color = vec3(0.0); vec3 color = vec3(0.0);
vec3 light_to_surface = vertex - light.position; vec3 light_to_surface = vertex - light.position;
float angle = dot(light.direction, normalize(light_to_surface)); float angle = dot(light.direction, normalize(light_to_surface));
if(acos(angle) < light.outer_angle) if(acos(angle) < light.outer_angle)
{ {
color = calc_point_light(light); color = calc_point_light(light);
color *= smoothstep(cos(light.outer_angle), cos(light.inner_angle), angle); color *= smoothstep(cos(light.outer_angle), cos(light.inner_angle), angle);
// if(light.cast_shadow != 0) // if(light.cast_shadow != 0)
// { // {
// float shadow_factor = calc_shadow_factor(vert_light_space.xyz / vert_light_space.w); // float shadow_factor = calc_shadow_factor(vert_light_space.xyz / vert_light_space.w);
// color *= shadow_factor; // color *= shadow_factor;
// } // }
} }
return color;// * shadowFactor; return color;// * shadowFactor;
} }
void main() void main()
{ {
vec4 albedo_color = diffuse_color * texture(diffuse_texture, uv); vec4 albedo_color = diffuse_color * texture(diffuse_texture, uv);
vec3 light_contribution = vec3(0.0, 0.0, 0.0); vec3 light_contribution = vec3(0.0, 0.0, 0.0);
for(int i = 0; i < total_active_lights; i++) for(int i = 0; i < total_active_lights; i++)
{ {
if(i == total_active_lights) break; if(i == total_active_lights) break;
if(lights[i].type == LT_POINT) if(lights[i].type == LT_POINT)
light_contribution += calc_point_light(lights[i]); light_contribution += calc_point_light(lights[i]);
else if(lights[i].type == LT_DIR) else if(lights[i].type == LT_DIR)
light_contribution += calc_dir_light(lights[i]); light_contribution += calc_dir_light(lights[i]);
else else
light_contribution += calc_spot_light(lights[i]); light_contribution += calc_spot_light(lights[i]);
} }
//frag_color = apply_fog((albedo_color * vec4(light_contribution + ambient_light, 1.0))); //frag_color = apply_fog((albedo_color * vec4(light_contribution + ambient_light, 1.0)));
frag_color = diffuse_color; frag_color = diffuse_color;
} }

@ -1,7 +1,7 @@
//include commonVert.glsl version.glsl //include commonVert.glsl version.glsl
void main() void main()
{ {
gl_Position = transformPosition(vPosition); gl_Position = transformPosition(vPosition);
setOutputs(); setOutputs();
} }

@ -1,5 +1,5 @@
// Common Uniforms // Common Uniforms
// uniform vec4 ambientLight; // uniform vec4 ambientLight;
// uniform vec3 eyePos; // uniform vec3 eyePos;
uniform vec4 diffuse_color; uniform vec4 diffuse_color;

@ -1,13 +1,13 @@
// Common Inputs // Common Inputs
in vec2 uv; in vec2 uv;
in vec3 normal; in vec3 normal;
in vec3 vertex; in vec3 vertex;
//in vec3 vertCamSpace; //in vec3 vertCamSpace;
//in vec4 vertLightSpace; //in vec4 vertLightSpace;
// Fragment Shader Output // Fragment Shader Output
//out vec4 frag_color; //out vec4 frag_color;
uniform vec3 ambient_light; uniform vec3 ambient_light;
uniform vec3 camera_pos; uniform vec3 camera_pos;

@ -1,33 +1,33 @@
// Common inputs and outputs // Common inputs and outputs
in vec3 vPosition; in vec3 vPosition;
in vec3 vNormal; in vec3 vNormal;
in vec2 vUV; in vec2 vUV;
out vec2 uv; out vec2 uv;
out vec3 normal; out vec3 normal;
out vec3 vertex; out vec3 vertex;
// out vec3 vertCamSpace; // out vec3 vertCamSpace;
// out vec4 vertLightSpace; // out vec4 vertLightSpace;
// Common uniforms // Common uniforms
uniform mat4 model_mat; uniform mat4 model_mat;
uniform mat4 inv_model_mat; uniform mat4 inv_model_mat;
// uniform mat4 view_mat; // uniform mat4 view_mat;
uniform mat4 mvp; uniform mat4 mvp;
uniform mat4 lightVPMat; uniform mat4 lightVPMat;
vec4 transformPosition(vec3 position) vec4 transformPosition(vec3 position)
{ {
return mvp * vec4(vPosition, 1.0); return mvp * vec4(vPosition, 1.0);
} }
void setOutputs() void setOutputs()
{ {
uv = vUV; uv = vUV;
//Normal and vertex sent to the fragment shader should be in the same space! //Normal and vertex sent to the fragment shader should be in the same space!
normal = vec4(transpose(inv_model_mat) * vec4(vNormal, 0.0)).xyz; normal = vec4(transpose(inv_model_mat) * vec4(vNormal, 0.0)).xyz;
vertex = vec4(model_mat * vec4(vPosition, 1.0)).xyz; vertex = vec4(model_mat * vec4(vPosition, 1.0)).xyz;
// vertCamSpace = vec4(view_mat * vec4(vPosition, 1.0)).xyz; // vertCamSpace = vec4(view_mat * vec4(vPosition, 1.0)).xyz;
// vertLightSpace = vec4((lightVPMat * model_mat) * vec4(vPosition, 1.0)); // vertLightSpace = vec4((lightVPMat * model_mat) * vec4(vPosition, 1.0));
} }

@ -1,10 +1,10 @@
//include version.glsl //include version.glsl
uniform vec4 debug_color; uniform vec4 debug_color;
out vec4 frag_color; out vec4 frag_color;
void main() void main()
{ {
frag_color = debug_color; frag_color = debug_color;
} }

@ -1,10 +1,10 @@
//include version.glsl //include version.glsl
uniform mat4 mvp; uniform mat4 mvp;
in vec3 vPosition; in vec3 vPosition;
void main() void main()
{ {
gl_Position = mvp * vec4(vPosition, 1.0); gl_Position = mvp * vec4(vPosition, 1.0);
} }

@ -1,118 +1,118 @@
//include version.glsl //include version.glsl
in vec2 uv; in vec2 uv;
out vec4 frag_color; out vec4 frag_color;
struct Light struct Light
{ {
vec3 position; vec3 position;
float outer_angle; float outer_angle;
float inner_angle; float inner_angle;
float falloff; float falloff;
float intensity; float intensity;
vec4 color; vec4 color;
uint pcf_enabled; uint pcf_enabled;
int type; int type;
int radius; int radius;
float depth_bias; float depth_bias;
}; };
const int LT_SPOT = 0; const int LT_SPOT = 0;
const int LT_DIR = 1; const int LT_DIR = 1;
const int LT_POINT = 2; const int LT_POINT = 2;
uniform sampler2D albedo_map; uniform sampler2D albedo_map;
uniform sampler2D position_map; uniform sampler2D position_map;
uniform sampler2D normal_map; uniform sampler2D normal_map;
uniform sampler2D depth_map; uniform sampler2D depth_map;
uniform Light light; uniform Light light;
uniform vec3 camera_pos; uniform vec3 camera_pos;
uniform mat4 mvp; uniform mat4 mvp;
uniform mat4 inv_proj_mat; uniform mat4 inv_proj_mat;
uniform vec2 screen_size; uniform vec2 screen_size;
uniform vec2 planes; uniform vec2 planes;
vec4 calc_point_light(Light point_light, vec4 calc_point_light(Light point_light,
vec3 vertex, vec3 vertex,
vec3 normal, vec3 normal,
vec4 albedo_color, vec4 albedo_color,
float mat_specular_strength, float mat_specular_strength,
float mat_specular) float mat_specular)
{ {
vec4 diffuse = vec4(0.0); vec4 diffuse = vec4(0.0);
vec4 specular = vec4(0.0); vec4 specular = vec4(0.0);
vec3 light_direction = vertex - point_light.position; vec3 light_direction = vertex - point_light.position;
light_direction = normalize(light_direction); light_direction = normalize(light_direction);
float distance = abs(length(light_direction)); float distance = abs(length(light_direction));
vec3 normalized_normal = normalize(normal); vec3 normalized_normal = normalize(normal);
float cos_ang_incidence = dot(normalized_normal, -light_direction); float cos_ang_incidence = dot(normalized_normal, -light_direction);
cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); cos_ang_incidence = clamp(cos_ang_incidence, 0, 1);
if(cos_ang_incidence > 0) if(cos_ang_incidence > 0)
{ {
diffuse = point_light.color * albedo_color * cos_ang_incidence; diffuse = point_light.color * albedo_color * cos_ang_incidence;
vec3 vertex_to_eye = normalize(camera_pos - vertex); vec3 vertex_to_eye = normalize(camera_pos - vertex);
vec3 light_reflect = normalize(reflect(light_direction, normalized_normal)); vec3 light_reflect = normalize(reflect(light_direction, normalized_normal));
float specular_factor = max(0.0, dot(vertex_to_eye, light_reflect)); float specular_factor = max(0.0, dot(vertex_to_eye, light_reflect));
specular_factor = pow(specular_factor, mat_specular_strength); specular_factor = pow(specular_factor, mat_specular_strength);
specular = point_light.color * mat_specular * specular_factor; specular = point_light.color * mat_specular * specular_factor;
} }
float attenuation = pow(max(0.0, (1.0 - (distance / point_light.radius))), point_light.falloff + 1.0f); float attenuation = pow(max(0.0, (1.0 - (distance / point_light.radius))), point_light.falloff + 1.0f);
return (((diffuse + specular) * attenuation) * point_light.intensity); return (((diffuse + specular) * attenuation) * point_light.intensity);
// if(distance <= point_light.radius) // if(distance <= point_light.radius)
// { // {
// light_direction = normalize(light_direction); // light_direction = normalize(light_direction);
// vec3 normalized_normal = normalize(normal); // vec3 normalized_normal = normalize(normal);
// float cos_ang_incidence = dot(normalized_normal, -light_direction); // float cos_ang_incidence = dot(normalized_normal, -light_direction);
// cos_ang_incidence = clamp(cos_ang_incidence, 0, 1); // cos_ang_incidence = clamp(cos_ang_incidence, 0, 1);
// if(cos_ang_incidence > 0) // if(cos_ang_incidence > 0)
// { // {
// diffuse = point_light.color * albedo_color * cos_ang_incidence; // diffuse = point_light.color * albedo_color * cos_ang_incidence;
// vec3 vertex_to_eye = normalize(camera_pos - vertex); // vec3 vertex_to_eye = normalize(camera_pos - vertex);
// vec3 light_reflect = normalize(reflect(light_direction, normalized_normal)); // vec3 light_reflect = normalize(reflect(light_direction, normalized_normal));
// float specular_factor = max(0.0, dot(vertex_to_eye, light_reflect)); // float specular_factor = max(0.0, dot(vertex_to_eye, light_reflect));
// specular_factor = pow(specular_factor, mat_specular_strength); // specular_factor = pow(specular_factor, mat_specular_strength);
// specular = point_light.color * mat_specular * specular_factor; // specular = point_light.color * mat_specular * specular_factor;
// } // }
// float attenuation = pow(max(0.0, (1.0 - (distance / point_light.radius))), point_light.falloff + 1.0f); // float attenuation = pow(max(0.0, (1.0 - (distance / point_light.radius))), point_light.falloff + 1.0f);
// return (((diffuse + specular) * attenuation) * point_light.intensity); // return (((diffuse + specular) * attenuation) * point_light.intensity);
// } // }
// else // else
// { // {
// return vec4(0.0); // return vec4(0.0);
// } // }
} }
float lz(float depth) float lz(float depth)
{ {
return planes.x / (planes.y - depth * (planes.y - planes.x)) * planes.y; return planes.x / (planes.y - depth * (planes.y - planes.x)) * planes.y;
} }
void main() void main()
{ {
//vec2 uv_coords = gl_FragCoord.xy / screen_size; //vec2 uv_coords = gl_FragCoord.xy / screen_size;
vec2 uv_coords = uv; vec2 uv_coords = uv;
vec4 albedo_color = texture(albedo_map, uv_coords); vec4 albedo_color = texture(albedo_map, uv_coords);
vec3 position = texture(position_map, uv_coords).rgb; vec3 position = texture(position_map, uv_coords).rgb;
vec3 normal = texture(normal_map, uv_coords).rgb; vec3 normal = texture(normal_map, uv_coords).rgb;
normal = normalize(normal); normal = normalize(normal);
// vec3 position = vec3(0); // vec3 position = vec3(0);
// position = vec4(inv_proj_mat * vec4(position, 1.0)).xyz; // position = vec4(inv_proj_mat * vec4(position, 1.0)).xyz;
// float depth = texture(depth_map, uv_coords.st).x; // float depth = texture(depth_map, uv_coords.st).x;
// position.x = ((gl_FragCoord.x / screen_size.x) - 0.5) * 2.0; // position.x = ((gl_FragCoord.x / screen_size.x) - 0.5) * 2.0;
// position.y = ((-gl_FragCoord.y/screen_size.y)+0.5) * 2.0 / (screen_size.x/screen_size.y); // position.y = ((-gl_FragCoord.y/screen_size.y)+0.5) * 2.0 / (screen_size.x/screen_size.y);
// position.z = lz(depth); // position.z = lz(depth);
// position.x *= position.z; // position.x *= position.z;
// position.y *= -position.z; // position.y *= -position.z;
//normal = vec4(inv_proj_mat * vec4(normal, 1.0)).xyz; //normal = vec4(inv_proj_mat * vec4(normal, 1.0)).xyz;
frag_color = calc_point_light(light, position, normal, albedo_color, 20, 1.f); frag_color = calc_point_light(light, position, normal, albedo_color, 20, 1.f);
//frag_color = vec4(albedo_color, 1.0); //frag_color = vec4(albedo_color, 1.0);
} }

@ -1,15 +1,15 @@
//include version.glsl //include version.glsl
in vec2 vPosition; in vec2 vPosition;
in vec2 vUV; in vec2 vUV;
out vec2 uv; out vec2 uv;
uniform mat4 mvp; uniform mat4 mvp;
void main() void main()
{ {
uv = vUV; uv = vUV;
//gl_Position = mvp * vec4(vPosition, 1.0); //gl_Position = mvp * vec4(vPosition, 1.0);
gl_Position = vec4(vPosition, 0, 1.0); gl_Position = vec4(vPosition, 0, 1.0);
} }

@ -1,16 +1,16 @@
//include version.glsl //include version.glsl
in vec2 uv; in vec2 uv;
out vec4 frag_color; out vec4 frag_color;
uniform sampler2D albedo_map; uniform sampler2D albedo_map;
//uniform sampler2D light_map; //uniform sampler2D light_map;
void main() void main()
{ {
vec4 albedo_color = texture(albedo_map, uv); vec4 albedo_color = texture(albedo_map, uv);
//frag_color = albedo_color * texture(light_map, uv); //frag_color = albedo_color * texture(light_map, uv);
//frag_color += (albedo_color * vec4(0.2, 0.2, 0.2, 1.0)); //frag_color += (albedo_color * vec4(0.2, 0.2, 0.2, 1.0));
frag_color = albedo_color; frag_color = albedo_color;
} }

@ -1,15 +1,15 @@
//include version.glsl //include version.glsl
in vec2 vPosition; in vec2 vPosition;
in vec2 vUV; in vec2 vUV;
out vec2 uv; out vec2 uv;
//uniform mat4 mvp; //uniform mat4 mvp;
void main() void main()
{ {
uv = vUV; uv = vUV;
//gl_Position = mvp * vec4(vPosition, 0, 1.0); //gl_Position = mvp * vec4(vPosition, 0, 1.0);
gl_Position = vec4(vPosition, 0, 1.0); gl_Position = vec4(vPosition, 0, 1.0);
} }

@ -1,41 +1,41 @@
struct Fog struct Fog
{ {
int mode; int mode;
float density; float density;
float start_dist; float start_dist;
float max_dist; float max_dist;
vec3 color; vec3 color;
}; };
uniform Fog fog; uniform Fog fog;
const int FM_NONE = 0; const int FM_NONE = 0;
const int FM_LINEAR = 1; const int FM_LINEAR = 1;
const int FM_EXPONENTIAL = 2; const int FM_EXPONENTIAL = 2;
const int FM_EXPONENTIAL_SQRD = 3; const int FM_EXPONENTIAL_SQRD = 3;
vec4 apply_fog(vec4 color) vec4 apply_fog(vec4 color)
{ {
vec4 final_color = color; vec4 final_color = color;
if(fog.mode != FM_NONE) if(fog.mode != FM_NONE)
{ {
float fog_factor; float fog_factor;
float dist_from_eye = abs(length(vertex - camera_pos)); float dist_from_eye = abs(length(vertex - camera_pos));
if(fog.mode == FM_LINEAR) if(fog.mode == FM_LINEAR)
{ {
fog_factor = (fog.max_dist - dist_from_eye) / (fog.max_dist - fog.start_dist); fog_factor = (fog.max_dist - dist_from_eye) / (fog.max_dist - fog.start_dist);
} }
else if(fog.mode == FM_EXPONENTIAL) else if(fog.mode == FM_EXPONENTIAL)
{ {
fog_factor = exp(fog.density * -dist_from_eye); fog_factor = exp(fog.density * -dist_from_eye);
} }
else if(fog.mode == FM_EXPONENTIAL_SQRD) else if(fog.mode == FM_EXPONENTIAL_SQRD)
{ {
fog_factor = exp(-pow(fog.density * dist_from_eye, 2)); fog_factor = exp(-pow(fog.density * dist_from_eye, 2));
} }
fog_factor = clamp(fog_factor, 0.0, 1.0); fog_factor = clamp(fog_factor, 0.0, 1.0);
final_color = mix(vec4(fog.color, 1.0), color, fog_factor); final_color = mix(vec4(fog.color, 1.0), color, fog_factor);
} }
return final_color; return final_color;
} }

@ -1,14 +1,14 @@
//include version.glsl //include version.glsl
in vec2 uv; in vec2 uv;
in vec4 color; in vec4 color;
out vec4 frag_color; out vec4 frag_color;
uniform sampler2D sampler; uniform sampler2D sampler;
void main() void main()
{ {
frag_color = color * texture(sampler, uv); frag_color = color * texture(sampler, uv);
//frag_color = color; //frag_color = color;
} }

@ -1,17 +1,17 @@
//include version.glsl //include version.glsl
uniform mat4 proj_mat; uniform mat4 proj_mat;
in vec2 vPosition; in vec2 vPosition;
in vec2 vUV; in vec2 vUV;
in vec4 vColor; in vec4 vColor;
out vec2 uv; out vec2 uv;
out vec4 color; out vec4 color;
void main() void main()
{ {
uv = vUV; uv = vUV;
color = vColor; color = vColor;
gl_Position = proj_mat * vec4(vPosition, 0, 1.0); gl_Position = proj_mat * vec4(vPosition, 0, 1.0);
} }

@ -1,7 +1,7 @@
//include fog.glsl phongCommon.glsl common.glsl commonFrag.glsl version.glsl //include fog.glsl phongCommon.glsl common.glsl commonFrag.glsl version.glsl
void main() void main()
{ {
vec4 totalLightColor = calculateLight(); vec4 totalLightColor = calculateLight();
fragColor = applyFog(diffuseColor * (totalLightColor + ambientLight)); fragColor = applyFog(diffuseColor * (totalLightColor + ambientLight));
} }

@ -1,8 +1,8 @@
//include commonVert.glsl version.glsl //include commonVert.glsl version.glsl
void main() void main()
{ {
gl_Position = transformPosition(vPosition); gl_Position = transformPosition(vPosition);
setOutputs(); setOutputs();
} }

@ -1,230 +1,230 @@
struct Light struct Light
{ {
vec4 color; vec4 color;
vec3 direction; vec3 direction;
vec3 position; vec3 position;
float intensity; float intensity;
float outerAngle; float outerAngle;
float innerAngle; float innerAngle;
float falloff; float falloff;
int radius; int radius;
int type; int type;
int castShadow; int castShadow;
int pcfEnabled; int pcfEnabled;
float depthBias; float depthBias;
}; };
struct Material struct Material
{ {
float specular; float specular;
float diffuse; float diffuse;
float specularStrength; float specularStrength;
}; };
#define EPSILON 0.00001 #define EPSILON 0.00001
const int MAX_LIGHTS = 32; const int MAX_LIGHTS = 32;
const int LT_SPOT = 0; const int LT_SPOT = 0;
const int LT_DIR = 1; const int LT_DIR = 1;
const int LT_POINT = 2; const int LT_POINT = 2;
uniform Material material; uniform Material material;
uniform int numLights; uniform int numLights;
uniform Light lightList[MAX_LIGHTS]; uniform Light lightList[MAX_LIGHTS];
uniform Light light; uniform Light light;
uniform sampler2DShadow shadowMap0; uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1; uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2; uniform sampler2DShadow shadowMap2;
uniform sampler2DShadow shadowMap3; uniform sampler2DShadow shadowMap3;
uniform vec2 mapSize; uniform vec2 mapSize;
//uniform int selectedShadowMap; //uniform int selectedShadowMap;
float calcShadowFactor(vec3 projCoords) float calcShadowFactor(vec3 projCoords)
{ {
float bias = 0.5; float bias = 0.5;
vec2 uvCoords; vec2 uvCoords;
uvCoords.x = (projCoords.x * bias) + bias; uvCoords.x = (projCoords.x * bias) + bias;
uvCoords.y = (projCoords.y * bias) + bias; uvCoords.y = (projCoords.y * bias) + bias;
float z = (projCoords.z * bias) + bias; float z = (projCoords.z * bias) + bias;
float visibility = 1.0; float visibility = 1.0;
//if uv outside shadowmap range then point out of shadow //if uv outside shadowmap range then point out of shadow
if(uvCoords.x > 1.0 || uvCoords.x < 0.0 || uvCoords.y > 1.0 || uvCoords.y < 0.0) if(uvCoords.x > 1.0 || uvCoords.x < 0.0 || uvCoords.y > 1.0 || uvCoords.y < 0.0)
{ {
return 1.0; return 1.0;
} }
else else
{ {
float dist = distance(eyePos, vertex); float dist = distance(eyePos, vertex);
int selectedShadowMap = 0; int selectedShadowMap = 0;
if(dist <= 30) if(dist <= 30)
selectedShadowMap = 0; selectedShadowMap = 0;
else if(dist > 30 && dist <= 80) else if(dist > 30 && dist <= 80)
selectedShadowMap = 1; selectedShadowMap = 1;
else if(dist > 80 && dist <= 120) else if(dist > 80 && dist <= 120)
selectedShadowMap = 2; selectedShadowMap = 2;
else else
selectedShadowMap = 3; selectedShadowMap = 3;
if(light.pcfEnabled == 0) if(light.pcfEnabled == 0)
{ {
float depth = 0; float depth = 0;
if(light.type == LT_DIR) if(light.type == LT_DIR)
{ {
switch(selectedShadowMap) switch(selectedShadowMap)
{ {
case 0: depth = texture(shadowMap0, vec3(uvCoords, z + EPSILON)); break; case 0: depth = texture(shadowMap0, vec3(uvCoords, z + EPSILON)); break;
case 1: depth = texture(shadowMap1, vec3(uvCoords, z + EPSILON)); break; case 1: depth = texture(shadowMap1, vec3(uvCoords, z + EPSILON)); break;
case 2: depth = texture(shadowMap2, vec3(uvCoords, z + EPSILON)); break; case 2: depth = texture(shadowMap2, vec3(uvCoords, z + EPSILON)); break;
case 3: depth = texture(shadowMap3, vec3(uvCoords, z + EPSILON)); break; case 3: depth = texture(shadowMap3, vec3(uvCoords, z + EPSILON)); break;
} }
} }
else else
{ {
depth = texture(shadowMap0, vec3(uvCoords, z + EPSILON)); depth = texture(shadowMap0, vec3(uvCoords, z + EPSILON));
} }
if((depth + light.depthBias) < z) if((depth + light.depthBias) < z)
visibility = 0.5; visibility = 0.5;
else else
visibility = 1.0; visibility = 1.0;
} }
else else
{ {
float xOffset = 1.0/mapSize.x; float xOffset = 1.0/mapSize.x;
float yOffset = 1.0/mapSize.y; float yOffset = 1.0/mapSize.y;
float Factor = 0.0; float Factor = 0.0;
for (int y = -1 ; y <= 1 ; y++) for (int y = -1 ; y <= 1 ; y++)
{ {
for (int x = -1 ; x <= 1 ; x++) for (int x = -1 ; x <= 1 ; x++)
{ {
vec2 Offsets = vec2(x * xOffset, y * yOffset); vec2 Offsets = vec2(x * xOffset, y * yOffset);
vec3 UVC = vec3(uvCoords + Offsets, z + EPSILON); vec3 UVC = vec3(uvCoords + Offsets, z + EPSILON);
if(light.type == LT_DIR) if(light.type == LT_DIR)
{ {
switch(selectedShadowMap) switch(selectedShadowMap)
{ {
case 0: Factor += texture(shadowMap0, UVC); break; case 0: Factor += texture(shadowMap0, UVC); break;
case 1: Factor += texture(shadowMap1, UVC); break; case 1: Factor += texture(shadowMap1, UVC); break;
case 2: Factor += texture(shadowMap2, UVC); break; case 2: Factor += texture(shadowMap2, UVC); break;
case 3: Factor += texture(shadowMap3, UVC); break; case 3: Factor += texture(shadowMap3, UVC); break;
} }
} }
else else
{ {
Factor += texture(shadowMap0, UVC); Factor += texture(shadowMap0, UVC);
} }
} }
} }
visibility = (0.5 + (Factor / 18.0)); visibility = (0.5 + (Factor / 18.0));
} }
} }
return visibility; return visibility;
} }
vec4 calcDirLight(Light dirLight) vec4 calcDirLight(Light dirLight)
{ {
vec4 diffuse = vec4(0.0); vec4 diffuse = vec4(0.0);
vec4 specular = vec4(0.0); vec4 specular = vec4(0.0);
vec3 normalizedNormal = normalize(normal); vec3 normalizedNormal = normalize(normal);
float cosAngIncidence = dot(normalizedNormal, -dirLight.direction); float cosAngIncidence = dot(normalizedNormal, -dirLight.direction);
cosAngIncidence = clamp(cosAngIncidence, 0, 1); cosAngIncidence = clamp(cosAngIncidence, 0, 1);
float shadowFactor = 1.0; float shadowFactor = 1.0;
if(cosAngIncidence > 0) if(cosAngIncidence > 0)
{ {
diffuse = dirLight.color * material.diffuse * cosAngIncidence; diffuse = dirLight.color * material.diffuse * cosAngIncidence;
vec3 vertexToEye = normalize(eyePos - vertex); vec3 vertexToEye = normalize(eyePos - vertex);
vec3 lightReflect = normalize(reflect(dirLight.direction, normalizedNormal)); vec3 lightReflect = normalize(reflect(dirLight.direction, normalizedNormal));
float specularFactor = max(0.0, dot(vertexToEye, lightReflect)); float specularFactor = max(0.0, dot(vertexToEye, lightReflect));
specularFactor = pow(specularFactor, material.specularStrength); specularFactor = pow(specularFactor, material.specularStrength);
specular = dirLight.color * material.specular * specularFactor; specular = dirLight.color * material.specular * specularFactor;
if(light.castShadow == 1) if(light.castShadow == 1)
{ {
shadowFactor = calcShadowFactor(vertLightSpace.xyz); shadowFactor = calcShadowFactor(vertLightSpace.xyz);
} }
} }
// return dirLight.intensity * shadowFactor * (diffuse + specular); // return dirLight.intensity * shadowFactor * (diffuse + specular);
return (dirLight.intensity * (diffuse + specular)) * shadowFactor; return (dirLight.intensity * (diffuse + specular)) * shadowFactor;
} }
vec4 calcPointLight(Light pointLight) vec4 calcPointLight(Light pointLight)
{ {
vec4 diffuse = vec4(0.0); vec4 diffuse = vec4(0.0);
vec4 specular = vec4(0.0); vec4 specular = vec4(0.0);
vec3 lightDirection = vertex - pointLight.position; vec3 lightDirection = vertex - pointLight.position;
float distance = abs(length(lightDirection)); float distance = abs(length(lightDirection));
if(distance <= pointLight.radius) if(distance <= pointLight.radius)
{ {
lightDirection = normalize(lightDirection); lightDirection = normalize(lightDirection);
vec3 normalizedNormal = normalize(normal); vec3 normalizedNormal = normalize(normal);
float cosAngIncidence = dot(normalizedNormal, -lightDirection); float cosAngIncidence = dot(normalizedNormal, -lightDirection);
cosAngIncidence = clamp(cosAngIncidence, 0, 1); cosAngIncidence = clamp(cosAngIncidence, 0, 1);
if(cosAngIncidence > 0) if(cosAngIncidence > 0)
{ {
diffuse = pointLight.color * material.diffuse * cosAngIncidence; diffuse = pointLight.color * material.diffuse * cosAngIncidence;
vec3 vertexToEye = normalize(eyePos - vertex); vec3 vertexToEye = normalize(eyePos - vertex);
vec3 lightReflect = normalize(reflect(lightDirection, normalizedNormal)); vec3 lightReflect = normalize(reflect(lightDirection, normalizedNormal));
float specularFactor = max(0.0, dot(vertexToEye, lightReflect)); float specularFactor = max(0.0, dot(vertexToEye, lightReflect));
specularFactor = pow(specularFactor, material.specularStrength); specularFactor = pow(specularFactor, material.specularStrength);
specular = pointLight.color * material.specular * specularFactor; specular = pointLight.color * material.specular * specularFactor;
} }
float attenuation = pow(max(0.0, (1.0 - (distance / pointLight.radius))), pointLight.falloff + 1.0f); float attenuation = pow(max(0.0, (1.0 - (distance / pointLight.radius))), pointLight.falloff + 1.0f);
return (((diffuse + specular) * attenuation) * pointLight.intensity); return (((diffuse + specular) * attenuation) * pointLight.intensity);
} }
else else
{ {
return vec4(0.0); return vec4(0.0);
} }
} }
vec4 calcSpotLight(Light spotLight) vec4 calcSpotLight(Light spotLight)
{ {
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
vec3 lightToSurface = vertex - spotLight.position; vec3 lightToSurface = vertex - spotLight.position;
float angle = dot(spotLight.direction, normalize(lightToSurface)); float angle = dot(spotLight.direction, normalize(lightToSurface));
if(acos(angle) < spotLight.outerAngle) if(acos(angle) < spotLight.outerAngle)
{ {
color = calcPointLight(spotLight); color = calcPointLight(spotLight);
color *= smoothstep(cos(spotLight.outerAngle), cos(spotLight.innerAngle), angle); color *= smoothstep(cos(spotLight.outerAngle), cos(spotLight.innerAngle), angle);
if(light.castShadow != 0) if(light.castShadow != 0)
{ {
float shadowFactor = calcShadowFactor(vertLightSpace.xyz / vertLightSpace.w); float shadowFactor = calcShadowFactor(vertLightSpace.xyz / vertLightSpace.w);
color *= shadowFactor; color *= shadowFactor;
} }
} }
return color;// * shadowFactor; return color;// * shadowFactor;
} }
vec4 doForwardLightLoop() vec4 doForwardLightLoop()
{ {
vec4 totalLightColor = vec4(0.0); vec4 totalLightColor = vec4(0.0);
for(int i = 0; i < numLights; i++) for(int i = 0; i < numLights; i++)
{ {
switch(lightList[i].type) switch(lightList[i].type)
{ {
case LT_DIR: totalLightColor += calcDirLight(lightList[i]); break; case LT_DIR: totalLightColor += calcDirLight(lightList[i]); break;
case LT_SPOT: totalLightColor += calcSpotLight(lightList[i]); break; case LT_SPOT: totalLightColor += calcSpotLight(lightList[i]); break;
case LT_POINT: totalLightColor += calcPointLight(lightList[i]); break; case LT_POINT: totalLightColor += calcPointLight(lightList[i]); break;
} }
} }
return totalLightColor; return totalLightColor;
} }
vec4 calculateLight() vec4 calculateLight()
{ {
vec4 totalLightColor = vec4(0.0); vec4 totalLightColor = vec4(0.0);
switch(light.type) switch(light.type)
{ {
case LT_DIR: totalLightColor = calcDirLight(light); break; case LT_DIR: totalLightColor = calcDirLight(light); break;
case LT_SPOT: totalLightColor = calcSpotLight(light); break; case LT_SPOT: totalLightColor = calcSpotLight(light); break;
case LT_POINT: totalLightColor = calcPointLight(light); break; case LT_POINT: totalLightColor = calcPointLight(light); break;
} }
return totalLightColor; return totalLightColor;
} }

@ -1,10 +1,10 @@
//include fog.glsl phongCommon.glsl common.glsl commonFrag.glsl version.glsl //include fog.glsl phongCommon.glsl common.glsl commonFrag.glsl version.glsl
uniform sampler2D sampler; uniform sampler2D sampler;
void main() void main()
{ {
vec4 pixelColor = diffuseColor * texture(sampler, uv); vec4 pixelColor = diffuseColor * texture(sampler, uv);
vec4 totalLightColor = calculateLight(); vec4 totalLightColor = calculateLight();
fragColor = applyFog(pixelColor * (totalLightColor + ambientLight)); fragColor = applyFog(pixelColor * (totalLightColor + ambientLight));
} }

@ -1,13 +1,13 @@
#version 130 #version 130
in vec2 uv; in vec2 uv;
out vec4 fragColor; out vec4 fragColor;
uniform vec4 textColor; uniform vec4 textColor;
uniform sampler2D sampler; uniform sampler2D sampler;
void main() void main()
{ {
fragColor = texture2D(sampler, uv) * textColor; fragColor = texture2D(sampler, uv) * textColor;
} }

@ -1,14 +1,14 @@
#version 130 #version 130
in vec2 vPosition; in vec2 vPosition;
in vec2 vUV; in vec2 vUV;
out vec2 uv; out vec2 uv;
uniform mat4 mvp; uniform mat4 mvp;
void main() void main()
{ {
uv = vUV; uv = vUV;
gl_Position = mvp * vec4(vPosition, 0, 1.0); gl_Position = mvp * vec4(vPosition, 0, 1.0);
} }

@ -1,13 +1,13 @@
#version 130 #version 130
uniform sampler2D sampler; uniform sampler2D sampler;
in vec2 uv; in vec2 uv;
out vec4 fragColor; out vec4 fragColor;
void main() void main()
{ {
// fragColor = vec4(0, 1, 0, 1) * texture2D(sampler, uv.st); // fragColor = vec4(0, 1, 0, 1) * texture2D(sampler, uv.st);
fragColor = vec4(0, 1, 0, 1); fragColor = vec4(0, 1, 0, 1);
} }

@ -1,12 +1,12 @@
#version 130 #version 130
in vec3 vPosition; in vec3 vPosition;
in vec2 vUV; in vec2 vUV;
out vec2 uv; out vec2 uv;
void main() void main()
{ {
uv = vUV; uv = vUV;
gl_Position = vec4(vPosition, 1.0); gl_Position = vec4(vPosition, 1.0);
} }

@ -1,10 +1,10 @@
//include fog.glsl common.glsl commonFrag.glsl version.glsl //include fog.glsl common.glsl commonFrag.glsl version.glsl
uniform sampler2D diffuse_texture; uniform sampler2D diffuse_texture;
out vec4 frag_color; out vec4 frag_color;
void main() void main()
{ {
frag_color = apply_fog(diffuse_color * texture(diffuse_texture, uv)); frag_color = apply_fog(diffuse_color * texture(diffuse_texture, uv));
} }

@ -1,7 +1,7 @@
//include commonVert.glsl version.glsl //include commonVert.glsl version.glsl
void main() void main()
{ {
gl_Position = transformPosition(vPosition); gl_Position = transformPosition(vPosition);
setOutputs(); setOutputs();
} }

@ -1,9 +1,9 @@
//include fog.glsl commonFrag.glsl common.glsl version.glsl //include fog.glsl commonFrag.glsl common.glsl version.glsl
uniform sampler2D sampler; uniform sampler2D sampler;
void main() void main()
{ {
vec4 pixelColor = diffuseColor * texture(sampler, uv); vec4 pixelColor = diffuseColor * texture(sampler, uv);
fragColor = applyFog(pixelColor); fragColor = applyFog(pixelColor);
} }

@ -1,7 +1,7 @@
//include commonVert.glsl version.glsl //include commonVert.glsl version.glsl
void main() void main()
{ {
gl_Position = transformPosition(vPosition); gl_Position = transformPosition(vPosition);
setOutputs(); setOutputs();
} }

@ -1,121 +1,121 @@
solution "Symmetry" solution "Symmetry"
configurations { "Debug", "Release" } configurations { "Debug", "Release" }
platforms {"x64"} platforms {"x64"}
location(_ACTION) location(_ACTION)
configuration {"linux"} configuration {"linux"}
postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets debug/assets"} postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets debug/assets"}
postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets release/assets"} postbuildcommands {"ln -fs " .. os.getcwd() .. "/../assets release/assets"}
buildoptions {"-Wall", "-std=c99"} buildoptions {"-Wall", "-std=c99"}
configuration {"windows", "vs2017"} configuration {"windows", "vs2017"}
defines {"_CRT_SECURE_NO_WARNINGS"} defines {"_CRT_SECURE_NO_WARNINGS"}
flags {"NoIncrementalLink", "NoEditAndContinue"} flags {"NoIncrementalLink", "NoEditAndContinue"}
local windowsPlatform = string.gsub(os.getenv("WindowsSDKVersion") or "10.0.16299.0", "\\", "") local windowsPlatform = string.gsub(os.getenv("WindowsSDKVersion") or "10.0.16299.0", "\\", "")
local action = premake.action.current() local action = premake.action.current()
if(action ~= nil and _ACTION == "vs2017") then if(action ~= nil and _ACTION == "vs2017") then
action.vstudio.windowsTargetPlatformVersion = windowsPlatform action.vstudio.windowsTargetPlatformVersion = windowsPlatform
action.vstudio.windowsTargetPlatformMinVersion = windowsPlatform action.vstudio.windowsTargetPlatformMinVersion = windowsPlatform
end end
configuration "Debug" configuration "Debug"
if (_ACTION ~= nil and _ACTION ~= "postbuild_copy" and _ACTION ~= "build_addon") then if (_ACTION ~= nil and _ACTION ~= "postbuild_copy" and _ACTION ~= "build_addon") then
os.mkdir(_ACTION .. "/debug") os.mkdir(_ACTION .. "/debug")
targetdir (_ACTION .. "/debug") targetdir (_ACTION .. "/debug")
end end
defines { "DEBUG" } defines { "DEBUG" }
flags { "Symbols" } flags { "Symbols" }
configuration "Release" configuration "Release"
if (_ACTION ~= nil and _ACTION ~= "postbuild_copy" and _ACTION ~= "build_addon") then if (_ACTION ~= nil and _ACTION ~= "postbuild_copy" and _ACTION ~= "build_addon") then
os.mkdir(_ACTION .. "/release") os.mkdir(_ACTION .. "/release")
targetdir (_ACTION .. "/release") targetdir (_ACTION .. "/release")
end end
defines { "NDEBUG", "ExtraWarnings" } defines { "NDEBUG", "ExtraWarnings" }
flags { "OptimizeSpeed"} flags { "OptimizeSpeed"}
newaction { newaction {
trigger = "postbuild_copy", trigger = "postbuild_copy",
description = "Action to copy relevant dlls to executable directory after build", description = "Action to copy relevant dlls to executable directory after build",
execute = function () execute = function ()
-- local copy_dest_dir = "" -- local copy_dest_dir = ""
-- local symlink_dest_dir = "" -- local symlink_dest_dir = ""
-- if(_ARGS[1] == "vs2017") then -- if(_ARGS[1] == "vs2017") then
-- copy_dest_dir = "vs2017" -- copy_dest_dir = "vs2017"
-- symlink_dest_dir = "..\\..\\..\\assets" -- symlink_dest_dir = "..\\..\\..\\assets"
-- printf("Copying DLLs to visual studio build directory...\n") -- printf("Copying DLLs to visual studio build directory...\n")
-- end -- end
-- -- Create sym links -- -- Create sym links
-- local output = os.outputof("mklink /D vs2017\\debug\\assets ..\\..\\..\\assets" .. path.translate(copy_dest_dir, "\\") .. "\\debug\\assets " .. symlink_dest_dir) -- local output = os.outputof("mklink /D vs2017\\debug\\assets ..\\..\\..\\assets" .. path.translate(copy_dest_dir, "\\") .. "\\debug\\assets " .. symlink_dest_dir)
-- printf("MKlink debug output : %s", output) -- printf("MKlink debug output : %s", output)
-- output = os.outputof("mklink /D " .. path.translate(copy_dest_dir, "\\") .. "\\release\\assets " ..symlink_dest_dir) -- output = os.outputof("mklink /D " .. path.translate(copy_dest_dir, "\\") .. "\\release\\assets " ..symlink_dest_dir)
-- printf("MKlink release output : %s", output) -- printf("MKlink release output : %s", output)
end end
} }
------------------------- -------------------------
-- Game -- Game
------------------------- -------------------------
project "Symmetry" project "Symmetry"
kind "ConsoleApp" kind "ConsoleApp"
targetname "Symmetry" targetname "Symmetry"
language "C" language "C"
files { "../src/common/**.c", "../src/common/**.h", "../src/system/**.c", "../src/system/**.h", "../src/game/**.h", "../src/game/**.c"} files { "../src/common/**.c", "../src/common/**.h", "../src/system/**.c", "../src/system/**.h", "../src/game/**.h", "../src/game/**.c"}
includedirs {"../include/common"} includedirs {"../include/common"}
defines {"USE_GLAD"} defines {"USE_GLAD"}
configuration "linux" configuration "linux"
includedirs {"../include/linux/sdl2/", "../include/common/soloud/", "../include/linux/"} includedirs {"../include/linux/sdl2/", "../include/common/soloud/", "../include/linux/"}
libdirs {"../lib/linux/sdl2/", "../lib/linux/soloud/", "../lib/linux/ode/"} libdirs {"../lib/linux/sdl2/", "../lib/linux/soloud/", "../lib/linux/ode/"}
linkoptions {"'-Wl,-rpath,$$ORIGIN'"} linkoptions {"'-Wl,-rpath,$$ORIGIN'"}
links {"SDL2", "m", "ode", "pthread"} links {"SDL2", "m", "ode", "pthread"}
configuration {"windows", "vs2017"} configuration {"windows", "vs2017"}
includedirs {"../include/windows/sdl2/", "../include/common/soloud/", "../include/windows/"} includedirs {"../include/windows/sdl2/", "../include/common/soloud/", "../include/windows/"}
libdirs {"../lib/windows/sdl2/", "../lib/windows/soloud/", "../lib/windows/ode/"} libdirs {"../lib/windows/sdl2/", "../lib/windows/soloud/", "../lib/windows/ode/"}
configuration "Debug" configuration "Debug"
links {"soloud_x64_d"} links {"soloud_x64_d"}
defines {"GL_DEBUG_CONTEXT"} defines {"GL_DEBUG_CONTEXT"}
configuration "Release" configuration "Release"
links {"soloud_x64"} links {"soloud_x64"}
configuration {"windows", "Release", "vs2017"} configuration {"windows", "Release", "vs2017"}
postbuildcommands postbuildcommands
{ {
"copy ..\\..\\lib\\windows\\sdl2\\SDL2.dll release\\ /Y", "copy ..\\..\\lib\\windows\\sdl2\\SDL2.dll release\\ /Y",
"copy ..\\..\\lib\\windows\\soloud\\soloud_x64.dll release\\ /Y", "copy ..\\..\\lib\\windows\\soloud\\soloud_x64.dll release\\ /Y",
"copy ..\\..\\lib\\windows\\ode\\ode_double.dll release\\ /Y", "copy ..\\..\\lib\\windows\\ode\\ode_double.dll release\\ /Y",
"xcopy ..\\..\\assets ..\\..\\bin\\assets /s /e /h /i /y /d", "xcopy ..\\..\\assets ..\\..\\bin\\assets /s /e /h /i /y /d",
"copy release\\Symmetry.exe ..\\..\\bin\\ /Y", "copy release\\Symmetry.exe ..\\..\\bin\\ /Y",
"copy release\\SDL2.dll ..\\..\\bin\\ /Y", "copy release\\SDL2.dll ..\\..\\bin\\ /Y",
"copy release\\soloud_x64.dll ..\\..\\bin\\ /Y", "copy release\\soloud_x64.dll ..\\..\\bin\\ /Y",
"copy release\\ode_double.dll ..\\..\\bin\\ /Y", "copy release\\ode_double.dll ..\\..\\bin\\ /Y",
"rmdir release\\assets", "rmdir release\\assets",
"mklink /D release\\assets ..\\..\\..\\assets" "mklink /D release\\assets ..\\..\\..\\assets"
} }
links {"ode_double", "SDL2"} links {"ode_double", "SDL2"}
configuration {"windows", "Debug", "vs2017"} configuration {"windows", "Debug", "vs2017"}
postbuildcommands postbuildcommands
{ {
"copy ..\\..\\lib\\windows\\sdl2\\SDL2d.dll debug\\ /Y", "copy ..\\..\\lib\\windows\\sdl2\\SDL2d.dll debug\\ /Y",
"copy ..\\..\\lib\\windows\\soloud\\soloud_x64_d.dll debug\\ /Y", "copy ..\\..\\lib\\windows\\soloud\\soloud_x64_d.dll debug\\ /Y",
"copy ..\\..\\lib\\windows\\ode\\ode_doubled.dll debug\\ /Y", "copy ..\\..\\lib\\windows\\ode\\ode_doubled.dll debug\\ /Y",
"copy ..\\..\\lib\\windows\\ode\\ode_doubled.pdb debug\\ /Y", "copy ..\\..\\lib\\windows\\ode\\ode_doubled.pdb debug\\ /Y",
"rmdir debug\\assets", "rmdir debug\\assets",
"mklink /D debug\\assets ..\\..\\..\\assets" "mklink /D debug\\assets ..\\..\\..\\assets"
} }
links {"ode_doubled", "SDL2d"} links {"ode_doubled", "SDL2d"}
newaction { newaction {
trigger = "build_addon", trigger = "build_addon",
description = "Build blender addon into zip file that can be loaded into blender, needs zip installed and available on PATH(Only works on bash/nix-style shell for now)", description = "Build blender addon into zip file that can be loaded into blender, needs zip installed and available on PATH(Only works on bash/nix-style shell for now)",
execute = function () execute = function ()
local output = os.outputof("cd ../blender_addon && zip -r io_symmetry_exp.zip io_symmetry_exp/__init__.py io_symmetry_exp/exporter.py && mv io_symmetry_exp.zip ../build"); local output = os.outputof("cd ../blender_addon && zip -r io_symmetry_exp.zip io_symmetry_exp/__init__.py io_symmetry_exp/exporter.py && mv io_symmetry_exp.zip ../build");
printf("Output of blender addon build : \n%s\n", output) printf("Output of blender addon build : \n%s\n", output)
end end
} }

File diff suppressed because it is too large Load Diff

@ -1,481 +1,481 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_H #ifndef SOLOUD_H
#define SOLOUD_H #define SOLOUD_H
#include <stdlib.h> // rand #include <stdlib.h> // rand
#include <math.h> // sin #include <math.h> // sin
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265359 #define M_PI 3.14159265359
#endif #endif
#if defined(_WIN32)||defined(_WIN64) #if defined(_WIN32)||defined(_WIN64)
#define WINDOWS_VERSION #define WINDOWS_VERSION
#endif #endif
#if !defined(DISABLE_SIMD) #if !defined(DISABLE_SIMD)
#if defined(__x86_64__) || defined( _M_X64 ) || defined( __i386 ) || defined( _M_IX86 ) #if defined(__x86_64__) || defined( _M_X64 ) || defined( __i386 ) || defined( _M_IX86 )
#define SOLOUD_SSE_INTRINSICS #define SOLOUD_SSE_INTRINSICS
#endif #endif
#endif #endif
#define SOLOUD_VERSION 111 #define SOLOUD_VERSION 111
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// Configuration defines // Configuration defines
// Maximum number of filters per stream // Maximum number of filters per stream
#define FILTERS_PER_STREAM 8 #define FILTERS_PER_STREAM 8
// Number of samples to process on one go // Number of samples to process on one go
#define SAMPLE_GRANULARITY 512 #define SAMPLE_GRANULARITY 512
// Maximum number of concurrent voices (hard limit is 4095) // Maximum number of concurrent voices (hard limit is 4095)
#define VOICE_COUNT 1024 #define VOICE_COUNT 1024
// Use linear resampler // Use linear resampler
#define RESAMPLER_LINEAR #define RESAMPLER_LINEAR
// 1)mono, 2)stereo 4)quad 6)5.1 // 1)mono, 2)stereo 4)quad 6)5.1
#define MAX_CHANNELS 6 #define MAX_CHANNELS 6
// //
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// Typedefs have to be made before the includes, as the // Typedefs have to be made before the includes, as the
// includes depend on them. // includes depend on them.
namespace SoLoud namespace SoLoud
{ {
class Soloud; class Soloud;
typedef void (*mutexCallFunction)(void *aMutexPtr); typedef void (*mutexCallFunction)(void *aMutexPtr);
typedef void (*soloudCallFunction)(Soloud *aSoloud); typedef void (*soloudCallFunction)(Soloud *aSoloud);
typedef unsigned int result; typedef unsigned int result;
typedef unsigned int handle; typedef unsigned int handle;
typedef double time; typedef double time;
}; };
namespace SoLoud namespace SoLoud
{ {
// Class that handles aligned allocations to support vectorized operations // Class that handles aligned allocations to support vectorized operations
class AlignedFloatBuffer class AlignedFloatBuffer
{ {
public: public:
float *mData; // aligned pointer float *mData; // aligned pointer
unsigned char *mBasePtr; // raw allocated pointer (for delete) unsigned char *mBasePtr; // raw allocated pointer (for delete)
// ctor // ctor
AlignedFloatBuffer(); AlignedFloatBuffer();
// Allocate and align buffer // Allocate and align buffer
result init(unsigned int aFloats); result init(unsigned int aFloats);
// dtor // dtor
~AlignedFloatBuffer(); ~AlignedFloatBuffer();
}; };
}; };
#include "soloud_filter.h" #include "soloud_filter.h"
#include "soloud_fader.h" #include "soloud_fader.h"
#include "soloud_audiosource.h" #include "soloud_audiosource.h"
#include "soloud_bus.h" #include "soloud_bus.h"
#include "soloud_error.h" #include "soloud_error.h"
namespace SoLoud namespace SoLoud
{ {
// Soloud core class. // Soloud core class.
class Soloud class Soloud
{ {
public: public:
// Back-end data; content is up to the back-end implementation. // Back-end data; content is up to the back-end implementation.
void * mBackendData; void * mBackendData;
// Pointer for the audio thread mutex. // Pointer for the audio thread mutex.
void * mAudioThreadMutex; void * mAudioThreadMutex;
// Called by SoLoud to shut down the back-end. If NULL, not called. Should be set by back-end. // Called by SoLoud to shut down the back-end. If NULL, not called. Should be set by back-end.
soloudCallFunction mBackendCleanupFunc; soloudCallFunction mBackendCleanupFunc;
// CTor // CTor
Soloud(); Soloud();
// DTor // DTor
~Soloud(); ~Soloud();
enum BACKENDS enum BACKENDS
{ {
AUTO = 0, AUTO = 0,
SDL, SDL,
SDL2, SDL2,
PORTAUDIO, PORTAUDIO,
WINMM, WINMM,
XAUDIO2, XAUDIO2,
WASAPI, WASAPI,
ALSA, ALSA,
OSS, OSS,
OPENAL, OPENAL,
COREAUDIO, COREAUDIO,
OPENSLES, OPENSLES,
VITA_HOMEBREW, VITA_HOMEBREW,
NULLDRIVER, NULLDRIVER,
BACKEND_MAX, BACKEND_MAX,
}; };
enum FLAGS enum FLAGS
{ {
// Use round-off clipper // Use round-off clipper
CLIP_ROUNDOFF = 1, CLIP_ROUNDOFF = 1,
ENABLE_VISUALIZATION = 2, ENABLE_VISUALIZATION = 2,
LEFT_HANDED_3D = 4 LEFT_HANDED_3D = 4
}; };
// Initialize SoLoud. Must be called before SoLoud can be used. // Initialize SoLoud. Must be called before SoLoud can be used.
result init(unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aBackend = Soloud::AUTO, unsigned int aSamplerate = Soloud::AUTO, unsigned int aBufferSize = Soloud::AUTO, unsigned int aChannels = 2); result init(unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aBackend = Soloud::AUTO, unsigned int aSamplerate = Soloud::AUTO, unsigned int aBufferSize = Soloud::AUTO, unsigned int aChannels = 2);
// Deinitialize SoLoud. Must be called before shutting down. // Deinitialize SoLoud. Must be called before shutting down.
void deinit(); void deinit();
// Query SoLoud version number (should equal to SOLOUD_VERSION macro) // Query SoLoud version number (should equal to SOLOUD_VERSION macro)
unsigned int getVersion() const; unsigned int getVersion() const;
// Translate error number to an asciiz string // Translate error number to an asciiz string
const char * getErrorString(result aErrorCode) const; const char * getErrorString(result aErrorCode) const;
// Returns current backend ID (BACKENDS enum) // Returns current backend ID (BACKENDS enum)
unsigned int getBackendId(); unsigned int getBackendId();
// Returns current backend string. May be NULL. // Returns current backend string. May be NULL.
const char * getBackendString(); const char * getBackendString();
// Returns current backend channel count (1 mono, 2 stereo, etc) // Returns current backend channel count (1 mono, 2 stereo, etc)
unsigned int getBackendChannels(); unsigned int getBackendChannels();
// Returns current backend sample rate // Returns current backend sample rate
unsigned int getBackendSamplerate(); unsigned int getBackendSamplerate();
// Returns current backend buffer size // Returns current backend buffer size
unsigned int getBackendBufferSize(); unsigned int getBackendBufferSize();
// Set speaker position in 3d space // Set speaker position in 3d space
result setSpeakerPosition(unsigned int aChannel, float aX, float aY, float aZ); result setSpeakerPosition(unsigned int aChannel, float aX, float aY, float aZ);
// Start playing a sound. Returns voice handle, which can be ignored or used to alter the playing sound's parameters. Negative volume means to use default. // Start playing a sound. Returns voice handle, which can be ignored or used to alter the playing sound's parameters. Negative volume means to use default.
handle play(AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, bool aPaused = 0, unsigned int aBus = 0); handle play(AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, bool aPaused = 0, unsigned int aBus = 0);
// Start playing a sound delayed in relation to other sounds called via this function. Negative volume means to use default. // Start playing a sound delayed in relation to other sounds called via this function. Negative volume means to use default.
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, unsigned int aBus = 0); handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = -1.0f, float aPan = 0.0f, unsigned int aBus = 0);
// Start playing a 3d audio source // Start playing a 3d audio source
handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0, unsigned int aBus = 0); handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0, unsigned int aBus = 0);
// Start playing a 3d audio source, delayed in relation to other sounds called via this function. // Start playing a 3d audio source, delayed in relation to other sounds called via this function.
handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, unsigned int aBus = 0); handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, unsigned int aBus = 0);
// Start playing a sound without any panning. It will be played at full volume. // Start playing a sound without any panning. It will be played at full volume.
handle playBackground(AudioSource &aSound, float aVolume = -1.0f, bool aPaused = 0, unsigned int aBus = 0); handle playBackground(AudioSource &aSound, float aVolume = -1.0f, bool aPaused = 0, unsigned int aBus = 0);
// Seek the audio stream to certain point in time. Some streams can't seek backwards. Relative play speed affects time. // Seek the audio stream to certain point in time. Some streams can't seek backwards. Relative play speed affects time.
void seek(handle aVoiceHandle, time aSeconds); void seek(handle aVoiceHandle, time aSeconds);
// Stop the sound. // Stop the sound.
void stop(handle aVoiceHandle); void stop(handle aVoiceHandle);
// Stop all voices. // Stop all voices.
void stopAll(); void stopAll();
// Stop all voices that play this sound source // Stop all voices that play this sound source
void stopAudioSource(AudioSource &aSound); void stopAudioSource(AudioSource &aSound);
// Set a live filter parameter. Use 0 for the global filters. // Set a live filter parameter. Use 0 for the global filters.
void setFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); void setFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue);
// Get a live filter parameter. Use 0 for the global filters. // Get a live filter parameter. Use 0 for the global filters.
float getFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); float getFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId);
// Fade a live filter parameter. Use 0 for the global filters. // Fade a live filter parameter. Use 0 for the global filters.
void fadeFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, time aTime); void fadeFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, time aTime);
// Oscillate a live filter parameter. Use 0 for the global filters. // Oscillate a live filter parameter. Use 0 for the global filters.
void oscillateFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, time aTime); void oscillateFilterParameter(handle aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, time aTime);
// Get current play time, in seconds. // Get current play time, in seconds.
time getStreamTime(handle aVoiceHandle); time getStreamTime(handle aVoiceHandle);
// Get current pause state. // Get current pause state.
bool getPause(handle aVoiceHandle); bool getPause(handle aVoiceHandle);
// Get current volume. // Get current volume.
float getVolume(handle aVoiceHandle); float getVolume(handle aVoiceHandle);
// Get current overall volume (set volume * 3d volume) // Get current overall volume (set volume * 3d volume)
float getOverallVolume(handle aVoiceHandle); float getOverallVolume(handle aVoiceHandle);
// Get current pan. // Get current pan.
float getPan(handle aVoiceHandle); float getPan(handle aVoiceHandle);
// Get current sample rate. // Get current sample rate.
float getSamplerate(handle aVoiceHandle); float getSamplerate(handle aVoiceHandle);
// Get current voice protection state. // Get current voice protection state.
bool getProtectVoice(handle aVoiceHandle); bool getProtectVoice(handle aVoiceHandle);
// Get the current number of busy voices. // Get the current number of busy voices.
unsigned int getActiveVoiceCount(); unsigned int getActiveVoiceCount();
// Get the current number of voices in SoLoud // Get the current number of voices in SoLoud
unsigned int getVoiceCount(); unsigned int getVoiceCount();
// Check if the handle is still valid, or if the sound has stopped. // Check if the handle is still valid, or if the sound has stopped.
bool isValidVoiceHandle(handle aVoiceHandle); bool isValidVoiceHandle(handle aVoiceHandle);
// Get current relative play speed. // Get current relative play speed.
float getRelativePlaySpeed(handle aVoiceHandle); float getRelativePlaySpeed(handle aVoiceHandle);
// Get current post-clip scaler value. // Get current post-clip scaler value.
float getPostClipScaler() const; float getPostClipScaler() const;
// Get current global volume // Get current global volume
float getGlobalVolume() const; float getGlobalVolume() const;
// Get current maximum active voice setting // Get current maximum active voice setting
unsigned int getMaxActiveVoiceCount() const; unsigned int getMaxActiveVoiceCount() const;
// Query whether a voice is set to loop. // Query whether a voice is set to loop.
bool getLooping(handle aVoiceHandle); bool getLooping(handle aVoiceHandle);
// Set voice's loop state // Set voice's loop state
void setLooping(handle aVoiceHandle, bool aLooping); void setLooping(handle aVoiceHandle, bool aLooping);
// Set current maximum active voice setting // Set current maximum active voice setting
result setMaxActiveVoiceCount(unsigned int aVoiceCount); result setMaxActiveVoiceCount(unsigned int aVoiceCount);
// Set behavior for inaudible sounds // Set behavior for inaudible sounds
void setInaudibleBehavior(handle aVoiceHandle, bool aMustTick, bool aKill); void setInaudibleBehavior(handle aVoiceHandle, bool aMustTick, bool aKill);
// Set the global volume // Set the global volume
void setGlobalVolume(float aVolume); void setGlobalVolume(float aVolume);
// Set the post clip scaler value // Set the post clip scaler value
void setPostClipScaler(float aScaler); void setPostClipScaler(float aScaler);
// Set the pause state // Set the pause state
void setPause(handle aVoiceHandle, bool aPause); void setPause(handle aVoiceHandle, bool aPause);
// Pause all voices // Pause all voices
void setPauseAll(bool aPause); void setPauseAll(bool aPause);
// Set the relative play speed // Set the relative play speed
result setRelativePlaySpeed(handle aVoiceHandle, float aSpeed); result setRelativePlaySpeed(handle aVoiceHandle, float aSpeed);
// Set the voice protection state // Set the voice protection state
void setProtectVoice(handle aVoiceHandle, bool aProtect); void setProtectVoice(handle aVoiceHandle, bool aProtect);
// Set the sample rate // Set the sample rate
void setSamplerate(handle aVoiceHandle, float aSamplerate); void setSamplerate(handle aVoiceHandle, float aSamplerate);
// Set panning value; -1 is left, 0 is center, 1 is right // Set panning value; -1 is left, 0 is center, 1 is right
void setPan(handle aVoiceHandle, float aPan); void setPan(handle aVoiceHandle, float aPan);
// Set absolute left/right volumes // Set absolute left/right volumes
void setPanAbsolute(handle aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume = 0, float aRBVolume = 0, float aCVolume = 0, float aSVolume = 0); void setPanAbsolute(handle aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume = 0, float aRBVolume = 0, float aCVolume = 0, float aSVolume = 0);
// Set overall volume // Set overall volume
void setVolume(handle aVoiceHandle, float aVolume); void setVolume(handle aVoiceHandle, float aVolume);
// Set delay, in samples, before starting to play samples. Calling this on a live sound will cause glitches. // Set delay, in samples, before starting to play samples. Calling this on a live sound will cause glitches.
void setDelaySamples(handle aVoiceHandle, unsigned int aSamples); void setDelaySamples(handle aVoiceHandle, unsigned int aSamples);
// Set up volume fader // Set up volume fader
void fadeVolume(handle aVoiceHandle, float aTo, time aTime); void fadeVolume(handle aVoiceHandle, float aTo, time aTime);
// Set up panning fader // Set up panning fader
void fadePan(handle aVoiceHandle, float aTo, time aTime); void fadePan(handle aVoiceHandle, float aTo, time aTime);
// Set up relative play speed fader // Set up relative play speed fader
void fadeRelativePlaySpeed(handle aVoiceHandle, float aTo, time aTime); void fadeRelativePlaySpeed(handle aVoiceHandle, float aTo, time aTime);
// Set up global volume fader // Set up global volume fader
void fadeGlobalVolume(float aTo, time aTime); void fadeGlobalVolume(float aTo, time aTime);
// Schedule a stream to pause // Schedule a stream to pause
void schedulePause(handle aVoiceHandle, time aTime); void schedulePause(handle aVoiceHandle, time aTime);
// Schedule a stream to stop // Schedule a stream to stop
void scheduleStop(handle aVoiceHandle, time aTime); void scheduleStop(handle aVoiceHandle, time aTime);
// Set up volume oscillator // Set up volume oscillator
void oscillateVolume(handle aVoiceHandle, float aFrom, float aTo, time aTime); void oscillateVolume(handle aVoiceHandle, float aFrom, float aTo, time aTime);
// Set up panning oscillator // Set up panning oscillator
void oscillatePan(handle aVoiceHandle, float aFrom, float aTo, time aTime); void oscillatePan(handle aVoiceHandle, float aFrom, float aTo, time aTime);
// Set up relative play speed oscillator // Set up relative play speed oscillator
void oscillateRelativePlaySpeed(handle aVoiceHandle, float aFrom, float aTo, time aTime); void oscillateRelativePlaySpeed(handle aVoiceHandle, float aFrom, float aTo, time aTime);
// Set up global volume oscillator // Set up global volume oscillator
void oscillateGlobalVolume(float aFrom, float aTo, time aTime); void oscillateGlobalVolume(float aFrom, float aTo, time aTime);
// Set global filters. Set to NULL to clear the filter. // Set global filters. Set to NULL to clear the filter.
void setGlobalFilter(unsigned int aFilterId, Filter *aFilter); void setGlobalFilter(unsigned int aFilterId, Filter *aFilter);
// Enable or disable visualization data gathering // Enable or disable visualization data gathering
void setVisualizationEnable(bool aEnable); void setVisualizationEnable(bool aEnable);
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use. // Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
float *calcFFT(); float *calcFFT();
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use. // Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
float *getWave(); float *getWave();
// Get current loop count. Returns 0 if handle is not valid. (All audio sources may not update loop count) // Get current loop count. Returns 0 if handle is not valid. (All audio sources may not update loop count)
unsigned int getLoopCount(handle aVoiceHandle); unsigned int getLoopCount(handle aVoiceHandle);
// Get audiosource-specific information from a voice. // Get audiosource-specific information from a voice.
float getInfo(handle aVoiceHandle, unsigned int aInfoKey); float getInfo(handle aVoiceHandle, unsigned int aInfoKey);
// Create a voice group. Returns 0 if unable (out of voice groups / out of memory) // Create a voice group. Returns 0 if unable (out of voice groups / out of memory)
handle createVoiceGroup(); handle createVoiceGroup();
// Destroy a voice group. // Destroy a voice group.
result destroyVoiceGroup(handle aVoiceGroupHandle); result destroyVoiceGroup(handle aVoiceGroupHandle);
// Add a voice handle to a voice group // Add a voice handle to a voice group
result addVoiceToGroup(handle aVoiceGroupHandle, handle aVoiceHandle); result addVoiceToGroup(handle aVoiceGroupHandle, handle aVoiceHandle);
// Is this handle a valid voice group? // Is this handle a valid voice group?
bool isVoiceGroup(handle aVoiceGroupHandle); bool isVoiceGroup(handle aVoiceGroupHandle);
// Is this voice group empty? // Is this voice group empty?
bool isVoiceGroupEmpty(handle aVoiceGroupHandle); bool isVoiceGroupEmpty(handle aVoiceGroupHandle);
// Perform 3d audio parameter update // Perform 3d audio parameter update
void update3dAudio(); void update3dAudio();
// Set the speed of sound constant for doppler // Set the speed of sound constant for doppler
result set3dSoundSpeed(float aSpeed); result set3dSoundSpeed(float aSpeed);
// Get the current speed of sound constant for doppler // Get the current speed of sound constant for doppler
float get3dSoundSpeed(); float get3dSoundSpeed();
// Set 3d listener parameters // Set 3d listener parameters
void set3dListenerParameters(float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); void set3dListenerParameters(float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f);
// Set 3d listener position // Set 3d listener position
void set3dListenerPosition(float aPosX, float aPosY, float aPosZ); void set3dListenerPosition(float aPosX, float aPosY, float aPosZ);
// Set 3d listener "at" vector // Set 3d listener "at" vector
void set3dListenerAt(float aAtX, float aAtY, float aAtZ); void set3dListenerAt(float aAtX, float aAtY, float aAtZ);
// set 3d listener "up" vector // set 3d listener "up" vector
void set3dListenerUp(float aUpX, float aUpY, float aUpZ); void set3dListenerUp(float aUpX, float aUpY, float aUpZ);
// Set 3d listener velocity // Set 3d listener velocity
void set3dListenerVelocity(float aVelocityX, float aVelocityY, float aVelocityZ); void set3dListenerVelocity(float aVelocityX, float aVelocityY, float aVelocityZ);
// Set 3d audio source parameters // Set 3d audio source parameters
void set3dSourceParameters(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f); void set3dSourceParameters(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX = 0.0f, float aVelocityY = 0.0f, float aVelocityZ = 0.0f);
// Set 3d audio source position // Set 3d audio source position
void set3dSourcePosition(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ); void set3dSourcePosition(handle aVoiceHandle, float aPosX, float aPosY, float aPosZ);
// Set 3d audio source velocity // Set 3d audio source velocity
void set3dSourceVelocity(handle aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); void set3dSourceVelocity(handle aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ);
// Set 3d audio source min/max distance (distance < min means max volume) // Set 3d audio source min/max distance (distance < min means max volume)
void set3dSourceMinMaxDistance(handle aVoiceHandle, float aMinDistance, float aMaxDistance); void set3dSourceMinMaxDistance(handle aVoiceHandle, float aMinDistance, float aMaxDistance);
// Set 3d audio source attenuation parameters // Set 3d audio source attenuation parameters
void set3dSourceAttenuation(handle aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void set3dSourceAttenuation(handle aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
// Set 3d audio source doppler factor to reduce or enhance doppler effect. Default = 1.0 // Set 3d audio source doppler factor to reduce or enhance doppler effect. Default = 1.0
void set3dSourceDopplerFactor(handle aVoiceHandle, float aDopplerFactor); void set3dSourceDopplerFactor(handle aVoiceHandle, float aDopplerFactor);
// Rest of the stuff is used internally. // Rest of the stuff is used internally.
// Returns mixed float samples in buffer. Called by the back-end, or user with null driver. // Returns mixed float samples in buffer. Called by the back-end, or user with null driver.
void mix(float *aBuffer, unsigned int aSamples); void mix(float *aBuffer, unsigned int aSamples);
// Returns mixed 16-bit signed integer samples in buffer. Called by the back-end, or user with null driver. // Returns mixed 16-bit signed integer samples in buffer. Called by the back-end, or user with null driver.
void mixSigned16(short *aBuffer, unsigned int aSamples); void mixSigned16(short *aBuffer, unsigned int aSamples);
public: public:
// Mix N samples * M channels. Called by other mix_ functions. // Mix N samples * M channels. Called by other mix_ functions.
void mix_internal(unsigned int aSamples); void mix_internal(unsigned int aSamples);
// Handle rest of initialization (called from backend) // Handle rest of initialization (called from backend)
void postinit(unsigned int aSamplerate, unsigned int aBufferSize, unsigned int aFlags, unsigned int aChannels); void postinit(unsigned int aSamplerate, unsigned int aBufferSize, unsigned int aFlags, unsigned int aChannels);
// Update list of active voices // Update list of active voices
void calcActiveVoices(); void calcActiveVoices();
// Perform mixing for a specific bus // Perform mixing for a specific bus
void mixBus(float *aBuffer, unsigned int aSamples, float *aScratch, unsigned int aBus, float aSamplerate, unsigned int aChannels); void mixBus(float *aBuffer, unsigned int aSamples, float *aScratch, unsigned int aBus, float aSamplerate, unsigned int aChannels);
// Max. number of active voices. Busses and tickable inaudibles also count against this. // Max. number of active voices. Busses and tickable inaudibles also count against this.
unsigned int mMaxActiveVoices; unsigned int mMaxActiveVoices;
// Highest voice in use so far // Highest voice in use so far
unsigned int mHighestVoice; unsigned int mHighestVoice;
// Scratch buffer, used for resampling. // Scratch buffer, used for resampling.
AlignedFloatBuffer mScratch; AlignedFloatBuffer mScratch;
// Current size of the scratch, in samples. // Current size of the scratch, in samples.
unsigned int mScratchSize; unsigned int mScratchSize;
// Amount of scratch needed. // Amount of scratch needed.
unsigned int mScratchNeeded; unsigned int mScratchNeeded;
// Output scratch buffer, used in mix_(). // Output scratch buffer, used in mix_().
AlignedFloatBuffer mOutputScratch; AlignedFloatBuffer mOutputScratch;
// Audio voices. // Audio voices.
AudioSourceInstance *mVoice[VOICE_COUNT]; AudioSourceInstance *mVoice[VOICE_COUNT];
// Output sample rate (not float) // Output sample rate (not float)
unsigned int mSamplerate; unsigned int mSamplerate;
// Output channel count // Output channel count
unsigned int mChannels; unsigned int mChannels;
// Current backend ID // Current backend ID
unsigned int mBackendID; unsigned int mBackendID;
// Current backend string // Current backend string
const char * mBackendString; const char * mBackendString;
// Maximum size of output buffer; used to calculate needed scratch. // Maximum size of output buffer; used to calculate needed scratch.
unsigned int mBufferSize; unsigned int mBufferSize;
// Flags; see Soloud::FLAGS // Flags; see Soloud::FLAGS
unsigned int mFlags; unsigned int mFlags;
// Global volume. Applied before clipping. // Global volume. Applied before clipping.
float mGlobalVolume; float mGlobalVolume;
// Post-clip scaler. Applied after clipping. // Post-clip scaler. Applied after clipping.
float mPostClipScaler; float mPostClipScaler;
// Current play index. Used to create audio handles. // Current play index. Used to create audio handles.
unsigned int mPlayIndex; unsigned int mPlayIndex;
// Current sound source index. Used to create sound source IDs. // Current sound source index. Used to create sound source IDs.
unsigned int mAudioSourceID; unsigned int mAudioSourceID;
// Fader for the global volume. // Fader for the global volume.
Fader mGlobalVolumeFader; Fader mGlobalVolumeFader;
// Global stream time, for the global volume fader. // Global stream time, for the global volume fader.
time mStreamTime; time mStreamTime;
// Last time seen by the playClocked call // Last time seen by the playClocked call
time mLastClockedTime; time mLastClockedTime;
// Global filter // Global filter
Filter *mFilter[FILTERS_PER_STREAM]; Filter *mFilter[FILTERS_PER_STREAM];
// Global filter instance // Global filter instance
FilterInstance *mFilterInstance[FILTERS_PER_STREAM]; FilterInstance *mFilterInstance[FILTERS_PER_STREAM];
// Find a free voice, stopping the oldest if no free voice is found. // Find a free voice, stopping the oldest if no free voice is found.
int findFreeVoice(); int findFreeVoice();
// Converts handle to voice, if the handle is valid. Returns -1 if not. // Converts handle to voice, if the handle is valid. Returns -1 if not.
int getVoiceFromHandle(handle aVoiceHandle) const; int getVoiceFromHandle(handle aVoiceHandle) const;
// Converts voice + playindex into handle // Converts voice + playindex into handle
handle getHandleFromVoice(unsigned int aVoice) const; handle getHandleFromVoice(unsigned int aVoice) const;
// Stop voice (not handle). // Stop voice (not handle).
void stopVoice(unsigned int aVoice); void stopVoice(unsigned int aVoice);
// Set voice (not handle) pan. // Set voice (not handle) pan.
void setVoicePan(unsigned int aVoice, float aPan); void setVoicePan(unsigned int aVoice, float aPan);
// Set voice (not handle) relative play speed. // Set voice (not handle) relative play speed.
result setVoiceRelativePlaySpeed(unsigned int aVoice, float aSpeed); result setVoiceRelativePlaySpeed(unsigned int aVoice, float aSpeed);
// Set voice (not handle) volume. // Set voice (not handle) volume.
void setVoiceVolume(unsigned int aVoice, float aVolume); void setVoiceVolume(unsigned int aVoice, float aVolume);
// Set voice (not handle) pause state. // Set voice (not handle) pause state.
void setVoicePause(unsigned int aVoice, int aPause); void setVoicePause(unsigned int aVoice, int aPause);
// Update overall volume from set and 3d volumes // Update overall volume from set and 3d volumes
void updateVoiceVolume(unsigned int aVoice); void updateVoiceVolume(unsigned int aVoice);
// Update overall relative play speed from set and 3d speeds // Update overall relative play speed from set and 3d speeds
void updateVoiceRelativePlaySpeed(unsigned int aVoice); void updateVoiceRelativePlaySpeed(unsigned int aVoice);
// Perform 3d audio calculation for array of voices // Perform 3d audio calculation for array of voices
void update3dVoices(unsigned int *aVoiceList, unsigned int aVoiceCount); void update3dVoices(unsigned int *aVoiceList, unsigned int aVoiceCount);
// Clip the samples in the buffer // Clip the samples in the buffer
void clip(AlignedFloatBuffer &aBuffer, AlignedFloatBuffer &aDestBuffer, unsigned int aSamples, float aVolume0, float aVolume1); void clip(AlignedFloatBuffer &aBuffer, AlignedFloatBuffer &aDestBuffer, unsigned int aSamples, float aVolume0, float aVolume1);
// Mono-mixed wave data for visualization and for visualization FFT input // Mono-mixed wave data for visualization and for visualization FFT input
float mVisualizationWaveData[256]; float mVisualizationWaveData[256];
// FFT output data // FFT output data
float mFFTData[256]; float mFFTData[256];
// Snapshot of wave data for visualization // Snapshot of wave data for visualization
float mWaveData[256]; float mWaveData[256];
// 3d listener position // 3d listener position
float m3dPosition[3]; float m3dPosition[3];
// 3d listener look-at // 3d listener look-at
float m3dAt[3]; float m3dAt[3];
// 3d listener up // 3d listener up
float m3dUp[3]; float m3dUp[3];
// 3d listener velocity // 3d listener velocity
float m3dVelocity[3]; float m3dVelocity[3];
// 3d speed of sound (for doppler) // 3d speed of sound (for doppler)
float m3dSoundSpeed; float m3dSoundSpeed;
// 3d position of speakers // 3d position of speakers
float m3dSpeakerPosition[3 * MAX_CHANNELS]; float m3dSpeakerPosition[3 * MAX_CHANNELS];
// Data related to 3d processing, separate from AudioSource so we can do 3d calculations without audio mutex. // Data related to 3d processing, separate from AudioSource so we can do 3d calculations without audio mutex.
AudioSourceInstance3dData m3dData[VOICE_COUNT]; AudioSourceInstance3dData m3dData[VOICE_COUNT];
// For each voice group, first int is number of ints alocated. // For each voice group, first int is number of ints alocated.
unsigned int **mVoiceGroup; unsigned int **mVoiceGroup;
unsigned int mVoiceGroupCount; unsigned int mVoiceGroupCount;
// List of currently active voices // List of currently active voices
unsigned int mActiveVoice[VOICE_COUNT]; unsigned int mActiveVoice[VOICE_COUNT];
// Number of currently active voices // Number of currently active voices
unsigned int mActiveVoiceCount; unsigned int mActiveVoiceCount;
// Active voices list needs to be recalculated // Active voices list needs to be recalculated
bool mActiveVoiceDirty; bool mActiveVoiceDirty;
// Remove all non-active voices from group // Remove all non-active voices from group
void trimVoiceGroup(handle aVoiceGroupHandle); void trimVoiceGroup(handle aVoiceGroupHandle);
// Get pointer to the zero-terminated array of voice handles in a voice group // Get pointer to the zero-terminated array of voice handles in a voice group
handle * voiceGroupHandleToArray(handle aVoiceGroupHandle) const; handle * voiceGroupHandleToArray(handle aVoiceGroupHandle) const;
// Lock audio thread mutex. // Lock audio thread mutex.
void lockAudioMutex(); void lockAudioMutex();
// Unlock audio thread mutex. // Unlock audio thread mutex.
void unlockAudioMutex(); void unlockAudioMutex();
}; };
}; };
#endif #endif

@ -1,313 +1,313 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_AUDIOSOURCE_H #ifndef SOLOUD_AUDIOSOURCE_H
#define SOLOUD_AUDIOSOURCE_H #define SOLOUD_AUDIOSOURCE_H
#include "soloud.h" #include "soloud.h"
#include "soloud_fader.h" #include "soloud_fader.h"
#include "soloud_filter.h" #include "soloud_filter.h"
namespace SoLoud namespace SoLoud
{ {
class AudioSource; class AudioSource;
class AudioSourceInstance; class AudioSourceInstance;
class AudioSourceInstance3dData; class AudioSourceInstance3dData;
struct AudioSourceResampleData struct AudioSourceResampleData
{ {
AudioSourceResampleData(); AudioSourceResampleData();
~AudioSourceResampleData(); ~AudioSourceResampleData();
float *mBuffer; float *mBuffer;
}; };
class AudioCollider class AudioCollider
{ {
public: public:
// Calculate volume multiplier. Assumed to return value between 0 and 1. // Calculate volume multiplier. Assumed to return value between 0 and 1.
virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0; virtual float collide(Soloud *aSoloud, AudioSourceInstance3dData *aAudioInstance3dData, int aUserData) = 0;
}; };
class AudioAttenuator class AudioAttenuator
{ {
public: public:
virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0; virtual float attenuate(float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor) = 0;
}; };
class AudioSourceInstance3dData class AudioSourceInstance3dData
{ {
public: public:
// ctor // ctor
AudioSourceInstance3dData(); AudioSourceInstance3dData();
// Set settings from audiosource // Set settings from audiosource
void init(AudioSource &aSource); void init(AudioSource &aSource);
// 3d position // 3d position
float m3dPosition[3]; float m3dPosition[3];
// 3d velocity // 3d velocity
float m3dVelocity[3]; float m3dVelocity[3];
// 3d cone direction // 3d cone direction
/* /*
float m3dConeDirection[3]; float m3dConeDirection[3];
// 3d cone inner angle // 3d cone inner angle
float m3dConeInnerAngle; float m3dConeInnerAngle;
// 3d cone outer angle // 3d cone outer angle
float m3dConeOuterAngle; float m3dConeOuterAngle;
// 3d cone outer volume multiplier // 3d cone outer volume multiplier
float m3dConeOuterVolume; float m3dConeOuterVolume;
*/ */
// 3d min distance // 3d min distance
float m3dMinDistance; float m3dMinDistance;
// 3d max distance // 3d max distance
float m3dMaxDistance; float m3dMaxDistance;
// 3d attenuation rolloff factor // 3d attenuation rolloff factor
float m3dAttenuationRolloff; float m3dAttenuationRolloff;
// 3d attenuation model // 3d attenuation model
unsigned int m3dAttenuationModel; unsigned int m3dAttenuationModel;
// 3d doppler factor // 3d doppler factor
float m3dDopplerFactor; float m3dDopplerFactor;
// Pointer to a custom audio collider object // Pointer to a custom audio collider object
AudioCollider *mCollider; AudioCollider *mCollider;
// Pointer to a custom audio attenuator object // Pointer to a custom audio attenuator object
AudioAttenuator *mAttenuator; AudioAttenuator *mAttenuator;
// User data related to audio collider // User data related to audio collider
int mColliderData; int mColliderData;
// Doppler sample rate multiplier // Doppler sample rate multiplier
float mDopplerValue; float mDopplerValue;
// Overall 3d volume // Overall 3d volume
float m3dVolume; float m3dVolume;
// Channel volume // Channel volume
float mChannelVolume[MAX_CHANNELS]; float mChannelVolume[MAX_CHANNELS];
// Copy of flags // Copy of flags
unsigned int mFlags; unsigned int mFlags;
// Latest handle for this voice // Latest handle for this voice
handle mHandle; handle mHandle;
}; };
// Base class for audio instances // Base class for audio instances
class AudioSourceInstance class AudioSourceInstance
{ {
public: public:
enum FLAGS enum FLAGS
{ {
// This audio instance loops (if supported) // This audio instance loops (if supported)
LOOPING = 1, LOOPING = 1,
// This audio instance is protected - won't get stopped if we run out of voices // This audio instance is protected - won't get stopped if we run out of voices
PROTECTED = 2, PROTECTED = 2,
// This audio instance is paused // This audio instance is paused
PAUSED = 4, PAUSED = 4,
// This audio instance is affected by 3d processing // This audio instance is affected by 3d processing
PROCESS_3D = 8, PROCESS_3D = 8,
// This audio instance has listener-relative 3d coordinates // This audio instance has listener-relative 3d coordinates
LISTENER_RELATIVE = 16, LISTENER_RELATIVE = 16,
// Currently inaudible // Currently inaudible
INAUDIBLE = 32, INAUDIBLE = 32,
// If inaudible, should be killed (default = don't kill kill) // If inaudible, should be killed (default = don't kill kill)
INAUDIBLE_KILL = 64, INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause) // If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128 INAUDIBLE_TICK = 128
}; };
// Ctor // Ctor
AudioSourceInstance(); AudioSourceInstance();
// Dtor // Dtor
virtual ~AudioSourceInstance(); virtual ~AudioSourceInstance();
// Play index; used to identify instances from handles // Play index; used to identify instances from handles
unsigned int mPlayIndex; unsigned int mPlayIndex;
// Loop count // Loop count
unsigned int mLoopCount; unsigned int mLoopCount;
// Flags; see AudioSourceInstance::FLAGS // Flags; see AudioSourceInstance::FLAGS
unsigned int mFlags; unsigned int mFlags;
// Pan value, for getPan() // Pan value, for getPan()
float mPan; float mPan;
// Volume for each channel (panning) // Volume for each channel (panning)
float mChannelVolume[MAX_CHANNELS]; float mChannelVolume[MAX_CHANNELS];
// Set volume // Set volume
float mSetVolume; float mSetVolume;
// Overall volume overall = set * 3d // Overall volume overall = set * 3d
float mOverallVolume; float mOverallVolume;
// Base samplerate; samplerate = base samplerate * relative play speed // Base samplerate; samplerate = base samplerate * relative play speed
float mBaseSamplerate; float mBaseSamplerate;
// Samplerate; samplerate = base samplerate * relative play speed // Samplerate; samplerate = base samplerate * relative play speed
float mSamplerate; float mSamplerate;
// Number of channels this audio source produces // Number of channels this audio source produces
unsigned int mChannels; unsigned int mChannels;
// Relative play speed; samplerate = base samplerate * relative play speed // Relative play speed; samplerate = base samplerate * relative play speed
float mSetRelativePlaySpeed; float mSetRelativePlaySpeed;
// Overall relative plays peed; overall = set * 3d // Overall relative plays peed; overall = set * 3d
float mOverallRelativePlaySpeed; float mOverallRelativePlaySpeed;
// How long this stream has played, in seconds. // How long this stream has played, in seconds.
time mStreamTime; time mStreamTime;
// Fader for the audio panning // Fader for the audio panning
Fader mPanFader; Fader mPanFader;
// Fader for the audio volume // Fader for the audio volume
Fader mVolumeFader; Fader mVolumeFader;
// Fader for the relative play speed // Fader for the relative play speed
Fader mRelativePlaySpeedFader; Fader mRelativePlaySpeedFader;
// Fader used to schedule pausing of the stream // Fader used to schedule pausing of the stream
Fader mPauseScheduler; Fader mPauseScheduler;
// Fader used to schedule stopping of the stream // Fader used to schedule stopping of the stream
Fader mStopScheduler; Fader mStopScheduler;
// Affected by some fader // Affected by some fader
int mActiveFader; int mActiveFader;
// Current channel volumes, used to ramp the volume changes to avoid clicks // Current channel volumes, used to ramp the volume changes to avoid clicks
float mCurrentChannelVolume[MAX_CHANNELS]; float mCurrentChannelVolume[MAX_CHANNELS];
// ID of the sound source that generated this instance // ID of the sound source that generated this instance
unsigned int mAudioSourceID; unsigned int mAudioSourceID;
// Handle of the bus this audio instance is playing on. 0 for root. // Handle of the bus this audio instance is playing on. 0 for root.
unsigned int mBusHandle; unsigned int mBusHandle;
// Filter pointer // Filter pointer
FilterInstance *mFilter[FILTERS_PER_STREAM]; FilterInstance *mFilter[FILTERS_PER_STREAM];
// Initialize instance. Mostly internal use. // Initialize instance. Mostly internal use.
void init(AudioSource &aSource, int aPlayIndex); void init(AudioSource &aSource, int aPlayIndex);
// Buffers for the resampler // Buffers for the resampler
AudioSourceResampleData *mResampleData[2]; AudioSourceResampleData *mResampleData[2];
// Sub-sample playhead; 16.16 fixed point // Sub-sample playhead; 16.16 fixed point
unsigned int mSrcOffset; unsigned int mSrcOffset;
// Samples left over from earlier pass // Samples left over from earlier pass
unsigned int mLeftoverSamples; unsigned int mLeftoverSamples;
// Number of samples to delay streaming // Number of samples to delay streaming
unsigned int mDelaySamples; unsigned int mDelaySamples;
// Get N samples from the stream to the buffer // Get N samples from the stream to the buffer
virtual void getAudio(float *aBuffer, unsigned int aSamples) = 0; virtual void getAudio(float *aBuffer, unsigned int aSamples) = 0;
// Has the stream ended? // Has the stream ended?
virtual bool hasEnded() = 0; virtual bool hasEnded() = 0;
// Seek to certain place in the stream. Base implementation is generic "tape" seek (and slow). // Seek to certain place in the stream. Base implementation is generic "tape" seek (and slow).
virtual void seek(time aSeconds, float *mScratch, unsigned int mScratchSize); virtual void seek(time aSeconds, float *mScratch, unsigned int mScratchSize);
// Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind. // Rewind stream. Base implementation returns NOT_IMPLEMENTED, meaning it can't rewind.
virtual result rewind(); virtual result rewind();
// Get information. Returns 0 by default. // Get information. Returns 0 by default.
virtual float getInfo(unsigned int aInfoKey); virtual float getInfo(unsigned int aInfoKey);
}; };
class Soloud; class Soloud;
// Base class for audio sources // Base class for audio sources
class AudioSource class AudioSource
{ {
public: public:
enum FLAGS enum FLAGS
{ {
// The instances from this audio source should loop // The instances from this audio source should loop
SHOULD_LOOP = 1, SHOULD_LOOP = 1,
// Only one instance of this audio source should play at the same time // Only one instance of this audio source should play at the same time
SINGLE_INSTANCE = 2, SINGLE_INSTANCE = 2,
// Visualization data gathering enabled. Only for busses. // Visualization data gathering enabled. Only for busses.
VISUALIZATION_DATA = 4, VISUALIZATION_DATA = 4,
// Audio instances created from this source are affected by 3d processing // Audio instances created from this source are affected by 3d processing
PROCESS_3D = 8, PROCESS_3D = 8,
// Audio instances created from this source have listener-relative 3d coordinates // Audio instances created from this source have listener-relative 3d coordinates
LISTENER_RELATIVE = 16, LISTENER_RELATIVE = 16,
// Delay start of sound by the distance from listener // Delay start of sound by the distance from listener
DISTANCE_DELAY = 32, DISTANCE_DELAY = 32,
// If inaudible, should be killed (default) // If inaudible, should be killed (default)
INAUDIBLE_KILL = 64, INAUDIBLE_KILL = 64,
// If inaudible, should still be ticked (default = pause) // If inaudible, should still be ticked (default = pause)
INAUDIBLE_TICK = 128 INAUDIBLE_TICK = 128
}; };
enum ATTENUATION_MODELS enum ATTENUATION_MODELS
{ {
// No attenuation // No attenuation
NO_ATTENUATION = 0, NO_ATTENUATION = 0,
// Inverse distance attenuation model // Inverse distance attenuation model
INVERSE_DISTANCE = 1, INVERSE_DISTANCE = 1,
// Linear distance attenuation model // Linear distance attenuation model
LINEAR_DISTANCE = 2, LINEAR_DISTANCE = 2,
// Exponential distance attenuation model // Exponential distance attenuation model
EXPONENTIAL_DISTANCE = 3 EXPONENTIAL_DISTANCE = 3
}; };
// Flags. See AudioSource::FLAGS // Flags. See AudioSource::FLAGS
unsigned int mFlags; unsigned int mFlags;
// Base sample rate, used to initialize instances // Base sample rate, used to initialize instances
float mBaseSamplerate; float mBaseSamplerate;
// Default volume for created instances // Default volume for created instances
float mVolume; float mVolume;
// Number of channels this audio source produces // Number of channels this audio source produces
unsigned int mChannels; unsigned int mChannels;
// Sound source ID. Assigned by SoLoud the first time it's played. // Sound source ID. Assigned by SoLoud the first time it's played.
unsigned int mAudioSourceID; unsigned int mAudioSourceID;
// 3d min distance // 3d min distance
float m3dMinDistance; float m3dMinDistance;
// 3d max distance // 3d max distance
float m3dMaxDistance; float m3dMaxDistance;
// 3d attenuation rolloff factor // 3d attenuation rolloff factor
float m3dAttenuationRolloff; float m3dAttenuationRolloff;
// 3d attenuation model // 3d attenuation model
unsigned int m3dAttenuationModel; unsigned int m3dAttenuationModel;
// 3d doppler factor // 3d doppler factor
float m3dDopplerFactor; float m3dDopplerFactor;
// Filter pointer // Filter pointer
Filter *mFilter[FILTERS_PER_STREAM]; Filter *mFilter[FILTERS_PER_STREAM];
// Pointer to the Soloud object. Needed to stop all instances in dtor. // Pointer to the Soloud object. Needed to stop all instances in dtor.
Soloud *mSoloud; Soloud *mSoloud;
// Pointer to a custom audio collider object // Pointer to a custom audio collider object
AudioCollider *mCollider; AudioCollider *mCollider;
// Pointer to custom attenuator object // Pointer to custom attenuator object
AudioAttenuator *mAttenuator; AudioAttenuator *mAttenuator;
// User data related to audio collider // User data related to audio collider
int mColliderData; int mColliderData;
// CTor // CTor
AudioSource(); AudioSource();
// Set default volume for instances // Set default volume for instances
void setVolume(float aVolume); void setVolume(float aVolume);
// Set the looping of the instances created from this audio source // Set the looping of the instances created from this audio source
void setLooping(bool aLoop); void setLooping(bool aLoop);
// Set whether only one instance of this sound should ever be playing at the same time // Set whether only one instance of this sound should ever be playing at the same time
void setSingleInstance(bool aSingleInstance); void setSingleInstance(bool aSingleInstance);
// Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol) // Set the minimum and maximum distances for 3d audio source (closer to min distance = max vol)
void set3dMinMaxDistance(float aMinDistance, float aMaxDistance); void set3dMinMaxDistance(float aMinDistance, float aMaxDistance);
// Set attenuation model and rolloff factor for 3d audio source // Set attenuation model and rolloff factor for 3d audio source
void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void set3dAttenuation(unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
// Set doppler factor to reduce or enhance doppler effect, default = 1.0 // Set doppler factor to reduce or enhance doppler effect, default = 1.0
void set3dDopplerFactor(float aDopplerFactor); void set3dDopplerFactor(float aDopplerFactor);
// Enable 3d processing. Implicitly set by play3d calls. // Enable 3d processing. Implicitly set by play3d calls.
void set3dProcessing(bool aDo3dProcessing); void set3dProcessing(bool aDo3dProcessing);
// Set the coordinates for this audio source to be relative to listener's coordinates. // Set the coordinates for this audio source to be relative to listener's coordinates.
void set3dListenerRelative(bool aListenerRelative); void set3dListenerRelative(bool aListenerRelative);
// Enable delaying the start of the sound based on the distance. // Enable delaying the start of the sound based on the distance.
void set3dDistanceDelay(bool aDistanceDelay); void set3dDistanceDelay(bool aDistanceDelay);
// Set a custom 3d audio collider. Set to NULL to disable. // Set a custom 3d audio collider. Set to NULL to disable.
void set3dCollider(AudioCollider *aCollider, int aUserData = 0); void set3dCollider(AudioCollider *aCollider, int aUserData = 0);
// Set a custom attenuator. Set to NULL to disable. // Set a custom attenuator. Set to NULL to disable.
void set3dAttenuator(AudioAttenuator *aAttenuator); void set3dAttenuator(AudioAttenuator *aAttenuator);
// Set behavior for inaudible sounds // Set behavior for inaudible sounds
void setInaudibleBehavior(bool aMustTick, bool aKill); void setInaudibleBehavior(bool aMustTick, bool aKill);
// Set filter. Set to NULL to clear the filter. // Set filter. Set to NULL to clear the filter.
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); virtual void setFilter(unsigned int aFilterId, Filter *aFilter);
// DTor // DTor
virtual ~AudioSource(); virtual ~AudioSource();
// Create instance from the audio source. Called from within Soloud class. // Create instance from the audio source. Called from within Soloud class.
virtual AudioSourceInstance *createInstance() = 0; virtual AudioSourceInstance *createInstance() = 0;
// Stop all instances of this audio source // Stop all instances of this audio source
void stop(); void stop();
}; };
}; };
#endif #endif

@ -1,63 +1,63 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_BASSBOOSTFILTER_H #ifndef SOLOUD_BASSBOOSTFILTER_H
#define SOLOUD_BASSBOOSTFILTER_H #define SOLOUD_BASSBOOSTFILTER_H
#include "soloud.h" #include "soloud.h"
#include "soloud_fftfilter.h" #include "soloud_fftfilter.h"
namespace SoLoud namespace SoLoud
{ {
class BassboostFilter; class BassboostFilter;
class BassboostFilterInstance : public FFTFilterInstance class BassboostFilterInstance : public FFTFilterInstance
{ {
enum FILTERATTRIBUTE enum FILTERATTRIBUTE
{ {
WET = 0, WET = 0,
BOOST = 1 BOOST = 1
}; };
BassboostFilter *mParent; BassboostFilter *mParent;
public: public:
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
BassboostFilterInstance(BassboostFilter *aParent); BassboostFilterInstance(BassboostFilter *aParent);
}; };
class BassboostFilter : public FFTFilter class BassboostFilter : public FFTFilter
{ {
public: public:
enum FILTERATTRIBUTE enum FILTERATTRIBUTE
{ {
WET = 0, WET = 0,
BOOST = 1 BOOST = 1
}; };
float mBoost; float mBoost;
result setParams(float aBoost); result setParams(float aBoost);
virtual FilterInstance *createInstance(); virtual FilterInstance *createInstance();
BassboostFilter(); BassboostFilter();
}; };
} }
#endif #endif

@ -1,91 +1,91 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_BQRFILTER_H #ifndef SOLOUD_BQRFILTER_H
#define SOLOUD_BQRFILTER_H #define SOLOUD_BQRFILTER_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class BiquadResonantFilter; class BiquadResonantFilter;
struct BQRStateData struct BQRStateData
{ {
float mY1, mY2, mX1, mX2; float mY1, mY2, mX1, mX2;
}; };
class BiquadResonantFilterInstance : public FilterInstance class BiquadResonantFilterInstance : public FilterInstance
{ {
enum FILTERATTRIBUTE enum FILTERATTRIBUTE
{ {
WET = 0, WET = 0,
SAMPLERATE = 1, SAMPLERATE = 1,
FREQUENCY = 2, FREQUENCY = 2,
RESONANCE = 3 RESONANCE = 3
}; };
int mActive; int mActive;
BQRStateData mState[2]; BQRStateData mState[2];
float mA0, mA1, mA2, mB1, mB2; float mA0, mA1, mA2, mB1, mB2;
int mDirty; int mDirty;
int mFilterType; int mFilterType;
BiquadResonantFilter *mParent; BiquadResonantFilter *mParent;
void calcBQRParams(); void calcBQRParams();
public: public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~BiquadResonantFilterInstance(); virtual ~BiquadResonantFilterInstance();
BiquadResonantFilterInstance(BiquadResonantFilter *aParent); BiquadResonantFilterInstance(BiquadResonantFilter *aParent);
}; };
class BiquadResonantFilter : public Filter class BiquadResonantFilter : public Filter
{ {
public: public:
enum FILTERTYPE enum FILTERTYPE
{ {
NONE = 0, NONE = 0,
LOWPASS = 1, LOWPASS = 1,
HIGHPASS = 2, HIGHPASS = 2,
BANDPASS = 3 BANDPASS = 3
}; };
enum FILTERATTRIBUTE enum FILTERATTRIBUTE
{ {
WET = 0, WET = 0,
SAMPLERATE = 1, SAMPLERATE = 1,
FREQUENCY = 2, FREQUENCY = 2,
RESONANCE = 3 RESONANCE = 3
}; };
int mFilterType; int mFilterType;
float mSampleRate; float mSampleRate;
float mFrequency; float mFrequency;
float mResonance; float mResonance;
virtual BiquadResonantFilterInstance *createInstance(); virtual BiquadResonantFilterInstance *createInstance();
BiquadResonantFilter(); BiquadResonantFilter();
result setParams(int aType, float aSampleRate, float aFrequency, float aResonance); result setParams(int aType, float aSampleRate, float aFrequency, float aResonance);
virtual ~BiquadResonantFilter(); virtual ~BiquadResonantFilter();
}; };
} }
#endif #endif

@ -1,86 +1,86 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_BUS_H #ifndef SOLOUD_BUS_H
#define SOLOUD_BUS_H #define SOLOUD_BUS_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class Bus; class Bus;
class BusInstance : public AudioSourceInstance class BusInstance : public AudioSourceInstance
{ {
Bus *mParent; Bus *mParent;
unsigned int mScratchSize; unsigned int mScratchSize;
AlignedFloatBuffer mScratch; AlignedFloatBuffer mScratch;
public: public:
// Mono-mixed wave data for visualization and for visualization FFT input // Mono-mixed wave data for visualization and for visualization FFT input
float mVisualizationWaveData[256]; float mVisualizationWaveData[256];
BusInstance(Bus *aParent); BusInstance(Bus *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded(); virtual bool hasEnded();
virtual ~BusInstance(); virtual ~BusInstance();
}; };
class Bus : public AudioSource class Bus : public AudioSource
{ {
public: public:
Bus(); Bus();
virtual BusInstance *createInstance(); virtual BusInstance *createInstance();
// Set filter. Set to NULL to clear the filter. // Set filter. Set to NULL to clear the filter.
virtual void setFilter(unsigned int aFilterId, Filter *aFilter); virtual void setFilter(unsigned int aFilterId, Filter *aFilter);
// Play sound through the bus // Play sound through the bus
handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0); handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0);
// Play sound through the bus, delayed in relation to other sounds called via this function. // Play sound through the bus, delayed in relation to other sounds called via this function.
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f); handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f);
// Start playing a 3d audio source through the bus // Start playing a 3d audio source through the bus
handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0); handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0);
// Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function. // Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function.
handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f); handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f);
// Set number of channels for the bus (default 2) // Set number of channels for the bus (default 2)
result setChannels(unsigned int aChannels); result setChannels(unsigned int aChannels);
// Enable or disable visualization data gathering // Enable or disable visualization data gathering
void setVisualizationEnable(bool aEnable); void setVisualizationEnable(bool aEnable);
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use. // Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
float *calcFFT(); float *calcFFT();
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use. // Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
float *getWave(); float *getWave();
public: public:
BusInstance *mInstance; BusInstance *mInstance;
unsigned int mChannelHandle; unsigned int mChannelHandle;
// FFT output data // FFT output data
float mFFTData[256]; float mFFTData[256];
// Snapshot of wave data for visualization // Snapshot of wave data for visualization
float mWaveData[256]; float mWaveData[256];
// Internal: find the bus' channel // Internal: find the bus' channel
void findBusHandle(); void findBusHandle();
}; };
}; };
#endif #endif

@ -1,490 +1,490 @@
/* ************************************************** /* **************************************************
* WARNING: this is a generated file. Do not edit. * * WARNING: this is a generated file. Do not edit. *
* Any edits will be overwritten by the generator. * * Any edits will be overwritten by the generator. *
************************************************** */ ************************************************** */
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2016 Jari Komppa Copyright (c) 2013-2016 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
/* SoLoud C-Api Code Generator (c)2013-2016 Jari Komppa http://iki.fi/sol/ */ /* SoLoud C-Api Code Generator (c)2013-2016 Jari Komppa http://iki.fi/sol/ */
#ifndef SOLOUD_C_H_INCLUDED #ifndef SOLOUD_C_H_INCLUDED
#define SOLOUD_C_H_INCLUDED #define SOLOUD_C_H_INCLUDED
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// Collected enumerations // Collected enumerations
enum SOLOUD_ENUMS enum SOLOUD_ENUMS
{ {
SOLOUD_AUTO = 0, SOLOUD_AUTO = 0,
SOLOUD_SDL = 1, SOLOUD_SDL = 1,
SOLOUD_SDL2 = 2, SOLOUD_SDL2 = 2,
SOLOUD_PORTAUDIO = 3, SOLOUD_PORTAUDIO = 3,
SOLOUD_WINMM = 4, SOLOUD_WINMM = 4,
SOLOUD_XAUDIO2 = 5, SOLOUD_XAUDIO2 = 5,
SOLOUD_WASAPI = 6, SOLOUD_WASAPI = 6,
SOLOUD_ALSA = 7, SOLOUD_ALSA = 7,
SOLOUD_OSS = 8, SOLOUD_OSS = 8,
SOLOUD_OPENAL = 9, SOLOUD_OPENAL = 9,
SOLOUD_COREAUDIO = 10, SOLOUD_COREAUDIO = 10,
SOLOUD_OPENSLES = 11, SOLOUD_OPENSLES = 11,
SOLOUD_NULLDRIVER = 12, SOLOUD_NULLDRIVER = 12,
SOLOUD_BACKEND_MAX = 13, SOLOUD_BACKEND_MAX = 13,
SOLOUD_CLIP_ROUNDOFF = 1, SOLOUD_CLIP_ROUNDOFF = 1,
SOLOUD_ENABLE_VISUALIZATION = 2, SOLOUD_ENABLE_VISUALIZATION = 2,
SOLOUD_LEFT_HANDED_3D = 4, SOLOUD_LEFT_HANDED_3D = 4,
BIQUADRESONANTFILTER_NONE = 0, BIQUADRESONANTFILTER_NONE = 0,
BIQUADRESONANTFILTER_LOWPASS = 1, BIQUADRESONANTFILTER_LOWPASS = 1,
BIQUADRESONANTFILTER_HIGHPASS = 2, BIQUADRESONANTFILTER_HIGHPASS = 2,
BIQUADRESONANTFILTER_BANDPASS = 3, BIQUADRESONANTFILTER_BANDPASS = 3,
BIQUADRESONANTFILTER_WET = 0, BIQUADRESONANTFILTER_WET = 0,
BIQUADRESONANTFILTER_SAMPLERATE = 1, BIQUADRESONANTFILTER_SAMPLERATE = 1,
BIQUADRESONANTFILTER_FREQUENCY = 2, BIQUADRESONANTFILTER_FREQUENCY = 2,
BIQUADRESONANTFILTER_RESONANCE = 3, BIQUADRESONANTFILTER_RESONANCE = 3,
LOFIFILTER_WET = 0, LOFIFILTER_WET = 0,
LOFIFILTER_SAMPLERATE = 1, LOFIFILTER_SAMPLERATE = 1,
LOFIFILTER_BITDEPTH = 2, LOFIFILTER_BITDEPTH = 2,
BASSBOOSTFILTER_WET = 0, BASSBOOSTFILTER_WET = 0,
BASSBOOSTFILTER_BOOST = 1, BASSBOOSTFILTER_BOOST = 1,
SFXR_COIN = 0, SFXR_COIN = 0,
SFXR_LASER = 1, SFXR_LASER = 1,
SFXR_EXPLOSION = 2, SFXR_EXPLOSION = 2,
SFXR_POWERUP = 3, SFXR_POWERUP = 3,
SFXR_HURT = 4, SFXR_HURT = 4,
SFXR_JUMP = 5, SFXR_JUMP = 5,
SFXR_BLIP = 6, SFXR_BLIP = 6,
FLANGERFILTER_WET = 0, FLANGERFILTER_WET = 0,
FLANGERFILTER_DELAY = 1, FLANGERFILTER_DELAY = 1,
FLANGERFILTER_FREQ = 2, FLANGERFILTER_FREQ = 2,
MONOTONE_SQUARE = 0, MONOTONE_SQUARE = 0,
MONOTONE_SAW = 1, MONOTONE_SAW = 1,
MONOTONE_SIN = 2, MONOTONE_SIN = 2,
MONOTONE_SAWSIN = 3 MONOTONE_SAWSIN = 3
}; };
// Object handle typedefs // Object handle typedefs
typedef void * AlignedFloatBuffer; typedef void * AlignedFloatBuffer;
typedef void * Soloud; typedef void * Soloud;
typedef void * AudioCollider; typedef void * AudioCollider;
typedef void * AudioAttenuator; typedef void * AudioAttenuator;
typedef void * AudioSource; typedef void * AudioSource;
typedef void * BiquadResonantFilter; typedef void * BiquadResonantFilter;
typedef void * LofiFilter; typedef void * LofiFilter;
typedef void * Bus; typedef void * Bus;
typedef void * EchoFilter; typedef void * EchoFilter;
typedef void * Fader; typedef void * Fader;
typedef void * FFTFilter; typedef void * FFTFilter;
typedef void * BassboostFilter; typedef void * BassboostFilter;
typedef void * Filter; typedef void * Filter;
typedef void * Speech; typedef void * Speech;
typedef void * Wav; typedef void * Wav;
typedef void * WavStream; typedef void * WavStream;
typedef void * Prg; typedef void * Prg;
typedef void * Sfxr; typedef void * Sfxr;
typedef void * FlangerFilter; typedef void * FlangerFilter;
typedef void * DCRemovalFilter; typedef void * DCRemovalFilter;
typedef void * Openmpt; typedef void * Openmpt;
typedef void * Monotone; typedef void * Monotone;
typedef void * TedSid; typedef void * TedSid;
typedef void * File; typedef void * File;
/* /*
* Soloud * Soloud
*/ */
void Soloud_destroy(Soloud * aSoloud); void Soloud_destroy(Soloud * aSoloud);
Soloud * Soloud_create(); Soloud * Soloud_create();
int Soloud_init(Soloud * aSoloud); int Soloud_init(Soloud * aSoloud);
int Soloud_initEx(Soloud * aSoloud, unsigned int aFlags /* = Soloud::CLIP_ROUNDOFF */, unsigned int aBackend /* = Soloud::AUTO */, unsigned int aSamplerate /* = Soloud::AUTO */, unsigned int aBufferSize /* = Soloud::AUTO */, unsigned int aChannels /* = 2 */); int Soloud_initEx(Soloud * aSoloud, unsigned int aFlags /* = Soloud::CLIP_ROUNDOFF */, unsigned int aBackend /* = Soloud::AUTO */, unsigned int aSamplerate /* = Soloud::AUTO */, unsigned int aBufferSize /* = Soloud::AUTO */, unsigned int aChannels /* = 2 */);
void Soloud_deinit(Soloud * aSoloud); void Soloud_deinit(Soloud * aSoloud);
unsigned int Soloud_getVersion(Soloud * aSoloud); unsigned int Soloud_getVersion(Soloud * aSoloud);
const char * Soloud_getErrorString(Soloud * aSoloud, int aErrorCode); const char * Soloud_getErrorString(Soloud * aSoloud, int aErrorCode);
unsigned int Soloud_getBackendId(Soloud * aSoloud); unsigned int Soloud_getBackendId(Soloud * aSoloud);
const char * Soloud_getBackendString(Soloud * aSoloud); const char * Soloud_getBackendString(Soloud * aSoloud);
unsigned int Soloud_getBackendChannels(Soloud * aSoloud); unsigned int Soloud_getBackendChannels(Soloud * aSoloud);
unsigned int Soloud_getBackendSamplerate(Soloud * aSoloud); unsigned int Soloud_getBackendSamplerate(Soloud * aSoloud);
unsigned int Soloud_getBackendBufferSize(Soloud * aSoloud); unsigned int Soloud_getBackendBufferSize(Soloud * aSoloud);
int Soloud_setSpeakerPosition(Soloud * aSoloud, unsigned int aChannel, float aX, float aY, float aZ); int Soloud_setSpeakerPosition(Soloud * aSoloud, unsigned int aChannel, float aX, float aY, float aZ);
unsigned int Soloud_play(Soloud * aSoloud, AudioSource * aSound); unsigned int Soloud_play(Soloud * aSoloud, AudioSource * aSound);
unsigned int Soloud_playEx(Soloud * aSoloud, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); unsigned int Soloud_playEx(Soloud * aSoloud, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */);
unsigned int Soloud_playClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound); unsigned int Soloud_playClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound);
unsigned int Soloud_playClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, unsigned int aBus /* = 0 */); unsigned int Soloud_playClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aVolume /* = -1.0f */, float aPan /* = 0.0f */, unsigned int aBus /* = 0 */);
unsigned int Soloud_play3d(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); unsigned int Soloud_play3d(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ);
unsigned int Soloud_play3dEx(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */); unsigned int Soloud_play3dEx(Soloud * aSoloud, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */, unsigned int aBus /* = 0 */);
unsigned int Soloud_play3dClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); unsigned int Soloud_play3dClocked(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ);
unsigned int Soloud_play3dClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, unsigned int aBus /* = 0 */); unsigned int Soloud_play3dClockedEx(Soloud * aSoloud, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, unsigned int aBus /* = 0 */);
void Soloud_seek(Soloud * aSoloud, unsigned int aVoiceHandle, double aSeconds); void Soloud_seek(Soloud * aSoloud, unsigned int aVoiceHandle, double aSeconds);
void Soloud_stop(Soloud * aSoloud, unsigned int aVoiceHandle); void Soloud_stop(Soloud * aSoloud, unsigned int aVoiceHandle);
void Soloud_stopAll(Soloud * aSoloud); void Soloud_stopAll(Soloud * aSoloud);
void Soloud_stopAudioSource(Soloud * aSoloud, AudioSource * aSound); void Soloud_stopAudioSource(Soloud * aSoloud, AudioSource * aSound);
void Soloud_setFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue); void Soloud_setFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aValue);
float Soloud_getFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId); float Soloud_getFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId);
void Soloud_fadeFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, double aTime); void Soloud_fadeFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aTo, double aTime);
void Soloud_oscillateFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, double aTime); void Soloud_oscillateFilterParameter(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aFilterId, unsigned int aAttributeId, float aFrom, float aTo, double aTime);
double Soloud_getStreamTime(Soloud * aSoloud, unsigned int aVoiceHandle); double Soloud_getStreamTime(Soloud * aSoloud, unsigned int aVoiceHandle);
int Soloud_getPause(Soloud * aSoloud, unsigned int aVoiceHandle); int Soloud_getPause(Soloud * aSoloud, unsigned int aVoiceHandle);
float Soloud_getVolume(Soloud * aSoloud, unsigned int aVoiceHandle); float Soloud_getVolume(Soloud * aSoloud, unsigned int aVoiceHandle);
float Soloud_getOverallVolume(Soloud * aSoloud, unsigned int aVoiceHandle); float Soloud_getOverallVolume(Soloud * aSoloud, unsigned int aVoiceHandle);
float Soloud_getPan(Soloud * aSoloud, unsigned int aVoiceHandle); float Soloud_getPan(Soloud * aSoloud, unsigned int aVoiceHandle);
float Soloud_getSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle); float Soloud_getSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle);
int Soloud_getProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle); int Soloud_getProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle);
unsigned int Soloud_getActiveVoiceCount(Soloud * aSoloud); unsigned int Soloud_getActiveVoiceCount(Soloud * aSoloud);
unsigned int Soloud_getVoiceCount(Soloud * aSoloud); unsigned int Soloud_getVoiceCount(Soloud * aSoloud);
int Soloud_isValidVoiceHandle(Soloud * aSoloud, unsigned int aVoiceHandle); int Soloud_isValidVoiceHandle(Soloud * aSoloud, unsigned int aVoiceHandle);
float Soloud_getRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle); float Soloud_getRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle);
float Soloud_getPostClipScaler(Soloud * aSoloud); float Soloud_getPostClipScaler(Soloud * aSoloud);
float Soloud_getGlobalVolume(Soloud * aSoloud); float Soloud_getGlobalVolume(Soloud * aSoloud);
unsigned int Soloud_getMaxActiveVoiceCount(Soloud * aSoloud); unsigned int Soloud_getMaxActiveVoiceCount(Soloud * aSoloud);
int Soloud_getLooping(Soloud * aSoloud, unsigned int aVoiceHandle); int Soloud_getLooping(Soloud * aSoloud, unsigned int aVoiceHandle);
void Soloud_setLooping(Soloud * aSoloud, unsigned int aVoiceHandle, int aLooping); void Soloud_setLooping(Soloud * aSoloud, unsigned int aVoiceHandle, int aLooping);
int Soloud_setMaxActiveVoiceCount(Soloud * aSoloud, unsigned int aVoiceCount); int Soloud_setMaxActiveVoiceCount(Soloud * aSoloud, unsigned int aVoiceCount);
void Soloud_setInaudibleBehavior(Soloud * aSoloud, unsigned int aVoiceHandle, int aMustTick, int aKill); void Soloud_setInaudibleBehavior(Soloud * aSoloud, unsigned int aVoiceHandle, int aMustTick, int aKill);
void Soloud_setGlobalVolume(Soloud * aSoloud, float aVolume); void Soloud_setGlobalVolume(Soloud * aSoloud, float aVolume);
void Soloud_setPostClipScaler(Soloud * aSoloud, float aScaler); void Soloud_setPostClipScaler(Soloud * aSoloud, float aScaler);
void Soloud_setPause(Soloud * aSoloud, unsigned int aVoiceHandle, int aPause); void Soloud_setPause(Soloud * aSoloud, unsigned int aVoiceHandle, int aPause);
void Soloud_setPauseAll(Soloud * aSoloud, int aPause); void Soloud_setPauseAll(Soloud * aSoloud, int aPause);
int Soloud_setRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aSpeed); int Soloud_setRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aSpeed);
void Soloud_setProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle, int aProtect); void Soloud_setProtectVoice(Soloud * aSoloud, unsigned int aVoiceHandle, int aProtect);
void Soloud_setSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle, float aSamplerate); void Soloud_setSamplerate(Soloud * aSoloud, unsigned int aVoiceHandle, float aSamplerate);
void Soloud_setPan(Soloud * aSoloud, unsigned int aVoiceHandle, float aPan); void Soloud_setPan(Soloud * aSoloud, unsigned int aVoiceHandle, float aPan);
void Soloud_setPanAbsolute(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume); void Soloud_setPanAbsolute(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume);
void Soloud_setPanAbsoluteEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume /* = 0 */, float aRBVolume /* = 0 */, float aCVolume /* = 0 */, float aSVolume /* = 0 */); void Soloud_setPanAbsoluteEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aLVolume, float aRVolume, float aLBVolume /* = 0 */, float aRBVolume /* = 0 */, float aCVolume /* = 0 */, float aSVolume /* = 0 */);
void Soloud_setVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aVolume); void Soloud_setVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aVolume);
void Soloud_setDelaySamples(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aSamples); void Soloud_setDelaySamples(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aSamples);
void Soloud_fadeVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); void Soloud_fadeVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime);
void Soloud_fadePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); void Soloud_fadePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime);
void Soloud_fadeRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime); void Soloud_fadeRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aTo, double aTime);
void Soloud_fadeGlobalVolume(Soloud * aSoloud, float aTo, double aTime); void Soloud_fadeGlobalVolume(Soloud * aSoloud, float aTo, double aTime);
void Soloud_schedulePause(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); void Soloud_schedulePause(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime);
void Soloud_scheduleStop(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime); void Soloud_scheduleStop(Soloud * aSoloud, unsigned int aVoiceHandle, double aTime);
void Soloud_oscillateVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); void Soloud_oscillateVolume(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime);
void Soloud_oscillatePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); void Soloud_oscillatePan(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime);
void Soloud_oscillateRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime); void Soloud_oscillateRelativePlaySpeed(Soloud * aSoloud, unsigned int aVoiceHandle, float aFrom, float aTo, double aTime);
void Soloud_oscillateGlobalVolume(Soloud * aSoloud, float aFrom, float aTo, double aTime); void Soloud_oscillateGlobalVolume(Soloud * aSoloud, float aFrom, float aTo, double aTime);
void Soloud_setGlobalFilter(Soloud * aSoloud, unsigned int aFilterId, Filter * aFilter); void Soloud_setGlobalFilter(Soloud * aSoloud, unsigned int aFilterId, Filter * aFilter);
void Soloud_setVisualizationEnable(Soloud * aSoloud, int aEnable); void Soloud_setVisualizationEnable(Soloud * aSoloud, int aEnable);
float * Soloud_calcFFT(Soloud * aSoloud); float * Soloud_calcFFT(Soloud * aSoloud);
float * Soloud_getWave(Soloud * aSoloud); float * Soloud_getWave(Soloud * aSoloud);
unsigned int Soloud_getLoopCount(Soloud * aSoloud, unsigned int aVoiceHandle); unsigned int Soloud_getLoopCount(Soloud * aSoloud, unsigned int aVoiceHandle);
float Soloud_getInfo(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aInfoKey); float Soloud_getInfo(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aInfoKey);
unsigned int Soloud_createVoiceGroup(Soloud * aSoloud); unsigned int Soloud_createVoiceGroup(Soloud * aSoloud);
int Soloud_destroyVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); int Soloud_destroyVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle);
int Soloud_addVoiceToGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle, unsigned int aVoiceHandle); int Soloud_addVoiceToGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle, unsigned int aVoiceHandle);
int Soloud_isVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle); int Soloud_isVoiceGroup(Soloud * aSoloud, unsigned int aVoiceGroupHandle);
int Soloud_isVoiceGroupEmpty(Soloud * aSoloud, unsigned int aVoiceGroupHandle); int Soloud_isVoiceGroupEmpty(Soloud * aSoloud, unsigned int aVoiceGroupHandle);
void Soloud_update3dAudio(Soloud * aSoloud); void Soloud_update3dAudio(Soloud * aSoloud);
int Soloud_set3dSoundSpeed(Soloud * aSoloud, float aSpeed); int Soloud_set3dSoundSpeed(Soloud * aSoloud, float aSpeed);
float Soloud_get3dSoundSpeed(Soloud * aSoloud); float Soloud_get3dSoundSpeed(Soloud * aSoloud);
void Soloud_set3dListenerParameters(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ); void Soloud_set3dListenerParameters(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ);
void Soloud_set3dListenerParametersEx(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); void Soloud_set3dListenerParametersEx(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ, float aAtX, float aAtY, float aAtZ, float aUpX, float aUpY, float aUpZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */);
void Soloud_set3dListenerPosition(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ); void Soloud_set3dListenerPosition(Soloud * aSoloud, float aPosX, float aPosY, float aPosZ);
void Soloud_set3dListenerAt(Soloud * aSoloud, float aAtX, float aAtY, float aAtZ); void Soloud_set3dListenerAt(Soloud * aSoloud, float aAtX, float aAtY, float aAtZ);
void Soloud_set3dListenerUp(Soloud * aSoloud, float aUpX, float aUpY, float aUpZ); void Soloud_set3dListenerUp(Soloud * aSoloud, float aUpX, float aUpY, float aUpZ);
void Soloud_set3dListenerVelocity(Soloud * aSoloud, float aVelocityX, float aVelocityY, float aVelocityZ); void Soloud_set3dListenerVelocity(Soloud * aSoloud, float aVelocityX, float aVelocityY, float aVelocityZ);
void Soloud_set3dSourceParameters(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); void Soloud_set3dSourceParameters(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ);
void Soloud_set3dSourceParametersEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */); void Soloud_set3dSourceParametersEx(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ, float aVelocityX /* = 0.0f */, float aVelocityY /* = 0.0f */, float aVelocityZ /* = 0.0f */);
void Soloud_set3dSourcePosition(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ); void Soloud_set3dSourcePosition(Soloud * aSoloud, unsigned int aVoiceHandle, float aPosX, float aPosY, float aPosZ);
void Soloud_set3dSourceVelocity(Soloud * aSoloud, unsigned int aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ); void Soloud_set3dSourceVelocity(Soloud * aSoloud, unsigned int aVoiceHandle, float aVelocityX, float aVelocityY, float aVelocityZ);
void Soloud_set3dSourceMinMaxDistance(Soloud * aSoloud, unsigned int aVoiceHandle, float aMinDistance, float aMaxDistance); void Soloud_set3dSourceMinMaxDistance(Soloud * aSoloud, unsigned int aVoiceHandle, float aMinDistance, float aMaxDistance);
void Soloud_set3dSourceAttenuation(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void Soloud_set3dSourceAttenuation(Soloud * aSoloud, unsigned int aVoiceHandle, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Soloud_set3dSourceDopplerFactor(Soloud * aSoloud, unsigned int aVoiceHandle, float aDopplerFactor); void Soloud_set3dSourceDopplerFactor(Soloud * aSoloud, unsigned int aVoiceHandle, float aDopplerFactor);
void Soloud_mix(Soloud * aSoloud, float * aBuffer, unsigned int aSamples); void Soloud_mix(Soloud * aSoloud, float * aBuffer, unsigned int aSamples);
void Soloud_mixSigned16(Soloud * aSoloud, short * aBuffer, unsigned int aSamples); void Soloud_mixSigned16(Soloud * aSoloud, short * aBuffer, unsigned int aSamples);
/* /*
* AudioAttenuator * AudioAttenuator
*/ */
void AudioAttenuator_destroy(AudioAttenuator * aAudioAttenuator); void AudioAttenuator_destroy(AudioAttenuator * aAudioAttenuator);
float AudioAttenuator_attenuate(AudioAttenuator * aAudioAttenuator, float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor); float AudioAttenuator_attenuate(AudioAttenuator * aAudioAttenuator, float aDistance, float aMinDistance, float aMaxDistance, float aRolloffFactor);
/* /*
* BiquadResonantFilter * BiquadResonantFilter
*/ */
void BiquadResonantFilter_destroy(BiquadResonantFilter * aBiquadResonantFilter); void BiquadResonantFilter_destroy(BiquadResonantFilter * aBiquadResonantFilter);
BiquadResonantFilter * BiquadResonantFilter_create(); BiquadResonantFilter * BiquadResonantFilter_create();
int BiquadResonantFilter_setParams(BiquadResonantFilter * aBiquadResonantFilter, int aType, float aSampleRate, float aFrequency, float aResonance); int BiquadResonantFilter_setParams(BiquadResonantFilter * aBiquadResonantFilter, int aType, float aSampleRate, float aFrequency, float aResonance);
/* /*
* LofiFilter * LofiFilter
*/ */
void LofiFilter_destroy(LofiFilter * aLofiFilter); void LofiFilter_destroy(LofiFilter * aLofiFilter);
LofiFilter * LofiFilter_create(); LofiFilter * LofiFilter_create();
int LofiFilter_setParams(LofiFilter * aLofiFilter, float aSampleRate, float aBitdepth); int LofiFilter_setParams(LofiFilter * aLofiFilter, float aSampleRate, float aBitdepth);
/* /*
* Bus * Bus
*/ */
void Bus_destroy(Bus * aBus); void Bus_destroy(Bus * aBus);
Bus * Bus_create(); Bus * Bus_create();
void Bus_setFilter(Bus * aBus, unsigned int aFilterId, Filter * aFilter); void Bus_setFilter(Bus * aBus, unsigned int aFilterId, Filter * aFilter);
unsigned int Bus_play(Bus * aBus, AudioSource * aSound); unsigned int Bus_play(Bus * aBus, AudioSource * aSound);
unsigned int Bus_playEx(Bus * aBus, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */); unsigned int Bus_playEx(Bus * aBus, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */, int aPaused /* = 0 */);
unsigned int Bus_playClocked(Bus * aBus, double aSoundTime, AudioSource * aSound); unsigned int Bus_playClocked(Bus * aBus, double aSoundTime, AudioSource * aSound);
unsigned int Bus_playClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */); unsigned int Bus_playClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aVolume /* = 1.0f */, float aPan /* = 0.0f */);
unsigned int Bus_play3d(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); unsigned int Bus_play3d(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ);
unsigned int Bus_play3dEx(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */); unsigned int Bus_play3dEx(Bus * aBus, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */, int aPaused /* = 0 */);
unsigned int Bus_play3dClocked(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ); unsigned int Bus_play3dClocked(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ);
unsigned int Bus_play3dClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */); unsigned int Bus_play3dClockedEx(Bus * aBus, double aSoundTime, AudioSource * aSound, float aPosX, float aPosY, float aPosZ, float aVelX /* = 0.0f */, float aVelY /* = 0.0f */, float aVelZ /* = 0.0f */, float aVolume /* = 1.0f */);
int Bus_setChannels(Bus * aBus, unsigned int aChannels); int Bus_setChannels(Bus * aBus, unsigned int aChannels);
void Bus_setVisualizationEnable(Bus * aBus, int aEnable); void Bus_setVisualizationEnable(Bus * aBus, int aEnable);
float * Bus_calcFFT(Bus * aBus); float * Bus_calcFFT(Bus * aBus);
float * Bus_getWave(Bus * aBus); float * Bus_getWave(Bus * aBus);
void Bus_setVolume(Bus * aBus, float aVolume); void Bus_setVolume(Bus * aBus, float aVolume);
void Bus_setLooping(Bus * aBus, int aLoop); void Bus_setLooping(Bus * aBus, int aLoop);
void Bus_set3dMinMaxDistance(Bus * aBus, float aMinDistance, float aMaxDistance); void Bus_set3dMinMaxDistance(Bus * aBus, float aMinDistance, float aMaxDistance);
void Bus_set3dAttenuation(Bus * aBus, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void Bus_set3dAttenuation(Bus * aBus, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Bus_set3dDopplerFactor(Bus * aBus, float aDopplerFactor); void Bus_set3dDopplerFactor(Bus * aBus, float aDopplerFactor);
void Bus_set3dProcessing(Bus * aBus, int aDo3dProcessing); void Bus_set3dProcessing(Bus * aBus, int aDo3dProcessing);
void Bus_set3dListenerRelative(Bus * aBus, int aListenerRelative); void Bus_set3dListenerRelative(Bus * aBus, int aListenerRelative);
void Bus_set3dDistanceDelay(Bus * aBus, int aDistanceDelay); void Bus_set3dDistanceDelay(Bus * aBus, int aDistanceDelay);
void Bus_set3dCollider(Bus * aBus, AudioCollider * aCollider); void Bus_set3dCollider(Bus * aBus, AudioCollider * aCollider);
void Bus_set3dColliderEx(Bus * aBus, AudioCollider * aCollider, int aUserData /* = 0 */); void Bus_set3dColliderEx(Bus * aBus, AudioCollider * aCollider, int aUserData /* = 0 */);
void Bus_set3dAttenuator(Bus * aBus, AudioAttenuator * aAttenuator); void Bus_set3dAttenuator(Bus * aBus, AudioAttenuator * aAttenuator);
void Bus_setInaudibleBehavior(Bus * aBus, int aMustTick, int aKill); void Bus_setInaudibleBehavior(Bus * aBus, int aMustTick, int aKill);
void Bus_stop(Bus * aBus); void Bus_stop(Bus * aBus);
/* /*
* EchoFilter * EchoFilter
*/ */
void EchoFilter_destroy(EchoFilter * aEchoFilter); void EchoFilter_destroy(EchoFilter * aEchoFilter);
EchoFilter * EchoFilter_create(); EchoFilter * EchoFilter_create();
int EchoFilter_setParams(EchoFilter * aEchoFilter, float aDelay); int EchoFilter_setParams(EchoFilter * aEchoFilter, float aDelay);
int EchoFilter_setParamsEx(EchoFilter * aEchoFilter, float aDelay, float aDecay /* = 0.7f */, float aFilter /* = 0.0f */); int EchoFilter_setParamsEx(EchoFilter * aEchoFilter, float aDelay, float aDecay /* = 0.7f */, float aFilter /* = 0.0f */);
/* /*
* FFTFilter * FFTFilter
*/ */
void FFTFilter_destroy(FFTFilter * aFFTFilter); void FFTFilter_destroy(FFTFilter * aFFTFilter);
FFTFilter * FFTFilter_create(); FFTFilter * FFTFilter_create();
/* /*
* BassboostFilter * BassboostFilter
*/ */
void BassboostFilter_destroy(BassboostFilter * aBassboostFilter); void BassboostFilter_destroy(BassboostFilter * aBassboostFilter);
int BassboostFilter_setParams(BassboostFilter * aBassboostFilter, float aBoost); int BassboostFilter_setParams(BassboostFilter * aBassboostFilter, float aBoost);
BassboostFilter * BassboostFilter_create(); BassboostFilter * BassboostFilter_create();
/* /*
* Speech * Speech
*/ */
void Speech_destroy(Speech * aSpeech); void Speech_destroy(Speech * aSpeech);
Speech * Speech_create(); Speech * Speech_create();
int Speech_setText(Speech * aSpeech, const char * aText); int Speech_setText(Speech * aSpeech, const char * aText);
void Speech_setVolume(Speech * aSpeech, float aVolume); void Speech_setVolume(Speech * aSpeech, float aVolume);
void Speech_setLooping(Speech * aSpeech, int aLoop); void Speech_setLooping(Speech * aSpeech, int aLoop);
void Speech_set3dMinMaxDistance(Speech * aSpeech, float aMinDistance, float aMaxDistance); void Speech_set3dMinMaxDistance(Speech * aSpeech, float aMinDistance, float aMaxDistance);
void Speech_set3dAttenuation(Speech * aSpeech, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void Speech_set3dAttenuation(Speech * aSpeech, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Speech_set3dDopplerFactor(Speech * aSpeech, float aDopplerFactor); void Speech_set3dDopplerFactor(Speech * aSpeech, float aDopplerFactor);
void Speech_set3dProcessing(Speech * aSpeech, int aDo3dProcessing); void Speech_set3dProcessing(Speech * aSpeech, int aDo3dProcessing);
void Speech_set3dListenerRelative(Speech * aSpeech, int aListenerRelative); void Speech_set3dListenerRelative(Speech * aSpeech, int aListenerRelative);
void Speech_set3dDistanceDelay(Speech * aSpeech, int aDistanceDelay); void Speech_set3dDistanceDelay(Speech * aSpeech, int aDistanceDelay);
void Speech_set3dCollider(Speech * aSpeech, AudioCollider * aCollider); void Speech_set3dCollider(Speech * aSpeech, AudioCollider * aCollider);
void Speech_set3dColliderEx(Speech * aSpeech, AudioCollider * aCollider, int aUserData /* = 0 */); void Speech_set3dColliderEx(Speech * aSpeech, AudioCollider * aCollider, int aUserData /* = 0 */);
void Speech_set3dAttenuator(Speech * aSpeech, AudioAttenuator * aAttenuator); void Speech_set3dAttenuator(Speech * aSpeech, AudioAttenuator * aAttenuator);
void Speech_setInaudibleBehavior(Speech * aSpeech, int aMustTick, int aKill); void Speech_setInaudibleBehavior(Speech * aSpeech, int aMustTick, int aKill);
void Speech_setFilter(Speech * aSpeech, unsigned int aFilterId, Filter * aFilter); void Speech_setFilter(Speech * aSpeech, unsigned int aFilterId, Filter * aFilter);
void Speech_stop(Speech * aSpeech); void Speech_stop(Speech * aSpeech);
/* /*
* Wav * Wav
*/ */
void Wav_destroy(Wav * aWav); void Wav_destroy(Wav * aWav);
Wav * Wav_create(); Wav * Wav_create();
int Wav_load(Wav * aWav, const char * aFilename); int Wav_load(Wav * aWav, const char * aFilename);
int Wav_loadMem(Wav * aWav, unsigned char * aMem, unsigned int aLength); int Wav_loadMem(Wav * aWav, unsigned char * aMem, unsigned int aLength);
int Wav_loadMemEx(Wav * aWav, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); int Wav_loadMemEx(Wav * aWav, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */);
int Wav_loadFile(Wav * aWav, File * aFile); int Wav_loadFile(Wav * aWav, File * aFile);
double Wav_getLength(Wav * aWav); double Wav_getLength(Wav * aWav);
void Wav_setVolume(Wav * aWav, float aVolume); void Wav_setVolume(Wav * aWav, float aVolume);
void Wav_setLooping(Wav * aWav, int aLoop); void Wav_setLooping(Wav * aWav, int aLoop);
void Wav_set3dMinMaxDistance(Wav * aWav, float aMinDistance, float aMaxDistance); void Wav_set3dMinMaxDistance(Wav * aWav, float aMinDistance, float aMaxDistance);
void Wav_set3dAttenuation(Wav * aWav, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void Wav_set3dAttenuation(Wav * aWav, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Wav_set3dDopplerFactor(Wav * aWav, float aDopplerFactor); void Wav_set3dDopplerFactor(Wav * aWav, float aDopplerFactor);
void Wav_set3dProcessing(Wav * aWav, int aDo3dProcessing); void Wav_set3dProcessing(Wav * aWav, int aDo3dProcessing);
void Wav_set3dListenerRelative(Wav * aWav, int aListenerRelative); void Wav_set3dListenerRelative(Wav * aWav, int aListenerRelative);
void Wav_set3dDistanceDelay(Wav * aWav, int aDistanceDelay); void Wav_set3dDistanceDelay(Wav * aWav, int aDistanceDelay);
void Wav_set3dCollider(Wav * aWav, AudioCollider * aCollider); void Wav_set3dCollider(Wav * aWav, AudioCollider * aCollider);
void Wav_set3dColliderEx(Wav * aWav, AudioCollider * aCollider, int aUserData /* = 0 */); void Wav_set3dColliderEx(Wav * aWav, AudioCollider * aCollider, int aUserData /* = 0 */);
void Wav_set3dAttenuator(Wav * aWav, AudioAttenuator * aAttenuator); void Wav_set3dAttenuator(Wav * aWav, AudioAttenuator * aAttenuator);
void Wav_setInaudibleBehavior(Wav * aWav, int aMustTick, int aKill); void Wav_setInaudibleBehavior(Wav * aWav, int aMustTick, int aKill);
void Wav_setFilter(Wav * aWav, unsigned int aFilterId, Filter * aFilter); void Wav_setFilter(Wav * aWav, unsigned int aFilterId, Filter * aFilter);
void Wav_stop(Wav * aWav); void Wav_stop(Wav * aWav);
/* /*
* WavStream * WavStream
*/ */
void WavStream_destroy(WavStream * aWavStream); void WavStream_destroy(WavStream * aWavStream);
WavStream * WavStream_create(); WavStream * WavStream_create();
int WavStream_load(WavStream * aWavStream, const char * aFilename); int WavStream_load(WavStream * aWavStream, const char * aFilename);
int WavStream_loadMem(WavStream * aWavStream, unsigned char * aData, unsigned int aDataLen); int WavStream_loadMem(WavStream * aWavStream, unsigned char * aData, unsigned int aDataLen);
int WavStream_loadMemEx(WavStream * aWavStream, unsigned char * aData, unsigned int aDataLen, int aCopy /* = false */, int aTakeOwnership /* = true */); int WavStream_loadMemEx(WavStream * aWavStream, unsigned char * aData, unsigned int aDataLen, int aCopy /* = false */, int aTakeOwnership /* = true */);
int WavStream_loadToMem(WavStream * aWavStream, const char * aFilename); int WavStream_loadToMem(WavStream * aWavStream, const char * aFilename);
int WavStream_loadFile(WavStream * aWavStream, File * aFile); int WavStream_loadFile(WavStream * aWavStream, File * aFile);
int WavStream_loadFileToMem(WavStream * aWavStream, File * aFile); int WavStream_loadFileToMem(WavStream * aWavStream, File * aFile);
double WavStream_getLength(WavStream * aWavStream); double WavStream_getLength(WavStream * aWavStream);
void WavStream_setVolume(WavStream * aWavStream, float aVolume); void WavStream_setVolume(WavStream * aWavStream, float aVolume);
void WavStream_setLooping(WavStream * aWavStream, int aLoop); void WavStream_setLooping(WavStream * aWavStream, int aLoop);
void WavStream_set3dMinMaxDistance(WavStream * aWavStream, float aMinDistance, float aMaxDistance); void WavStream_set3dMinMaxDistance(WavStream * aWavStream, float aMinDistance, float aMaxDistance);
void WavStream_set3dAttenuation(WavStream * aWavStream, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void WavStream_set3dAttenuation(WavStream * aWavStream, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void WavStream_set3dDopplerFactor(WavStream * aWavStream, float aDopplerFactor); void WavStream_set3dDopplerFactor(WavStream * aWavStream, float aDopplerFactor);
void WavStream_set3dProcessing(WavStream * aWavStream, int aDo3dProcessing); void WavStream_set3dProcessing(WavStream * aWavStream, int aDo3dProcessing);
void WavStream_set3dListenerRelative(WavStream * aWavStream, int aListenerRelative); void WavStream_set3dListenerRelative(WavStream * aWavStream, int aListenerRelative);
void WavStream_set3dDistanceDelay(WavStream * aWavStream, int aDistanceDelay); void WavStream_set3dDistanceDelay(WavStream * aWavStream, int aDistanceDelay);
void WavStream_set3dCollider(WavStream * aWavStream, AudioCollider * aCollider); void WavStream_set3dCollider(WavStream * aWavStream, AudioCollider * aCollider);
void WavStream_set3dColliderEx(WavStream * aWavStream, AudioCollider * aCollider, int aUserData /* = 0 */); void WavStream_set3dColliderEx(WavStream * aWavStream, AudioCollider * aCollider, int aUserData /* = 0 */);
void WavStream_set3dAttenuator(WavStream * aWavStream, AudioAttenuator * aAttenuator); void WavStream_set3dAttenuator(WavStream * aWavStream, AudioAttenuator * aAttenuator);
void WavStream_setInaudibleBehavior(WavStream * aWavStream, int aMustTick, int aKill); void WavStream_setInaudibleBehavior(WavStream * aWavStream, int aMustTick, int aKill);
void WavStream_setFilter(WavStream * aWavStream, unsigned int aFilterId, Filter * aFilter); void WavStream_setFilter(WavStream * aWavStream, unsigned int aFilterId, Filter * aFilter);
void WavStream_stop(WavStream * aWavStream); void WavStream_stop(WavStream * aWavStream);
/* /*
* Prg * Prg
*/ */
void Prg_destroy(Prg * aPrg); void Prg_destroy(Prg * aPrg);
Prg * Prg_create(); Prg * Prg_create();
unsigned int Prg_rand(Prg * aPrg); unsigned int Prg_rand(Prg * aPrg);
void Prg_srand(Prg * aPrg, int aSeed); void Prg_srand(Prg * aPrg, int aSeed);
/* /*
* Sfxr * Sfxr
*/ */
void Sfxr_destroy(Sfxr * aSfxr); void Sfxr_destroy(Sfxr * aSfxr);
Sfxr * Sfxr_create(); Sfxr * Sfxr_create();
void Sfxr_resetParams(Sfxr * aSfxr); void Sfxr_resetParams(Sfxr * aSfxr);
int Sfxr_loadParams(Sfxr * aSfxr, const char * aFilename); int Sfxr_loadParams(Sfxr * aSfxr, const char * aFilename);
int Sfxr_loadParamsMem(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength); int Sfxr_loadParamsMem(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength);
int Sfxr_loadParamsMemEx(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); int Sfxr_loadParamsMemEx(Sfxr * aSfxr, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */);
int Sfxr_loadParamsFile(Sfxr * aSfxr, File * aFile); int Sfxr_loadParamsFile(Sfxr * aSfxr, File * aFile);
int Sfxr_loadPreset(Sfxr * aSfxr, int aPresetNo, int aRandSeed); int Sfxr_loadPreset(Sfxr * aSfxr, int aPresetNo, int aRandSeed);
void Sfxr_setVolume(Sfxr * aSfxr, float aVolume); void Sfxr_setVolume(Sfxr * aSfxr, float aVolume);
void Sfxr_setLooping(Sfxr * aSfxr, int aLoop); void Sfxr_setLooping(Sfxr * aSfxr, int aLoop);
void Sfxr_set3dMinMaxDistance(Sfxr * aSfxr, float aMinDistance, float aMaxDistance); void Sfxr_set3dMinMaxDistance(Sfxr * aSfxr, float aMinDistance, float aMaxDistance);
void Sfxr_set3dAttenuation(Sfxr * aSfxr, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void Sfxr_set3dAttenuation(Sfxr * aSfxr, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Sfxr_set3dDopplerFactor(Sfxr * aSfxr, float aDopplerFactor); void Sfxr_set3dDopplerFactor(Sfxr * aSfxr, float aDopplerFactor);
void Sfxr_set3dProcessing(Sfxr * aSfxr, int aDo3dProcessing); void Sfxr_set3dProcessing(Sfxr * aSfxr, int aDo3dProcessing);
void Sfxr_set3dListenerRelative(Sfxr * aSfxr, int aListenerRelative); void Sfxr_set3dListenerRelative(Sfxr * aSfxr, int aListenerRelative);
void Sfxr_set3dDistanceDelay(Sfxr * aSfxr, int aDistanceDelay); void Sfxr_set3dDistanceDelay(Sfxr * aSfxr, int aDistanceDelay);
void Sfxr_set3dCollider(Sfxr * aSfxr, AudioCollider * aCollider); void Sfxr_set3dCollider(Sfxr * aSfxr, AudioCollider * aCollider);
void Sfxr_set3dColliderEx(Sfxr * aSfxr, AudioCollider * aCollider, int aUserData /* = 0 */); void Sfxr_set3dColliderEx(Sfxr * aSfxr, AudioCollider * aCollider, int aUserData /* = 0 */);
void Sfxr_set3dAttenuator(Sfxr * aSfxr, AudioAttenuator * aAttenuator); void Sfxr_set3dAttenuator(Sfxr * aSfxr, AudioAttenuator * aAttenuator);
void Sfxr_setInaudibleBehavior(Sfxr * aSfxr, int aMustTick, int aKill); void Sfxr_setInaudibleBehavior(Sfxr * aSfxr, int aMustTick, int aKill);
void Sfxr_setFilter(Sfxr * aSfxr, unsigned int aFilterId, Filter * aFilter); void Sfxr_setFilter(Sfxr * aSfxr, unsigned int aFilterId, Filter * aFilter);
void Sfxr_stop(Sfxr * aSfxr); void Sfxr_stop(Sfxr * aSfxr);
/* /*
* FlangerFilter * FlangerFilter
*/ */
void FlangerFilter_destroy(FlangerFilter * aFlangerFilter); void FlangerFilter_destroy(FlangerFilter * aFlangerFilter);
FlangerFilter * FlangerFilter_create(); FlangerFilter * FlangerFilter_create();
int FlangerFilter_setParams(FlangerFilter * aFlangerFilter, float aDelay, float aFreq); int FlangerFilter_setParams(FlangerFilter * aFlangerFilter, float aDelay, float aFreq);
/* /*
* DCRemovalFilter * DCRemovalFilter
*/ */
void DCRemovalFilter_destroy(DCRemovalFilter * aDCRemovalFilter); void DCRemovalFilter_destroy(DCRemovalFilter * aDCRemovalFilter);
DCRemovalFilter * DCRemovalFilter_create(); DCRemovalFilter * DCRemovalFilter_create();
int DCRemovalFilter_setParams(DCRemovalFilter * aDCRemovalFilter); int DCRemovalFilter_setParams(DCRemovalFilter * aDCRemovalFilter);
int DCRemovalFilter_setParamsEx(DCRemovalFilter * aDCRemovalFilter, float aLength /* = 0.1f */); int DCRemovalFilter_setParamsEx(DCRemovalFilter * aDCRemovalFilter, float aLength /* = 0.1f */);
/* /*
* Openmpt * Openmpt
*/ */
void Openmpt_destroy(Openmpt * aOpenmpt); void Openmpt_destroy(Openmpt * aOpenmpt);
Openmpt * Openmpt_create(); Openmpt * Openmpt_create();
int Openmpt_load(Openmpt * aOpenmpt, const char * aFilename); int Openmpt_load(Openmpt * aOpenmpt, const char * aFilename);
int Openmpt_loadMem(Openmpt * aOpenmpt, unsigned char * aMem, unsigned int aLength); int Openmpt_loadMem(Openmpt * aOpenmpt, unsigned char * aMem, unsigned int aLength);
int Openmpt_loadMemEx(Openmpt * aOpenmpt, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); int Openmpt_loadMemEx(Openmpt * aOpenmpt, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */);
int Openmpt_loadFile(Openmpt * aOpenmpt, File * aFile); int Openmpt_loadFile(Openmpt * aOpenmpt, File * aFile);
void Openmpt_setVolume(Openmpt * aOpenmpt, float aVolume); void Openmpt_setVolume(Openmpt * aOpenmpt, float aVolume);
void Openmpt_setLooping(Openmpt * aOpenmpt, int aLoop); void Openmpt_setLooping(Openmpt * aOpenmpt, int aLoop);
void Openmpt_set3dMinMaxDistance(Openmpt * aOpenmpt, float aMinDistance, float aMaxDistance); void Openmpt_set3dMinMaxDistance(Openmpt * aOpenmpt, float aMinDistance, float aMaxDistance);
void Openmpt_set3dAttenuation(Openmpt * aOpenmpt, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void Openmpt_set3dAttenuation(Openmpt * aOpenmpt, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Openmpt_set3dDopplerFactor(Openmpt * aOpenmpt, float aDopplerFactor); void Openmpt_set3dDopplerFactor(Openmpt * aOpenmpt, float aDopplerFactor);
void Openmpt_set3dProcessing(Openmpt * aOpenmpt, int aDo3dProcessing); void Openmpt_set3dProcessing(Openmpt * aOpenmpt, int aDo3dProcessing);
void Openmpt_set3dListenerRelative(Openmpt * aOpenmpt, int aListenerRelative); void Openmpt_set3dListenerRelative(Openmpt * aOpenmpt, int aListenerRelative);
void Openmpt_set3dDistanceDelay(Openmpt * aOpenmpt, int aDistanceDelay); void Openmpt_set3dDistanceDelay(Openmpt * aOpenmpt, int aDistanceDelay);
void Openmpt_set3dCollider(Openmpt * aOpenmpt, AudioCollider * aCollider); void Openmpt_set3dCollider(Openmpt * aOpenmpt, AudioCollider * aCollider);
void Openmpt_set3dColliderEx(Openmpt * aOpenmpt, AudioCollider * aCollider, int aUserData /* = 0 */); void Openmpt_set3dColliderEx(Openmpt * aOpenmpt, AudioCollider * aCollider, int aUserData /* = 0 */);
void Openmpt_set3dAttenuator(Openmpt * aOpenmpt, AudioAttenuator * aAttenuator); void Openmpt_set3dAttenuator(Openmpt * aOpenmpt, AudioAttenuator * aAttenuator);
void Openmpt_setInaudibleBehavior(Openmpt * aOpenmpt, int aMustTick, int aKill); void Openmpt_setInaudibleBehavior(Openmpt * aOpenmpt, int aMustTick, int aKill);
void Openmpt_setFilter(Openmpt * aOpenmpt, unsigned int aFilterId, Filter * aFilter); void Openmpt_setFilter(Openmpt * aOpenmpt, unsigned int aFilterId, Filter * aFilter);
void Openmpt_stop(Openmpt * aOpenmpt); void Openmpt_stop(Openmpt * aOpenmpt);
/* /*
* Monotone * Monotone
*/ */
void Monotone_destroy(Monotone * aMonotone); void Monotone_destroy(Monotone * aMonotone);
Monotone * Monotone_create(); Monotone * Monotone_create();
int Monotone_setParams(Monotone * aMonotone, int aHardwareChannels); int Monotone_setParams(Monotone * aMonotone, int aHardwareChannels);
int Monotone_setParamsEx(Monotone * aMonotone, int aHardwareChannels, int aWaveform /* = SQUARE */); int Monotone_setParamsEx(Monotone * aMonotone, int aHardwareChannels, int aWaveform /* = SQUARE */);
int Monotone_load(Monotone * aMonotone, const char * aFilename); int Monotone_load(Monotone * aMonotone, const char * aFilename);
int Monotone_loadMem(Monotone * aMonotone, unsigned char * aMem, unsigned int aLength); int Monotone_loadMem(Monotone * aMonotone, unsigned char * aMem, unsigned int aLength);
int Monotone_loadMemEx(Monotone * aMonotone, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); int Monotone_loadMemEx(Monotone * aMonotone, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */);
int Monotone_loadFile(Monotone * aMonotone, File * aFile); int Monotone_loadFile(Monotone * aMonotone, File * aFile);
void Monotone_setVolume(Monotone * aMonotone, float aVolume); void Monotone_setVolume(Monotone * aMonotone, float aVolume);
void Monotone_setLooping(Monotone * aMonotone, int aLoop); void Monotone_setLooping(Monotone * aMonotone, int aLoop);
void Monotone_set3dMinMaxDistance(Monotone * aMonotone, float aMinDistance, float aMaxDistance); void Monotone_set3dMinMaxDistance(Monotone * aMonotone, float aMinDistance, float aMaxDistance);
void Monotone_set3dAttenuation(Monotone * aMonotone, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void Monotone_set3dAttenuation(Monotone * aMonotone, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void Monotone_set3dDopplerFactor(Monotone * aMonotone, float aDopplerFactor); void Monotone_set3dDopplerFactor(Monotone * aMonotone, float aDopplerFactor);
void Monotone_set3dProcessing(Monotone * aMonotone, int aDo3dProcessing); void Monotone_set3dProcessing(Monotone * aMonotone, int aDo3dProcessing);
void Monotone_set3dListenerRelative(Monotone * aMonotone, int aListenerRelative); void Monotone_set3dListenerRelative(Monotone * aMonotone, int aListenerRelative);
void Monotone_set3dDistanceDelay(Monotone * aMonotone, int aDistanceDelay); void Monotone_set3dDistanceDelay(Monotone * aMonotone, int aDistanceDelay);
void Monotone_set3dCollider(Monotone * aMonotone, AudioCollider * aCollider); void Monotone_set3dCollider(Monotone * aMonotone, AudioCollider * aCollider);
void Monotone_set3dColliderEx(Monotone * aMonotone, AudioCollider * aCollider, int aUserData /* = 0 */); void Monotone_set3dColliderEx(Monotone * aMonotone, AudioCollider * aCollider, int aUserData /* = 0 */);
void Monotone_set3dAttenuator(Monotone * aMonotone, AudioAttenuator * aAttenuator); void Monotone_set3dAttenuator(Monotone * aMonotone, AudioAttenuator * aAttenuator);
void Monotone_setInaudibleBehavior(Monotone * aMonotone, int aMustTick, int aKill); void Monotone_setInaudibleBehavior(Monotone * aMonotone, int aMustTick, int aKill);
void Monotone_setFilter(Monotone * aMonotone, unsigned int aFilterId, Filter * aFilter); void Monotone_setFilter(Monotone * aMonotone, unsigned int aFilterId, Filter * aFilter);
void Monotone_stop(Monotone * aMonotone); void Monotone_stop(Monotone * aMonotone);
/* /*
* TedSid * TedSid
*/ */
void TedSid_destroy(TedSid * aTedSid); void TedSid_destroy(TedSid * aTedSid);
TedSid * TedSid_create(); TedSid * TedSid_create();
int TedSid_load(TedSid * aTedSid, const char * aFilename); int TedSid_load(TedSid * aTedSid, const char * aFilename);
int TedSid_loadToMem(TedSid * aTedSid, const char * aFilename); int TedSid_loadToMem(TedSid * aTedSid, const char * aFilename);
int TedSid_loadMem(TedSid * aTedSid, unsigned char * aMem, unsigned int aLength); int TedSid_loadMem(TedSid * aTedSid, unsigned char * aMem, unsigned int aLength);
int TedSid_loadMemEx(TedSid * aTedSid, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */); int TedSid_loadMemEx(TedSid * aTedSid, unsigned char * aMem, unsigned int aLength, int aCopy /* = false */, int aTakeOwnership /* = true */);
int TedSid_loadFileToMem(TedSid * aTedSid, File * aFile); int TedSid_loadFileToMem(TedSid * aTedSid, File * aFile);
int TedSid_loadFile(TedSid * aTedSid, File * aFile); int TedSid_loadFile(TedSid * aTedSid, File * aFile);
void TedSid_setVolume(TedSid * aTedSid, float aVolume); void TedSid_setVolume(TedSid * aTedSid, float aVolume);
void TedSid_setLooping(TedSid * aTedSid, int aLoop); void TedSid_setLooping(TedSid * aTedSid, int aLoop);
void TedSid_set3dMinMaxDistance(TedSid * aTedSid, float aMinDistance, float aMaxDistance); void TedSid_set3dMinMaxDistance(TedSid * aTedSid, float aMinDistance, float aMaxDistance);
void TedSid_set3dAttenuation(TedSid * aTedSid, unsigned int aAttenuationModel, float aAttenuationRolloffFactor); void TedSid_set3dAttenuation(TedSid * aTedSid, unsigned int aAttenuationModel, float aAttenuationRolloffFactor);
void TedSid_set3dDopplerFactor(TedSid * aTedSid, float aDopplerFactor); void TedSid_set3dDopplerFactor(TedSid * aTedSid, float aDopplerFactor);
void TedSid_set3dProcessing(TedSid * aTedSid, int aDo3dProcessing); void TedSid_set3dProcessing(TedSid * aTedSid, int aDo3dProcessing);
void TedSid_set3dListenerRelative(TedSid * aTedSid, int aListenerRelative); void TedSid_set3dListenerRelative(TedSid * aTedSid, int aListenerRelative);
void TedSid_set3dDistanceDelay(TedSid * aTedSid, int aDistanceDelay); void TedSid_set3dDistanceDelay(TedSid * aTedSid, int aDistanceDelay);
void TedSid_set3dCollider(TedSid * aTedSid, AudioCollider * aCollider); void TedSid_set3dCollider(TedSid * aTedSid, AudioCollider * aCollider);
void TedSid_set3dColliderEx(TedSid * aTedSid, AudioCollider * aCollider, int aUserData /* = 0 */); void TedSid_set3dColliderEx(TedSid * aTedSid, AudioCollider * aCollider, int aUserData /* = 0 */);
void TedSid_set3dAttenuator(TedSid * aTedSid, AudioAttenuator * aAttenuator); void TedSid_set3dAttenuator(TedSid * aTedSid, AudioAttenuator * aAttenuator);
void TedSid_setInaudibleBehavior(TedSid * aTedSid, int aMustTick, int aKill); void TedSid_setInaudibleBehavior(TedSid * aTedSid, int aMustTick, int aKill);
void TedSid_setFilter(TedSid * aTedSid, unsigned int aFilterId, Filter * aFilter); void TedSid_setFilter(TedSid * aTedSid, unsigned int aFilterId, Filter * aFilter);
void TedSid_stop(TedSid * aTedSid); void TedSid_stop(TedSid * aTedSid);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
#endif // SOLOUD_C_H_INCLUDED #endif // SOLOUD_C_H_INCLUDED

@ -1,58 +1,58 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_DCREMOVAL_H #ifndef SOLOUD_DCREMOVAL_H
#define SOLOUD_DCREMOVAL_H #define SOLOUD_DCREMOVAL_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class DCRemovalFilter; class DCRemovalFilter;
class DCRemovalFilterInstance : public FilterInstance class DCRemovalFilterInstance : public FilterInstance
{ {
float *mBuffer; float *mBuffer;
float *mTotals; float *mTotals;
int mBufferLength; int mBufferLength;
DCRemovalFilter *mParent; DCRemovalFilter *mParent;
int mOffset; int mOffset;
public: public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~DCRemovalFilterInstance(); virtual ~DCRemovalFilterInstance();
DCRemovalFilterInstance(DCRemovalFilter *aParent); DCRemovalFilterInstance(DCRemovalFilter *aParent);
}; };
class DCRemovalFilter : public Filter class DCRemovalFilter : public Filter
{ {
public: public:
float mLength; float mLength;
virtual FilterInstance *createInstance(); virtual FilterInstance *createInstance();
DCRemovalFilter(); DCRemovalFilter();
result setParams(float aLength = 0.1f); result setParams(float aLength = 0.1f);
}; };
} }
#endif #endif

@ -1,59 +1,59 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_ECHOFILTER_H #ifndef SOLOUD_ECHOFILTER_H
#define SOLOUD_ECHOFILTER_H #define SOLOUD_ECHOFILTER_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class EchoFilter; class EchoFilter;
class EchoFilterInstance : public FilterInstance class EchoFilterInstance : public FilterInstance
{ {
float *mBuffer; float *mBuffer;
int mBufferLength; int mBufferLength;
EchoFilter *mParent; EchoFilter *mParent;
int mOffset; int mOffset;
public: public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~EchoFilterInstance(); virtual ~EchoFilterInstance();
EchoFilterInstance(EchoFilter *aParent); EchoFilterInstance(EchoFilter *aParent);
}; };
class EchoFilter : public Filter class EchoFilter : public Filter
{ {
public: public:
float mDelay; float mDelay;
float mDecay; float mDecay;
float mFilter; float mFilter;
virtual FilterInstance *createInstance(); virtual FilterInstance *createInstance();
EchoFilter(); EchoFilter();
result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f); result setParams(float aDelay, float aDecay = 0.7f, float aFilter = 0.0f);
}; };
} }
#endif #endif

@ -1,41 +1,41 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_ERROR_H #ifndef SOLOUD_ERROR_H
#define SOLOUD_ERROR_H #define SOLOUD_ERROR_H
namespace SoLoud namespace SoLoud
{ {
enum SOLOUD_ERRORS enum SOLOUD_ERRORS
{ {
SO_NO_ERROR = 0, // No error SO_NO_ERROR = 0, // No error
INVALID_PARAMETER = 1, // Some parameter is invalid INVALID_PARAMETER = 1, // Some parameter is invalid
FILE_NOT_FOUND = 2, // File not found FILE_NOT_FOUND = 2, // File not found
FILE_LOAD_FAILED = 3, // File found, but could not be loaded FILE_LOAD_FAILED = 3, // File found, but could not be loaded
DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL
OUT_OF_MEMORY = 5, // Out of memory OUT_OF_MEMORY = 5, // Out of memory
NOT_IMPLEMENTED = 6, // Feature not implemented NOT_IMPLEMENTED = 6, // Feature not implemented
UNKNOWN_ERROR = 7 // Other error UNKNOWN_ERROR = 7 // Other error
}; };
}; };
#endif #endif

@ -1,63 +1,63 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_FADER_H #ifndef SOLOUD_FADER_H
#define SOLOUD_FADER_H #define SOLOUD_FADER_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
// Helper class to process faders // Helper class to process faders
class Fader class Fader
{ {
public: public:
// Value to fade from // Value to fade from
float mFrom; float mFrom;
// Value to fade to // Value to fade to
float mTo; float mTo;
// Delta between from and to // Delta between from and to
float mDelta; float mDelta;
// Total time to fade // Total time to fade
time mTime; time mTime;
// Time fading started // Time fading started
time mStartTime; time mStartTime;
// Time fading will end // Time fading will end
time mEndTime; time mEndTime;
// Current value. Used in case time rolls over. // Current value. Used in case time rolls over.
float mCurrent; float mCurrent;
// Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped // Active flag; 0 means disabled, 1 is active, 2 is LFO, -1 means was active, but stopped
int mActive; int mActive;
// Ctor // Ctor
Fader(); Fader();
// Set up LFO // Set up LFO
void setLFO(float aFrom, float aTo, time aTime, time aStartTime); void setLFO(float aFrom, float aTo, time aTime, time aStartTime);
// Set up fader // Set up fader
void set(float aFrom, float aTo, time aTime, time aStartTime); void set(float aFrom, float aTo, time aTime, time aStartTime);
// Get the current fading value // Get the current fading value
float get(time aCurrentTime); float get(time aCurrentTime);
}; };
}; };
#endif #endif

@ -1,45 +1,45 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_FFT_H #ifndef SOLOUD_FFT_H
#define SOLOUD_FFT_H #define SOLOUD_FFT_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
namespace FFT namespace FFT
{ {
// Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten // Perform 1024 unit FFT. Buffer must have 1024 floats, and will be overwritten
void fft1024(float *aBuffer); void fft1024(float *aBuffer);
// Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten // Perform 256 unit FFT. Buffer must have 256 floats, and will be overwritten
void fft256(float *aBuffer); void fft256(float *aBuffer);
// Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten // Perform 256 unit IFFT. Buffer must have 256 floats, and will be overwritten
void ifft256(float *aBuffer); void ifft256(float *aBuffer);
}; };
}; };
#endif #endif

@ -1,57 +1,57 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_FFTFILTER_H #ifndef SOLOUD_FFTFILTER_H
#define SOLOUD_FFTFILTER_H #define SOLOUD_FFTFILTER_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class FFTFilter; class FFTFilter;
class FFTFilterInstance : public FilterInstance class FFTFilterInstance : public FilterInstance
{ {
float *mTemp; float *mTemp;
float *mInputBuffer; float *mInputBuffer;
float *mMixBuffer; float *mMixBuffer;
unsigned int mOffset[MAX_CHANNELS]; unsigned int mOffset[MAX_CHANNELS];
FFTFilter *mParent; FFTFilter *mParent;
public: public:
virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); virtual void fftFilterChannel(float *aFFTBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~FFTFilterInstance(); virtual ~FFTFilterInstance();
FFTFilterInstance(FFTFilter *aParent); FFTFilterInstance(FFTFilter *aParent);
FFTFilterInstance(); FFTFilterInstance();
}; };
class FFTFilter : public Filter class FFTFilter : public Filter
{ {
public: public:
virtual FilterInstance *createInstance(); virtual FilterInstance *createInstance();
FFTFilter(); FFTFilter();
}; };
} }
#endif #endif

@ -1,35 +1,35 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
/* /*
See soloud_file_hack_on.h See soloud_file_hack_on.h
*/ */
#undef FILE #undef FILE
#undef fgetc #undef fgetc
#undef fread #undef fread
#undef fseek #undef fseek
#undef ftell #undef ftell
#undef fclose #undef fclose
#undef fopen #undef fopen

@ -1,58 +1,58 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
/* /*
This is a "hack" header to fool third party code to use our File stuff instead This is a "hack" header to fool third party code to use our File stuff instead
of stdio FILE* stuff. of stdio FILE* stuff.
You can use soloud_file_hack_off.h to undef the stuff defined here. You can use soloud_file_hack_off.h to undef the stuff defined here.
*/ */
#ifndef SEEK_SET #ifndef SEEK_SET
#error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio. #error soloud_file_hack_on must be included after stdio, otherwise the #define hacks will break stdio.
#endif #endif
typedef void* Soloud_Filehack; typedef void* Soloud_Filehack;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern int Soloud_Filehack_fgetc(Soloud_Filehack *f); extern int Soloud_Filehack_fgetc(Soloud_Filehack *f);
extern int Soloud_Filehack_fread(void *dst, int s, int c, Soloud_Filehack *f); extern int Soloud_Filehack_fread(void *dst, int s, int c, Soloud_Filehack *f);
extern int Soloud_Filehack_fseek(Soloud_Filehack *f, int idx, int base); extern int Soloud_Filehack_fseek(Soloud_Filehack *f, int idx, int base);
extern int Soloud_Filehack_ftell(Soloud_Filehack *f); extern int Soloud_Filehack_ftell(Soloud_Filehack *f);
extern int Soloud_Filehack_fclose(Soloud_Filehack *f); extern int Soloud_Filehack_fclose(Soloud_Filehack *f);
extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode); extern Soloud_Filehack * Soloud_Filehack_fopen(const char *aFilename, char *aMode);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#define FILE Soloud_Filehack #define FILE Soloud_Filehack
#define fgetc Soloud_Filehack_fgetc #define fgetc Soloud_Filehack_fgetc
#define fread Soloud_Filehack_fread #define fread Soloud_Filehack_fread
#define fseek Soloud_Filehack_fseek #define fseek Soloud_Filehack_fseek
#define ftell Soloud_Filehack_ftell #define ftell Soloud_Filehack_ftell
#define fclose Soloud_Filehack_fclose #define fclose Soloud_Filehack_fclose
#define fopen Soloud_Filehack_fopen #define fopen Soloud_Filehack_fopen

@ -1,64 +1,64 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_FILTER_H #ifndef SOLOUD_FILTER_H
#define SOLOUD_FILTER_H #define SOLOUD_FILTER_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class Fader; class Fader;
class FilterInstance class FilterInstance
{ {
public: public:
unsigned int mNumParams; unsigned int mNumParams;
unsigned int mParamChanged; unsigned int mParamChanged;
float *mParam; float *mParam;
Fader *mParamFader; Fader *mParamFader;
FilterInstance(); FilterInstance();
virtual result initParams(int aNumParams); virtual result initParams(int aNumParams);
virtual void updateParams(time aTime); virtual void updateParams(time aTime);
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual float getFilterParameter(unsigned int aAttributeId); virtual float getFilterParameter(unsigned int aAttributeId);
virtual void setFilterParameter(unsigned int aAttributeId, float aValue); virtual void setFilterParameter(unsigned int aAttributeId, float aValue);
virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime); virtual void fadeFilterParameter(unsigned int aAttributeId, float aTo, time aTime, time aStartTime);
virtual void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime); virtual void oscillateFilterParameter(unsigned int aAttributeId, float aFrom, float aTo, time aTime, time aStartTime);
virtual ~FilterInstance(); virtual ~FilterInstance();
}; };
class Filter class Filter
{ {
public: public:
Filter(); Filter();
virtual FilterInstance *createInstance() = 0; virtual FilterInstance *createInstance() = 0;
virtual ~Filter(); virtual ~Filter();
}; };
}; };
#endif #endif

@ -1,65 +1,65 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_FLANGERFILTER_H #ifndef SOLOUD_FLANGERFILTER_H
#define SOLOUD_FLANGERFILTER_H #define SOLOUD_FLANGERFILTER_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class FlangerFilter; class FlangerFilter;
class FlangerFilterInstance : public FilterInstance class FlangerFilterInstance : public FilterInstance
{ {
float *mBuffer; float *mBuffer;
int mBufferLength; int mBufferLength;
FlangerFilter *mParent; FlangerFilter *mParent;
int mOffset; int mOffset;
double mIndex; double mIndex;
public: public:
virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime); virtual void filter(float *aBuffer, unsigned int aSamples, unsigned int aChannels, float aSamplerate, time aTime);
virtual ~FlangerFilterInstance(); virtual ~FlangerFilterInstance();
FlangerFilterInstance(FlangerFilter *aParent); FlangerFilterInstance(FlangerFilter *aParent);
}; };
class FlangerFilter : public Filter class FlangerFilter : public Filter
{ {
public: public:
enum FILTERPARAMS enum FILTERPARAMS
{ {
WET, WET,
DELAY, DELAY,
FREQ FREQ
}; };
float mDelay; float mDelay;
float mFreq; float mFreq;
virtual FilterInstance *createInstance(); virtual FilterInstance *createInstance();
FlangerFilter(); FlangerFilter();
result setParams(float aDelay, float aFreq); result setParams(float aDelay, float aFreq);
}; };
} }
#endif #endif

@ -1,118 +1,118 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_INTERNAL_H #ifndef SOLOUD_INTERNAL_H
#define SOLOUD_INTERNAL_H #define SOLOUD_INTERNAL_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
// SDL back-end initialization call // SDL back-end initialization call
result sdl_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result sdl_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// SDL "non-dynamic" back-end initialization call // SDL "non-dynamic" back-end initialization call
result sdlstatic_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result sdlstatic_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// SDL2 "non-dynamic" back-end initialization call // SDL2 "non-dynamic" back-end initialization call
result sdl2static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result sdl2static_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// OpenAL back-end initialization call // OpenAL back-end initialization call
result openal_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result openal_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// Core Audio driver back-end initialization call // Core Audio driver back-end initialization call
result coreaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result coreaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// OpenSL ES back-end initialization call // OpenSL ES back-end initialization call
result opensles_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result opensles_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// PortAudio back-end initialization call // PortAudio back-end initialization call
result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result portaudio_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// WinMM back-end initialization call // WinMM back-end initialization call
result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); result winmm_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2);
// XAudio2 back-end initialization call // XAudio2 back-end initialization call
result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result xaudio2_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// WASAPI back-end initialization call // WASAPI back-end initialization call
result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2); result wasapi_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 4096, unsigned int aChannels = 2);
// OSS back-end initialization call // OSS back-end initialization call
result oss_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result oss_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// PS Vita homebrew back-end initialization call // PS Vita homebrew back-end initialization call
result vita_homebrew_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result vita_homebrew_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// ALSA back-end initialization call // ALSA back-end initialization call
result alsa_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result alsa_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// null driver back-end initialization call // null driver back-end initialization call
result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2); result null_init(SoLoud::Soloud *aSoloud, unsigned int aFlags = Soloud::CLIP_ROUNDOFF, unsigned int aSamplerate = 44100, unsigned int aBuffer = 2048, unsigned int aChannels = 2);
// Deinterlace samples in a buffer. From 12121212 to 11112222 // Deinterlace samples in a buffer. From 12121212 to 11112222
void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
// Interlace samples in a buffer. From 11112222 to 12121212 // Interlace samples in a buffer. From 11112222 to 12121212
void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels); void interlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
// Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212 // Convert to 16-bit and interlace samples in a buffer. From 11112222 to 12121212
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels); void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
}; };
#define FOR_ALL_VOICES_PRE \ #define FOR_ALL_VOICES_PRE \
handle *h_ = NULL; \ handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \ handle th_[2] = { aVoiceHandle, 0 }; \
lockAudioMutex(); \ lockAudioMutex(); \
h_ = voiceGroupHandleToArray(aVoiceHandle); \ h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \ if (h_ == NULL) h_ = th_; \
while (*h_) \ while (*h_) \
{ \ { \
int ch = getVoiceFromHandle(*h_); \ int ch = getVoiceFromHandle(*h_); \
if (ch != -1) \ if (ch != -1) \
{ {
#define FOR_ALL_VOICES_POST \ #define FOR_ALL_VOICES_POST \
} \ } \
h_++; \ h_++; \
} \ } \
unlockAudioMutex(); unlockAudioMutex();
#define FOR_ALL_VOICES_PRE_3D \ #define FOR_ALL_VOICES_PRE_3D \
handle *h_ = NULL; \ handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \ handle th_[2] = { aVoiceHandle, 0 }; \
h_ = voiceGroupHandleToArray(aVoiceHandle); \ h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \ if (h_ == NULL) h_ = th_; \
while (*h_) \ while (*h_) \
{ \ { \
int ch = (*h_ & 0xfff) - 1; \ int ch = (*h_ & 0xfff) - 1; \
if (ch != -1 && m3dData[ch].mHandle == *h_) \ if (ch != -1 && m3dData[ch].mHandle == *h_) \
{ {
#define FOR_ALL_VOICES_POST_3D \ #define FOR_ALL_VOICES_POST_3D \
} \ } \
h_++; \ h_++; \
} }
#endif #endif

@ -1,75 +1,75 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_LOFIFILTER_H #ifndef SOLOUD_LOFIFILTER_H
#define SOLOUD_LOFIFILTER_H #define SOLOUD_LOFIFILTER_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class LofiFilter; class LofiFilter;
struct LofiChannelData struct LofiChannelData
{ {
float mSample; float mSample;
float mSamplesToSkip; float mSamplesToSkip;
}; };
class LofiFilterInstance : public FilterInstance class LofiFilterInstance : public FilterInstance
{ {
enum FILTERPARAMS enum FILTERPARAMS
{ {
WET, WET,
SAMPLERATE, SAMPLERATE,
BITDEPTH BITDEPTH
}; };
LofiChannelData mChannelData[2]; LofiChannelData mChannelData[2];
LofiFilter *mParent; LofiFilter *mParent;
public: public:
virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels); virtual void filterChannel(float *aBuffer, unsigned int aSamples, float aSamplerate, time aTime, unsigned int aChannel, unsigned int aChannels);
virtual ~LofiFilterInstance(); virtual ~LofiFilterInstance();
LofiFilterInstance(LofiFilter *aParent); LofiFilterInstance(LofiFilter *aParent);
}; };
class LofiFilter : public Filter class LofiFilter : public Filter
{ {
public: public:
enum FILTERPARAMS enum FILTERPARAMS
{ {
WET, WET,
SAMPLERATE, SAMPLERATE,
BITDEPTH BITDEPTH
}; };
float mSampleRate; float mSampleRate;
float mBitdepth; float mBitdepth;
virtual LofiFilterInstance *createInstance(); virtual LofiFilterInstance *createInstance();
LofiFilter(); LofiFilter();
result setParams(float aSampleRate, float aBitdepth); result setParams(float aSampleRate, float aBitdepth);
virtual ~LofiFilter(); virtual ~LofiFilter();
}; };
} }
#endif #endif

@ -1,116 +1,116 @@
/* /*
MONOTONE module for SoLoud audio engine MONOTONE module for SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef MONOTONE_H #ifndef MONOTONE_H
#define MONOTONE_H #define MONOTONE_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class Monotone; class Monotone;
class File; class File;
struct MonotoneSong struct MonotoneSong
{ {
char *mTitle; char *mTitle;
char *mComment; char *mComment;
unsigned char mVersion; // must be 1 unsigned char mVersion; // must be 1
unsigned char mTotalPatterns; unsigned char mTotalPatterns;
unsigned char mTotalTracks; unsigned char mTotalTracks;
unsigned char mCellSize; // must be 2 for version 1 unsigned char mCellSize; // must be 2 for version 1
unsigned char mOrder[256]; unsigned char mOrder[256];
unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks unsigned int *mPatternData; // 64 rows * mTotalPatterns * mTotalTracks
}; };
struct MonotoneChannel struct MonotoneChannel
{ {
int mEnabled; int mEnabled;
int mActive; int mActive;
int mFreq[3]; int mFreq[3];
int mPortamento; int mPortamento;
int mArpCounter; int mArpCounter;
int mArp; int mArp;
int mLastNote; int mLastNote;
int mPortamentoToNote; int mPortamentoToNote;
int mVibrato; int mVibrato;
int mVibratoIndex; int mVibratoIndex;
int mVibratoDepth; int mVibratoDepth;
int mVibratoSpeed; int mVibratoSpeed;
}; };
struct MonotoneHardwareChannel struct MonotoneHardwareChannel
{ {
int mEnabled; int mEnabled;
float mSamplePos; float mSamplePos;
float mSamplePosInc; float mSamplePosInc;
}; };
class MonotoneInstance : public AudioSourceInstance class MonotoneInstance : public AudioSourceInstance
{ {
Monotone *mParent; Monotone *mParent;
public: public:
MonotoneChannel mChannel[12]; MonotoneChannel mChannel[12];
MonotoneHardwareChannel mOutput[12]; MonotoneHardwareChannel mOutput[12];
int mNextChannel; int mNextChannel;
int mTempo; // ticks / row. Tick = 60hz. Default 4. int mTempo; // ticks / row. Tick = 60hz. Default 4.
int mOrder; int mOrder;
int mRow; int mRow;
int mSampleCount; int mSampleCount;
int mRowTick; int mRowTick;
MonotoneInstance(Monotone *aParent); MonotoneInstance(Monotone *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded(); virtual bool hasEnded();
}; };
class Monotone : public AudioSource class Monotone : public AudioSource
{ {
public: public:
enum MONOTONE_WAVEFORMS enum MONOTONE_WAVEFORMS
{ {
SQUARE = 0, SQUARE = 0,
SAW = 1, SAW = 1,
SIN = 2, SIN = 2,
SAWSIN = 3 SAWSIN = 3
}; };
int mNotesHz[800]; int mNotesHz[800];
int mVibTable[32]; int mVibTable[32];
int mHardwareChannels; int mHardwareChannels;
int mWaveform; int mWaveform;
MonotoneSong mSong; MonotoneSong mSong;
Monotone(); Monotone();
~Monotone(); ~Monotone();
result setParams(int aHardwareChannels, int aWaveform = SQUARE); result setParams(int aHardwareChannels, int aWaveform = SQUARE);
result load(const char *aFilename); result load(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile); result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
public: public:
void clear(); void clear();
}; };
}; };
#endif #endif

@ -1,62 +1,62 @@
/* /*
Openmpt module for SoLoud audio engine Openmpt module for SoLoud audio engine
Copyright (c) 2016 Jari Komppa Copyright (c) 2016 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef OPENMPT_H #ifndef OPENMPT_H
#define OPENMPT_H #define OPENMPT_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class Openmpt; class Openmpt;
class File; class File;
class OpenmptInstance : public AudioSourceInstance class OpenmptInstance : public AudioSourceInstance
{ {
Openmpt *mParent; Openmpt *mParent;
void *mModfile; void *mModfile;
int mPlaying; int mPlaying;
public: public:
OpenmptInstance(Openmpt *aParent); OpenmptInstance(Openmpt *aParent);
virtual ~OpenmptInstance(); virtual ~OpenmptInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded(); virtual bool hasEnded();
}; };
class Openmpt : public AudioSource class Openmpt : public AudioSource
{ {
public: public:
char *mData; char *mData;
unsigned int mDataLen; unsigned int mDataLen;
Openmpt(); Openmpt();
virtual ~Openmpt(); virtual ~Openmpt();
result load(const char* aFilename); result load(const char* aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile); result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
}; };
}; };
#endif #endif

@ -1,169 +1,169 @@
/* /*
SFXR module for SoLoud audio engine SFXR module for SoLoud audio engine
Copyright (c) 2014 Jari Komppa Copyright (c) 2014 Jari Komppa
Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission Based on code (c) by Tomas Pettersson, re-licensed under zlib by permission
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SFXR_H #ifndef SFXR_H
#define SFXR_H #define SFXR_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
class File; class File;
class Prg class Prg
{ {
public: public:
// random generator // random generator
Prg(); Prg();
unsigned int state[16]; unsigned int state[16];
unsigned int index; unsigned int index;
unsigned int rand(); unsigned int rand();
void srand(int aSeed); void srand(int aSeed);
}; };
struct SfxrParams struct SfxrParams
{ {
int wave_type; int wave_type;
float p_base_freq; float p_base_freq;
float p_freq_limit; float p_freq_limit;
float p_freq_ramp; float p_freq_ramp;
float p_freq_dramp; float p_freq_dramp;
float p_duty; float p_duty;
float p_duty_ramp; float p_duty_ramp;
float p_vib_strength; float p_vib_strength;
float p_vib_speed; float p_vib_speed;
float p_vib_delay; float p_vib_delay;
float p_env_attack; float p_env_attack;
float p_env_sustain; float p_env_sustain;
float p_env_decay; float p_env_decay;
float p_env_punch; float p_env_punch;
bool filter_on; bool filter_on;
float p_lpf_resonance; float p_lpf_resonance;
float p_lpf_freq; float p_lpf_freq;
float p_lpf_ramp; float p_lpf_ramp;
float p_hpf_freq; float p_hpf_freq;
float p_hpf_ramp; float p_hpf_ramp;
float p_pha_offset; float p_pha_offset;
float p_pha_ramp; float p_pha_ramp;
float p_repeat_speed; float p_repeat_speed;
float p_arp_speed; float p_arp_speed;
float p_arp_mod; float p_arp_mod;
float master_vol; float master_vol;
float sound_vol; float sound_vol;
}; };
class Sfxr; class Sfxr;
class SfxrInstance : public AudioSourceInstance class SfxrInstance : public AudioSourceInstance
{ {
Sfxr *mParent; Sfxr *mParent;
Prg mRand; Prg mRand;
SfxrParams mParams; SfxrParams mParams;
bool playing_sample; bool playing_sample;
int phase; int phase;
double fperiod; double fperiod;
double fmaxperiod; double fmaxperiod;
double fslide; double fslide;
double fdslide; double fdslide;
int period; int period;
float square_duty; float square_duty;
float square_slide; float square_slide;
int env_stage; int env_stage;
int env_time; int env_time;
int env_length[3]; int env_length[3];
float env_vol; float env_vol;
float fphase; float fphase;
float fdphase; float fdphase;
int iphase; int iphase;
float phaser_buffer[1024]; float phaser_buffer[1024];
int ipp; int ipp;
float noise_buffer[32]; float noise_buffer[32];
float fltp; float fltp;
float fltdp; float fltdp;
float fltw; float fltw;
float fltw_d; float fltw_d;
float fltdmp; float fltdmp;
float fltphp; float fltphp;
float flthp; float flthp;
float flthp_d; float flthp_d;
float vib_phase; float vib_phase;
float vib_speed; float vib_speed;
float vib_amp; float vib_amp;
int rep_time; int rep_time;
int rep_limit; int rep_limit;
int arp_time; int arp_time;
int arp_limit; int arp_limit;
double arp_mod; double arp_mod;
void resetSample(bool aRestart); void resetSample(bool aRestart);
public: public:
SfxrInstance(Sfxr *aParent); SfxrInstance(Sfxr *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded(); virtual bool hasEnded();
}; };
class Sfxr : public AudioSource class Sfxr : public AudioSource
{ {
public: public:
SfxrParams mParams; SfxrParams mParams;
enum SFXR_PRESETS enum SFXR_PRESETS
{ {
COIN, COIN,
LASER, LASER,
EXPLOSION, EXPLOSION,
POWERUP, POWERUP,
HURT, HURT,
JUMP, JUMP,
BLIP BLIP
}; };
Prg mRand; Prg mRand;
Sfxr(); Sfxr();
virtual ~Sfxr(); virtual ~Sfxr();
void resetParams(); void resetParams();
result loadParams(const char* aFilename); result loadParams(const char* aFilename);
result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); result loadParamsMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadParamsFile(File *aFile); result loadParamsFile(File *aFile);
result loadPreset(int aPresetNo, int aRandSeed); result loadPreset(int aPresetNo, int aRandSeed);
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
}; };
}; };
#endif #endif

@ -1,63 +1,63 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_SPEECH_H #ifndef SOLOUD_SPEECH_H
#define SOLOUD_SPEECH_H #define SOLOUD_SPEECH_H
#include "soloud.h" #include "soloud.h"
#include "../src/audiosource/speech/darray.h" #include "../src/audiosource/speech/darray.h"
#include "../src/audiosource/speech/klatt.h" #include "../src/audiosource/speech/klatt.h"
#include "../src/audiosource/speech/tts.h" #include "../src/audiosource/speech/tts.h"
namespace SoLoud namespace SoLoud
{ {
class Speech; class Speech;
class Speech : public AudioSource class Speech : public AudioSource
{ {
public: public:
int mFrames; int mFrames;
darray mElement; darray mElement;
Speech(); Speech();
result setText(const char *aText); result setText(const char *aText);
virtual ~Speech(); virtual ~Speech();
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
}; };
class SpeechInstance : public AudioSourceInstance class SpeechInstance : public AudioSourceInstance
{ {
klatt mSynth; klatt mSynth;
Speech *mParent; Speech *mParent;
short *mSample; short *mSample;
int mSampleCount; int mSampleCount;
int mOffset; int mOffset;
public: public:
SpeechInstance(Speech *aParent); SpeechInstance(Speech *aParent);
virtual ~SpeechInstance(); virtual ~SpeechInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind(); virtual result rewind();
virtual bool hasEnded(); virtual bool hasEnded();
}; };
}; };
#endif #endif

@ -1,74 +1,74 @@
/* /*
TED/SID module for SoLoud audio engine TED/SID module for SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef TEDSID_H #ifndef TEDSID_H
#define TEDSID_H #define TEDSID_H
#include "soloud.h" #include "soloud.h"
class SIDsound; class SIDsound;
class TED; class TED;
namespace SoLoud namespace SoLoud
{ {
class TedSid; class TedSid;
class File; class File;
class TedSidInstance : public AudioSourceInstance class TedSidInstance : public AudioSourceInstance
{ {
TedSid *mParent; TedSid *mParent;
SIDsound *mSID; SIDsound *mSID;
TED *mTED; TED *mTED;
unsigned int mSampleCount; unsigned int mSampleCount;
int mNextReg; int mNextReg;
int mNextVal; int mNextVal;
int mRegValues[128]; int mRegValues[128];
public: public:
TedSidInstance(TedSid *aParent); TedSidInstance(TedSid *aParent);
~TedSidInstance(); ~TedSidInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual void tick(); virtual void tick();
virtual bool hasEnded(); virtual bool hasEnded();
virtual float getInfo(unsigned int aInfoKey); virtual float getInfo(unsigned int aInfoKey);
}; };
class TedSid : public AudioSource class TedSid : public AudioSource
{ {
public: public:
File *mFile; File *mFile;
int mModel; int mModel;
bool mFileOwned; bool mFileOwned;
TedSid(); TedSid();
~TedSid(); ~TedSid();
result load(const char *aFilename); result load(const char *aFilename);
result loadToMem(const char *aFilename); result loadToMem(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFileToMem(File *aFile); result loadFileToMem(File *aFile);
result loadFile(File *aFile); result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
}; };
}; };
#endif #endif

@ -1,83 +1,83 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_THREAD_H #ifndef SOLOUD_THREAD_H
#define SOLOUD_THREAD_H #define SOLOUD_THREAD_H
#include "soloud.h" #include "soloud.h"
namespace SoLoud namespace SoLoud
{ {
namespace Thread namespace Thread
{ {
typedef void (*threadFunction)(void *aParam); typedef void (*threadFunction)(void *aParam);
struct ThreadHandleData; struct ThreadHandleData;
typedef ThreadHandleData* ThreadHandle; typedef ThreadHandleData* ThreadHandle;
void * createMutex(); void * createMutex();
void destroyMutex(void *aHandle); void destroyMutex(void *aHandle);
void lockMutex(void *aHandle); void lockMutex(void *aHandle);
void unlockMutex(void *aHandle); void unlockMutex(void *aHandle);
ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter); ThreadHandle createThread(threadFunction aThreadFunction, void *aParameter);
void sleep(int aMSec); void sleep(int aMSec);
void wait(ThreadHandle aThreadHandle); void wait(ThreadHandle aThreadHandle);
void release(ThreadHandle aThreadHandle); void release(ThreadHandle aThreadHandle);
#define MAX_THREADPOOL_TASKS 1024 #define MAX_THREADPOOL_TASKS 1024
class PoolTask class PoolTask
{ {
public: public:
virtual void work() = 0; virtual void work() = 0;
}; };
class Pool class Pool
{ {
public: public:
// Initialize and run thread pool. For thread count 0, work is done at addWork call. // Initialize and run thread pool. For thread count 0, work is done at addWork call.
void init(int aThreadCount); void init(int aThreadCount);
// Ctor, sets known state // Ctor, sets known state
Pool(); Pool();
// Dtor. Waits for the threads to finish. Work may be unfinished. // Dtor. Waits for the threads to finish. Work may be unfinished.
~Pool(); ~Pool();
// Add work to work list. Object is not automatically deleted when work is done. // Add work to work list. Object is not automatically deleted when work is done.
void addWork(PoolTask *aTask); void addWork(PoolTask *aTask);
// Called from worker thread to get a new task. Returns null if no work available. // Called from worker thread to get a new task. Returns null if no work available.
PoolTask *getWork(); PoolTask *getWork();
public: public:
int mThreadCount; // number of threads int mThreadCount; // number of threads
ThreadHandle *mThread; // array of thread handles ThreadHandle *mThread; // array of thread handles
void *mWorkMutex; // mutex to protect task array/maxtask void *mWorkMutex; // mutex to protect task array/maxtask
PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks PoolTask *mTaskArray[MAX_THREADPOOL_TASKS]; // pointers to tasks
int mMaxTask; // how many tasks are pending int mMaxTask; // how many tasks are pending
int mRobin; // cyclic counter, used to pick jobs for threads int mRobin; // cyclic counter, used to pick jobs for threads
volatile int mRunning; // running flag, used to flag threads to stop volatile int mRunning; // running flag, used to flag threads to stop
}; };
} }
} }
#endif #endif

@ -1,108 +1,108 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2015 Jari Komppa Copyright (c) 2015 Jari Komppa
VIC 6560/6561 sound chip emulator VIC 6560/6561 sound chip emulator
Copyright (c) 2015 Petri Hakkinen Copyright (c) 2015 Petri Hakkinen
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_VIC_H #ifndef SOLOUD_VIC_H
#define SOLOUD_VIC_H #define SOLOUD_VIC_H
#include "soloud.h" #include "soloud.h"
/* /*
A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models. A very bare bones emulator for Commodore VIC-20 sound chip. Supports both PAL and NTSC models.
Bass, alto and soprano should be quite close to original vic, noise probably not so. Bass, alto and soprano should be quite close to original vic, noise probably not so.
The first three channels (bass, alto and soprano) are square waveform generators with 7-bit frequency. The first three channels (bass, alto and soprano) are square waveform generators with 7-bit frequency.
The highest bit of each oscillator register switches the oscillator on/off. The highest bit of each oscillator register switches the oscillator on/off.
The fourth oscillator generates a noise waveform. The fourth oscillator generates a noise waveform.
VIC-20 does not have per channel volume control, only global volume, VIC-20 does not have per channel volume control, only global volume,
which you can change by setting audio source's volume. which you can change by setting audio source's volume.
To get that authentic moldy VIC-20 sound, the audio source should be coupled with a biquad resonant filter To get that authentic moldy VIC-20 sound, the audio source should be coupled with a biquad resonant filter
with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0. with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0.
*/ */
namespace SoLoud namespace SoLoud
{ {
class Vic; class Vic;
class VicInstance : public AudioSourceInstance class VicInstance : public AudioSourceInstance
{ {
public: public:
VicInstance(Vic *aParent); VicInstance(Vic *aParent);
~VicInstance(); ~VicInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded(); virtual bool hasEnded();
private: private:
Vic* m_parent; Vic* m_parent;
unsigned int m_phase[4]; unsigned int m_phase[4];
unsigned int m_noisePos; unsigned int m_noisePos;
}; };
class Vic : public AudioSource class Vic : public AudioSource
{ {
public: public:
// VIC model // VIC model
enum enum
{ {
PAL = 0, PAL = 0,
NTSC, NTSC,
}; };
// VIC sound registers // VIC sound registers
enum enum
{ {
BASS = 0, BASS = 0,
ALTO, ALTO,
SOPRANO, SOPRANO,
NOISE, NOISE,
MAX_REGS MAX_REGS
}; };
Vic(); Vic();
virtual ~Vic(); virtual ~Vic();
void setModel(int model); void setModel(int model);
int getModel() const; int getModel() const;
void setRegister(int reg, unsigned char value) { m_regs[reg] = value; } void setRegister(int reg, unsigned char value) { m_regs[reg] = value; }
unsigned char getRegister(int reg) const { return m_regs[reg]; } unsigned char getRegister(int reg) const { return m_regs[reg]; }
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
private: private:
friend class VicInstance; friend class VicInstance;
int m_model; int m_model;
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
unsigned char m_regs[MAX_REGS]; unsigned char m_regs[MAX_REGS];
unsigned char m_noise[8192]; unsigned char m_noise[8192];
}; };
}; };
#endif #endif

@ -1,68 +1,68 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_WAV_H #ifndef SOLOUD_WAV_H
#define SOLOUD_WAV_H #define SOLOUD_WAV_H
#include "soloud.h" #include "soloud.h"
struct stb_vorbis; struct stb_vorbis;
namespace SoLoud namespace SoLoud
{ {
class Wav; class Wav;
class File; class File;
class WavInstance : public AudioSourceInstance class WavInstance : public AudioSourceInstance
{ {
Wav *mParent; Wav *mParent;
unsigned int mOffset; unsigned int mOffset;
public: public:
WavInstance(Wav *aParent); WavInstance(Wav *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind(); virtual result rewind();
virtual bool hasEnded(); virtual bool hasEnded();
}; };
class Wav : public AudioSource class Wav : public AudioSource
{ {
result loadwav(File *aReader); result loadwav(File *aReader);
result loadogg(File *aReader); result loadogg(File *aReader);
result testAndLoadFile(File *aReader); result testAndLoadFile(File *aReader);
public: public:
float *mData; float *mData;
unsigned int mSampleCount; unsigned int mSampleCount;
Wav(); Wav();
virtual ~Wav(); virtual ~Wav();
result load(const char *aFilename); result load(const char *aFilename);
result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true); result loadMem(unsigned char *aMem, unsigned int aLength, bool aCopy = false, bool aTakeOwnership = true);
result loadFile(File *aFile); result loadFile(File *aFile);
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
time getLength(); time getLength();
}; };
}; };
#endif #endif

@ -1,83 +1,83 @@
/* /*
SoLoud audio engine SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
#ifndef SOLOUD_WAVSTREAM_H #ifndef SOLOUD_WAVSTREAM_H
#define SOLOUD_WAVSTREAM_H #define SOLOUD_WAVSTREAM_H
#include <stdio.h> #include <stdio.h>
#include "soloud.h" #include "soloud.h"
struct stb_vorbis; struct stb_vorbis;
namespace SoLoud namespace SoLoud
{ {
class WavStream; class WavStream;
class File; class File;
class WavStreamInstance : public AudioSourceInstance class WavStreamInstance : public AudioSourceInstance
{ {
WavStream *mParent; WavStream *mParent;
unsigned int mOffset; unsigned int mOffset;
File *mFile; File *mFile;
stb_vorbis *mOgg; stb_vorbis *mOgg;
unsigned int mOggFrameSize; unsigned int mOggFrameSize;
unsigned int mOggFrameOffset; unsigned int mOggFrameOffset;
float **mOggOutputs; float **mOggOutputs;
public: public:
WavStreamInstance(WavStream *aParent); WavStreamInstance(WavStream *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples); virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind(); virtual result rewind();
virtual bool hasEnded(); virtual bool hasEnded();
virtual ~WavStreamInstance(); virtual ~WavStreamInstance();
}; };
class WavStream : public AudioSource class WavStream : public AudioSource
{ {
result loadwav(File * fp); result loadwav(File * fp);
result loadogg(File * fp); result loadogg(File * fp);
public: public:
int mOgg; int mOgg;
char *mFilename; char *mFilename;
File *mMemFile; File *mMemFile;
File *mStreamFile; File *mStreamFile;
unsigned int mDataOffset; unsigned int mDataOffset;
unsigned int mBits; unsigned int mBits;
unsigned int mSampleCount; unsigned int mSampleCount;
WavStream(); WavStream();
virtual ~WavStream(); virtual ~WavStream();
result load(const char *aFilename); result load(const char *aFilename);
result loadMem(unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true); result loadMem(unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true);
result loadToMem(const char *aFilename); result loadToMem(const char *aFilename);
result loadFile(File *aFile); result loadFile(File *aFile);
result loadFileToMem(File *aFile); result loadFileToMem(File *aFile);
virtual AudioSourceInstance *createInstance(); virtual AudioSourceInstance *createInstance();
time getLength(); time getLength();
public: public:
result parse(File *aFile); result parse(File *aFile);
}; };
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

@ -1,182 +1,182 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_COLLISION_SPACE_H_ #ifndef _ODE_COLLISION_SPACE_H_
#define _ODE_COLLISION_SPACE_H_ #define _ODE_COLLISION_SPACE_H_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct dContactGeom; struct dContactGeom;
/** /**
* @brief User callback for geom-geom collision testing. * @brief User callback for geom-geom collision testing.
* *
* @param data The user data object, as passed to dSpaceCollide. * @param data The user data object, as passed to dSpaceCollide.
* @param o1 The first geom being tested. * @param o1 The first geom being tested.
* @param o2 The second geom being test. * @param o2 The second geom being test.
* *
* @remarks The callback function can call dCollide on o1 and o2 to generate * @remarks The callback function can call dCollide on o1 and o2 to generate
* contact points between each pair. Then these contact points may be added * contact points between each pair. Then these contact points may be added
* to the simulation as contact joints. The user's callback function can of * to the simulation as contact joints. The user's callback function can of
* course chose not to call dCollide for any pair, e.g. if the user decides * course chose not to call dCollide for any pair, e.g. if the user decides
* that those pairs should not interact. * that those pairs should not interact.
* *
* @ingroup collide * @ingroup collide
*/ */
typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2); typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space); ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space);
ODE_API dSpaceID dHashSpaceCreate (dSpaceID space); ODE_API dSpaceID dHashSpaceCreate (dSpaceID space);
ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth); ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
/* SAP */ /* SAP */
/* Order XZY or ZXY usually works best, if your Y is up. */ /* Order XZY or ZXY usually works best, if your Y is up. */
#define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4)) #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
#define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4)) #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
#define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4)) #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
#define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4)) #define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
#define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4)) #define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
#define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4)) #define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder ); ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder );
ODE_API void dSpaceDestroy (dSpaceID); ODE_API void dSpaceDestroy (dSpaceID);
ODE_API void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel); ODE_API void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel);
ODE_API void dHashSpaceGetLevels (dSpaceID space, int *minlevel, int *maxlevel); ODE_API void dHashSpaceGetLevels (dSpaceID space, int *minlevel, int *maxlevel);
ODE_API void dSpaceSetCleanup (dSpaceID space, int mode); ODE_API void dSpaceSetCleanup (dSpaceID space, int mode);
ODE_API int dSpaceGetCleanup (dSpaceID space); ODE_API int dSpaceGetCleanup (dSpaceID space);
/** /**
* @brief Sets sublevel value for a space. * @brief Sets sublevel value for a space.
* *
* Sublevel affects how the space is handled in dSpaceCollide2 when it is collided * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
* with another space. If sublevels of both spaces match, the function iterates * with another space. If sublevels of both spaces match, the function iterates
* geometries of both spaces and collides them with each other. If sublevel of one * geometries of both spaces and collides them with each other. If sublevel of one
* space is greater than the sublevel of another one, only the geometries of the * space is greater than the sublevel of another one, only the geometries of the
* space with greater sublevel are iterated, another space is passed into * space with greater sublevel are iterated, another space is passed into
* collision callback as a geometry itself. By default all the spaces are assigned * collision callback as a geometry itself. By default all the spaces are assigned
* zero sublevel. * zero sublevel.
* *
* @note * @note
* The space sublevel @e IS @e NOT automatically updated when one space is inserted * The space sublevel @e IS @e NOT automatically updated when one space is inserted
* into another or removed from one. It is a client's responsibility to update sublevel * into another or removed from one. It is a client's responsibility to update sublevel
* value if necessary. * value if necessary.
* *
* @param space the space to modify * @param space the space to modify
* @param sublevel the sublevel value to be assigned * @param sublevel the sublevel value to be assigned
* @ingroup collide * @ingroup collide
* @see dSpaceGetSublevel * @see dSpaceGetSublevel
* @see dSpaceCollide2 * @see dSpaceCollide2
*/ */
ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel); ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel);
/** /**
* @brief Gets sublevel value of a space. * @brief Gets sublevel value of a space.
* *
* Sublevel affects how the space is handled in dSpaceCollide2 when it is collided * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
* with another space. See @c dSpaceSetSublevel for more details. * with another space. See @c dSpaceSetSublevel for more details.
* *
* @param space the space to query * @param space the space to query
* @returns the sublevel value of the space * @returns the sublevel value of the space
* @ingroup collide * @ingroup collide
* @see dSpaceSetSublevel * @see dSpaceSetSublevel
* @see dSpaceCollide2 * @see dSpaceCollide2
*/ */
ODE_API int dSpaceGetSublevel (dSpaceID space); ODE_API int dSpaceGetSublevel (dSpaceID space);
/** /**
* @brief Sets manual cleanup flag for a space. * @brief Sets manual cleanup flag for a space.
* *
* Manual cleanup flag marks a space as eligible for manual thread data cleanup. * Manual cleanup flag marks a space as eligible for manual thread data cleanup.
* This function should be called for every space object right after creation in * This function should be called for every space object right after creation in
* case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag. * case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag.
* *
* Failure to set manual cleanup flag for a space may lead to some resources * Failure to set manual cleanup flag for a space may lead to some resources
* remaining leaked until the program exit. * remaining leaked until the program exit.
* *
* @param space the space to modify * @param space the space to modify
* @param mode 1 for manual cleanup mode and 0 for default cleanup mode * @param mode 1 for manual cleanup mode and 0 for default cleanup mode
* @ingroup collide * @ingroup collide
* @see dSpaceGetManualCleanup * @see dSpaceGetManualCleanup
* @see dInitODE2 * @see dInitODE2
*/ */
ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode); ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode);
/** /**
* @brief Get manual cleanup flag of a space. * @brief Get manual cleanup flag of a space.
* *
* Manual cleanup flag marks a space space as eligible for manual thread data cleanup. * Manual cleanup flag marks a space space as eligible for manual thread data cleanup.
* See @c dSpaceSetManualCleanup for more details. * See @c dSpaceSetManualCleanup for more details.
* *
* @param space the space to query * @param space the space to query
* @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space * @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space
* @ingroup collide * @ingroup collide
* @see dSpaceSetManualCleanup * @see dSpaceSetManualCleanup
* @see dInitODE2 * @see dInitODE2
*/ */
ODE_API int dSpaceGetManualCleanup (dSpaceID space); ODE_API int dSpaceGetManualCleanup (dSpaceID space);
ODE_API void dSpaceAdd (dSpaceID, dGeomID); ODE_API void dSpaceAdd (dSpaceID, dGeomID);
ODE_API void dSpaceRemove (dSpaceID, dGeomID); ODE_API void dSpaceRemove (dSpaceID, dGeomID);
ODE_API int dSpaceQuery (dSpaceID, dGeomID); ODE_API int dSpaceQuery (dSpaceID, dGeomID);
ODE_API void dSpaceClean (dSpaceID); ODE_API void dSpaceClean (dSpaceID);
ODE_API int dSpaceGetNumGeoms (dSpaceID); ODE_API int dSpaceGetNumGeoms (dSpaceID);
ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i); ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i);
/** /**
* @brief Given a space, this returns its class. * @brief Given a space, this returns its class.
* *
* The ODE classes are: * The ODE classes are:
* @li dSimpleSpaceClass * @li dSimpleSpaceClass
* @li dHashSpaceClass * @li dHashSpaceClass
* @li dSweepAndPruneSpaceClass * @li dSweepAndPruneSpaceClass
* @li dQuadTreeSpaceClass * @li dQuadTreeSpaceClass
* @li dFirstUserClass * @li dFirstUserClass
* @li dLastUserClass * @li dLastUserClass
* *
* The class id not defined by the user should be between * The class id not defined by the user should be between
* dFirstSpaceClass and dLastSpaceClass. * dFirstSpaceClass and dLastSpaceClass.
* *
* User-defined class will return their own number. * User-defined class will return their own number.
* *
* @param space the space to query * @param space the space to query
* @returns The space class ID. * @returns The space class ID.
* @ingroup collide * @ingroup collide
*/ */
ODE_API int dSpaceGetClass(dSpaceID space); ODE_API int dSpaceGetClass(dSpaceID space);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,316 +1,316 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* /*
* TriMesh code by Erwin de Vries. * TriMesh code by Erwin de Vries.
* *
* Trimesh data. * Trimesh data.
* This is where the actual vertexdata (pointers), and BV tree is stored. * This is where the actual vertexdata (pointers), and BV tree is stored.
* Vertices should be single precision! * Vertices should be single precision!
* This should be more sophisticated, so that the user can easyly implement * This should be more sophisticated, so that the user can easyly implement
* another collision library, but this is a lot of work, and also costs some * another collision library, but this is a lot of work, and also costs some
* performance because some data has to be copied. * performance because some data has to be copied.
*/ */
#ifndef _ODE_COLLISION_TRIMESH_H_ #ifndef _ODE_COLLISION_TRIMESH_H_
#define _ODE_COLLISION_TRIMESH_H_ #define _ODE_COLLISION_TRIMESH_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* /*
* Data storage for triangle meshes. * Data storage for triangle meshes.
*/ */
struct dxTriMeshData; struct dxTriMeshData;
typedef struct dxTriMeshData* dTriMeshDataID; typedef struct dxTriMeshData* dTriMeshDataID;
typedef enum typedef enum
{ {
dMTV__MIN, dMTV__MIN,
dMTV_FIRST = dMTV__MIN, dMTV_FIRST = dMTV__MIN,
dMTV_SECOND, dMTV_SECOND,
dMTV_THIRD, dMTV_THIRD,
dMTV__MAX, dMTV__MAX,
} dMeshTriangleVertex; } dMeshTriangleVertex;
/* /*
* These don't make much sense now, but they will later when we add more * These don't make much sense now, but they will later when we add more
* features. * features.
*/ */
ODE_API dTriMeshDataID dGeomTriMeshDataCreate(void); ODE_API dTriMeshDataID dGeomTriMeshDataCreate(void);
ODE_API void dGeomTriMeshDataDestroy(dTriMeshDataID g); ODE_API void dGeomTriMeshDataDestroy(dTriMeshDataID g);
/* /*
* The values of data_id that can be used with dGeomTriMeshDataSet/dGeomTriMeshDataGet * The values of data_id that can be used with dGeomTriMeshDataSet/dGeomTriMeshDataGet
*/ */
enum enum
{ {
dTRIMESHDATA__MIN, dTRIMESHDATA__MIN,
dTRIMESHDATA_FACE_NORMALS = dTRIMESHDATA__MIN, dTRIMESHDATA_FACE_NORMALS = dTRIMESHDATA__MIN,
dTRIMESHDATA_USE_FLAGS, dTRIMESHDATA_USE_FLAGS,
dTRIMESHDATA__MAX, dTRIMESHDATA__MAX,
#ifndef TRIMESH_FACE_NORMALS // Define this name during the header inclusion if you need it for something else #ifndef TRIMESH_FACE_NORMALS // Define this name during the header inclusion if you need it for something else
// Included for backward compatibility -- please use the corrected name above. Sorry. // Included for backward compatibility -- please use the corrected name above. Sorry.
TRIMESH_FACE_NORMALS = dTRIMESHDATA_FACE_NORMALS, TRIMESH_FACE_NORMALS = dTRIMESHDATA_FACE_NORMALS,
#endif #endif
}; };
/* /*
* The flags of the dTRIMESHDATA_USE_FLAGS data elements * The flags of the dTRIMESHDATA_USE_FLAGS data elements
*/ */
enum enum
{ {
dMESHDATAUSE_EDGE1 = 0x01, dMESHDATAUSE_EDGE1 = 0x01,
dMESHDATAUSE_EDGE2 = 0x02, dMESHDATAUSE_EDGE2 = 0x02,
dMESHDATAUSE_EDGE3 = 0x04, dMESHDATAUSE_EDGE3 = 0x04,
dMESHDATAUSE_VERTEX1 = 0x08, dMESHDATAUSE_VERTEX1 = 0x08,
dMESHDATAUSE_VERTEX2 = 0x10, dMESHDATAUSE_VERTEX2 = 0x10,
dMESHDATAUSE_VERTEX3 = 0x20, dMESHDATAUSE_VERTEX3 = 0x20,
}; };
/* /*
* Set and get the TriMeshData additional data * Set and get the TriMeshData additional data
* Note: The data is NOT COPIED on assignment * Note: The data is NOT COPIED on assignment
*/ */
ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void *in_data); ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void *in_data);
ODE_API void *dGeomTriMeshDataGet(dTriMeshDataID g, int data_id); ODE_API void *dGeomTriMeshDataGet(dTriMeshDataID g, int data_id);
ODE_API void *dGeomTriMeshDataGet2(dTriMeshDataID g, int data_id, dsizeint *pout_size/*=NULL*/); ODE_API void *dGeomTriMeshDataGet2(dTriMeshDataID g, int data_id, dsizeint *pout_size/*=NULL*/);
/** /**
* We need to set the last transform after each time step for * We need to set the last transform after each time step for
* accurate collision response. These functions get and set that transform. * accurate collision response. These functions get and set that transform.
* It is stored per geom instance, rather than per dTriMeshDataID. * It is stored per geom instance, rather than per dTriMeshDataID.
*/ */
ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, const dMatrix4 last_trans ); ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, const dMatrix4 last_trans );
ODE_API const dReal* dGeomTriMeshGetLastTransform( dGeomID g ); ODE_API const dReal* dGeomTriMeshGetLastTransform( dGeomID g );
/* /*
* Build a TriMesh data object with single precision vertex data. * Build a TriMesh data object with single precision vertex data.
*/ */
ODE_API void dGeomTriMeshDataBuildSingle(dTriMeshDataID g, ODE_API void dGeomTriMeshDataBuildSingle(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount, const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride); const void* Indices, int IndexCount, int TriStride);
/* same again with a normals array (used as trimesh-trimesh optimization) */ /* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g, ODE_API void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount, const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride, const void* Indices, int IndexCount, int TriStride,
const void* Normals); const void* Normals);
/* /*
* Build a TriMesh data object with double precision vertex data. * Build a TriMesh data object with double precision vertex data.
*/ */
ODE_API void dGeomTriMeshDataBuildDouble(dTriMeshDataID g, ODE_API void dGeomTriMeshDataBuildDouble(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount, const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride); const void* Indices, int IndexCount, int TriStride);
/* same again with a normals array (used as trimesh-trimesh optimization) */ /* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g, ODE_API void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount, const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride, const void* Indices, int IndexCount, int TriStride,
const void* Normals); const void* Normals);
/* /*
* Simple build. Single/double precision based on dSINGLE/dDOUBLE! * Simple build. Single/double precision based on dSINGLE/dDOUBLE!
*/ */
ODE_API void dGeomTriMeshDataBuildSimple(dTriMeshDataID g, ODE_API void dGeomTriMeshDataBuildSimple(dTriMeshDataID g,
const dReal* Vertices, int VertexCount, const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount); const dTriIndex* Indices, int IndexCount);
/* same again with a normals array (used as trimesh-trimesh optimization) */ /* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g, ODE_API void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g,
const dReal* Vertices, int VertexCount, const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount, const dTriIndex* Indices, int IndexCount,
const int* Normals); const int* Normals);
/* /*
* Data preprocessing build request flags. * Data preprocessing build request flags.
*/ */
enum enum
{ {
dTRIDATAPREPROCESS_BUILD__MIN, dTRIDATAPREPROCESS_BUILD__MIN,
dTRIDATAPREPROCESS_BUILD_CONCAVE_EDGES = dTRIDATAPREPROCESS_BUILD__MIN, // Used to optimize OPCODE trimesh-capsule collisions; allocates 1 byte per triangle; no extra data associated dTRIDATAPREPROCESS_BUILD_CONCAVE_EDGES = dTRIDATAPREPROCESS_BUILD__MIN, // Used to optimize OPCODE trimesh-capsule collisions; allocates 1 byte per triangle; no extra data associated
dTRIDATAPREPROCESS_BUILD_FACE_ANGLES, // Used to aid trimesh-convex collisions; memory requirements depend on extra data dTRIDATAPREPROCESS_BUILD_FACE_ANGLES, // Used to aid trimesh-convex collisions; memory requirements depend on extra data
dTRIDATAPREPROCESS_BUILD__MAX, dTRIDATAPREPROCESS_BUILD__MAX,
}; };
/* /*
* Data preprocessing extra values for dTRIDATAPREPROCESS_BUILD_FACE_ANGLES. * Data preprocessing extra values for dTRIDATAPREPROCESS_BUILD_FACE_ANGLES.
*/ */
enum enum
{ {
dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__MIN, dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__MIN,
dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_BYTE_POSITIVE = dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__MIN, // Build angles for convex edges only and store as bytes; allocates 3 bytes per triangle; stores angles (0..180] in 1/254 fractions leaving two values for the flat and all the concaves dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_BYTE_POSITIVE = dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__MIN, // Build angles for convex edges only and store as bytes; allocates 3 bytes per triangle; stores angles (0..180] in 1/254 fractions leaving two values for the flat and all the concaves
dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_BYTE_ALL, // Build angles for all the edges and store in bytes; allocates 3 bytes per triangle; stores angles [-180..0) and (0..180] in 1/127 fractions plus a value for the flat angle dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_BYTE_ALL, // Build angles for all the edges and store in bytes; allocates 3 bytes per triangle; stores angles [-180..0) and (0..180] in 1/127 fractions plus a value for the flat angle
dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_WORD_ALL, // Build angles for all the edges and store in words; allocates 6 bytes per triangle; stores angles [-180..0) and (0..180] in 1/32767 fractions plus a value for the flat angle dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_WORD_ALL, // Build angles for all the edges and store in words; allocates 6 bytes per triangle; stores angles [-180..0) and (0..180] in 1/32767 fractions plus a value for the flat angle
dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__MAX, dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__MAX,
dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__DEFAULT = dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_BYTE_POSITIVE, // The default value assumed if the extra data is not provided dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA__DEFAULT = dTRIDATAPREPROCESS_FACE_ANGLES_EXTRA_BYTE_POSITIVE, // The default value assumed if the extra data is not provided
}; };
/* /*
* Pre-process the trimesh data according to the request flags. * Pre-process the trimesh data according to the request flags.
* *
* buildRequestFlags is a bitmask of 1U << dTRIDATAPREPROCESS_BUILD_... * buildRequestFlags is a bitmask of 1U << dTRIDATAPREPROCESS_BUILD_...
* It is allowed to call the function multiple times provided the bitmasks are different each time. * It is allowed to call the function multiple times provided the bitmasks are different each time.
* *
* requestExtraData is an optional pointer to array of extra parameters per bitmask bits * requestExtraData is an optional pointer to array of extra parameters per bitmask bits
* (only the elements indexed by positions of raised bits are examined; * (only the elements indexed by positions of raised bits are examined;
* defaults are assumed if the pointer is NULL) * defaults are assumed if the pointer is NULL)
* *
* The function returns a boolean status the only failure reason being insufficient memory. * The function returns a boolean status the only failure reason being insufficient memory.
*/ */
ODE_API int dGeomTriMeshDataPreprocess2(dTriMeshDataID g, unsigned int buildRequestFlags, const dintptr *requestExtraData/*=NULL | const dintptr (*)[dTRIDATAPREPROCESS_BUILD__MAX]*/); ODE_API int dGeomTriMeshDataPreprocess2(dTriMeshDataID g, unsigned int buildRequestFlags, const dintptr *requestExtraData/*=NULL | const dintptr (*)[dTRIDATAPREPROCESS_BUILD__MAX]*/);
/* /*
* Obsolete. Equivalent to calling dGeomTriMeshDataPreprocess2(g, (1U << dTRIDATAPREPROCESS_BUILD_CONCAVE_EDGES), NULL) * Obsolete. Equivalent to calling dGeomTriMeshDataPreprocess2(g, (1U << dTRIDATAPREPROCESS_BUILD_CONCAVE_EDGES), NULL)
*/ */
ODE_API int dGeomTriMeshDataPreprocess(dTriMeshDataID g); ODE_API int dGeomTriMeshDataPreprocess(dTriMeshDataID g);
/* /*
* Get and set the internal preprocessed trimesh data buffer (see the enumerated type above), for loading and saving * Get and set the internal preprocessed trimesh data buffer (see the enumerated type above), for loading and saving
* These functions are deprecated. Use dGeomTriMeshDataSet/dGeomTriMeshDataGet2 with dTRIMESHDATA_USE_FLAGS instead. * These functions are deprecated. Use dGeomTriMeshDataSet/dGeomTriMeshDataGet2 with dTRIMESHDATA_USE_FLAGS instead.
*/ */
ODE_API_DEPRECATED ODE_API void dGeomTriMeshDataGetBuffer(dTriMeshDataID g, unsigned char** buf, int* bufLen); ODE_API_DEPRECATED ODE_API void dGeomTriMeshDataGetBuffer(dTriMeshDataID g, unsigned char** buf, int* bufLen);
ODE_API_DEPRECATED ODE_API void dGeomTriMeshDataSetBuffer(dTriMeshDataID g, unsigned char* buf); ODE_API_DEPRECATED ODE_API void dGeomTriMeshDataSetBuffer(dTriMeshDataID g, unsigned char* buf);
/* /*
* Per triangle callback. Allows the user to say if he wants a collision with * Per triangle callback. Allows the user to say if he wants a collision with
* a particular triangle. * a particular triangle.
*/ */
typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex); typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
ODE_API void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback); ODE_API void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback);
ODE_API dTriCallback* dGeomTriMeshGetCallback(dGeomID g); ODE_API dTriCallback* dGeomTriMeshGetCallback(dGeomID g);
/* /*
* Per object callback. Allows the user to get the list of triangles in 1 * Per object callback. Allows the user to get the list of triangles in 1
* shot. Maybe we should remove this one. * shot. Maybe we should remove this one.
*/ */
typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount); typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
ODE_API void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback); ODE_API void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback);
ODE_API dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g); ODE_API dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g);
/* /*
* Ray callback. * Ray callback.
* Allows the user to say if a ray collides with a triangle on barycentric * Allows the user to say if a ray collides with a triangle on barycentric
* coords. The user can for example sample a texture with alpha transparency * coords. The user can for example sample a texture with alpha transparency
* to determine if a collision should occur. * to determine if a collision should occur.
*/ */
typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v); typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
ODE_API void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback); ODE_API void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback);
ODE_API dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g); ODE_API dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g);
/* /*
* Triangle merging callback. * Triangle merging callback.
* Allows the user to generate a fake triangle index for a new contact generated * Allows the user to generate a fake triangle index for a new contact generated
* from merging of two other contacts. That index could later be used by the * from merging of two other contacts. That index could later be used by the
* user to determine attributes of original triangles used as sources for a * user to determine attributes of original triangles used as sources for a
* merged contact. * merged contact.
*/ */
typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex); typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
ODE_API void dGeomTriMeshSetTriMergeCallback(dGeomID g, dTriTriMergeCallback* Callback); ODE_API void dGeomTriMeshSetTriMergeCallback(dGeomID g, dTriTriMergeCallback* Callback);
ODE_API dTriTriMergeCallback* dGeomTriMeshGetTriMergeCallback(dGeomID g); ODE_API dTriTriMergeCallback* dGeomTriMeshGetTriMergeCallback(dGeomID g);
/* /*
* Trimesh class * Trimesh class
* Construction. Callbacks are optional. * Construction. Callbacks are optional.
*/ */
ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback); ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
ODE_API void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data); ODE_API void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data);
ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g); ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g);
/* enable/disable/check temporal coherence*/ /* enable/disable/check temporal coherence*/
ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable); ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable);
ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass); ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass);
/* /*
* Clears the internal temporal coherence caches. When a geom has its * Clears the internal temporal coherence caches. When a geom has its
* collision checked with a trimesh once, data is stored inside the trimesh. * collision checked with a trimesh once, data is stored inside the trimesh.
* With large worlds with lots of seperate objects this list could get huge. * With large worlds with lots of seperate objects this list could get huge.
* We should be able to do this automagically. * We should be able to do this automagically.
*/ */
ODE_API void dGeomTriMeshClearTCCache(dGeomID g); ODE_API void dGeomTriMeshClearTCCache(dGeomID g);
/* /*
* returns the TriMeshDataID * returns the TriMeshDataID
*/ */
ODE_API dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g); ODE_API dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g);
/* /*
* Gets a triangle. * Gets a triangle.
*/ */
ODE_API void dGeomTriMeshGetTriangle(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2); ODE_API void dGeomTriMeshGetTriangle(dGeomID g, int Index, dVector3* v0, dVector3* v1, dVector3* v2);
/* /*
* Gets the point on the requested triangle and the given barycentric * Gets the point on the requested triangle and the given barycentric
* coordinates. * coordinates.
*/ */
ODE_API void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out); ODE_API void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
/* /*
This is how the strided data works: This is how the strided data works:
struct StridedVertex{ struct StridedVertex{
dVector3 Vertex; dVector3 Vertex;
// Userdata // Userdata
}; };
int VertexStride = sizeof(StridedVertex); int VertexStride = sizeof(StridedVertex);
struct StridedTri{ struct StridedTri{
int Indices[3]; int Indices[3];
// Userdata // Userdata
}; };
int TriStride = sizeof(StridedTri); int TriStride = sizeof(StridedTri);
*/ */
ODE_API int dGeomTriMeshGetTriangleCount (dGeomID g); ODE_API int dGeomTriMeshGetTriangleCount (dGeomID g);
ODE_API void dGeomTriMeshDataUpdate(dTriMeshDataID g); ODE_API void dGeomTriMeshDataUpdate(dTriMeshDataID g);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _ODE_COLLISION_TRIMESH_H_ */ #endif /* _ODE_COLLISION_TRIMESH_H_ */

File diff suppressed because it is too large Load Diff

@ -1,40 +1,40 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_COMPATIBILITY_H_ #ifndef _ODE_COMPATIBILITY_H_
#define _ODE_COMPATIBILITY_H_ #define _ODE_COMPATIBILITY_H_
/* /*
* ODE's backward compatibility system ensures that as ODE's API * ODE's backward compatibility system ensures that as ODE's API
* evolves, user code will not break. * evolves, user code will not break.
*/ */
/* /*
* These new rotation function names are more consistent with the * These new rotation function names are more consistent with the
* rest of the API. * rest of the API.
*/ */
#define dQtoR(q,R) dRfromQ((R),(q)) #define dQtoR(q,R) dRfromQ((R),(q))
#define dRtoQ(R,q) dQfromR((q),(R)) #define dRtoQ(R,q) dQfromR((q),(R))
#define dWtoDQ(w,q,dq) dDQfromW((dq),(w),(q)) #define dWtoDQ(w,q,dq) dDQfromW((dq),(w),(q))
#endif #endif

@ -1,110 +1,110 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_CONTACT_H_ #ifndef _ODE_CONTACT_H_
#define _ODE_CONTACT_H_ #define _ODE_CONTACT_H_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
enum { enum {
dContactMu2 = 0x001, /**< Use axis dependent friction */ dContactMu2 = 0x001, /**< Use axis dependent friction */
dContactAxisDep = 0x001, /**< Same as above */ dContactAxisDep = 0x001, /**< Same as above */
dContactFDir1 = 0x002, /**< Use FDir for the first friction value */ dContactFDir1 = 0x002, /**< Use FDir for the first friction value */
dContactBounce = 0x004, /**< Restore collision energy anti-parallel to the normal */ dContactBounce = 0x004, /**< Restore collision energy anti-parallel to the normal */
dContactSoftERP = 0x008, /**< Don't use global erp for penetration reduction */ dContactSoftERP = 0x008, /**< Don't use global erp for penetration reduction */
dContactSoftCFM = 0x010, /**< Don't use global cfm for penetration constraint */ dContactSoftCFM = 0x010, /**< Don't use global cfm for penetration constraint */
dContactMotion1 = 0x020, /**< Use a non-zero target velocity for the constraint */ dContactMotion1 = 0x020, /**< Use a non-zero target velocity for the constraint */
dContactMotion2 = 0x040, dContactMotion2 = 0x040,
dContactMotionN = 0x080, dContactMotionN = 0x080,
dContactSlip1 = 0x100, /**< Force-dependent slip. */ dContactSlip1 = 0x100, /**< Force-dependent slip. */
dContactSlip2 = 0x200, dContactSlip2 = 0x200,
dContactRolling = 0x400, /**< Rolling/Angular friction */ dContactRolling = 0x400, /**< Rolling/Angular friction */
dContactApprox0 = 0x0000, dContactApprox0 = 0x0000,
dContactApprox1_1 = 0x1000, dContactApprox1_1 = 0x1000,
dContactApprox1_2 = 0x2000, dContactApprox1_2 = 0x2000,
dContactApprox1_N = 0x4000, /**< For rolling friction */ dContactApprox1_N = 0x4000, /**< For rolling friction */
dContactApprox1 = 0x7000 dContactApprox1 = 0x7000
}; };
typedef struct dSurfaceParameters { typedef struct dSurfaceParameters {
/* must always be defined */ /* must always be defined */
int mode; int mode;
dReal mu; dReal mu;
/* only defined if the corresponding flag is set in mode */ /* only defined if the corresponding flag is set in mode */
dReal mu2; dReal mu2;
dReal rho; /**< Rolling friction */ dReal rho; /**< Rolling friction */
dReal rho2; dReal rho2;
dReal rhoN; /**< Spinning friction */ dReal rhoN; /**< Spinning friction */
dReal bounce; /**< Coefficient of restitution */ dReal bounce; /**< Coefficient of restitution */
dReal bounce_vel; /**< Bouncing threshold */ dReal bounce_vel; /**< Bouncing threshold */
dReal soft_erp; dReal soft_erp;
dReal soft_cfm; dReal soft_cfm;
dReal motion1,motion2,motionN; dReal motion1,motion2,motionN;
dReal slip1,slip2; dReal slip1,slip2;
} dSurfaceParameters; } dSurfaceParameters;
/** /**
* @brief Describe the contact point between two geoms. * @brief Describe the contact point between two geoms.
* *
* If two bodies touch, or if a body touches a static feature in its * If two bodies touch, or if a body touches a static feature in its
* environment, the contact is represented by one or more "contact * environment, the contact is represented by one or more "contact
* points", described by dContactGeom. * points", described by dContactGeom.
* *
* The convention is that if body 1 is moved along the normal vector by * The convention is that if body 1 is moved along the normal vector by
* a distance depth (or equivalently if body 2 is moved the same distance * a distance depth (or equivalently if body 2 is moved the same distance
* in the opposite direction) then the contact depth will be reduced to * in the opposite direction) then the contact depth will be reduced to
* zero. This means that the normal vector points "in" to body 1. * zero. This means that the normal vector points "in" to body 1.
* *
* @ingroup collide * @ingroup collide
*/ */
typedef struct dContactGeom { typedef struct dContactGeom {
dVector3 pos; /*< contact position*/ dVector3 pos; /*< contact position*/
dVector3 normal; /*< normal vector*/ dVector3 normal; /*< normal vector*/
dReal depth; /*< penetration depth*/ dReal depth; /*< penetration depth*/
dGeomID g1,g2; /*< the colliding geoms*/ dGeomID g1,g2; /*< the colliding geoms*/
int side1,side2; /*< (to be documented)*/ int side1,side2; /*< (to be documented)*/
} dContactGeom; } dContactGeom;
/* contact info used by contact joint */ /* contact info used by contact joint */
typedef struct dContact { typedef struct dContact {
dSurfaceParameters surface; dSurfaceParameters surface;
dContactGeom geom; dContactGeom geom;
dVector3 fdir1; dVector3 fdir1;
} dContact; } dContact;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,229 +1,229 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_COOPERATIVE_H_ #ifndef _ODE_COOPERATIVE_H_
#define _ODE_COOPERATIVE_H_ #define _ODE_COOPERATIVE_H_
#include <ode/common.h> #include <ode/common.h>
#include <ode/threading.h> #include <ode/threading.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**
* @defgroup coop Cooperative Algorithms * @defgroup coop Cooperative Algorithms
* *
* Algorithms implemented as multiple threads doing work cooperatively. * Algorithms implemented as multiple threads doing work cooperatively.
*/ */
struct dxCooperative; struct dxCooperative;
struct dxResourceRequirements; struct dxResourceRequirements;
struct dxResourceContainer; struct dxResourceContainer;
/** /**
* @brief A container for cooperative algorithms shared context * @brief A container for cooperative algorithms shared context
* *
* The Cooperative is a container for cooperative algorithms shared context. * The Cooperative is a container for cooperative algorithms shared context.
* At present it contains threading object (either a real one or a defaulted * At present it contains threading object (either a real one or a defaulted
* self-threading). * self-threading).
* *
* Cooperative use in functions performing computations must be serialized. That is, * Cooperative use in functions performing computations must be serialized. That is,
* functions referring to a single instance of Cooperative object must not be called in * functions referring to a single instance of Cooperative object must not be called in
* parallel. * parallel.
*/ */
typedef struct dxCooperative *dCooperativeID; typedef struct dxCooperative *dCooperativeID;
/** /**
* @brief A container for resource requirements information * @brief A container for resource requirements information
* *
* The ResourceRequirements object is a container for descriptive information * The ResourceRequirements object is a container for descriptive information
* regarding what resources (memory, synchronization objects, etc.) need to be * regarding what resources (memory, synchronization objects, etc.) need to be
* allocated for particular computations. The object can be used for accumulating * allocated for particular computations. The object can be used for accumulating
* resource requirement maxima over multiple functions and then allocating resources * resource requirement maxima over multiple functions and then allocating resources
* that would suffice for any of those function calls. * that would suffice for any of those function calls.
* *
* ResourceRequirements objects maintain relations to Cooperative objects since * ResourceRequirements objects maintain relations to Cooperative objects since
* amounts of resources that could be required can depend on characteristics of * amounts of resources that could be required can depend on characteristics of
* shared context, e.g. on maximal number of threads in the threading object. * shared context, e.g. on maximal number of threads in the threading object.
* *
* @ingroup coop * @ingroup coop
* @see dCooperativeID * @see dCooperativeID
* @see dResourceContainerID * @see dResourceContainerID
*/ */
typedef struct dxResourceRequirements *dResourceRequirementsID; typedef struct dxResourceRequirements *dResourceRequirementsID;
/** /**
* @brief A container for algorithm allocated resources * @brief A container for algorithm allocated resources
* *
* The ResourceContainer object can contain resources allocated according to information * The ResourceContainer object can contain resources allocated according to information
* in a ResourceRequirements. The resources inherit link to the threading object * in a ResourceRequirements. The resources inherit link to the threading object
* from the requirements they are allocated according to. * from the requirements they are allocated according to.
* *
* @ingroup coop * @ingroup coop
* @see dResourceRequirementsID * @see dResourceRequirementsID
* @see dCooperativeID * @see dCooperativeID
*/ */
typedef struct dxResourceContainer *dResourceContainerID; typedef struct dxResourceContainer *dResourceContainerID;
/** /**
* @brief Creates a Cooperative object related to the specified threading. * @brief Creates a Cooperative object related to the specified threading.
* *
* NULL's are allowed for the threading. In this case the default (global) self-threading * NULL's are allowed for the threading. In this case the default (global) self-threading
* object will be used. * object will be used.
* *
* Use @c dCooperativeDestroy to destroy the object. The Cooperative object must exist * Use @c dCooperativeDestroy to destroy the object. The Cooperative object must exist
* until after all the objects referencing it are destroyed. * until after all the objects referencing it are destroyed.
* *
* @param functionInfo The threading functions to use * @param functionInfo The threading functions to use
* @param threadingImpl The threading implementation object to use * @param threadingImpl The threading implementation object to use
* @returns The Cooperative object instance or NULL if allocation fails. * @returns The Cooperative object instance or NULL if allocation fails.
* @ingroup coop * @ingroup coop
* @see dCooperativeDestroy * @see dCooperativeDestroy
*/ */
ODE_API dCooperativeID dCooperativeCreate(const dThreadingFunctionsInfo *functionInfo/*=NULL*/, dThreadingImplementationID threadingImpl/*=NULL*/); ODE_API dCooperativeID dCooperativeCreate(const dThreadingFunctionsInfo *functionInfo/*=NULL*/, dThreadingImplementationID threadingImpl/*=NULL*/);
/** /**
* @brief Destroys Cooperative object. * @brief Destroys Cooperative object.
* *
* The Cooperative object can only be destroyed after all the objects referencing it. * The Cooperative object can only be destroyed after all the objects referencing it.
* *
* @param cooperative A Cooperative object to be deleted (NULL is allowed) * @param cooperative A Cooperative object to be deleted (NULL is allowed)
* @ingroup coop * @ingroup coop
* @see dCooperativeCreate * @see dCooperativeCreate
*/ */
ODE_API void dCooperativeDestroy(dCooperativeID cooperative); ODE_API void dCooperativeDestroy(dCooperativeID cooperative);
/** /**
* @brief Creates a ResourceRequirements object related to a Cooperative. * @brief Creates a ResourceRequirements object related to a Cooperative.
* *
* The object is purely descriptive and does not contain any resources by itself. * The object is purely descriptive and does not contain any resources by itself.
* The actual resources are allocated by means of ResourceContainer object. * The actual resources are allocated by means of ResourceContainer object.
* *
* The object is created with empty requirements. It can be then used to accumulate * The object is created with empty requirements. It can be then used to accumulate
* requirements for one or more function calls and can be cloned or merged with others. * requirements for one or more function calls and can be cloned or merged with others.
* The actual requirements information is added to the object by computation related * The actual requirements information is added to the object by computation related
* functions. * functions.
* *
* Use @c dResourceRequirementsDestroy to delete the object when it is no longer needed. * Use @c dResourceRequirementsDestroy to delete the object when it is no longer needed.
* *
* @param cooperative A Cooperative object to be used * @param cooperative A Cooperative object to be used
* @returns The ResourceRequirements object instance or NULL if allocation fails * @returns The ResourceRequirements object instance or NULL if allocation fails
* @ingroup coop * @ingroup coop
* @see dResourceRequirementsDestroy * @see dResourceRequirementsDestroy
* @see dResourceRequirementsClone * @see dResourceRequirementsClone
* @see dResourceRequirementsMergeIn * @see dResourceRequirementsMergeIn
* @see dCooperativeCreate * @see dCooperativeCreate
* @see dResourceContainerAcquire * @see dResourceContainerAcquire
*/ */
ODE_API dResourceRequirementsID dResourceRequirementsCreate(dCooperativeID cooperative); ODE_API dResourceRequirementsID dResourceRequirementsCreate(dCooperativeID cooperative);
/** /**
* @brief Destroys ResourceRequirements object. * @brief Destroys ResourceRequirements object.
* *
* The ResourceRequirements object can be destroyed at any time with no regards * The ResourceRequirements object can be destroyed at any time with no regards
* to other objects' lifetime. * to other objects' lifetime.
* *
* @param requirements A ResourceRequirements object to be deleted (NULL is allowed) * @param requirements A ResourceRequirements object to be deleted (NULL is allowed)
* @ingroup coop * @ingroup coop
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
*/ */
ODE_API void dResourceRequirementsDestroy(dResourceRequirementsID requirements); ODE_API void dResourceRequirementsDestroy(dResourceRequirementsID requirements);
/** /**
* @brief Clones ResourceRequirements object. * @brief Clones ResourceRequirements object.
* *
* The function creates a copy of the ResourceRequirements object with all the * The function creates a copy of the ResourceRequirements object with all the
* contents and the relation to Cooperative matching. The object passed in * contents and the relation to Cooperative matching. The object passed in
* the parameter is not changed. * the parameter is not changed.
* *
* The object created with the function must later be destroyed with @c dResourceRequirementsDestroy. * The object created with the function must later be destroyed with @c dResourceRequirementsDestroy.
* *
* @param requirements A ResourceRequirements object to be cloned * @param requirements A ResourceRequirements object to be cloned
* @returns A handle to the new object or NULL if allocation fails * @returns A handle to the new object or NULL if allocation fails
* @ingroup coop * @ingroup coop
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
* @see dResourceRequirementsDestroy * @see dResourceRequirementsDestroy
* @see dResourceRequirementsMergeIn * @see dResourceRequirementsMergeIn
*/ */
ODE_API dResourceRequirementsID dResourceRequirementsClone(/*const */dResourceRequirementsID requirements); ODE_API dResourceRequirementsID dResourceRequirementsClone(/*const */dResourceRequirementsID requirements);
/** /**
* @brief Merges one ResourceRequirements object into another ResourceRequirements object. * @brief Merges one ResourceRequirements object into another ResourceRequirements object.
* *
* The function updates @a summaryRequirements requirements to be also sufficient * The function updates @a summaryRequirements requirements to be also sufficient
* for the purposes @a extraRequirements could be used for. The @a extraRequirements * for the purposes @a extraRequirements could be used for. The @a extraRequirements
* object is not changed. The both objects should normally have had been created * object is not changed. The both objects should normally have had been created
* with the same Cooperative object. * with the same Cooperative object.
* *
* @param summaryRequirements A ResourceRequirements object to be changed * @param summaryRequirements A ResourceRequirements object to be changed
* @param extraRequirements A ResourceRequirements the requirements to be taken from * @param extraRequirements A ResourceRequirements the requirements to be taken from
* @ingroup coop * @ingroup coop
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
* @see dResourceRequirementsDestroy * @see dResourceRequirementsDestroy
* @see dResourceRequirementsClone * @see dResourceRequirementsClone
*/ */
ODE_API void dResourceRequirementsMergeIn(dResourceRequirementsID summaryRequirements, /*const */dResourceRequirementsID extraRequirements); ODE_API void dResourceRequirementsMergeIn(dResourceRequirementsID summaryRequirements, /*const */dResourceRequirementsID extraRequirements);
/** /**
* @brief Allocates resources as specified in ResourceRequirements object. * @brief Allocates resources as specified in ResourceRequirements object.
* *
* The ResourceContainer object can be used in cooperative computation algorithms. * The ResourceContainer object can be used in cooperative computation algorithms.
* *
* The same @a requirements object can be passed to many resource allocations * The same @a requirements object can be passed to many resource allocations
* (with or without modifications) and can be deleted immediately, without waiting * (with or without modifications) and can be deleted immediately, without waiting
* for the ResourceContainer object destruction. * for the ResourceContainer object destruction.
* *
* Use @c dResourceContainerDestroy to delete the object and release the resources * Use @c dResourceContainerDestroy to delete the object and release the resources
* when they are no longer needed. * when they are no longer needed.
* *
* @param requirements The ResourceRequirements object to allocate resources according to * @param requirements The ResourceRequirements object to allocate resources according to
* @returns A ResourceContainer object instance with the resources allocated or NULL if allocation fails * @returns A ResourceContainer object instance with the resources allocated or NULL if allocation fails
* @ingroup coop * @ingroup coop
* @see dResourceContainerDestroy * @see dResourceContainerDestroy
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
*/ */
ODE_API dResourceContainerID dResourceContainerAcquire(/*const */dResourceRequirementsID requirements); ODE_API dResourceContainerID dResourceContainerAcquire(/*const */dResourceRequirementsID requirements);
/** /**
* @brief Destroys ResourceContainer object and releases resources allocated in it. * @brief Destroys ResourceContainer object and releases resources allocated in it.
* *
* @param resources A ResourceContainer object to be deleted (NULL is allowed) * @param resources A ResourceContainer object to be deleted (NULL is allowed)
* @ingroup coop * @ingroup coop
* @see dResourceContainerAcquire * @see dResourceContainerAcquire
*/ */
ODE_API void dResourceContainerDestroy(dResourceContainerID resources); ODE_API void dResourceContainerDestroy(dResourceContainerID resources);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
#endif // #ifndef _ODE_COOPERATIVE_H_ #endif // #ifndef _ODE_COOPERATIVE_H_

@ -1,63 +1,63 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* this comes from the `reuse' library. copy any changes back to the source */ /* this comes from the `reuse' library. copy any changes back to the source */
#ifndef _ODE_ERROR_H_ #ifndef _ODE_ERROR_H_
#define _ODE_ERROR_H_ #define _ODE_ERROR_H_
#include <ode/odeconfig.h> #include <ode/odeconfig.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* all user defined error functions have this type. error and debug functions /* all user defined error functions have this type. error and debug functions
* should not return. * should not return.
*/ */
typedef void dMessageFunction (int errnum, const char *msg, va_list ap); typedef void dMessageFunction (int errnum, const char *msg, va_list ap);
/* set a new error, debug or warning handler. if fn is 0, the default handlers /* set a new error, debug or warning handler. if fn is 0, the default handlers
* are used. * are used.
*/ */
ODE_API void dSetErrorHandler (dMessageFunction *fn); ODE_API void dSetErrorHandler (dMessageFunction *fn);
ODE_API void dSetDebugHandler (dMessageFunction *fn); ODE_API void dSetDebugHandler (dMessageFunction *fn);
ODE_API void dSetMessageHandler (dMessageFunction *fn); ODE_API void dSetMessageHandler (dMessageFunction *fn);
/* return the current error, debug or warning handler. if the return value is /* return the current error, debug or warning handler. if the return value is
* 0, the default handlers are in place. * 0, the default handlers are in place.
*/ */
ODE_API dMessageFunction *dGetErrorHandler(void); ODE_API dMessageFunction *dGetErrorHandler(void);
ODE_API dMessageFunction *dGetDebugHandler(void); ODE_API dMessageFunction *dGetDebugHandler(void);
ODE_API dMessageFunction *dGetMessageHandler(void); ODE_API dMessageFunction *dGetMessageHandler(void);
/* generate a fatal error, debug trap or a message. */ /* generate a fatal error, debug trap or a message. */
ODE_API void ODE_NORETURN dError (int num, const char *msg, ...); ODE_API void ODE_NORETURN dError (int num, const char *msg, ...);
ODE_API void ODE_NORETURN dDebug (int num, const char *msg, ...); ODE_API void ODE_NORETURN dDebug (int num, const char *msg, ...);
ODE_API void dMessage (int num, const char *msg, ...); ODE_API void dMessage (int num, const char *msg, ...);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,40 +1,40 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_EXPORT_DIF_ #ifndef _ODE_EXPORT_DIF_
#define _ODE_EXPORT_DIF_ #define _ODE_EXPORT_DIF_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
ODE_API void dWorldExportDIF (dWorldID w, FILE *file, const char *world_name); ODE_API void dWorldExportDIF (dWorldID w, FILE *file, const char *world_name);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,144 +1,144 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_MASS_H_ #ifndef _ODE_MASS_H_
#define _ODE_MASS_H_ #define _ODE_MASS_H_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct dMass; struct dMass;
typedef struct dMass dMass; typedef struct dMass dMass;
/** /**
* Check if a mass structure has valid value. * Check if a mass structure has valid value.
* The function check if the mass and innertia matrix are positive definits * The function check if the mass and innertia matrix are positive definits
* *
* @param m A mass structure to check * @param m A mass structure to check
* *
* @return 1 if both codition are met * @return 1 if both codition are met
*/ */
ODE_API int dMassCheck(const dMass *m); ODE_API int dMassCheck(const dMass *m);
ODE_API void dMassSetZero (dMass *); ODE_API void dMassSetZero (dMass *);
ODE_API void dMassSetParameters (dMass *, dReal themass, ODE_API void dMassSetParameters (dMass *, dReal themass,
dReal cgx, dReal cgy, dReal cgz, dReal cgx, dReal cgy, dReal cgz,
dReal I11, dReal I22, dReal I33, dReal I11, dReal I22, dReal I33,
dReal I12, dReal I13, dReal I23); dReal I12, dReal I13, dReal I23);
ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius); ODE_API void dMassSetSphere (dMass *, dReal density, dReal radius);
ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius); ODE_API void dMassSetSphereTotal (dMass *, dReal total_mass, dReal radius);
ODE_API void dMassSetCapsule (dMass *, dReal density, int direction, ODE_API void dMassSetCapsule (dMass *, dReal density, int direction,
dReal radius, dReal length); dReal radius, dReal length);
ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction, ODE_API void dMassSetCapsuleTotal (dMass *, dReal total_mass, int direction,
dReal radius, dReal length); dReal radius, dReal length);
ODE_API void dMassSetCylinder (dMass *, dReal density, int direction, ODE_API void dMassSetCylinder (dMass *, dReal density, int direction,
dReal radius, dReal length); dReal radius, dReal length);
ODE_API void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction, ODE_API void dMassSetCylinderTotal (dMass *, dReal total_mass, int direction,
dReal radius, dReal length); dReal radius, dReal length);
ODE_API void dMassSetBox (dMass *, dReal density, ODE_API void dMassSetBox (dMass *, dReal density,
dReal lx, dReal ly, dReal lz); dReal lx, dReal ly, dReal lz);
ODE_API void dMassSetBoxTotal (dMass *, dReal total_mass, ODE_API void dMassSetBoxTotal (dMass *, dReal total_mass,
dReal lx, dReal ly, dReal lz); dReal lx, dReal ly, dReal lz);
ODE_API void dMassSetTrimesh (dMass *, dReal density, dGeomID g); ODE_API void dMassSetTrimesh (dMass *, dReal density, dGeomID g);
ODE_API void dMassSetTrimeshTotal (dMass *m, dReal total_mass, dGeomID g); ODE_API void dMassSetTrimeshTotal (dMass *m, dReal total_mass, dGeomID g);
ODE_API void dMassAdjust (dMass *, dReal newmass); ODE_API void dMassAdjust (dMass *, dReal newmass);
ODE_API void dMassTranslate (dMass *, dReal x, dReal y, dReal z); ODE_API void dMassTranslate (dMass *, dReal x, dReal y, dReal z);
ODE_API void dMassRotate (dMass *, const dMatrix3 R); ODE_API void dMassRotate (dMass *, const dMatrix3 R);
ODE_API void dMassAdd (dMass *a, const dMass *b); ODE_API void dMassAdd (dMass *a, const dMass *b);
/* Backwards compatible API */ /* Backwards compatible API */
ODE_API_DEPRECATED ODE_API void dMassSetCappedCylinder(dMass *a, dReal b, int c, dReal d, dReal e); ODE_API_DEPRECATED ODE_API void dMassSetCappedCylinder(dMass *a, dReal b, int c, dReal d, dReal e);
ODE_API_DEPRECATED ODE_API void dMassSetCappedCylinderTotal(dMass *a, dReal b, int c, dReal d, dReal e); ODE_API_DEPRECATED ODE_API void dMassSetCappedCylinderTotal(dMass *a, dReal b, int c, dReal d, dReal e);
struct dMass { struct dMass {
dReal mass; dReal mass;
dVector3 c; dVector3 c;
dMatrix3 I; dMatrix3 I;
#ifdef __cplusplus #ifdef __cplusplus
dMass() dMass()
{ dMassSetZero (this); } { dMassSetZero (this); }
void setZero() void setZero()
{ dMassSetZero (this); } { dMassSetZero (this); }
void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz, void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz,
dReal I11, dReal I22, dReal I33, dReal I11, dReal I22, dReal I33,
dReal I12, dReal I13, dReal I23) dReal I12, dReal I13, dReal I23)
{ dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); } { dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); }
void setSphere (dReal density, dReal radius) void setSphere (dReal density, dReal radius)
{ dMassSetSphere (this,density,radius); } { dMassSetSphere (this,density,radius); }
void setSphereTotal (dReal total, dReal radius) void setSphereTotal (dReal total, dReal radius)
{ dMassSetSphereTotal (this,total,radius); } { dMassSetSphereTotal (this,total,radius); }
void setCapsule (dReal density, int direction, dReal radius, dReal length) void setCapsule (dReal density, int direction, dReal radius, dReal length)
{ dMassSetCapsule (this,density,direction,radius,length); } { dMassSetCapsule (this,density,direction,radius,length); }
void setCapsuleTotal (dReal total, int direction, dReal radius, dReal length) void setCapsuleTotal (dReal total, int direction, dReal radius, dReal length)
{ dMassSetCapsule (this,total,direction,radius,length); } { dMassSetCapsule (this,total,direction,radius,length); }
void setCylinder(dReal density, int direction, dReal radius, dReal length) void setCylinder(dReal density, int direction, dReal radius, dReal length)
{ dMassSetCylinder (this,density,direction,radius,length); } { dMassSetCylinder (this,density,direction,radius,length); }
void setCylinderTotal(dReal total, int direction, dReal radius, dReal length) void setCylinderTotal(dReal total, int direction, dReal radius, dReal length)
{ dMassSetCylinderTotal (this,total,direction,radius,length); } { dMassSetCylinderTotal (this,total,direction,radius,length); }
void setBox (dReal density, dReal lx, dReal ly, dReal lz) void setBox (dReal density, dReal lx, dReal ly, dReal lz)
{ dMassSetBox (this,density,lx,ly,lz); } { dMassSetBox (this,density,lx,ly,lz); }
void setBoxTotal (dReal total, dReal lx, dReal ly, dReal lz) void setBoxTotal (dReal total, dReal lx, dReal ly, dReal lz)
{ dMassSetBoxTotal (this,total,lx,ly,lz); } { dMassSetBoxTotal (this,total,lx,ly,lz); }
void setTrimesh(dReal density, dGeomID g) void setTrimesh(dReal density, dGeomID g)
{ dMassSetTrimesh (this, density, g); } { dMassSetTrimesh (this, density, g); }
void setTrimeshTotal(dReal total, dGeomID g) void setTrimeshTotal(dReal total, dGeomID g)
{ dMassSetTrimeshTotal (this, total, g); } { dMassSetTrimeshTotal (this, total, g); }
void adjust (dReal newmass) void adjust (dReal newmass)
{ dMassAdjust (this,newmass); } { dMassAdjust (this,newmass); }
void translate (dReal x, dReal y, dReal z) void translate (dReal x, dReal y, dReal z)
{ dMassTranslate (this,x,y,z); } { dMassTranslate (this,x,y,z); }
void rotate (const dMatrix3 R) void rotate (const dMatrix3 R)
{ dMassRotate (this,R); } { dMassRotate (this,R); }
void add (const dMass *b) void add (const dMass *b)
{ dMassAdd (this,b); } { dMassAdd (this,b); }
#endif #endif
}; };
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,200 +1,200 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* optimized and unoptimized vector and matrix functions */ /* optimized and unoptimized vector and matrix functions */
#ifndef _ODE_MATRIX_H_ #ifndef _ODE_MATRIX_H_
#define _ODE_MATRIX_H_ #define _ODE_MATRIX_H_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* set a vector/matrix of size n to all zeros, or to a specific value. */ /* set a vector/matrix of size n to all zeros, or to a specific value. */
ODE_API void dSetZero (dReal *a, int n); ODE_API void dSetZero (dReal *a, int n);
ODE_API void dSetValue (dReal *a, int n, dReal value); ODE_API void dSetValue (dReal *a, int n, dReal value);
/* get the dot product of two n*1 vectors. if n <= 0 then /* get the dot product of two n*1 vectors. if n <= 0 then
* zero will be returned (in which case a and b need not be valid). * zero will be returned (in which case a and b need not be valid).
*/ */
ODE_API dReal dDot (const dReal *a, const dReal *b, int n); ODE_API dReal dDot (const dReal *a, const dReal *b, int n);
/* get the dot products of (a0,b), (a1,b), etc and return them in outsum. /* get the dot products of (a0,b), (a1,b), etc and return them in outsum.
* all vectors are n*1. if n <= 0 then zeroes will be returned (in which case * all vectors are n*1. if n <= 0 then zeroes will be returned (in which case
* the input vectors need not be valid). this function is somewhat faster * the input vectors need not be valid). this function is somewhat faster
* than calling dDot() for all of the combinations separately. * than calling dDot() for all of the combinations separately.
*/ */
/* NOT INCLUDED in the library for now. /* NOT INCLUDED in the library for now.
void dMultidot2 (const dReal *a0, const dReal *a1, void dMultidot2 (const dReal *a0, const dReal *a1,
const dReal *b, dReal *outsum, int n); const dReal *b, dReal *outsum, int n);
*/ */
/* matrix multiplication. all matrices are stored in standard row format. /* matrix multiplication. all matrices are stored in standard row format.
* the digit refers to the argument that is transposed: * the digit refers to the argument that is transposed:
* 0: A = B * C (sizes: A:p*r B:p*q C:q*r) * 0: A = B * C (sizes: A:p*r B:p*q C:q*r)
* 1: A = B' * C (sizes: A:p*r B:q*p C:q*r) * 1: A = B' * C (sizes: A:p*r B:q*p C:q*r)
* 2: A = B * C' (sizes: A:p*r B:p*q C:r*q) * 2: A = B * C' (sizes: A:p*r B:p*q C:r*q)
* case 1,2 are equivalent to saying that the operation is A=B*C but * case 1,2 are equivalent to saying that the operation is A=B*C but
* B or C are stored in standard column format. * B or C are stored in standard column format.
*/ */
ODE_API void dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); ODE_API void dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r);
ODE_API void dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); ODE_API void dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r);
ODE_API void dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); ODE_API void dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r);
/* do an in-place cholesky decomposition on the lower triangle of the n*n /* do an in-place cholesky decomposition on the lower triangle of the n*n
* symmetric matrix A (which is stored by rows). the resulting lower triangle * symmetric matrix A (which is stored by rows). the resulting lower triangle
* will be such that L*L'=A. return 1 on success and 0 on failure (on failure * will be such that L*L'=A. return 1 on success and 0 on failure (on failure
* the matrix is not positive definite). * the matrix is not positive definite).
*/ */
ODE_API int dFactorCholesky (dReal *A, int n); ODE_API int dFactorCholesky (dReal *A, int n);
/* solve for x: L*L'*x = b, and put the result back into x. /* solve for x: L*L'*x = b, and put the result back into x.
* L is size n*n, b is size n*1. only the lower triangle of L is considered. * L is size n*n, b is size n*1. only the lower triangle of L is considered.
*/ */
ODE_API void dSolveCholesky (const dReal *L, dReal *b, int n); ODE_API void dSolveCholesky (const dReal *L, dReal *b, int n);
/* compute the inverse of the n*n positive definite matrix A and put it in /* compute the inverse of the n*n positive definite matrix A and put it in
* Ainv. this is not especially fast. this returns 1 on success (A was * Ainv. this is not especially fast. this returns 1 on success (A was
* positive definite) or 0 on failure (not PD). * positive definite) or 0 on failure (not PD).
*/ */
ODE_API int dInvertPDMatrix (const dReal *A, dReal *Ainv, int n); ODE_API int dInvertPDMatrix (const dReal *A, dReal *Ainv, int n);
/* check whether an n*n matrix A is positive definite, return 1/0 (yes/no). /* check whether an n*n matrix A is positive definite, return 1/0 (yes/no).
* positive definite means that x'*A*x > 0 for any x. this performs a * positive definite means that x'*A*x > 0 for any x. this performs a
* cholesky decomposition of A. if the decomposition fails then the matrix * cholesky decomposition of A. if the decomposition fails then the matrix
* is not positive definite. A is stored by rows. A is not altered. * is not positive definite. A is stored by rows. A is not altered.
*/ */
ODE_API int dIsPositiveDefinite (const dReal *A, int n); ODE_API int dIsPositiveDefinite (const dReal *A, int n);
/* factorize a matrix A into L*D*L', where L is lower triangular with ones on /* factorize a matrix A into L*D*L', where L is lower triangular with ones on
* the diagonal, and D is diagonal. * the diagonal, and D is diagonal.
* A is an n*n matrix stored by rows, with a leading dimension of n rounded * A is an n*n matrix stored by rows, with a leading dimension of n rounded
* up to 4. L is written into the strict lower triangle of A (the ones are not * up to 4. L is written into the strict lower triangle of A (the ones are not
* written) and the reciprocal of the diagonal elements of D are written into * written) and the reciprocal of the diagonal elements of D are written into
* d. * d.
*/ */
ODE_API void dFactorLDLT (dReal *A, dReal *d, int n, int nskip); ODE_API void dFactorLDLT (dReal *A, dReal *d, int n, int nskip);
/* solve L*x=b, where L is n*n lower triangular with ones on the diagonal, /* solve L*x=b, where L is n*n lower triangular with ones on the diagonal,
* and x,b are n*1. b is overwritten with x. * and x,b are n*1. b is overwritten with x.
* the leading dimension of L is `nskip'. * the leading dimension of L is `nskip'.
*/ */
ODE_API void dSolveL1 (const dReal *L, dReal *b, int n, int nskip); ODE_API void dSolveL1 (const dReal *L, dReal *b, int n, int nskip);
/* solve L'*x=b, where L is n*n lower triangular with ones on the diagonal, /* solve L'*x=b, where L is n*n lower triangular with ones on the diagonal,
* and x,b are n*1. b is overwritten with x. * and x,b are n*1. b is overwritten with x.
* the leading dimension of L is `nskip'. * the leading dimension of L is `nskip'.
*/ */
ODE_API void dSolveL1T (const dReal *L, dReal *b, int n, int nskip); ODE_API void dSolveL1T (const dReal *L, dReal *b, int n, int nskip);
/* in matlab syntax: a(1:n) = a(1:n) .* d(1:n) /* in matlab syntax: a(1:n) = a(1:n) .* d(1:n)
*/ */
ODE_API void dScaleVector (dReal *a, const dReal *d, int n); ODE_API void dScaleVector (dReal *a, const dReal *d, int n);
/* The function is an alias for @c dScaleVector. /* The function is an alias for @c dScaleVector.
* It has been deprecated because of a wrong naming schema used. * It has been deprecated because of a wrong naming schema used.
*/ */
ODE_API_DEPRECATED ODE_API void dVectorScale (dReal *a, const dReal *d, int n); ODE_API_DEPRECATED ODE_API void dVectorScale (dReal *a, const dReal *d, int n);
/* given `L', a n*n lower triangular matrix with ones on the diagonal, /* given `L', a n*n lower triangular matrix with ones on the diagonal,
* and `d', a n*1 vector of the reciprocal diagonal elements of an n*n matrix * and `d', a n*1 vector of the reciprocal diagonal elements of an n*n matrix
* D, solve L*D*L'*x=b where x,b are n*1. x overwrites b. * D, solve L*D*L'*x=b where x,b are n*1. x overwrites b.
* the leading dimension of L is `nskip'. * the leading dimension of L is `nskip'.
*/ */
ODE_API void dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip); ODE_API void dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip);
/* given an L*D*L' factorization of an n*n matrix A, return the updated /* given an L*D*L' factorization of an n*n matrix A, return the updated
* factorization L2*D2*L2' of A plus the following "top left" matrix: * factorization L2*D2*L2' of A plus the following "top left" matrix:
* *
* [ b a' ] <-- b is a[0] * [ b a' ] <-- b is a[0]
* [ a 0 ] <-- a is a[1..n-1] * [ a 0 ] <-- a is a[1..n-1]
* *
* - L has size n*n, its leading dimension is nskip. L is lower triangular * - L has size n*n, its leading dimension is nskip. L is lower triangular
* with ones on the diagonal. only the lower triangle of L is referenced. * with ones on the diagonal. only the lower triangle of L is referenced.
* - d has size n. d contains the reciprocal diagonal elements of D. * - d has size n. d contains the reciprocal diagonal elements of D.
* - a has size n. * - a has size n.
* the result is written into L, except that the left column of L and d[0] * the result is written into L, except that the left column of L and d[0]
* are not actually modified. see ldltaddTL.m for further comments. * are not actually modified. see ldltaddTL.m for further comments.
*/ */
ODE_API void dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip); ODE_API void dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip);
/* given an L*D*L' factorization of a permuted matrix A, produce a new /* given an L*D*L' factorization of a permuted matrix A, produce a new
* factorization for row and column `r' removed. * factorization for row and column `r' removed.
* - A has size n1*n1, its leading dimension in nskip. A is symmetric and * - A has size n1*n1, its leading dimension in nskip. A is symmetric and
* positive definite. only the lower triangle of A is referenced. * positive definite. only the lower triangle of A is referenced.
* A itself may actually be an array of row pointers. * A itself may actually be an array of row pointers.
* - L has size n2*n2, its leading dimension in nskip. L is lower triangular * - L has size n2*n2, its leading dimension in nskip. L is lower triangular
* with ones on the diagonal. only the lower triangle of L is referenced. * with ones on the diagonal. only the lower triangle of L is referenced.
* - d has size n2. d contains the reciprocal diagonal elements of D. * - d has size n2. d contains the reciprocal diagonal elements of D.
* - p is a permutation vector. it contains n2 indexes into A. each index * - p is a permutation vector. it contains n2 indexes into A. each index
* must be in the range 0..n1-1. * must be in the range 0..n1-1.
* - r is the row/column of L to remove. * - r is the row/column of L to remove.
* the new L will be written within the old L, i.e. will have the same leading * the new L will be written within the old L, i.e. will have the same leading
* dimension. the last row and column of L, and the last element of d, are * dimension. the last row and column of L, and the last element of d, are
* undefined on exit. * undefined on exit.
* *
* a fast O(n^2) algorithm is used. see ldltremove.m for further comments. * a fast O(n^2) algorithm is used. see ldltremove.m for further comments.
*/ */
ODE_API void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, ODE_API void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d,
int n1, int n2, int r, int nskip); int n1, int n2, int r, int nskip);
/* given an n*n matrix A (with leading dimension nskip), remove the r'th row /* given an n*n matrix A (with leading dimension nskip), remove the r'th row
* and column by moving elements. the new matrix will have the same leading * and column by moving elements. the new matrix will have the same leading
* dimension. the last row and column of A are untouched on exit. * dimension. the last row and column of A are untouched on exit.
*/ */
ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r); ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,291 +1,291 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_MATRIX_COOP_H_ #ifndef _ODE_MATRIX_COOP_H_
#define _ODE_MATRIX_COOP_H_ #define _ODE_MATRIX_COOP_H_
#include <ode/common.h> #include <ode/common.h>
#include <ode/cooperative.h> #include <ode/cooperative.h>
#include <ode/threading.h> #include <ode/threading.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**
* @defgroup matrix_coop Matrix Cooperative Algorithms * @defgroup matrix_coop Matrix Cooperative Algorithms
* *
* Cooperative algorithms operating on matrices and vectors. * Cooperative algorithms operating on matrices and vectors.
* *
* @ingroup coop * @ingroup coop
*/ */
/** /**
* @brief Estimates resource requirements for a @c dCooperativelyFactorLDLT call * @brief Estimates resource requirements for a @c dCooperativelyFactorLDLT call
* *
* The function updates the contents of @a requirements to also suffice for calling * The function updates the contents of @a requirements to also suffice for calling
* @c dCooperativelyFactorLDLT with the given parameters. * @c dCooperativelyFactorLDLT with the given parameters.
* *
* Note: The requirements that could have already been in the @a requirements parameter * Note: The requirements that could have already been in the @a requirements parameter
* are never decreased. * are never decreased.
* *
* @param requirements The ResourceRequirements object to update * @param requirements The ResourceRequirements object to update
* @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
* @param maximalRowCount Maximal value of rowCount parameter that is going to be used * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dCooperativelyFactorLDLT * @see dCooperativelyFactorLDLT
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
*/ */
ODE_API void dEstimateCooperativelyFactorLDLTResourceRequirements(dResourceRequirementsID requirements, ODE_API void dEstimateCooperativelyFactorLDLTResourceRequirements(dResourceRequirementsID requirements,
unsigned maximalAllowedThreadCount, unsigned maximalRowCount); unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
/** /**
* @brief Cooperatively factorizes a matrix `A' into L*D*L' * @brief Cooperatively factorizes a matrix `A' into L*D*L'
* *
* The function factorizes a matrix `A' into L*D*L', where `L' is lower triangular with ones on * The function factorizes a matrix `A' into L*D*L', where `L' is lower triangular with ones on
* the diagonal, and `D' is diagonal. * the diagonal, and `D' is diagonal.
* @a A is a rowCount*rowCount matrix stored by rows, with a leading dimension of @a rowCount rounded * @a A is a rowCount*rowCount matrix stored by rows, with a leading dimension of @a rowCount rounded
* up at least to 4 elements. `L; is written into the strict lower triangle of @a A * up at least to 4 elements. `L; is written into the strict lower triangle of @a A
* (the ones are not written) and the reciprocal of the diagonal elements of `D' are written into @a d. * (the ones are not written) and the reciprocal of the diagonal elements of `D' are written into @a d.
* *
* The @a resources must have had been allocated from a ResourceRequirements object * The @a resources must have had been allocated from a ResourceRequirements object
* estimated in @c dEstimateCooperativelyFactorLDLTResourceRequirements. * estimated in @c dEstimateCooperativelyFactorLDLTResourceRequirements.
* *
* The operation is performed cooperatively by up to @a allowedThreadCount threads * The operation is performed cooperatively by up to @a allowedThreadCount threads
* from thread pool available in @a resources. The threading must must not be simultaneously * from thread pool available in @a resources. The threading must must not be simultaneously
* used (via other @c dResourceContainerID instances) in other calls that employ its features. * used (via other @c dResourceContainerID instances) in other calls that employ its features.
* *
* @param resources The resources allocated for the function * @param resources The resources allocated for the function
* @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters) * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
* @param A The `A' matrix * @param A The `A' matrix
* @param d The `d' vector * @param d The `d' vector
* @param rowCount The row count in @a A and @a d * @param rowCount The row count in @a A and @a d
* @param rowskip The actual number of elements to be added to skip to next row in @a A * @param rowskip The actual number of elements to be added to skip to next row in @a A
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dEstimateCooperativelyFactorLDLTResourceRequirements * @see dEstimateCooperativelyFactorLDLTResourceRequirements
* @see dResourceContainerAcquire * @see dResourceContainerAcquire
* @see dCooperativelySolveLDLT * @see dCooperativelySolveLDLT
*/ */
ODE_API void dCooperativelyFactorLDLT(dResourceContainerID resources, unsigned allowedThreadCount, ODE_API void dCooperativelyFactorLDLT(dResourceContainerID resources, unsigned allowedThreadCount,
dReal *A, dReal *d, unsigned rowCount, unsigned rowSkip); dReal *A, dReal *d, unsigned rowCount, unsigned rowSkip);
/** /**
* @brief Estimates resource requirements for a @c dCooperativelySolveLDLT call * @brief Estimates resource requirements for a @c dCooperativelySolveLDLT call
* *
* The function updates the contents of @a requirements to also suffice for calling * The function updates the contents of @a requirements to also suffice for calling
* @c dCooperativelySolveLDLT with the given parameters. * @c dCooperativelySolveLDLT with the given parameters.
* *
* Note: The requirements that could have already been in the @a requirements parameter * Note: The requirements that could have already been in the @a requirements parameter
* are never decreased. * are never decreased.
* *
* @param requirements The ResourceRequirements object to update * @param requirements The ResourceRequirements object to update
* @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
* @param maximalRowCount Maximal value of rowCount parameter that is going to be used * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dCooperativelySolveLDLT * @see dCooperativelySolveLDLT
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
*/ */
ODE_API void dEstimateCooperativelySolveLDLTResourceRequirements(dResourceRequirementsID requirements, ODE_API void dEstimateCooperativelySolveLDLTResourceRequirements(dResourceRequirementsID requirements,
unsigned maximalAllowedThreadCount, unsigned maximalRowCount); unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
/** /**
* @brief Cooperatively solves L*D*L'*x=b * @brief Cooperatively solves L*D*L'*x=b
* *
* Given `L', a rowCount*rowCount lower triangular matrix with ones on the diagonal, * Given `L', a rowCount*rowCount lower triangular matrix with ones on the diagonal,
* and `d', a rowCount*1 vector of the reciprocal diagonal elements of a rowCount*rowCount matrix * and `d', a rowCount*1 vector of the reciprocal diagonal elements of a rowCount*rowCount matrix
* D, the function solves L*D*L'*x=b where `x' and `b' are rowCount*1. * D, the function solves L*D*L'*x=b where `x' and `b' are rowCount*1.
* The leading dimension of @a L is @a rowSkip. The resulting vector `x' overwrites @a b. * The leading dimension of @a L is @a rowSkip. The resulting vector `x' overwrites @a b.
* *
* The @a resources must have had been allocated from a ResourceRequirements object * The @a resources must have had been allocated from a ResourceRequirements object
* estimated in @c dEstimateCooperativelySolveLDLTResourceRequirements. * estimated in @c dEstimateCooperativelySolveLDLTResourceRequirements.
* *
* The operation is performed cooperatively by up to @a allowedThreadCount threads * The operation is performed cooperatively by up to @a allowedThreadCount threads
* from thread pool available in @a resources. The threading must must not be simultaneously * from thread pool available in @a resources. The threading must must not be simultaneously
* used (via other @c dResourceContainerID instances) in other calls that employ its features. * used (via other @c dResourceContainerID instances) in other calls that employ its features.
* *
* @param resources The resources allocated for the function * @param resources The resources allocated for the function
* @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters) * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
* @param L The `L' matrix * @param L The `L' matrix
* @param d The `d' vector * @param d The `d' vector
* @param b The `b' vector; also the result is stored here * @param b The `b' vector; also the result is stored here
* @param rowCount The row count in @a L, @a d and @a b * @param rowCount The row count in @a L, @a d and @a b
* @param rowskip The actual number of elements to be added to skip to next row in @a L * @param rowskip The actual number of elements to be added to skip to next row in @a L
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dEstimateCooperativelySolveLDLTResourceRequirements * @see dEstimateCooperativelySolveLDLTResourceRequirements
* @see dResourceContainerAcquire * @see dResourceContainerAcquire
* @see dCooperativelyFactorLDLT * @see dCooperativelyFactorLDLT
*/ */
ODE_API void dCooperativelySolveLDLT(dResourceContainerID resources, unsigned allowedThreadCount, ODE_API void dCooperativelySolveLDLT(dResourceContainerID resources, unsigned allowedThreadCount,
const dReal *L, const dReal *d, dReal *b, unsigned rowCount, unsigned rowSkip); const dReal *L, const dReal *d, dReal *b, unsigned rowCount, unsigned rowSkip);
/** /**
* @brief Estimates resource requirements for a @c dCooperativelySolveL1Straight call * @brief Estimates resource requirements for a @c dCooperativelySolveL1Straight call
* *
* The function updates the contents of @a requirements to also suffice for calling * The function updates the contents of @a requirements to also suffice for calling
* @c dCooperativelySolveL1Straight with the given parameters. * @c dCooperativelySolveL1Straight with the given parameters.
* *
* Note: The requirements that could have already been in the @a requirements parameter * Note: The requirements that could have already been in the @a requirements parameter
* are never decreased. * are never decreased.
* *
* @param requirements The ResourceRequirements object to update * @param requirements The ResourceRequirements object to update
* @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
* @param maximalRowCount Maximal value of rowCount parameter that is going to be used * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dCooperativelySolveL1Straight * @see dCooperativelySolveL1Straight
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
*/ */
ODE_API void dEstimateCooperativelySolveL1StraightResourceRequirements(dResourceRequirementsID requirements, ODE_API void dEstimateCooperativelySolveL1StraightResourceRequirements(dResourceRequirementsID requirements,
unsigned maximalAllowedThreadCount, unsigned maximalRowCount); unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
/** /**
* @brief Cooperatively solves L*x=b * @brief Cooperatively solves L*x=b
* *
* The function solves L*x=b, where `L' is rowCount*rowCount lower triangular with ones on the diagonal, * The function solves L*x=b, where `L' is rowCount*rowCount lower triangular with ones on the diagonal,
* and `x', `b' are rowCount*1. The leading dimension of @a L is @a rowSkip. * and `x', `b' are rowCount*1. The leading dimension of @a L is @a rowSkip.
* @a b is overwritten with `x'. * @a b is overwritten with `x'.
* *
* The @a resources must have had been allocated from a ResourceRequirements object * The @a resources must have had been allocated from a ResourceRequirements object
* estimated in @c dEstimateCooperativelySolveL1StraightResourceRequirements. * estimated in @c dEstimateCooperativelySolveL1StraightResourceRequirements.
* *
* The operation is performed cooperatively by up to @a allowedThreadCount threads * The operation is performed cooperatively by up to @a allowedThreadCount threads
* from thread pool available in @a resources. The threading must must not be simultaneously * from thread pool available in @a resources. The threading must must not be simultaneously
* used (via other @c dResourceContainerID instances) in other calls that employ its features. * used (via other @c dResourceContainerID instances) in other calls that employ its features.
* *
* @param resources The resources allocated for the function * @param resources The resources allocated for the function
* @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters) * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
* @param L The `L' matrix * @param L The `L' matrix
* @param b The `b' vector; also the result is stored here * @param b The `b' vector; also the result is stored here
* @param rowCount The row count in @a L and @a b * @param rowCount The row count in @a L and @a b
* @param rowskip The actual number of elements to be added to skip to next row in @a L * @param rowskip The actual number of elements to be added to skip to next row in @a L
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dEstimateCooperativelySolveL1StraightResourceRequirements * @see dEstimateCooperativelySolveL1StraightResourceRequirements
* @see dResourceContainerAcquire * @see dResourceContainerAcquire
* @see dCooperativelyFactorLDLT * @see dCooperativelyFactorLDLT
*/ */
ODE_API void dCooperativelySolveL1Straight(dResourceContainerID resources, unsigned allowedThreadCount, ODE_API void dCooperativelySolveL1Straight(dResourceContainerID resources, unsigned allowedThreadCount,
const dReal *L, dReal *b, unsigned rowCount, unsigned rowSkip); const dReal *L, dReal *b, unsigned rowCount, unsigned rowSkip);
/** /**
* @brief Estimates resource requirements for a @c dCooperativelySolveL1Transposed call * @brief Estimates resource requirements for a @c dCooperativelySolveL1Transposed call
* *
* The function updates the contents of @a requirements to also suffice for calling * The function updates the contents of @a requirements to also suffice for calling
* @c dCooperativelySolveL1Transposed with the given parameters. * @c dCooperativelySolveL1Transposed with the given parameters.
* *
* Note: The requirements that could have already been in the @a requirements parameter * Note: The requirements that could have already been in the @a requirements parameter
* are never decreased. * are never decreased.
* *
* @param requirements The ResourceRequirements object to update * @param requirements The ResourceRequirements object to update
* @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
* @param maximalRowCount Maximal value of rowCount parameter that is going to be used * @param maximalRowCount Maximal value of rowCount parameter that is going to be used
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dCooperativelySolveL1Transposed * @see dCooperativelySolveL1Transposed
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
*/ */
ODE_API void dEstimateCooperativelySolveL1TransposedResourceRequirements(dResourceRequirementsID requirements, ODE_API void dEstimateCooperativelySolveL1TransposedResourceRequirements(dResourceRequirementsID requirements,
unsigned maximalAllowedThreadCount, unsigned maximalRowCount); unsigned maximalAllowedThreadCount, unsigned maximalRowCount);
/** /**
* @brief Cooperatively solves L'*x=b * @brief Cooperatively solves L'*x=b
* *
* The function solves L'*x=b, where `L' is rowCount*rowCount lower triangular with ones on the diagonal, * The function solves L'*x=b, where `L' is rowCount*rowCount lower triangular with ones on the diagonal,
* and `x', b are rowCount*1. The leading dimension of @a L is @a rowSkip. * and `x', b are rowCount*1. The leading dimension of @a L is @a rowSkip.
* @a b is overwritten with `x'. * @a b is overwritten with `x'.
* *
* The @a resources must have had been allocated from a ResourceRequirements object * The @a resources must have had been allocated from a ResourceRequirements object
* estimated in @c dEstimateCooperativelySolveL1TransposedResourceRequirements. * estimated in @c dEstimateCooperativelySolveL1TransposedResourceRequirements.
* *
* The operation is performed cooperatively by up to @a allowedThreadCount threads * The operation is performed cooperatively by up to @a allowedThreadCount threads
* from thread pool available in @a resources. The threading must must not be simultaneously * from thread pool available in @a resources. The threading must must not be simultaneously
* used (via other @c dResourceContainerID instances) in other calls that employ its features. * used (via other @c dResourceContainerID instances) in other calls that employ its features.
* *
* @param resources The resources allocated for the function * @param resources The resources allocated for the function
* @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters) * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
* @param L The `L' matrix * @param L The `L' matrix
* @param b The `b' vector; also the result is stored here * @param b The `b' vector; also the result is stored here
* @param rowCount The row count in @a L and @a b * @param rowCount The row count in @a L and @a b
* @param rowskip The actual number of elements to be added to skip to next row in @a L * @param rowskip The actual number of elements to be added to skip to next row in @a L
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dEstimateCooperativelySolveL1TransposedResourceRequirements * @see dEstimateCooperativelySolveL1TransposedResourceRequirements
* @see dResourceContainerAcquire * @see dResourceContainerAcquire
* @see dCooperativelyFactorLDLT * @see dCooperativelyFactorLDLT
*/ */
ODE_API void dCooperativelySolveL1Transposed(dResourceContainerID resources, unsigned allowedThreadCount, ODE_API void dCooperativelySolveL1Transposed(dResourceContainerID resources, unsigned allowedThreadCount,
const dReal *L, dReal *b, unsigned rowCount, unsigned rowSkip); const dReal *L, dReal *b, unsigned rowCount, unsigned rowSkip);
/** /**
* @brief Estimates resource requirements for a @c dCooperativelyScaleVector call * @brief Estimates resource requirements for a @c dCooperativelyScaleVector call
* *
* The function updates the contents of @a requirements to also suffice for calling * The function updates the contents of @a requirements to also suffice for calling
* @c dCooperativelyScaleVector with the given parameters. * @c dCooperativelyScaleVector with the given parameters.
* *
* Note: The requirements that could have already been in the @a requirements parameter * Note: The requirements that could have already been in the @a requirements parameter
* are never decreased. * are never decreased.
* *
* @param requirements The ResourceRequirements object to update * @param requirements The ResourceRequirements object to update
* @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used * @param maximalAllowedThreadCount Maximal value of allowedThreadCount parameter that is going to be used
* @param maximalElementCount Maximal value of elementCount parameter that is going to be used * @param maximalElementCount Maximal value of elementCount parameter that is going to be used
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dCooperativelyScaleVector * @see dCooperativelyScaleVector
* @see dResourceRequirementsCreate * @see dResourceRequirementsCreate
*/ */
ODE_API void dEstimateCooperativelyScaleVectorResourceRequirements(dResourceRequirementsID requirements, ODE_API void dEstimateCooperativelyScaleVectorResourceRequirements(dResourceRequirementsID requirements,
unsigned maximalAllowedThreadCount, unsigned maximalElementCount); unsigned maximalAllowedThreadCount, unsigned maximalElementCount);
/** /**
* @brief Multiplies elements of one vector by corresponding element of another one * @brief Multiplies elements of one vector by corresponding element of another one
* *
* In matlab syntax, the operation performed is: dataVector(1:elementCount) = dataVector(1:elementCount) .* scaleVector(1:elementCount) * In matlab syntax, the operation performed is: dataVector(1:elementCount) = dataVector(1:elementCount) .* scaleVector(1:elementCount)
* *
* The @a resources must have had been allocated from a ResourceRequirements object * The @a resources must have had been allocated from a ResourceRequirements object
* estimated in @c dEstimateCooperativelyScaleVectorResourceRequirements. * estimated in @c dEstimateCooperativelyScaleVectorResourceRequirements.
* *
* The operation is performed cooperatively by up to @a allowedThreadCount threads * The operation is performed cooperatively by up to @a allowedThreadCount threads
* from thread pool available in @a resources. The threading must must not be simultaneously * from thread pool available in @a resources. The threading must must not be simultaneously
* used (via other @c dResourceContainerID instances) in other calls that employ its features. * used (via other @c dResourceContainerID instances) in other calls that employ its features.
* *
* @param resources The resources allocated for the function * @param resources The resources allocated for the function
* @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters) * @param allowedThreadCount Maximum thread count to use (the actual thread count could be less, depending on other parameters)
* @param dataVector The vector to be scaled in place * @param dataVector The vector to be scaled in place
* @param scaleVector The scale vector * @param scaleVector The scale vector
* @param elementCount The number of elements in @a dataVector and @a scaleVector * @param elementCount The number of elements in @a dataVector and @a scaleVector
* @ingroup matrix_coop * @ingroup matrix_coop
* @see dEstimateCooperativelyScaleVectorResourceRequirements * @see dEstimateCooperativelyScaleVectorResourceRequirements
* @see dResourceContainerAcquire * @see dResourceContainerAcquire
* @see dCooperativelyFactorLDLT * @see dCooperativelyFactorLDLT
*/ */
ODE_API void dCooperativelyScaleVector(dResourceContainerID resources, unsigned allowedThreadCount, ODE_API void dCooperativelyScaleVector(dResourceContainerID resources, unsigned allowedThreadCount,
dReal *dataVector, const dReal *scaleVector, unsigned elementCount); dReal *dataVector, const dReal *scaleVector, unsigned elementCount);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif
#endif // #ifndef _ODE_MATRIX_COOP_H_ #endif // #ifndef _ODE_MATRIX_COOP_H_

@ -1,59 +1,59 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* this comes from the `reuse' library. copy any changes back to the source */ /* this comes from the `reuse' library. copy any changes back to the source */
#ifndef _ODE_MEMORY_H_ #ifndef _ODE_MEMORY_H_
#define _ODE_MEMORY_H_ #define _ODE_MEMORY_H_
#include <ode/odeconfig.h> #include <ode/odeconfig.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* function types to allocate and free memory */ /* function types to allocate and free memory */
typedef void * dAllocFunction (dsizeint size); typedef void * dAllocFunction (dsizeint size);
typedef void * dReallocFunction (void *ptr, dsizeint oldsize, dsizeint newsize); typedef void * dReallocFunction (void *ptr, dsizeint oldsize, dsizeint newsize);
typedef void dFreeFunction (void *ptr, dsizeint size); typedef void dFreeFunction (void *ptr, dsizeint size);
/* set new memory management functions. if fn is 0, the default handlers are /* set new memory management functions. if fn is 0, the default handlers are
* used. */ * used. */
ODE_API void dSetAllocHandler (dAllocFunction *fn); ODE_API void dSetAllocHandler (dAllocFunction *fn);
ODE_API void dSetReallocHandler (dReallocFunction *fn); ODE_API void dSetReallocHandler (dReallocFunction *fn);
ODE_API void dSetFreeHandler (dFreeFunction *fn); ODE_API void dSetFreeHandler (dFreeFunction *fn);
/* get current memory management functions */ /* get current memory management functions */
ODE_API dAllocFunction *dGetAllocHandler (void); ODE_API dAllocFunction *dGetAllocHandler (void);
ODE_API dReallocFunction *dGetReallocHandler (void); ODE_API dReallocFunction *dGetReallocHandler (void);
ODE_API dFreeFunction *dGetFreeHandler (void); ODE_API dFreeFunction *dGetFreeHandler (void);
/* allocate and free memory. */ /* allocate and free memory. */
ODE_API void * dAlloc (dsizeint size); ODE_API void * dAlloc (dsizeint size);
ODE_API void * dRealloc (void *ptr, dsizeint oldsize, dsizeint newsize); ODE_API void * dRealloc (void *ptr, dsizeint oldsize, dsizeint newsize);
ODE_API void dFree (void *ptr, dsizeint size); ODE_API void dFree (void *ptr, dsizeint size);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,86 +1,86 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* miscellaneous math functions. these are mostly useful for testing */ /* miscellaneous math functions. these are mostly useful for testing */
#ifndef _ODE_MISC_H_ #ifndef _ODE_MISC_H_
#define _ODE_MISC_H_ #define _ODE_MISC_H_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* return 1 if the random number generator is working. */ /* return 1 if the random number generator is working. */
ODE_API int dTestRand(void); ODE_API int dTestRand(void);
/* return next 32 bit random number. this uses a not-very-random linear /* return next 32 bit random number. this uses a not-very-random linear
* congruential method. * congruential method.
*/ */
ODE_API unsigned long dRand(void); ODE_API unsigned long dRand(void);
/* get and set the current random number seed. */ /* get and set the current random number seed. */
ODE_API unsigned long dRandGetSeed(void); ODE_API unsigned long dRandGetSeed(void);
ODE_API void dRandSetSeed (unsigned long s); ODE_API void dRandSetSeed (unsigned long s);
/* return a random integer between 0..n-1. the distribution will get worse /* return a random integer between 0..n-1. the distribution will get worse
* as n approaches 2^32. * as n approaches 2^32.
*/ */
ODE_API int dRandInt (int n); ODE_API int dRandInt (int n);
/* return a random real number between 0..1 */ /* return a random real number between 0..1 */
ODE_API dReal dRandReal(void); ODE_API dReal dRandReal(void);
/* print out a matrix */ /* print out a matrix */
ODE_API void dPrintMatrix (const dReal *A, int n, int m, const char *fmt, FILE *f); ODE_API void dPrintMatrix (const dReal *A, int n, int m, const char *fmt, FILE *f);
/* make a random vector with entries between +/- range. A has n elements. */ /* make a random vector with entries between +/- range. A has n elements. */
ODE_API void dMakeRandomVector (dReal *A, int n, dReal range); ODE_API void dMakeRandomVector (dReal *A, int n, dReal range);
/* make a random matrix with entries between +/- range. A has size n*m. */ /* make a random matrix with entries between +/- range. A has size n*m. */
ODE_API void dMakeRandomMatrix (dReal *A, int n, int m, dReal range); ODE_API void dMakeRandomMatrix (dReal *A, int n, int m, dReal range);
/* clear the upper triangle of a square matrix */ /* clear the upper triangle of a square matrix */
ODE_API void dClearUpperTriangle (dReal *A, int n); ODE_API void dClearUpperTriangle (dReal *A, int n);
/* return the maximum element difference between the two n*m matrices */ /* return the maximum element difference between the two n*m matrices */
ODE_API dReal dMaxDifference (const dReal *A, const dReal *B, int n, int m); ODE_API dReal dMaxDifference (const dReal *A, const dReal *B, int n, int m);
/* return the maximum element difference between the lower triangle of two /* return the maximum element difference between the lower triangle of two
* n*n matrices */ * n*n matrices */
ODE_API dReal dMaxDifferenceLowerTriangle (const dReal *A, const dReal *B, int n); ODE_API dReal dMaxDifferenceLowerTriangle (const dReal *A, const dReal *B, int n);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
static inline void dPrintMatrix (const dReal *A, int n, int m, const char *fmt="%10.4f ") { dPrintMatrix(A, n, m, fmt, stdout); } static inline void dPrintMatrix (const dReal *A, int n, int m, const char *fmt="%10.4f ") { dPrintMatrix(A, n, m, fmt, stdout); }
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

@ -1,56 +1,56 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_ODE_H_ #ifndef _ODE_ODE_H_
#define _ODE_ODE_H_ #define _ODE_ODE_H_
/* include *everything* here */ /* include *everything* here */
#include <ode/odeconfig.h> #include <ode/odeconfig.h>
#include <ode/compatibility.h> #include <ode/compatibility.h>
#include <ode/common.h> #include <ode/common.h>
#include <ode/odeinit.h> #include <ode/odeinit.h>
#include <ode/contact.h> #include <ode/contact.h>
#include <ode/error.h> #include <ode/error.h>
#include <ode/memory.h> #include <ode/memory.h>
#include <ode/odemath.h> #include <ode/odemath.h>
#include <ode/matrix.h> #include <ode/matrix.h>
#include <ode/matrix_coop.h> #include <ode/matrix_coop.h>
#include <ode/timer.h> #include <ode/timer.h>
#include <ode/rotation.h> #include <ode/rotation.h>
#include <ode/mass.h> #include <ode/mass.h>
#include <ode/misc.h> #include <ode/misc.h>
#include <ode/objects.h> #include <ode/objects.h>
#include <ode/collision_space.h> #include <ode/collision_space.h>
#include <ode/collision.h> #include <ode/collision.h>
#include <ode/threading.h> #include <ode/threading.h>
#include <ode/threading_impl.h> #include <ode/threading_impl.h>
#include <ode/cooperative.h> #include <ode/cooperative.h>
#include <ode/export-dif.h> #include <ode/export-dif.h>
#include <ode/version.h> #include <ode/version.h>
#ifdef __cplusplus #ifdef __cplusplus
# include <ode/odecpp.h> # include <ode/odecpp.h>
# include <ode/odecpp_collision.h> # include <ode/odecpp_collision.h>
#endif #endif
#endif #endif

@ -1,215 +1,215 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_ODECONFIG_H_ #ifndef _ODE_ODECONFIG_H_
#define _ODE_ODECONFIG_H_ #define _ODE_ODECONFIG_H_
/* Pull in the standard headers */ /* Pull in the standard headers */
#include <stddef.h> #include <stddef.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <float.h> #include <float.h>
#include <ode/precision.h> #include <ode/precision.h>
#if defined(ODE_DLL) || defined(ODE_LIB) #if defined(ODE_DLL) || defined(ODE_LIB)
#define __ODE__ #define __ODE__
#endif #endif
/* Define a DLL export symbol for those platforms that need it */ /* Define a DLL export symbol for those platforms that need it */
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32)) #if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
#if defined(ODE_DLL) #if defined(ODE_DLL)
#define ODE_API __declspec(dllexport) #define ODE_API __declspec(dllexport)
#elif !defined(ODE_LIB) #elif !defined(ODE_LIB)
#define ODE_DLL_API __declspec(dllimport) #define ODE_DLL_API __declspec(dllimport)
#endif #endif
#endif #endif
#if !defined(ODE_API) #if !defined(ODE_API)
#define ODE_API #define ODE_API
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
# define ODE_API_DEPRECATED __declspec(deprecated) # define ODE_API_DEPRECATED __declspec(deprecated)
#elif defined (__GNUC__) && ( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) ) #elif defined (__GNUC__) && ( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) )
# define ODE_API_DEPRECATED __attribute__((__deprecated__)) # define ODE_API_DEPRECATED __attribute__((__deprecated__))
#else #else
# define ODE_API_DEPRECATED # define ODE_API_DEPRECATED
#endif #endif
#define ODE_PURE_INLINE static __inline #define ODE_PURE_INLINE static __inline
#define ODE_INLINE __inline #define ODE_INLINE __inline
#if defined(__cplusplus) #if defined(__cplusplus)
#define ODE_EXTERN_C extern "C" #define ODE_EXTERN_C extern "C"
#else #else
#define ODE_EXTERN_C #define ODE_EXTERN_C
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__)
#define ODE_NORETURN __attribute__((noreturn)) #define ODE_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#define ODE_NORETURN __declspec(noreturn) #define ODE_NORETURN __declspec(noreturn)
#else // #if !defined(_MSC_VER) #else // #if !defined(_MSC_VER)
#define ODE_NORETURN #define ODE_NORETURN
#endif // #if !defined(__GNUC__) #endif // #if !defined(__GNUC__)
/* Well-defined common data types...need to define for 64 bit systems */ /* Well-defined common data types...need to define for 64 bit systems */
#if defined(__aarch64__) #if defined(__aarch64__)
#include <stdint.h> #include <stdint.h>
typedef int64_t dint64; typedef int64_t dint64;
typedef uint64_t duint64; typedef uint64_t duint64;
typedef int32_t dint32; typedef int32_t dint32;
typedef uint32_t duint32; typedef uint32_t duint32;
typedef int16_t dint16; typedef int16_t dint16;
typedef uint16_t duint16; typedef uint16_t duint16;
typedef int8_t dint8; typedef int8_t dint8;
typedef uint8_t duint8; typedef uint8_t duint8;
typedef intptr_t dintptr; typedef intptr_t dintptr;
typedef uintptr_t duintptr; typedef uintptr_t duintptr;
typedef ptrdiff_t ddiffint; typedef ptrdiff_t ddiffint;
typedef size_t dsizeint; typedef size_t dsizeint;
#elif defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__) #elif defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)
#define X86_64_SYSTEM 1 #define X86_64_SYSTEM 1
#if defined(_MSC_VER) #if defined(_MSC_VER)
typedef __int64 dint64; typedef __int64 dint64;
typedef unsigned __int64 duint64; typedef unsigned __int64 duint64;
#else #else
#if defined(_LP64) #if defined(_LP64)
typedef long dint64; typedef long dint64;
typedef unsigned long duint64; typedef unsigned long duint64;
#else #else
typedef long long dint64; typedef long long dint64;
typedef unsigned long long duint64; typedef unsigned long long duint64;
#endif #endif
#endif #endif
typedef int dint32; typedef int dint32;
typedef unsigned int duint32; typedef unsigned int duint32;
typedef short dint16; typedef short dint16;
typedef unsigned short duint16; typedef unsigned short duint16;
typedef signed char dint8; typedef signed char dint8;
typedef unsigned char duint8; typedef unsigned char duint8;
typedef dint64 dintptr; typedef dint64 dintptr;
typedef duint64 duintptr; typedef duint64 duintptr;
typedef dint64 ddiffint; typedef dint64 ddiffint;
typedef duint64 dsizeint; typedef duint64 dsizeint;
#else #else
#if defined(_MSC_VER) #if defined(_MSC_VER)
typedef __int64 dint64; typedef __int64 dint64;
typedef unsigned __int64 duint64; typedef unsigned __int64 duint64;
#else #else
typedef long long dint64; typedef long long dint64;
typedef unsigned long long duint64; typedef unsigned long long duint64;
#endif #endif
typedef int dint32; typedef int dint32;
typedef unsigned int duint32; typedef unsigned int duint32;
typedef short dint16; typedef short dint16;
typedef unsigned short duint16; typedef unsigned short duint16;
typedef signed char dint8; typedef signed char dint8;
typedef unsigned char duint8; typedef unsigned char duint8;
typedef dint32 dintptr; typedef dint32 dintptr;
typedef duint32 duintptr; typedef duint32 duintptr;
typedef dint32 ddiffint; typedef dint32 ddiffint;
typedef duint32 dsizeint; typedef duint32 dsizeint;
#endif #endif
/* Define the dInfinity macro */ /* Define the dInfinity macro */
#ifdef INFINITY #ifdef INFINITY
#ifdef dSINGLE #ifdef dSINGLE
#define dInfinity ((float)INFINITY) #define dInfinity ((float)INFINITY)
#else #else
#define dInfinity ((double)INFINITY) #define dInfinity ((double)INFINITY)
#endif #endif
#elif defined(HUGE_VAL) #elif defined(HUGE_VAL)
#ifdef dSINGLE #ifdef dSINGLE
#ifdef HUGE_VALF #ifdef HUGE_VALF
#define dInfinity HUGE_VALF #define dInfinity HUGE_VALF
#else #else
#define dInfinity ((float)HUGE_VAL) #define dInfinity ((float)HUGE_VAL)
#endif #endif
#else #else
#define dInfinity HUGE_VAL #define dInfinity HUGE_VAL
#endif #endif
#else #else
#ifdef dSINGLE #ifdef dSINGLE
#define dInfinity ((float)(1.0/0.0)) #define dInfinity ((float)(1.0/0.0))
#else #else
#define dInfinity (1.0/0.0) #define dInfinity (1.0/0.0)
#endif #endif
#endif #endif
/* Define the dNaN macro */ /* Define the dNaN macro */
#if defined(NAN) #if defined(NAN)
#define dNaN NAN #define dNaN NAN
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; }) #define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; })
#elif defined(__cplusplus) #elif defined(__cplusplus)
union _dNaNUnion union _dNaNUnion
{ {
_dNaNUnion(): m_ui(0x7FC00000) {} _dNaNUnion(): m_ui(0x7FC00000) {}
duint32 m_ui; duint32 m_ui;
float m_f; float m_f;
}; };
#define dNaN (_dNaNUnion().m_f) #define dNaN (_dNaNUnion().m_f)
#else #else
#ifdef dSINGLE #ifdef dSINGLE
#define dNaN ((float)(dInfinity - dInfinity)) #define dNaN ((float)(dInfinity - dInfinity))
#else #else
#define dNaN (dInfinity - dInfinity) #define dNaN (dInfinity - dInfinity)
#endif #endif
#endif #endif
/* Visual C does not define these functions */ /* Visual C does not define these functions */
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define _ode_copysignf(x, y) ((float)_copysign(x, y)) #define _ode_copysignf(x, y) ((float)_copysign(x, y))
#define _ode_copysign(x, y) _copysign(x, y) #define _ode_copysign(x, y) _copysign(x, y)
#define _ode_nextafterf(x, y) _nextafterf(x, y) #define _ode_nextafterf(x, y) _nextafterf(x, y)
#define _ode_nextafter(x, y) _nextafter(x, y) #define _ode_nextafter(x, y) _nextafter(x, y)
#if !defined(_WIN64) && defined(dSINGLE) #if !defined(_WIN64) && defined(dSINGLE)
#define _ODE__NEXTAFTERF_REQUIRED #define _ODE__NEXTAFTERF_REQUIRED
ODE_EXTERN_C float _nextafterf(float x, float y); ODE_EXTERN_C float _nextafterf(float x, float y);
#endif #endif
#else #else
#define _ode_copysignf(x, y) copysignf(x, y) #define _ode_copysignf(x, y) copysignf(x, y)
#define _ode_copysign(x, y) copysign(x, y) #define _ode_copysign(x, y) copysign(x, y)
#define _ode_nextafterf(x, y) nextafterf(x, y) #define _ode_nextafterf(x, y) nextafterf(x, y)
#define _ode_nextafter(x, y) nextafter(x, y) #define _ode_nextafter(x, y) nextafter(x, y)
#endif #endif
#endif #endif

File diff suppressed because it is too large Load Diff

@ -1,467 +1,467 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* C++ interface for new collision API */ /* C++ interface for new collision API */
#ifndef _ODE_ODECPP_COLLISION_H_ #ifndef _ODE_ODECPP_COLLISION_H_
#define _ODE_ODECPP_COLLISION_H_ #define _ODE_ODECPP_COLLISION_H_
#ifdef __cplusplus #ifdef __cplusplus
//#include <ode/error.h> //#include <ode/error.h>
//namespace ode { //namespace ode {
class dGeom { class dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dGeom (dGeom &); dGeom (dGeom &);
void operator= (dGeom &); void operator= (dGeom &);
protected: protected:
dGeomID _id; dGeomID _id;
dGeom() dGeom()
{ _id = 0; } { _id = 0; }
public: public:
~dGeom() ~dGeom()
{ if (_id) dGeomDestroy (_id); } { if (_id) dGeomDestroy (_id); }
dGeomID id() const dGeomID id() const
{ return _id; } { return _id; }
operator dGeomID() const operator dGeomID() const
{ return _id; } { return _id; }
void destroy() { void destroy() {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = 0; _id = 0;
} }
int getClass() const int getClass() const
{ return dGeomGetClass (_id); } { return dGeomGetClass (_id); }
dSpaceID getSpace() const dSpaceID getSpace() const
{ return dGeomGetSpace (_id); } { return dGeomGetSpace (_id); }
void setData (void *data) void setData (void *data)
{ dGeomSetData (_id,data); } { dGeomSetData (_id,data); }
void *getData() const void *getData() const
{ return dGeomGetData (_id); } { return dGeomGetData (_id); }
void setBody (dBodyID b) void setBody (dBodyID b)
{ dGeomSetBody (_id,b); } { dGeomSetBody (_id,b); }
dBodyID getBody() const dBodyID getBody() const
{ return dGeomGetBody (_id); } { return dGeomGetBody (_id); }
void setPosition (dReal x, dReal y, dReal z) void setPosition (dReal x, dReal y, dReal z)
{ dGeomSetPosition (_id,x,y,z); } { dGeomSetPosition (_id,x,y,z); }
const dReal * getPosition() const const dReal * getPosition() const
{ return dGeomGetPosition (_id); } { return dGeomGetPosition (_id); }
void setRotation (const dMatrix3 R) void setRotation (const dMatrix3 R)
{ dGeomSetRotation (_id,R); } { dGeomSetRotation (_id,R); }
const dReal * getRotation() const const dReal * getRotation() const
{ return dGeomGetRotation (_id); } { return dGeomGetRotation (_id); }
void setQuaternion (const dQuaternion quat) void setQuaternion (const dQuaternion quat)
{ dGeomSetQuaternion (_id,quat); } { dGeomSetQuaternion (_id,quat); }
void getQuaternion (dQuaternion quat) const void getQuaternion (dQuaternion quat) const
{ dGeomGetQuaternion (_id,quat); } { dGeomGetQuaternion (_id,quat); }
void getAABB (dReal aabb[6]) const void getAABB (dReal aabb[6]) const
{ dGeomGetAABB (_id, aabb); } { dGeomGetAABB (_id, aabb); }
int isSpace() int isSpace()
{ return dGeomIsSpace (_id); } { return dGeomIsSpace (_id); }
void setCategoryBits (unsigned long bits) void setCategoryBits (unsigned long bits)
{ dGeomSetCategoryBits (_id, bits); } { dGeomSetCategoryBits (_id, bits); }
void setCollideBits (unsigned long bits) void setCollideBits (unsigned long bits)
{ dGeomSetCollideBits (_id, bits); } { dGeomSetCollideBits (_id, bits); }
unsigned long getCategoryBits() unsigned long getCategoryBits()
{ return dGeomGetCategoryBits (_id); } { return dGeomGetCategoryBits (_id); }
unsigned long getCollideBits() unsigned long getCollideBits()
{ return dGeomGetCollideBits (_id); } { return dGeomGetCollideBits (_id); }
void enable() void enable()
{ dGeomEnable (_id); } { dGeomEnable (_id); }
void disable() void disable()
{ dGeomDisable (_id); } { dGeomDisable (_id); }
int isEnabled() int isEnabled()
{ return dGeomIsEnabled (_id); } { return dGeomIsEnabled (_id); }
void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetRelPointPos (_id, px, py, pz, result); } { dGeomGetRelPointPos (_id, px, py, pz, result); }
void getRelPointPos (const dVector3 p, dVector3 result) const void getRelPointPos (const dVector3 p, dVector3 result) const
{ getRelPointPos (p[0], p[1], p[2], result); } { getRelPointPos (p[0], p[1], p[2], result); }
void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetPosRelPoint (_id, px, py, pz, result); } { dGeomGetPosRelPoint (_id, px, py, pz, result); }
void getPosRelPoint (const dVector3 p, dVector3 result) const void getPosRelPoint (const dVector3 p, dVector3 result) const
{ getPosRelPoint (p[0], p[1], p[2], result); } { getPosRelPoint (p[0], p[1], p[2], result); }
void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorToWorld (_id, px, py, pz, result); } { dGeomVectorToWorld (_id, px, py, pz, result); }
void vectorToWorld (const dVector3 p, dVector3 result) const void vectorToWorld (const dVector3 p, dVector3 result) const
{ vectorToWorld (p[0], p[1], p[2], result); } { vectorToWorld (p[0], p[1], p[2], result); }
void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorFromWorld (_id, px, py, pz, result); } { dGeomVectorFromWorld (_id, px, py, pz, result); }
void vectorFromWorld (const dVector3 p, dVector3 result) const void vectorFromWorld (const dVector3 p, dVector3 result) const
{ vectorFromWorld (p[0], p[1], p[2], result); } { vectorFromWorld (p[0], p[1], p[2], result); }
void collide2 (dGeomID g, void *data, dNearCallback *callback) void collide2 (dGeomID g, void *data, dNearCallback *callback)
{ dSpaceCollide2 (_id,g,data,callback); } { dSpaceCollide2 (_id,g,data,callback); }
}; };
class dSpace : public dGeom { class dSpace : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dSpace (dSpace &); dSpace (dSpace &);
void operator= (dSpace &); void operator= (dSpace &);
protected: protected:
// the default constructor is protected so that you // the default constructor is protected so that you
// can't instance this class. you must instance one // can't instance this class. you must instance one
// of its subclasses instead. // of its subclasses instead.
dSpace () { _id = 0; } dSpace () { _id = 0; }
public: public:
dSpaceID id() const dSpaceID id() const
{ return (dSpaceID) _id; } { return (dSpaceID) _id; }
operator dSpaceID() const operator dSpaceID() const
{ return (dSpaceID) _id; } { return (dSpaceID) _id; }
void setCleanup (int mode) void setCleanup (int mode)
{ dSpaceSetCleanup (id(), mode); } { dSpaceSetCleanup (id(), mode); }
int getCleanup() int getCleanup()
{ return dSpaceGetCleanup (id()); } { return dSpaceGetCleanup (id()); }
void add (dGeomID x) void add (dGeomID x)
{ dSpaceAdd (id(), x); } { dSpaceAdd (id(), x); }
void remove (dGeomID x) void remove (dGeomID x)
{ dSpaceRemove (id(), x); } { dSpaceRemove (id(), x); }
int query (dGeomID x) int query (dGeomID x)
{ return dSpaceQuery (id(),x); } { return dSpaceQuery (id(),x); }
int getNumGeoms() int getNumGeoms()
{ return dSpaceGetNumGeoms (id()); } { return dSpaceGetNumGeoms (id()); }
dGeomID getGeom (int i) dGeomID getGeom (int i)
{ return dSpaceGetGeom (id(),i); } { return dSpaceGetGeom (id(),i); }
void collide (void *data, dNearCallback *callback) void collide (void *data, dNearCallback *callback)
{ dSpaceCollide (id(),data,callback); } { dSpaceCollide (id(),data,callback); }
}; };
class dSimpleSpace : public dSpace { class dSimpleSpace : public dSpace {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dSimpleSpace (dSimpleSpace &); dSimpleSpace (dSimpleSpace &);
void operator= (dSimpleSpace &); void operator= (dSimpleSpace &);
public: public:
dSimpleSpace () dSimpleSpace ()
{ _id = (dGeomID) dSimpleSpaceCreate (0); } { _id = (dGeomID) dSimpleSpaceCreate (0); }
dSimpleSpace (dSpace &space) dSimpleSpace (dSpace &space)
{ _id = (dGeomID) dSimpleSpaceCreate (space.id()); } { _id = (dGeomID) dSimpleSpaceCreate (space.id()); }
dSimpleSpace (dSpaceID space) dSimpleSpace (dSpaceID space)
{ _id = (dGeomID) dSimpleSpaceCreate (space); } { _id = (dGeomID) dSimpleSpaceCreate (space); }
}; };
class dHashSpace : public dSpace { class dHashSpace : public dSpace {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dHashSpace (dHashSpace &); dHashSpace (dHashSpace &);
void operator= (dHashSpace &); void operator= (dHashSpace &);
public: public:
dHashSpace () dHashSpace ()
{ _id = (dGeomID) dHashSpaceCreate (0); } { _id = (dGeomID) dHashSpaceCreate (0); }
dHashSpace (dSpace &space) dHashSpace (dSpace &space)
{ _id = (dGeomID) dHashSpaceCreate (space.id()); } { _id = (dGeomID) dHashSpaceCreate (space.id()); }
dHashSpace (dSpaceID space) dHashSpace (dSpaceID space)
{ _id = (dGeomID) dHashSpaceCreate (space); } { _id = (dGeomID) dHashSpaceCreate (space); }
void setLevels (int minlevel, int maxlevel) void setLevels (int minlevel, int maxlevel)
{ dHashSpaceSetLevels (id(),minlevel,maxlevel); } { dHashSpaceSetLevels (id(),minlevel,maxlevel); }
}; };
class dQuadTreeSpace : public dSpace { class dQuadTreeSpace : public dSpace {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dQuadTreeSpace (dQuadTreeSpace &); dQuadTreeSpace (dQuadTreeSpace &);
void operator= (dQuadTreeSpace &); void operator= (dQuadTreeSpace &);
public: public:
dQuadTreeSpace (const dVector3 center, const dVector3 extents, int depth) dQuadTreeSpace (const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (0,center,extents,depth); } { _id = (dGeomID) dQuadTreeSpaceCreate (0,center,extents,depth); }
dQuadTreeSpace (dSpace &space, const dVector3 center, const dVector3 extents, int depth) dQuadTreeSpace (dSpace &space, const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (space.id(),center,extents,depth); } { _id = (dGeomID) dQuadTreeSpaceCreate (space.id(),center,extents,depth); }
dQuadTreeSpace (dSpaceID space, const dVector3 center, const dVector3 extents, int depth) dQuadTreeSpace (dSpaceID space, const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); } { _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
}; };
class dSphere : public dGeom { class dSphere : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dSphere (dSphere &); dSphere (dSphere &);
void operator= (dSphere &); void operator= (dSphere &);
public: public:
dSphere () { } dSphere () { }
dSphere (dReal radius) dSphere (dReal radius)
{ _id = dCreateSphere (0, radius); } { _id = dCreateSphere (0, radius); }
dSphere (dSpace &space, dReal radius) dSphere (dSpace &space, dReal radius)
{ _id = dCreateSphere (space.id(), radius); } { _id = dCreateSphere (space.id(), radius); }
dSphere (dSpaceID space, dReal radius) dSphere (dSpaceID space, dReal radius)
{ _id = dCreateSphere (space, radius); } { _id = dCreateSphere (space, radius); }
void create (dSpaceID space, dReal radius) { void create (dSpaceID space, dReal radius) {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = dCreateSphere (space, radius); _id = dCreateSphere (space, radius);
} }
void setRadius (dReal radius) void setRadius (dReal radius)
{ dGeomSphereSetRadius (_id, radius); } { dGeomSphereSetRadius (_id, radius); }
dReal getRadius() const dReal getRadius() const
{ return dGeomSphereGetRadius (_id); } { return dGeomSphereGetRadius (_id); }
}; };
class dBox : public dGeom { class dBox : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dBox (dBox &); dBox (dBox &);
void operator= (dBox &); void operator= (dBox &);
public: public:
dBox () { } dBox () { }
dBox (dReal lx, dReal ly, dReal lz) dBox (dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (0,lx,ly,lz); } { _id = dCreateBox (0,lx,ly,lz); }
dBox (dSpace &space, dReal lx, dReal ly, dReal lz) dBox (dSpace &space, dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (space,lx,ly,lz); } { _id = dCreateBox (space,lx,ly,lz); }
dBox (dSpaceID space, dReal lx, dReal ly, dReal lz) dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (space,lx,ly,lz); } { _id = dCreateBox (space,lx,ly,lz); }
void create (dSpaceID space, dReal lx, dReal ly, dReal lz) { void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = dCreateBox (space,lx,ly,lz); _id = dCreateBox (space,lx,ly,lz);
} }
void setLengths (dReal lx, dReal ly, dReal lz) void setLengths (dReal lx, dReal ly, dReal lz)
{ dGeomBoxSetLengths (_id, lx, ly, lz); } { dGeomBoxSetLengths (_id, lx, ly, lz); }
void getLengths (dVector3 result) const void getLengths (dVector3 result) const
{ dGeomBoxGetLengths (_id,result); } { dGeomBoxGetLengths (_id,result); }
}; };
class dPlane : public dGeom { class dPlane : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dPlane (dPlane &); dPlane (dPlane &);
void operator= (dPlane &); void operator= (dPlane &);
public: public:
dPlane() { } dPlane() { }
dPlane (dReal a, dReal b, dReal c, dReal d) dPlane (dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (0,a,b,c,d); } { _id = dCreatePlane (0,a,b,c,d); }
dPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d) dPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (space.id(),a,b,c,d); } { _id = dCreatePlane (space.id(),a,b,c,d); }
dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d) dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (space,a,b,c,d); } { _id = dCreatePlane (space,a,b,c,d); }
void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) { void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = dCreatePlane (space,a,b,c,d); _id = dCreatePlane (space,a,b,c,d);
} }
void setParams (dReal a, dReal b, dReal c, dReal d) void setParams (dReal a, dReal b, dReal c, dReal d)
{ dGeomPlaneSetParams (_id, a, b, c, d); } { dGeomPlaneSetParams (_id, a, b, c, d); }
void getParams (dVector4 result) const void getParams (dVector4 result) const
{ dGeomPlaneGetParams (_id,result); } { dGeomPlaneGetParams (_id,result); }
}; };
class dCapsule : public dGeom { class dCapsule : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dCapsule (dCapsule &); dCapsule (dCapsule &);
void operator= (dCapsule &); void operator= (dCapsule &);
public: public:
dCapsule() { } dCapsule() { }
dCapsule (dReal radius, dReal length) dCapsule (dReal radius, dReal length)
{ _id = dCreateCapsule (0,radius,length); } { _id = dCreateCapsule (0,radius,length); }
dCapsule (dSpace &space, dReal radius, dReal length) dCapsule (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCapsule (space.id(),radius,length); } { _id = dCreateCapsule (space.id(),radius,length); }
dCapsule (dSpaceID space, dReal radius, dReal length) dCapsule (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCapsule (space,radius,length); } { _id = dCreateCapsule (space,radius,length); }
void create (dSpaceID space, dReal radius, dReal length) { void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = dCreateCapsule (space,radius,length); _id = dCreateCapsule (space,radius,length);
} }
void setParams (dReal radius, dReal length) void setParams (dReal radius, dReal length)
{ dGeomCapsuleSetParams (_id, radius, length); } { dGeomCapsuleSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const void getParams (dReal *radius, dReal *length) const
{ dGeomCapsuleGetParams (_id,radius,length); } { dGeomCapsuleGetParams (_id,radius,length); }
}; };
class dCylinder : public dGeom { class dCylinder : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dCylinder (dCylinder &); dCylinder (dCylinder &);
void operator= (dCylinder &); void operator= (dCylinder &);
public: public:
dCylinder() { } dCylinder() { }
dCylinder (dReal radius, dReal length) dCylinder (dReal radius, dReal length)
{ _id = dCreateCylinder (0,radius,length); } { _id = dCreateCylinder (0,radius,length); }
dCylinder (dSpace &space, dReal radius, dReal length) dCylinder (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCylinder (space.id(),radius,length); } { _id = dCreateCylinder (space.id(),radius,length); }
dCylinder (dSpaceID space, dReal radius, dReal length) dCylinder (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCylinder (space,radius,length); } { _id = dCreateCylinder (space,radius,length); }
void create (dSpaceID space, dReal radius, dReal length) { void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = dCreateCylinder (space,radius,length); _id = dCreateCylinder (space,radius,length);
} }
void setParams (dReal radius, dReal length) void setParams (dReal radius, dReal length)
{ dGeomCylinderSetParams (_id, radius, length); } { dGeomCylinderSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const void getParams (dReal *radius, dReal *length) const
{ dGeomCylinderGetParams (_id,radius,length); } { dGeomCylinderGetParams (_id,radius,length); }
}; };
class dRay : public dGeom { class dRay : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dRay (dRay &); dRay (dRay &);
void operator= (dRay &); void operator= (dRay &);
public: public:
dRay() { } dRay() { }
dRay (dReal length) dRay (dReal length)
{ _id = dCreateRay (0,length); } { _id = dCreateRay (0,length); }
dRay (dSpace &space, dReal length) dRay (dSpace &space, dReal length)
{ _id = dCreateRay (space.id(),length); } { _id = dCreateRay (space.id(),length); }
dRay (dSpaceID space, dReal length) dRay (dSpaceID space, dReal length)
{ _id = dCreateRay (space,length); } { _id = dCreateRay (space,length); }
void create (dSpaceID space, dReal length) { void create (dSpaceID space, dReal length) {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = dCreateRay (space,length); _id = dCreateRay (space,length);
} }
void setLength (dReal length) void setLength (dReal length)
{ dGeomRaySetLength (_id, length); } { dGeomRaySetLength (_id, length); }
dReal getLength() dReal getLength()
{ return dGeomRayGetLength (_id); } { return dGeomRayGetLength (_id); }
void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz) void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
{ dGeomRaySet (_id, px, py, pz, dx, dy, dz); } { dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
void get (dVector3 start, dVector3 dir) void get (dVector3 start, dVector3 dir)
{ dGeomRayGet (_id, start, dir); } { dGeomRayGet (_id, start, dir); }
#ifdef WIN32 #ifdef WIN32
#pragma warning( push ) #pragma warning( push )
#pragma warning( disable : 4996 ) #pragma warning( disable : 4996 )
#else #else
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif #endif
ODE_API_DEPRECATED ODE_API_DEPRECATED
void setParams (int firstContact, int backfaceCull) void setParams (int firstContact, int backfaceCull)
{ dGeomRaySetParams (_id, firstContact, backfaceCull); } { dGeomRaySetParams (_id, firstContact, backfaceCull); }
ODE_API_DEPRECATED ODE_API_DEPRECATED
void getParams (int *firstContact, int *backfaceCull) void getParams (int *firstContact, int *backfaceCull)
{ dGeomRayGetParams (_id, firstContact, backfaceCull); } { dGeomRayGetParams (_id, firstContact, backfaceCull); }
#ifdef WIN32 #ifdef WIN32
#pragma warning( pop ) #pragma warning( pop )
#else #else
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
void setBackfaceCull (int backfaceCull) void setBackfaceCull (int backfaceCull)
{ dGeomRaySetBackfaceCull (_id, backfaceCull); } { dGeomRaySetBackfaceCull (_id, backfaceCull); }
int getBackfaceCull() int getBackfaceCull()
{ return dGeomRayGetBackfaceCull (_id); } { return dGeomRayGetBackfaceCull (_id); }
void setFirstContact (int firstContact) void setFirstContact (int firstContact)
{ dGeomRaySetFirstContact (_id, firstContact); } { dGeomRaySetFirstContact (_id, firstContact); }
int getFirstContact() int getFirstContact()
{ return dGeomRayGetFirstContact (_id); } { return dGeomRayGetFirstContact (_id); }
void setClosestHit (int closestHit) void setClosestHit (int closestHit)
{ dGeomRaySetClosestHit (_id, closestHit); } { dGeomRaySetClosestHit (_id, closestHit); }
int getClosestHit() int getClosestHit()
{ return dGeomRayGetClosestHit (_id); } { return dGeomRayGetClosestHit (_id); }
}; };
#ifdef WIN32 #ifdef WIN32
#pragma warning( push ) #pragma warning( push )
#pragma warning( disable : 4996 ) #pragma warning( disable : 4996 )
#else #else
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif #endif
class ODE_API_DEPRECATED dGeomTransform : public dGeom { class ODE_API_DEPRECATED dGeomTransform : public dGeom {
// intentionally undefined, don't use these // intentionally undefined, don't use these
dGeomTransform (dGeomTransform &); dGeomTransform (dGeomTransform &);
void operator= (dGeomTransform &); void operator= (dGeomTransform &);
public: public:
dGeomTransform() { } dGeomTransform() { }
dGeomTransform (dSpace &space) dGeomTransform (dSpace &space)
{ _id = dCreateGeomTransform (space.id()); } { _id = dCreateGeomTransform (space.id()); }
dGeomTransform (dSpaceID space) dGeomTransform (dSpaceID space)
{ _id = dCreateGeomTransform (space); } { _id = dCreateGeomTransform (space); }
void create (dSpaceID space=0) { void create (dSpaceID space=0) {
if (_id) dGeomDestroy (_id); if (_id) dGeomDestroy (_id);
_id = dCreateGeomTransform (space); _id = dCreateGeomTransform (space);
} }
void setGeom (dGeomID geom) void setGeom (dGeomID geom)
{ dGeomTransformSetGeom (_id, geom); } { dGeomTransformSetGeom (_id, geom); }
dGeomID getGeom() const dGeomID getGeom() const
{ return dGeomTransformGetGeom (_id); } { return dGeomTransformGetGeom (_id); }
void setCleanup (int mode) void setCleanup (int mode)
{ dGeomTransformSetCleanup (_id,mode); } { dGeomTransformSetCleanup (_id,mode); }
int getCleanup () int getCleanup ()
{ return dGeomTransformGetCleanup (_id); } { return dGeomTransformGetCleanup (_id); }
void setInfo (int mode) void setInfo (int mode)
{ dGeomTransformSetInfo (_id,mode); } { dGeomTransformSetInfo (_id,mode); }
int getInfo() int getInfo()
{ return dGeomTransformGetInfo (_id); } { return dGeomTransformGetInfo (_id); }
}; };
#ifdef WIN32 #ifdef WIN32
#pragma warning( pop ) #pragma warning( pop )
#else #else
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
//} //}
#endif #endif
#endif #endif

@ -1,236 +1,236 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* Library initialization/finalization functions. */ /* Library initialization/finalization functions. */
#ifndef _ODE_ODEINIT_H_ #ifndef _ODE_ODEINIT_H_
#define _ODE_ODEINIT_H_ #define _ODE_ODEINIT_H_
#include <ode/common.h> #include <ode/common.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* ************************************************************************ */ /* ************************************************************************ */
/* Library initialization */ /* Library initialization */
/** /**
* @defgroup init Library Initialization * @defgroup init Library Initialization
* *
* Library initialization functions prepare ODE internal data structures for use * Library initialization functions prepare ODE internal data structures for use
* and release allocated resources after ODE is not needed any more. * and release allocated resources after ODE is not needed any more.
*/ */
/** /**
* @brief Library initialization flags. * @brief Library initialization flags.
* *
* These flags define ODE library initialization options. * These flags define ODE library initialization options.
* *
* @c dInitFlagManualThreadCleanup indicates that resources allocated in TLS for threads * @c dInitFlagManualThreadCleanup indicates that resources allocated in TLS for threads
* using ODE are to be cleared by library client with explicit call to @c dCleanupODEAllDataForThread. * using ODE are to be cleared by library client with explicit call to @c dCleanupODEAllDataForThread.
* If this flag is not specified the automatic resource tracking algorithm is used. * If this flag is not specified the automatic resource tracking algorithm is used.
* *
* With automatic resource tracking, On Windows, memory allocated for a thread may * With automatic resource tracking, On Windows, memory allocated for a thread may
* remain not freed for some time after the thread exits. The resources may be * remain not freed for some time after the thread exits. The resources may be
* released when one of other threads calls @c dAllocateODEDataForThread. Ultimately, * released when one of other threads calls @c dAllocateODEDataForThread. Ultimately,
* the resources are released when library is closed with @c dCloseODE. On other * the resources are released when library is closed with @c dCloseODE. On other
* operating systems resources are always released by the thread itself on its exit * operating systems resources are always released by the thread itself on its exit
* or on library closure with @c dCloseODE. * or on library closure with @c dCloseODE.
* *
* With manual thread data cleanup mode every collision space object must be * With manual thread data cleanup mode every collision space object must be
* explicitly switched to manual cleanup mode with @c dSpaceSetManualCleanup * explicitly switched to manual cleanup mode with @c dSpaceSetManualCleanup
* after creation. See description of the function for more details. * after creation. See description of the function for more details.
* *
* If @c dInitFlagManualThreadCleanup was not specified during initialization, * If @c dInitFlagManualThreadCleanup was not specified during initialization,
* calls to @c dCleanupODEAllDataForThread are not allowed. * calls to @c dCleanupODEAllDataForThread are not allowed.
* *
* @see dInitODE2 * @see dInitODE2
* @see dAllocateODEDataForThread * @see dAllocateODEDataForThread
* @see dSpaceSetManualCleanup * @see dSpaceSetManualCleanup
* @see dCloseODE * @see dCloseODE
* @ingroup init * @ingroup init
*/ */
enum dInitODEFlags { enum dInitODEFlags {
dInitFlagManualThreadCleanup = 0x00000001 /*@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call*/ dInitFlagManualThreadCleanup = 0x00000001 /*@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call*/
}; };
/** /**
* @brief Initializes ODE library. * @brief Initializes ODE library.
* *
* @c dInitODE is obsolete. @c dInitODE2 is to be used for library initialization. * @c dInitODE is obsolete. @c dInitODE2 is to be used for library initialization.
* *
* A call to @c dInitODE is equal to the following initialization sequence * A call to @c dInitODE is equal to the following initialization sequence
* @code * @code
* dInitODE2(0); * dInitODE2(0);
* dAllocateODEDataForThread(dAllocateMaskAll); * dAllocateODEDataForThread(dAllocateMaskAll);
* @endcode * @endcode
* *
* @see dInitODE2 * @see dInitODE2
* @see dAllocateODEDataForThread * @see dAllocateODEDataForThread
* @ingroup init * @ingroup init
*/ */
ODE_API void dInitODE(void); ODE_API void dInitODE(void);
/** /**
* @brief Initializes ODE library. * @brief Initializes ODE library.
* @param uiInitFlags Initialization options bitmask * @param uiInitFlags Initialization options bitmask
* @return A nonzero if initialization succeeded and zero otherwise. * @return A nonzero if initialization succeeded and zero otherwise.
* *
* This function must be called to initialize ODE library before first use. If * This function must be called to initialize ODE library before first use. If
* initialization succeeds the function may not be called again until library is * initialization succeeds the function may not be called again until library is
* closed with a call to @c dCloseODE. * closed with a call to @c dCloseODE.
* *
* The @a uiInitFlags parameter specifies initialization options to be used. These * The @a uiInitFlags parameter specifies initialization options to be used. These
* can be combination of zero or more @c dInitODEFlags flags. * can be combination of zero or more @c dInitODEFlags flags.
* *
* @note * @note
* If @c dInitFlagManualThreadCleanup flag is used for initialization, * If @c dInitFlagManualThreadCleanup flag is used for initialization,
* @c dSpaceSetManualCleanup must be called to set manual cleanup mode for every * @c dSpaceSetManualCleanup must be called to set manual cleanup mode for every
* space object right after creation. Failure to do so may lead to resource leaks. * space object right after creation. Failure to do so may lead to resource leaks.
* *
* @see dInitODEFlags * @see dInitODEFlags
* @see dCloseODE * @see dCloseODE
* @see dSpaceSetManualCleanup * @see dSpaceSetManualCleanup
* @ingroup init * @ingroup init
*/ */
ODE_API int dInitODE2(unsigned int uiInitFlags/*=0*/); ODE_API int dInitODE2(unsigned int uiInitFlags/*=0*/);
/** /**
* @brief ODE data allocation flags. * @brief ODE data allocation flags.
* *
* These flags are used to indicate which data is to be pre-allocated in call to * These flags are used to indicate which data is to be pre-allocated in call to
* @c dAllocateODEDataForThread. * @c dAllocateODEDataForThread.
* *
* @c dAllocateFlagBasicData tells to allocate the basic data set required for * @c dAllocateFlagBasicData tells to allocate the basic data set required for
* normal library operation. This flag is equal to zero and is always implicitly * normal library operation. This flag is equal to zero and is always implicitly
* included. * included.
* *
* @c dAllocateFlagCollisionData tells that collision detection data is to be allocated. * @c dAllocateFlagCollisionData tells that collision detection data is to be allocated.
* Collision detection functions may not be called if the data has not be allocated * Collision detection functions may not be called if the data has not be allocated
* in advance. If collision detection is not going to be used, it is not necessary * in advance. If collision detection is not going to be used, it is not necessary
* to specify this flag. * to specify this flag.
* *
* @c dAllocateMaskAll is a mask that can be used for for allocating all possible * @c dAllocateMaskAll is a mask that can be used for for allocating all possible
* data in cases when it is not known what exactly features of ODE will be used. * data in cases when it is not known what exactly features of ODE will be used.
* The mask may not be used in combination with other flags. It is guaranteed to * The mask may not be used in combination with other flags. It is guaranteed to
* include all the current and future legal allocation flags. However, mature * include all the current and future legal allocation flags. However, mature
* applications should use explicit flags they need rather than allocating everything. * applications should use explicit flags they need rather than allocating everything.
* *
* @see dAllocateODEDataForThread * @see dAllocateODEDataForThread
* @ingroup init * @ingroup init
*/ */
enum dAllocateODEDataFlags { enum dAllocateODEDataFlags {
dAllocateFlagBasicData = 0, /*@< Allocate basic data required for library to operate*/ dAllocateFlagBasicData = 0, /*@< Allocate basic data required for library to operate*/
dAllocateFlagCollisionData = 0x00000001, /*@< Allocate data for collision detection*/ dAllocateFlagCollisionData = 0x00000001, /*@< Allocate data for collision detection*/
dAllocateMaskAll = ~0 /*@< Allocate all the possible data that is currently defined or will be defined in the future.*/ dAllocateMaskAll = ~0 /*@< Allocate all the possible data that is currently defined or will be defined in the future.*/
}; };
/** /**
* @brief Allocate thread local data to allow the thread calling ODE. * @brief Allocate thread local data to allow the thread calling ODE.
* @param uiAllocateFlags Allocation options bitmask. * @param uiAllocateFlags Allocation options bitmask.
* @return A nonzero if allocation succeeded and zero otherwise. * @return A nonzero if allocation succeeded and zero otherwise.
* *
* The function is required to be called for every thread that is going to use * The function is required to be called for every thread that is going to use
* ODE. This function allocates the data that is required for accessing ODE from * ODE. This function allocates the data that is required for accessing ODE from
* current thread along with optional data required for particular ODE subsystems. * current thread along with optional data required for particular ODE subsystems.
* *
* @a uiAllocateFlags parameter can contain zero or more flags from @c dAllocateODEDataFlags * @a uiAllocateFlags parameter can contain zero or more flags from @c dAllocateODEDataFlags
* enumerated type. Multiple calls with different allocation flags are allowed. * enumerated type. Multiple calls with different allocation flags are allowed.
* The flags that are already allocated are ignored in subsequent calls. If zero * The flags that are already allocated are ignored in subsequent calls. If zero
* is passed as the parameter, it means to only allocate the set of most important * is passed as the parameter, it means to only allocate the set of most important
* data the library can not operate without. * data the library can not operate without.
* *
* If the function returns failure status it means that none of the requested * If the function returns failure status it means that none of the requested
* data has been allocated. The client may retry allocation attempt with the same * data has been allocated. The client may retry allocation attempt with the same
* flags when more system resources are available. * flags when more system resources are available.
* *
* @see dAllocateODEDataFlags * @see dAllocateODEDataFlags
* @see dCleanupODEAllDataForThread * @see dCleanupODEAllDataForThread
* @ingroup init * @ingroup init
*/ */
ODE_API int dAllocateODEDataForThread(unsigned int uiAllocateFlags); ODE_API int dAllocateODEDataForThread(unsigned int uiAllocateFlags);
/** /**
* @brief Free thread local data that was allocated for current thread. * @brief Free thread local data that was allocated for current thread.
* *
* If library was initialized with @c dInitFlagManualThreadCleanup flag the function * If library was initialized with @c dInitFlagManualThreadCleanup flag the function
* is required to be called on exit of every thread that was calling @c dAllocateODEDataForThread. * is required to be called on exit of every thread that was calling @c dAllocateODEDataForThread.
* Failure to call @c dCleanupODEAllDataForThread may result in some resources remaining * Failure to call @c dCleanupODEAllDataForThread may result in some resources remaining
* not freed until program exit. The function may also be called when ODE is still * not freed until program exit. The function may also be called when ODE is still
* being used to release resources allocated for all the current subsystems and * being used to release resources allocated for all the current subsystems and
* possibly proceed with data pre-allocation for other subsystems. * possibly proceed with data pre-allocation for other subsystems.
* *
* The function can safely be called several times in a row. The function can be * The function can safely be called several times in a row. The function can be
* called without prior invocation of @c dAllocateODEDataForThread. The function * called without prior invocation of @c dAllocateODEDataForThread. The function
* may not be called before ODE is initialized with @c dInitODE2 or after library * may not be called before ODE is initialized with @c dInitODE2 or after library
* has been closed with @c dCloseODE. A call to @c dCloseODE implicitly releases * has been closed with @c dCloseODE. A call to @c dCloseODE implicitly releases
* all the thread local resources that might be allocated for all the threads that * all the thread local resources that might be allocated for all the threads that
* were using ODE. * were using ODE.
* *
* If library was initialized without @c dInitFlagManualThreadCleanup flag * If library was initialized without @c dInitFlagManualThreadCleanup flag
* @c dCleanupODEAllDataForThread must not be called. * @c dCleanupODEAllDataForThread must not be called.
* *
* @see dAllocateODEDataForThread * @see dAllocateODEDataForThread
* @see dInitODE2 * @see dInitODE2
* @see dCloseODE * @see dCloseODE
* @ingroup init * @ingroup init
*/ */
ODE_API void dCleanupODEAllDataForThread(); ODE_API void dCleanupODEAllDataForThread();
/** /**
* @brief Close ODE after it is not needed any more. * @brief Close ODE after it is not needed any more.
* *
* The function is required to be called when program does not need ODE features any more. * The function is required to be called when program does not need ODE features any more.
* The call to @c dCloseODE releases all the resources allocated for library * The call to @c dCloseODE releases all the resources allocated for library
* including all the thread local data that might be allocated for all the threads * including all the thread local data that might be allocated for all the threads
* that were using ODE. * that were using ODE.
* *
* @c dCloseODE is a paired function for @c dInitODE2 and must only be called * @c dCloseODE is a paired function for @c dInitODE2 and must only be called
* after successful library initialization. * after successful library initialization.
* *
* @note Important! * @note Important!
* Make sure that all the threads that were using ODE have already terminated * Make sure that all the threads that were using ODE have already terminated
* before calling @c dCloseODE. In particular it is not allowed to call * before calling @c dCloseODE. In particular it is not allowed to call
* @c dCleanupODEAllDataForThread after @c dCloseODE. * @c dCleanupODEAllDataForThread after @c dCloseODE.
* *
* @see dInitODE2 * @see dInitODE2
* @see dCleanupODEAllDataForThread * @see dCleanupODEAllDataForThread
* @ingroup init * @ingroup init
*/ */
ODE_API void dCloseODE(void); ODE_API void dCloseODE(void);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /* _ODE_ODEINIT_H_ */ #endif /* _ODE_ODEINIT_H_ */

File diff suppressed because it is too large Load Diff

@ -1,162 +1,162 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_ODEMATH_LEGACY_H_ #ifndef _ODE_ODEMATH_LEGACY_H_
#define _ODE_ODEMATH_LEGACY_H_ #define _ODE_ODEMATH_LEGACY_H_
/* /*
* These macros are not used any more inside of ODE * These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that * They are kept for backward compatibility with external code that
* might still be using them. * might still be using them.
*/ */
/* /*
* General purpose vector operations with other vectors or constants. * General purpose vector operations with other vectors or constants.
*/ */
#define dOP(a,op,b,c) do { \ #define dOP(a,op,b,c) do { \
(a)[0] = ((b)[0]) op ((c)[0]); \ (a)[0] = ((b)[0]) op ((c)[0]); \
(a)[1] = ((b)[1]) op ((c)[1]); \ (a)[1] = ((b)[1]) op ((c)[1]); \
(a)[2] = ((b)[2]) op ((c)[2]); \ (a)[2] = ((b)[2]) op ((c)[2]); \
} while (0) } while (0)
#define dOPC(a,op,b,c) do { \ #define dOPC(a,op,b,c) do { \
(a)[0] = ((b)[0]) op (c); \ (a)[0] = ((b)[0]) op (c); \
(a)[1] = ((b)[1]) op (c); \ (a)[1] = ((b)[1]) op (c); \
(a)[2] = ((b)[2]) op (c); \ (a)[2] = ((b)[2]) op (c); \
} while (0) } while (0)
#define dOPE(a,op,b) do {\ #define dOPE(a,op,b) do {\
(a)[0] op ((b)[0]); \ (a)[0] op ((b)[0]); \
(a)[1] op ((b)[1]); \ (a)[1] op ((b)[1]); \
(a)[2] op ((b)[2]); \ (a)[2] op ((b)[2]); \
} while (0) } while (0)
#define dOPEC(a,op,c) do { \ #define dOPEC(a,op,c) do { \
(a)[0] op (c); \ (a)[0] op (c); \
(a)[1] op (c); \ (a)[1] op (c); \
(a)[2] op (c); \ (a)[2] op (c); \
} while (0) } while (0)
/* Define an equation with operators /* Define an equation with operators
* For example this function can be used to replace * For example this function can be used to replace
* <PRE> * <PRE>
* for (int i=0; i<3; ++i) * for (int i=0; i<3; ++i)
* a[i] += b[i] + c[i]; * a[i] += b[i] + c[i];
* </PRE> * </PRE>
*/ */
#define dOPE2(a,op1,b,op2,c) do { \ #define dOPE2(a,op1,b,op2,c) do { \
(a)[0] op1 ((b)[0]) op2 ((c)[0]); \ (a)[0] op1 ((b)[0]) op2 ((c)[0]); \
(a)[1] op1 ((b)[1]) op2 ((c)[1]); \ (a)[1] op1 ((b)[1]) op2 ((c)[1]); \
(a)[2] op1 ((b)[2]) op2 ((c)[2]); \ (a)[2] op1 ((b)[2]) op2 ((c)[2]); \
} while (0) } while (0)
#define dLENGTHSQUARED(a) dCalcVectorLengthSquare3(a) #define dLENGTHSQUARED(a) dCalcVectorLengthSquare3(a)
#define dLENGTH(a) dCalcVectorLength3(a) #define dLENGTH(a) dCalcVectorLength3(a)
#define dDISTANCE(a, b) dCalcPointsDistance3(a, b) #define dDISTANCE(a, b) dCalcPointsDistance3(a, b)
#define dDOT(a, b) dCalcVectorDot3(a, b) #define dDOT(a, b) dCalcVectorDot3(a, b)
#define dDOT13(a, b) dCalcVectorDot3_13(a, b) #define dDOT13(a, b) dCalcVectorDot3_13(a, b)
#define dDOT31(a, b) dCalcVectorDot3_31(a, b) #define dDOT31(a, b) dCalcVectorDot3_31(a, b)
#define dDOT33(a, b) dCalcVectorDot3_33(a, b) #define dDOT33(a, b) dCalcVectorDot3_33(a, b)
#define dDOT14(a, b) dCalcVectorDot3_14(a, b) #define dDOT14(a, b) dCalcVectorDot3_14(a, b)
#define dDOT41(a, b) dCalcVectorDot3_41(a, b) #define dDOT41(a, b) dCalcVectorDot3_41(a, b)
#define dDOT44(a, b) dCalcVectorDot3_44(a, b) #define dDOT44(a, b) dCalcVectorDot3_44(a, b)
/* /*
* cross product, set a = b x c. dCROSSpqr means that elements of `a', `b' * cross product, set a = b x c. dCROSSpqr means that elements of `a', `b'
* and `c' are spaced p, q and r indexes apart respectively. * and `c' are spaced p, q and r indexes apart respectively.
* dCROSS() means dCROSS111. `op' is normally `=', but you can set it to * dCROSS() means dCROSS111. `op' is normally `=', but you can set it to
* +=, -= etc to get other effects. * +=, -= etc to get other effects.
*/ */
#define dCROSS(a,op,b,c) \ #define dCROSS(a,op,b,c) \
do { \ do { \
(a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \ (a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \
(a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \ (a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \
(a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \ (a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \
} while(0) } while(0)
#define dCROSSpqr(a,op,b,c,p,q,r) \ #define dCROSSpqr(a,op,b,c,p,q,r) \
do { \ do { \
(a)[ 0] op ((b)[ q]*(c)[2*r] - (b)[2*q]*(c)[ r]); \ (a)[ 0] op ((b)[ q]*(c)[2*r] - (b)[2*q]*(c)[ r]); \
(a)[ p] op ((b)[2*q]*(c)[ 0] - (b)[ 0]*(c)[2*r]); \ (a)[ p] op ((b)[2*q]*(c)[ 0] - (b)[ 0]*(c)[2*r]); \
(a)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \ (a)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \
} while(0) } while(0)
#define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4) #define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4)
#define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1) #define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1)
#define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4) #define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4)
#define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1) #define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1)
#define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4) #define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4)
#define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1) #define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1)
#define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4) #define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4)
/* /*
* set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b. * set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b.
* A is stored by rows, and has `skip' elements per row. the matrix is * A is stored by rows, and has `skip' elements per row. the matrix is
* assumed to be already zero, so this does not write zero elements! * assumed to be already zero, so this does not write zero elements!
* if (plus,minus) is (+,-) then a positive version will be written. * if (plus,minus) is (+,-) then a positive version will be written.
* if (plus,minus) is (-,+) then a negative version will be written. * if (plus,minus) is (-,+) then a negative version will be written.
*/ */
#define dCROSSMAT(A,a,skip,plus,minus) \ #define dCROSSMAT(A,a,skip,plus,minus) \
do { \ do { \
(A)[1] = minus (a)[2]; \ (A)[1] = minus (a)[2]; \
(A)[2] = plus (a)[1]; \ (A)[2] = plus (a)[1]; \
(A)[(skip)+0] = plus (a)[2]; \ (A)[(skip)+0] = plus (a)[2]; \
(A)[(skip)+2] = minus (a)[0]; \ (A)[(skip)+2] = minus (a)[0]; \
(A)[2*(skip)+0] = minus (a)[1]; \ (A)[2*(skip)+0] = minus (a)[1]; \
(A)[2*(skip)+1] = plus (a)[0]; \ (A)[2*(skip)+1] = plus (a)[0]; \
} while(0) } while(0)
/* /*
Note: NEVER call any of these functions/macros with the same variable for A and C, Note: NEVER call any of these functions/macros with the same variable for A and C,
it is not equivalent to A*=B. it is not equivalent to A*=B.
*/ */
#define dMULTIPLY0_331(A, B, C) dMultiply0_331(A, B, C) #define dMULTIPLY0_331(A, B, C) dMultiply0_331(A, B, C)
#define dMULTIPLY1_331(A, B, C) dMultiply1_331(A, B, C) #define dMULTIPLY1_331(A, B, C) dMultiply1_331(A, B, C)
#define dMULTIPLY0_133(A, B, C) dMultiply0_133(A, B, C) #define dMULTIPLY0_133(A, B, C) dMultiply0_133(A, B, C)
#define dMULTIPLY0_333(A, B, C) dMultiply0_333(A, B, C) #define dMULTIPLY0_333(A, B, C) dMultiply0_333(A, B, C)
#define dMULTIPLY1_333(A, B, C) dMultiply1_333(A, B, C) #define dMULTIPLY1_333(A, B, C) dMultiply1_333(A, B, C)
#define dMULTIPLY2_333(A, B, C) dMultiply2_333(A, B, C) #define dMULTIPLY2_333(A, B, C) dMultiply2_333(A, B, C)
#define dMULTIPLYADD0_331(A, B, C) dMultiplyAdd0_331(A, B, C) #define dMULTIPLYADD0_331(A, B, C) dMultiplyAdd0_331(A, B, C)
#define dMULTIPLYADD1_331(A, B, C) dMultiplyAdd1_331(A, B, C) #define dMULTIPLYADD1_331(A, B, C) dMultiplyAdd1_331(A, B, C)
#define dMULTIPLYADD0_133(A, B, C) dMultiplyAdd0_133(A, B, C) #define dMULTIPLYADD0_133(A, B, C) dMultiplyAdd0_133(A, B, C)
#define dMULTIPLYADD0_333(A, B, C) dMultiplyAdd0_333(A, B, C) #define dMULTIPLYADD0_333(A, B, C) dMultiplyAdd0_333(A, B, C)
#define dMULTIPLYADD1_333(A, B, C) dMultiplyAdd1_333(A, B, C) #define dMULTIPLYADD1_333(A, B, C) dMultiplyAdd1_333(A, B, C)
#define dMULTIPLYADD2_333(A, B, C) dMultiplyAdd2_333(A, B, C) #define dMULTIPLYADD2_333(A, B, C) dMultiplyAdd2_333(A, B, C)
/* /*
* These macros are not used any more inside of ODE * These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that * They are kept for backward compatibility with external code that
* might still be using them. * might still be using them.
*/ */
#endif /* #ifndef _ODE_ODEMATH_LEGACY_H_ */ #endif /* #ifndef _ODE_ODEMATH_LEGACY_H_ */

@ -1,16 +1,16 @@
#ifndef _ODE_PRECISION_H_ #ifndef _ODE_PRECISION_H_
#define _ODE_PRECISION_H_ #define _ODE_PRECISION_H_
/* Define dSINGLE for single precision, dDOUBLE for double precision, /* Define dSINGLE for single precision, dDOUBLE for double precision,
* but never both! * but never both!
*/ */
#if defined(dIDESINGLE) #if defined(dIDESINGLE)
#define dSINGLE #define dSINGLE
#elif defined(dIDEDOUBLE) #elif defined(dIDEDOUBLE)
#define dDOUBLE #define dDOUBLE
#else #else
#define dDOUBLE #define dDOUBLE
#endif #endif
#endif #endif

@ -1,70 +1,70 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_ROTATION_H_ #ifndef _ODE_ROTATION_H_
#define _ODE_ROTATION_H_ #define _ODE_ROTATION_H_
#include <ode/common.h> #include <ode/common.h>
#include <ode/compatibility.h> #include <ode/compatibility.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
ODE_API void dRSetIdentity (dMatrix3 R); ODE_API void dRSetIdentity (dMatrix3 R);
ODE_API void dRFromAxisAndAngle (dMatrix3 R, dReal ax, dReal ay, dReal az, ODE_API void dRFromAxisAndAngle (dMatrix3 R, dReal ax, dReal ay, dReal az,
dReal angle); dReal angle);
ODE_API void dRFromEulerAngles (dMatrix3 R, dReal phi, dReal theta, dReal psi); ODE_API void dRFromEulerAngles (dMatrix3 R, dReal phi, dReal theta, dReal psi);
ODE_API void dRFrom2Axes (dMatrix3 R, dReal ax, dReal ay, dReal az, ODE_API void dRFrom2Axes (dMatrix3 R, dReal ax, dReal ay, dReal az,
dReal bx, dReal by, dReal bz); dReal bx, dReal by, dReal bz);
ODE_API void dRFromZAxis (dMatrix3 R, dReal ax, dReal ay, dReal az); ODE_API void dRFromZAxis (dMatrix3 R, dReal ax, dReal ay, dReal az);
ODE_API void dQSetIdentity (dQuaternion q); ODE_API void dQSetIdentity (dQuaternion q);
ODE_API void dQFromAxisAndAngle (dQuaternion q, dReal ax, dReal ay, dReal az, ODE_API void dQFromAxisAndAngle (dQuaternion q, dReal ax, dReal ay, dReal az,
dReal angle); dReal angle);
/* Quaternion multiplication, analogous to the matrix multiplication routines. */ /* Quaternion multiplication, analogous to the matrix multiplication routines. */
/* qa = rotate by qc, then qb */ /* qa = rotate by qc, then qb */
ODE_API void dQMultiply0 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); ODE_API void dQMultiply0 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
/* qa = rotate by qc, then by inverse of qb */ /* qa = rotate by qc, then by inverse of qb */
ODE_API void dQMultiply1 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); ODE_API void dQMultiply1 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
/* qa = rotate by inverse of qc, then by qb */ /* qa = rotate by inverse of qc, then by qb */
ODE_API void dQMultiply2 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); ODE_API void dQMultiply2 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
/* qa = rotate by inverse of qc, then by inverse of qb */ /* qa = rotate by inverse of qc, then by inverse of qb */
ODE_API void dQMultiply3 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); ODE_API void dQMultiply3 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc);
ODE_API void dRfromQ (dMatrix3 R, const dQuaternion q); ODE_API void dRfromQ (dMatrix3 R, const dQuaternion q);
ODE_API void dQfromR (dQuaternion q, const dMatrix3 R); ODE_API void dQfromR (dQuaternion q, const dMatrix3 R);
ODE_API void dDQfromW (dReal dq[4], const dVector3 w, const dQuaternion q); ODE_API void dDQfromW (dReal dq[4], const dVector3 w, const dQuaternion q);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,412 +1,412 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* Threading support header file. * * Threading support header file. *
* Copyright (C) 2011-2012 Oleh Derevenko. All rights reserved. * * Copyright (C) 2011-2012 Oleh Derevenko. All rights reserved. *
* e-mail: odar@eleks.com (change all "a" to "e") * * e-mail: odar@eleks.com (change all "a" to "e") *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* /*
* ODE threading support interfaces * ODE threading support interfaces
*/ */
#ifndef _ODE_THREADING_H_ #ifndef _ODE_THREADING_H_
#define _ODE_THREADING_H_ #define _ODE_THREADING_H_
#include <ode/odeconfig.h> #include <ode/odeconfig.h>
// Include <time.h> since time_t is used and it is not available by default in some OSes // Include <time.h> since time_t is used and it is not available by default in some OSes
#include <time.h> #include <time.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct dxThreadingImplementation; struct dxThreadingImplementation;
typedef struct dxThreadingImplementation *dThreadingImplementationID; typedef struct dxThreadingImplementation *dThreadingImplementationID;
typedef unsigned dmutexindex_t; typedef unsigned dmutexindex_t;
struct dxMutexGroup; struct dxMutexGroup;
typedef struct dxMutexGroup *dMutexGroupID; typedef struct dxMutexGroup *dMutexGroupID;
#define dTHREADING_THREAD_COUNT_UNLIMITED 0U #define dTHREADING_THREAD_COUNT_UNLIMITED 0U
/** /**
* @brief Allocates a group of muteces. * @brief Allocates a group of muteces.
* *
* The Mutex allocated do not need to support recursive locking. * The Mutex allocated do not need to support recursive locking.
* *
* The Mutex names are provided to aid in debugging and thread state tracking. * The Mutex names are provided to aid in debugging and thread state tracking.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param Mutex_count Number of Mutex to create * @param Mutex_count Number of Mutex to create
* @Mutex_names_ptr Pointer to optional Mutex names array to be associated with individual Mutex * @Mutex_names_ptr Pointer to optional Mutex names array to be associated with individual Mutex
* @returns MutexGroup ID or NULL if error occurred. * @returns MutexGroup ID or NULL if error occurred.
* *
* @ingroup threading * @ingroup threading
* @see dMutexGroupFreeFunction * @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction * @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction * @see dMutexGroupMutexUnlockFunction
*/ */
typedef dMutexGroupID dMutexGroupAllocFunction (dThreadingImplementationID impl, dmutexindex_t Mutex_count, const char *const *Mutex_names_ptr/*=NULL*/); typedef dMutexGroupID dMutexGroupAllocFunction (dThreadingImplementationID impl, dmutexindex_t Mutex_count, const char *const *Mutex_names_ptr/*=NULL*/);
/** /**
* @brief Deletes a group of muteces. * @brief Deletes a group of muteces.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param mutex_group Mutex group to deallocate * @param mutex_group Mutex group to deallocate
* *
* @ingroup threading * @ingroup threading
* @see dMutexGroupAllocFunction * @see dMutexGroupAllocFunction
* @see dMutexGroupMutexLockFunction * @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction * @see dMutexGroupMutexUnlockFunction
*/ */
typedef void dMutexGroupFreeFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group); typedef void dMutexGroupFreeFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group);
/** /**
* @brief Locks a mutex in a group of muteces. * @brief Locks a mutex in a group of muteces.
* *
* The function is to block execution until requested mutex can be locked. * The function is to block execution until requested mutex can be locked.
* *
* Note: Mutex provided may not support recursive locking. Calling this function * Note: Mutex provided may not support recursive locking. Calling this function
* while mutex is already locked by current thread will result in unpredictable behavior. * while mutex is already locked by current thread will result in unpredictable behavior.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param mutex_group Mutex group to use for locking * @param mutex_group Mutex group to use for locking
* @param mutex_index The index of mutex to be locked (0..Mutex_count - 1) * @param mutex_index The index of mutex to be locked (0..Mutex_count - 1)
* *
* @ingroup threading * @ingroup threading
* @see dMutexGroupAllocFunction * @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction * @see dMutexGroupFreeFunction
* @see dMutexGroupMutexUnlockFunction * @see dMutexGroupMutexUnlockFunction
*/ */
typedef void dMutexGroupMutexLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index); typedef void dMutexGroupMutexLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);
/** /**
* @brief Attempts to lock a mutex in a group of muteces. * @brief Attempts to lock a mutex in a group of muteces.
* *
* The function is to lock the requested mutex if it is unoccupied or * The function is to lock the requested mutex if it is unoccupied or
* immediately return failure if mutex is already locked by other thread. * immediately return failure if mutex is already locked by other thread.
* *
* Note: Mutex provided may not support recursive locking. Calling this function * Note: Mutex provided may not support recursive locking. Calling this function
* while mutex is already locked by current thread will result in unpredictable behavior. * while mutex is already locked by current thread will result in unpredictable behavior.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param mutex_group Mutex group to use for locking * @param mutex_group Mutex group to use for locking
* @param mutex_index The index of mutex to be locked (0..Mutex_count - 1) * @param mutex_index The index of mutex to be locked (0..Mutex_count - 1)
* @returns 1 for success (mutex is locked) and 0 for failure (mutex is not locked) * @returns 1 for success (mutex is locked) and 0 for failure (mutex is not locked)
* *
* @ingroup threading * @ingroup threading
* @see dMutexGroupAllocFunction * @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction * @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction * @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction * @see dMutexGroupMutexUnlockFunction
*/ */
/* typedef int dMutexGroupMutexTryLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);*/ /* typedef int dMutexGroupMutexTryLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);*/
/** /**
* @brief Unlocks a mutex in a group of muteces. * @brief Unlocks a mutex in a group of muteces.
* *
* The function is to unlock the given mutex provided it had been locked before. * The function is to unlock the given mutex provided it had been locked before.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param mutex_group Mutex group to use for unlocking * @param mutex_group Mutex group to use for unlocking
* @param mutex_index The index of mutex to be unlocked (0..Mutex_count - 1) * @param mutex_index The index of mutex to be unlocked (0..Mutex_count - 1)
* *
* @ingroup threading * @ingroup threading
* @see dMutexGroupAllocFunction * @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction * @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction * @see dMutexGroupMutexLockFunction
*/ */
typedef void dMutexGroupMutexUnlockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index); typedef void dMutexGroupMutexUnlockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);
struct dxCallReleasee; struct dxCallReleasee;
typedef struct dxCallReleasee *dCallReleaseeID; typedef struct dxCallReleasee *dCallReleaseeID;
struct dxCallWait; struct dxCallWait;
typedef struct dxCallWait *dCallWaitID; typedef struct dxCallWait *dCallWaitID;
typedef dsizeint ddependencycount_t; typedef dsizeint ddependencycount_t;
typedef ddiffint ddependencychange_t; typedef ddiffint ddependencychange_t;
typedef dsizeint dcallindex_t; typedef dsizeint dcallindex_t;
typedef int dThreadedCallFunction(void *call_context, dcallindex_t instance_index, typedef int dThreadedCallFunction(void *call_context, dcallindex_t instance_index,
dCallReleaseeID this_releasee); dCallReleaseeID this_releasee);
typedef struct dxThreadedWaitTime typedef struct dxThreadedWaitTime
{ {
time_t wait_sec; time_t wait_sec;
unsigned long wait_nsec; unsigned long wait_nsec;
} dThreadedWaitTime; } dThreadedWaitTime;
/** /**
* @brief Allocates a Wait ID that can be used to wait for a call. * @brief Allocates a Wait ID that can be used to wait for a call.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @returns Wait ID or NULL if error occurred * @returns Wait ID or NULL if error occurred
* *
* @ingroup threading * @ingroup threading
* @see dThreadedCallWaitResetFunction * @see dThreadedCallWaitResetFunction
* @see dThreadedCallWaitFreeFunction * @see dThreadedCallWaitFreeFunction
* @see dThreadedCallPostFunction * @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction * @see dThreadedCallWaitFunction
*/ */
typedef dCallWaitID dThreadedCallWaitAllocFunction(dThreadingImplementationID impl); typedef dCallWaitID dThreadedCallWaitAllocFunction(dThreadingImplementationID impl);
/** /**
* @brief Resets a Wait ID so that it could be used to wait for another call. * @brief Resets a Wait ID so that it could be used to wait for another call.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param call_wait Wait ID to reset * @param call_wait Wait ID to reset
* *
* @ingroup threading * @ingroup threading
* @see dThreadedCallWaitAllocFunction * @see dThreadedCallWaitAllocFunction
* @see dThreadedCallWaitFreeFunction * @see dThreadedCallWaitFreeFunction
* @see dThreadedCallPostFunction * @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction * @see dThreadedCallWaitFunction
*/ */
typedef void dThreadedCallWaitResetFunction(dThreadingImplementationID impl, dCallWaitID call_wait); typedef void dThreadedCallWaitResetFunction(dThreadingImplementationID impl, dCallWaitID call_wait);
/** /**
* @brief Frees a Wait ID. * @brief Frees a Wait ID.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param call_wait Wait ID to delete * @param call_wait Wait ID to delete
* *
* @ingroup threading * @ingroup threading
* @see dThreadedCallWaitAllocFunction * @see dThreadedCallWaitAllocFunction
* @see dThreadedCallPostFunction * @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction * @see dThreadedCallWaitFunction
*/ */
typedef void dThreadedCallWaitFreeFunction(dThreadingImplementationID impl, dCallWaitID call_wait); typedef void dThreadedCallWaitFreeFunction(dThreadingImplementationID impl, dCallWaitID call_wait);
/** /**
* @brief Post a function to be called in another thread. * @brief Post a function to be called in another thread.
* *
* A call is scheduled to be executed asynchronously. * A call is scheduled to be executed asynchronously.
* *
* A @a out_summary_fault variable can be provided for call to accumulate any * A @a out_summary_fault variable can be provided for call to accumulate any
* possible faults from its execution and execution of any possible sub-calls. * possible faults from its execution and execution of any possible sub-calls.
* This variable gets result that @a call_func returns. Also, if dependent calls * This variable gets result that @a call_func returns. Also, if dependent calls
* are executed after the call already exits, the variable is also going to be * are executed after the call already exits, the variable is also going to be
* updated with results of all those calls before control is released to master. * updated with results of all those calls before control is released to master.
* *
* @a out_post_releasee parameter receives a value of @c dCallReleaseeID that can * @a out_post_releasee parameter receives a value of @c dCallReleaseeID that can
* later be used for @a dependent_releasee while scheduling sub-calls to make * later be used for @a dependent_releasee while scheduling sub-calls to make
* current call depend on them. The value is only returned if @a dependencies_count * current call depend on them. The value is only returned if @a dependencies_count
* is not zero (i.e. if any dependencies are expected at all). The call is not going * is not zero (i.e. if any dependencies are expected at all). The call is not going
* to start until all its dependencies complete. * to start until all its dependencies complete.
* *
* In case if number of dependencies is unknown in advance 1 can be passed on call * In case if number of dependencies is unknown in advance 1 can be passed on call
* scheduling. Then @c dThreadedCallDependenciesCountAlterFunction can be used to * scheduling. Then @c dThreadedCallDependenciesCountAlterFunction can be used to
* add one more extra dependencies before scheduling each subcall. And then, after * add one more extra dependencies before scheduling each subcall. And then, after
* all sub-calls had been scheduled, @c dThreadedCallDependenciesCountAlterFunction * all sub-calls had been scheduled, @c dThreadedCallDependenciesCountAlterFunction
* can be used again to subtract initial extra dependency from total number. * can be used again to subtract initial extra dependency from total number.
* Adding one dependency in advance is necessary to obtain releasee ID and to make * Adding one dependency in advance is necessary to obtain releasee ID and to make
* sure the call will not start and will not terminate before all sub-calls are scheduled. * sure the call will not start and will not terminate before all sub-calls are scheduled.
* *
* Extra dependencies can also be added from the call itself after it has already * Extra dependencies can also be added from the call itself after it has already
* been started (with parameter received in @c dThreadedCallFunction). * been started (with parameter received in @c dThreadedCallFunction).
* In that case those dependencies will start immediately or after call returns * In that case those dependencies will start immediately or after call returns
* but the call's master will not be released/notified until all additional * but the call's master will not be released/notified until all additional
* dependencies complete. This can be used to schedule sub-calls from a call and * dependencies complete. This can be used to schedule sub-calls from a call and
* then pass own job to another sub-call dependent on those initial sub-calls. * then pass own job to another sub-call dependent on those initial sub-calls.
* *
* By using @ call_wait it is possible to assign a Wait ID that can later * By using @ call_wait it is possible to assign a Wait ID that can later
* be passed into @c dThreadedCallWaitFunction to wait for call completion. * be passed into @c dThreadedCallWaitFunction to wait for call completion.
* *
* If @a call_name is available (and it should!) the string must remain valid until * If @a call_name is available (and it should!) the string must remain valid until
* after call completion. In most cases this should be a static string literal. * after call completion. In most cases this should be a static string literal.
* *
* Since the function is an analogue of normal method call it is not supposed to fail. * Since the function is an analogue of normal method call it is not supposed to fail.
* Any complications with resource allocation on call scheduling should be * Any complications with resource allocation on call scheduling should be
* anticipated, avoided and worked around by implementation. * anticipated, avoided and worked around by implementation.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param out_summary_fault Optional pointer to variable to be set to 1 if function * @param out_summary_fault Optional pointer to variable to be set to 1 if function
* call (or any sub-call) fails internally, or 0 if all calls return success * call (or any sub-call) fails internally, or 0 if all calls return success
* @param out_post_releasee Optional pointer to variable to receive releasee ID * @param out_post_releasee Optional pointer to variable to receive releasee ID
* associated with the call * associated with the call
* @param dependencies_count Number of dependencies that are going to reference * @param dependencies_count Number of dependencies that are going to reference
* this call as dependent releasee * this call as dependent releasee
* @param dependent_releasee Optional releasee ID to reference with this call * @param dependent_releasee Optional releasee ID to reference with this call
* @param call_wait Optional Wait ID that can later be used to wait for the call * @param call_wait Optional Wait ID that can later be used to wait for the call
* @param call_func Pointer to function to be called * @param call_func Pointer to function to be called
* @param call_context Context parameter to be passed into the call * @param call_context Context parameter to be passed into the call
* @param instance_index Index parameter to be passed into the call * @param instance_index Index parameter to be passed into the call
* @param call_name Optional name to be associated with the call (for debugging and state tracking) * @param call_name Optional name to be associated with the call (for debugging and state tracking)
* *
* @ingroup threading * @ingroup threading
* @see dThreadedCallWaitFunction * @see dThreadedCallWaitFunction
* @see dThreadedCallDependenciesCountAlterFunction * @see dThreadedCallDependenciesCountAlterFunction
* @see dThreadingImplResourcesForCallsPreallocateFunction * @see dThreadingImplResourcesForCallsPreallocateFunction
*/ */
typedef void dThreadedCallPostFunction(dThreadingImplementationID impl, int *out_summary_fault/*=NULL*/, typedef void dThreadedCallPostFunction(dThreadingImplementationID impl, int *out_summary_fault/*=NULL*/,
dCallReleaseeID *out_post_releasee/*=NULL*/, ddependencycount_t dependencies_count, dCallReleaseeID dependent_releasee/*=NULL*/, dCallReleaseeID *out_post_releasee/*=NULL*/, ddependencycount_t dependencies_count, dCallReleaseeID dependent_releasee/*=NULL*/,
dCallWaitID call_wait/*=NULL*/, dCallWaitID call_wait/*=NULL*/,
dThreadedCallFunction *call_func, void *call_context, dcallindex_t instance_index, dThreadedCallFunction *call_func, void *call_context, dcallindex_t instance_index,
const char *call_name/*=NULL*/); const char *call_name/*=NULL*/);
/** /**
* @brief Add or remove extra dependencies from call that has been scheduled * @brief Add or remove extra dependencies from call that has been scheduled
* or is in process of execution. * or is in process of execution.
* *
* Extra dependencies can be added to a call if exact number of sub-calls is * Extra dependencies can be added to a call if exact number of sub-calls is
* not known in advance at the moment the call is scheduled. Also, some dependencies * not known in advance at the moment the call is scheduled. Also, some dependencies
* can be removed if sub-calls were planned but then dropped. * can be removed if sub-calls were planned but then dropped.
* *
* In case if total dependency count of a call reaches zero by result of invoking * In case if total dependency count of a call reaches zero by result of invoking
* this function, the call is free to start executing immediately. * this function, the call is free to start executing immediately.
* *
* After the call execution had been started, any additional dependencies can only * After the call execution had been started, any additional dependencies can only
* be added from the call function itself! * be added from the call function itself!
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param target_releasee ID of releasee to apply dependencies count change to * @param target_releasee ID of releasee to apply dependencies count change to
* @param dependencies_count_change Number of dependencies to add or remove * @param dependencies_count_change Number of dependencies to add or remove
* *
* @ingroup threading * @ingroup threading
* @see dThreadedCallPostFunction * @see dThreadedCallPostFunction
*/ */
typedef void dThreadedCallDependenciesCountAlterFunction(dThreadingImplementationID impl, dCallReleaseeID target_releasee, typedef void dThreadedCallDependenciesCountAlterFunction(dThreadingImplementationID impl, dCallReleaseeID target_releasee,
ddependencychange_t dependencies_count_change); ddependencychange_t dependencies_count_change);
/** /**
* @brief Wait for a posted call to complete. * @brief Wait for a posted call to complete.
* *
* Function blocks until a call identified by @a call_wait completes or * Function blocks until a call identified by @a call_wait completes or
* timeout elapses. * timeout elapses.
* *
* IT IS ILLEGAL TO INVOKE THIS FUNCTION FROM WITHIN A THREADED CALL! * IT IS ILLEGAL TO INVOKE THIS FUNCTION FROM WITHIN A THREADED CALL!
* This is because doing so will block a physical thread and will require * This is because doing so will block a physical thread and will require
* increasing worker thread count to avoid starvation. Use call dependencies * increasing worker thread count to avoid starvation. Use call dependencies
* if it is necessary make sure sub-calls have been completed instead! * if it is necessary make sure sub-calls have been completed instead!
* *
* If @a timeout_time_ptr is NULL, the function waits without time limit. If @a timeout_time_ptr * If @a timeout_time_ptr is NULL, the function waits without time limit. If @a timeout_time_ptr
* points to zero value, the function only checks status and does not block. * points to zero value, the function only checks status and does not block.
* *
* If @a wait_name is available (and it should!) the string must remain valid for * If @a wait_name is available (and it should!) the string must remain valid for
* the duration of wait. In most cases this should be a static string literal. * the duration of wait. In most cases this should be a static string literal.
* *
* Function is not expected to return failures caused by system call faults as * Function is not expected to return failures caused by system call faults as
* those are hardly ever possible to be handled in this case anyway. In event of * those are hardly ever possible to be handled in this case anyway. In event of
* system call fault the function is supposed to terminate application. * system call fault the function is supposed to terminate application.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param out_wait_status Optional pointer to variable to receive 1 if waiting succeeded * @param out_wait_status Optional pointer to variable to receive 1 if waiting succeeded
* or 0 in case of timeout * or 0 in case of timeout
* @param call_wait Wait ID that had been passed to scheduling a call that needs to be waited for * @param call_wait Wait ID that had been passed to scheduling a call that needs to be waited for
* @param timeout_time_ptr Optional pointer to time specification the wait must not * @param timeout_time_ptr Optional pointer to time specification the wait must not
* last longer than (pass NULL for infinite timeout) * last longer than (pass NULL for infinite timeout)
* @param wait_name Optional name to be associated with the wait (for debugging and state tracking) * @param wait_name Optional name to be associated with the wait (for debugging and state tracking)
* *
* @ingroup threading * @ingroup threading
* @see dThreadedCallPostFunction * @see dThreadedCallPostFunction
*/ */
typedef void dThreadedCallWaitFunction(dThreadingImplementationID impl, int *out_wait_status/*=NULL*/, typedef void dThreadedCallWaitFunction(dThreadingImplementationID impl, int *out_wait_status/*=NULL*/,
dCallWaitID call_wait, const dThreadedWaitTime *timeout_time_ptr/*=NULL*/, dCallWaitID call_wait, const dThreadedWaitTime *timeout_time_ptr/*=NULL*/,
const char *wait_name/*=NULL*/); const char *wait_name/*=NULL*/);
/** /**
* @brief Retrieve number of active threads that serve the implementation. * @brief Retrieve number of active threads that serve the implementation.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @returns Number of active threads * @returns Number of active threads
* *
* @ingroup threading * @ingroup threading
*/ */
typedef unsigned dThreadingImplThreadCountRetrieveFunction(dThreadingImplementationID impl); typedef unsigned dThreadingImplThreadCountRetrieveFunction(dThreadingImplementationID impl);
/** /**
* @brief Preallocate resources to handle posted calls. * @brief Preallocate resources to handle posted calls.
* *
* The function is intended to make sure enough resources is preallocated for the * The function is intended to make sure enough resources is preallocated for the
* implementation to be able to handle posted calls. Then @c max_simultaneous_calls_estimate * implementation to be able to handle posted calls. Then @c max_simultaneous_calls_estimate
* is an estimate of how many posted calls can potentially be active or scheduled * is an estimate of how many posted calls can potentially be active or scheduled
* at the same time. The value is usually derived from the way the calls are posted * at the same time. The value is usually derived from the way the calls are posted
* in library code and dependencies between them. * in library code and dependencies between them.
* *
* @warning While working on an implementation be prepared that the estimate provided * @warning While working on an implementation be prepared that the estimate provided
* yet rarely but theoretically can be exceeded due to unpredictability of thread execution. * yet rarely but theoretically can be exceeded due to unpredictability of thread execution.
* *
* This function is normally going to be invoked by library each time it is entered * This function is normally going to be invoked by library each time it is entered
* from outside to do the job but before any threaded calls are going to be posted. * from outside to do the job but before any threaded calls are going to be posted.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param max_simultaneous_calls_estimate An estimated number of calls that can be posted simultaneously * @param max_simultaneous_calls_estimate An estimated number of calls that can be posted simultaneously
* @returns 1 or 0 to indicate success or failure * @returns 1 or 0 to indicate success or failure
* *
* @ingroup threading * @ingroup threading
* @see dThreadedCallPostFunction * @see dThreadedCallPostFunction
*/ */
typedef int dThreadingImplResourcesForCallsPreallocateFunction(dThreadingImplementationID impl, typedef int dThreadingImplResourcesForCallsPreallocateFunction(dThreadingImplementationID impl,
ddependencycount_t max_simultaneous_calls_estimate); ddependencycount_t max_simultaneous_calls_estimate);
/** /**
* @brief An interface structure with function pointers to be provided by threading implementation. * @brief An interface structure with function pointers to be provided by threading implementation.
*/ */
typedef struct dxThreadingFunctionsInfo typedef struct dxThreadingFunctionsInfo
{ {
unsigned struct_size; unsigned struct_size;
dMutexGroupAllocFunction *alloc_mutex_group; dMutexGroupAllocFunction *alloc_mutex_group;
dMutexGroupFreeFunction *free_mutex_group; dMutexGroupFreeFunction *free_mutex_group;
dMutexGroupMutexLockFunction *lock_group_mutex; dMutexGroupMutexLockFunction *lock_group_mutex;
dMutexGroupMutexUnlockFunction *unlock_group_mutex; dMutexGroupMutexUnlockFunction *unlock_group_mutex;
dThreadedCallWaitAllocFunction *alloc_call_wait; dThreadedCallWaitAllocFunction *alloc_call_wait;
dThreadedCallWaitResetFunction *reset_call_wait; dThreadedCallWaitResetFunction *reset_call_wait;
dThreadedCallWaitFreeFunction *free_call_wait; dThreadedCallWaitFreeFunction *free_call_wait;
dThreadedCallPostFunction *post_call; dThreadedCallPostFunction *post_call;
dThreadedCallDependenciesCountAlterFunction *alter_call_dependencies_count; dThreadedCallDependenciesCountAlterFunction *alter_call_dependencies_count;
dThreadedCallWaitFunction *wait_call; dThreadedCallWaitFunction *wait_call;
dThreadingImplThreadCountRetrieveFunction *retrieve_thread_count; dThreadingImplThreadCountRetrieveFunction *retrieve_thread_count;
dThreadingImplResourcesForCallsPreallocateFunction *preallocate_resources_for_calls; dThreadingImplResourcesForCallsPreallocateFunction *preallocate_resources_for_calls;
/* /*
* Beware of Jon Watte's anger if you dare to uncomment this! * Beware of Jon Watte's anger if you dare to uncomment this!
* May cryptic text below be you a warning! * May cryptic text below be you a warning!
* Стародавні легенди розказують, що кожного сміливця, хто наважиться порушити табу * Стародавні легенди розказують, що кожного сміливця, хто наважиться порушити табу
* і відкрити заборонений код, спіткає страшне прокляття і він відразу почне робити * і відкрити заборонений код, спіткає страшне прокляття і він відразу почне робити
* одні лиш помилки. * одні лиш помилки.
* *
* dMutexGroupMutexTryLockFunction *trylock_group_mutex; * dMutexGroupMutexTryLockFunction *trylock_group_mutex;
*/ */
} dThreadingFunctionsInfo; } dThreadingFunctionsInfo;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* #ifndef _ODE_THREADING_H_ */ #endif /* #ifndef _ODE_THREADING_H_ */

@ -1,292 +1,292 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* Builtin ODE threading implementation header. * * Builtin ODE threading implementation header. *
* Copyright (C) 2011-2012 Oleh Derevenko. All rights reserved. * * Copyright (C) 2011-2012 Oleh Derevenko. All rights reserved. *
* e-mail: odar@eleks.com (change all "a" to "e") * * e-mail: odar@eleks.com (change all "a" to "e") *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
/* /*
* A threading implementation built into ODE for those who does not care to * A threading implementation built into ODE for those who does not care to
* or can't implement an own one. * or can't implement an own one.
*/ */
#ifndef _ODE_THREADING_IMPL_H_ #ifndef _ODE_THREADING_IMPL_H_
#define _ODE_THREADING_IMPL_H_ #define _ODE_THREADING_IMPL_H_
#include <ode/odeconfig.h> #include <ode/odeconfig.h>
#include <ode/threading.h> #include <ode/threading.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct dxThreadingThreadPool; struct dxThreadingThreadPool;
typedef struct dxThreadingThreadPool *dThreadingThreadPoolID; typedef struct dxThreadingThreadPool *dThreadingThreadPoolID;
/** /**
* @brief Allocates built-in self-threaded threading implementation object. * @brief Allocates built-in self-threaded threading implementation object.
* *
* A self-threaded implementation is a type of implementation that performs * A self-threaded implementation is a type of implementation that performs
* processing of posted calls by means of caller thread itself. This type of * processing of posted calls by means of caller thread itself. This type of
* implementation does not need thread pool to serve it. * implementation does not need thread pool to serve it.
* *
* Note that since May 9th, 2017 (rev. #2066) the Self-Threaded implementation * Note that since May 9th, 2017 (rev. #2066) the Self-Threaded implementation
* returns 0 rather than 1 as available thread count to distinguish from * returns 0 rather than 1 as available thread count to distinguish from
* thread pools with just one thread in them. * thread pools with just one thread in them.
* *
* The processing is arranged in a way to prevent call stack depth growth * The processing is arranged in a way to prevent call stack depth growth
* as more and more nested calls are posted. * as more and more nested calls are posted.
* *
* Note that it is not necessary to create and assign a self-threaded * Note that it is not necessary to create and assign a self-threaded
* implementation to a world, as there is a global one used by default * implementation to a world, as there is a global one used by default
* if no implementation is explicitly assigned. You should only assign * if no implementation is explicitly assigned. You should only assign
* each world an individual threading implementation instance if simulations * each world an individual threading implementation instance if simulations
* need to be run in parallel in multiple threads for the worlds. * need to be run in parallel in multiple threads for the worlds.
* *
* @returns ID of object allocated or NULL on failure * @returns ID of object allocated or NULL on failure
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
* @see dThreadingFreeImplementation * @see dThreadingFreeImplementation
*/ */
ODE_API dThreadingImplementationID dThreadingAllocateSelfThreadedImplementation(); ODE_API dThreadingImplementationID dThreadingAllocateSelfThreadedImplementation();
/** /**
* @brief Allocates built-in multi-threaded threading implementation object. * @brief Allocates built-in multi-threaded threading implementation object.
* *
* A multi-threaded implementation is a type of implementation that has to be * A multi-threaded implementation is a type of implementation that has to be
* served with a thread pool. The thread pool can be either the built-in ODE object * served with a thread pool. The thread pool can be either the built-in ODE object
* or set of external threads that dedicate themselves to this purpose and stay * or set of external threads that dedicate themselves to this purpose and stay
* in ODE until implementation releases them. * in ODE until implementation releases them.
* *
* @returns ID of object allocated or NULL on failure * @returns ID of object allocated or NULL on failure
* *
* @ingroup threading * @ingroup threading
* @see dThreadingThreadPoolServeMultiThreadedImplementation * @see dThreadingThreadPoolServeMultiThreadedImplementation
* @see dExternalThreadingServeMultiThreadedImplementation * @see dExternalThreadingServeMultiThreadedImplementation
* @see dThreadingFreeImplementation * @see dThreadingFreeImplementation
*/ */
ODE_API dThreadingImplementationID dThreadingAllocateMultiThreadedImplementation(); ODE_API dThreadingImplementationID dThreadingAllocateMultiThreadedImplementation();
/** /**
* @brief Retrieves the functions record of a built-in threading implementation. * @brief Retrieves the functions record of a built-in threading implementation.
* *
* The implementation can be the one allocated by ODE (from @c dThreadingAllocateMultiThreadedImplementation). * The implementation can be the one allocated by ODE (from @c dThreadingAllocateMultiThreadedImplementation).
* Do not use this function with self-made custom implementations - * Do not use this function with self-made custom implementations -
* they should be bundled with their own set of functions. * they should be bundled with their own set of functions.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @returns Pointer to associated functions structure * @returns Pointer to associated functions structure
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
*/ */
ODE_API const dThreadingFunctionsInfo *dThreadingImplementationGetFunctions(dThreadingImplementationID impl); ODE_API const dThreadingFunctionsInfo *dThreadingImplementationGetFunctions(dThreadingImplementationID impl);
/** /**
* @brief Requests a built-in implementation to release threads serving it. * @brief Requests a built-in implementation to release threads serving it.
* *
* The function unblocks threads employed in implementation serving and lets them * The function unblocks threads employed in implementation serving and lets them
* return to from where they originate. It's the responsibility of external code * return to from where they originate. It's the responsibility of external code
* to make sure all the calls to ODE that might be dependent on given threading * to make sure all the calls to ODE that might be dependent on given threading
* implementation object had already returned before this call is made. If threading * implementation object had already returned before this call is made. If threading
* implementation is still processing some posted calls while this function is * implementation is still processing some posted calls while this function is
* invoked the behavior is implementation dependent. * invoked the behavior is implementation dependent.
* *
* This call is to be used to request the threads to be released before waiting * This call is to be used to request the threads to be released before waiting
* for them in host pool or before waiting for them to exit. Implementation object * for them in host pool or before waiting for them to exit. Implementation object
* must not be destroyed before it is known that all the serving threads have already * must not be destroyed before it is known that all the serving threads have already
* returned from it. If implementation needs to be reused after this function is called * returned from it. If implementation needs to be reused after this function is called
* and all the threads have exited from it a call to @c dThreadingImplementationCleanupForRestart * and all the threads have exited from it a call to @c dThreadingImplementationCleanupForRestart
* must be made to restore internal state of the object. * must be made to restore internal state of the object.
* *
* If this function is called for self-threaded built-in threading implementation * If this function is called for self-threaded built-in threading implementation
* the call has no effect. * the call has no effect.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
* @see dThreadingImplementationCleanupForRestart * @see dThreadingImplementationCleanupForRestart
*/ */
ODE_API void dThreadingImplementationShutdownProcessing(dThreadingImplementationID impl); ODE_API void dThreadingImplementationShutdownProcessing(dThreadingImplementationID impl);
/** /**
* @brief Restores built-in implementation's state to let it be reused after shutdown. * @brief Restores built-in implementation's state to let it be reused after shutdown.
* *
* If a multi-threaded built-in implementation needs to be reused after a call * If a multi-threaded built-in implementation needs to be reused after a call
* to @c dThreadingImplementationShutdownProcessing this call is to be made to * to @c dThreadingImplementationShutdownProcessing this call is to be made to
* restore object's internal state. After that the implementation can be served again. * restore object's internal state. After that the implementation can be served again.
* *
* If this function is called for self-threaded built-in threading implementation * If this function is called for self-threaded built-in threading implementation
* the call has no effect. * the call has no effect.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
* @see dThreadingImplementationShutdownProcessing * @see dThreadingImplementationShutdownProcessing
*/ */
ODE_API void dThreadingImplementationCleanupForRestart(dThreadingImplementationID impl); ODE_API void dThreadingImplementationCleanupForRestart(dThreadingImplementationID impl);
/** /**
* @brief Deletes an instance of built-in threading implementation. * @brief Deletes an instance of built-in threading implementation.
* *
* @warning A care must be taken to make sure the implementation is unassigned * @warning A care must be taken to make sure the implementation is unassigned
* from all the objects it was assigned to and that there are no more threads * from all the objects it was assigned to and that there are no more threads
* serving it before attempting to call this function. * serving it before attempting to call this function.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
*/ */
ODE_API void dThreadingFreeImplementation(dThreadingImplementationID impl); ODE_API void dThreadingFreeImplementation(dThreadingImplementationID impl);
typedef void (dThreadReadyToServeCallback)(void *callback_context); typedef void (dThreadReadyToServeCallback)(void *callback_context);
/** /**
* @brief An entry point for external threads that would like to serve a built-in * @brief An entry point for external threads that would like to serve a built-in
* threading implementation object. * threading implementation object.
* *
* A thread that calls this function remains blocked in ODE and serves implementation * A thread that calls this function remains blocked in ODE and serves implementation
* object @p impl until being released with @c dThreadingImplementationShutdownProcessing call. * object @p impl until being released with @c dThreadingImplementationShutdownProcessing call.
* This function can be used to provide external threads instead of ODE's built-in * This function can be used to provide external threads instead of ODE's built-in
* thread pools. * thread pools.
* *
* The optional callback @readiness_callback is called after the thread has reached * The optional callback @readiness_callback is called after the thread has reached
* and has registered within the implementation. The implementation should not * and has registered within the implementation. The implementation should not
* be used until all dedicated threads register within it as otherwise it will not * be used until all dedicated threads register within it as otherwise it will not
* have accurate view of the execution resources available. * have accurate view of the execution resources available.
* *
* @param impl Threading implementation ID * @param impl Threading implementation ID
* @param readiness_callback Optional readiness callback to be called after thread enters the implementation * @param readiness_callback Optional readiness callback to be called after thread enters the implementation
* @param callback_context A value to be passed as parameter to readiness callback * @param callback_context A value to be passed as parameter to readiness callback
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
* @see dThreadingImplementationShutdownProcessing * @see dThreadingImplementationShutdownProcessing
*/ */
ODE_API void dExternalThreadingServeMultiThreadedImplementation(dThreadingImplementationID impl, ODE_API void dExternalThreadingServeMultiThreadedImplementation(dThreadingImplementationID impl,
dThreadReadyToServeCallback *readiness_callback/*=NULL*/, void *callback_context/*=NULL*/); dThreadReadyToServeCallback *readiness_callback/*=NULL*/, void *callback_context/*=NULL*/);
/** /**
* @brief Creates an instance of built-in thread pool object that can be used to serve * @brief Creates an instance of built-in thread pool object that can be used to serve
* multi-threaded threading implementations. * multi-threaded threading implementations.
* *
* The threads allocated inherit priority of caller thread. Their affinity is not * The threads allocated inherit priority of caller thread. Their affinity is not
* explicitly adjusted and gets the value the system assigns by default. Threads * explicitly adjusted and gets the value the system assigns by default. Threads
* have their stack memory fully committed immediately on start. On POSIX platforms * have their stack memory fully committed immediately on start. On POSIX platforms
* threads are started with all the possible signals blocked. Threads execute * threads are started with all the possible signals blocked. Threads execute
* calls to @c dAllocateODEDataForThread with @p ode_data_allocate_flags * calls to @c dAllocateODEDataForThread with @p ode_data_allocate_flags
* on initialization. * on initialization.
* *
* On POSIX platforms this function must be called with signals masked * On POSIX platforms this function must be called with signals masked
* or other measures must be taken to prevent reception of signals by calling thread * or other measures must be taken to prevent reception of signals by calling thread
* for the duration of the call. * for the duration of the call.
* *
* @param thread_count Number of threads to start in pool * @param thread_count Number of threads to start in pool
* @param stack_size Size of stack to be used for every thread or 0 for system default value * @param stack_size Size of stack to be used for every thread or 0 for system default value
* @param ode_data_allocate_flags Flags to be passed to @c dAllocateODEDataForThread on behalf of each thread * @param ode_data_allocate_flags Flags to be passed to @c dAllocateODEDataForThread on behalf of each thread
* @returns ID of object allocated or NULL on failure * @returns ID of object allocated or NULL on failure
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
* @see dThreadingImplementationShutdownProcessing * @see dThreadingImplementationShutdownProcessing
* @see dThreadingFreeThreadPool * @see dThreadingFreeThreadPool
*/ */
ODE_API dThreadingThreadPoolID dThreadingAllocateThreadPool(unsigned thread_count, ODE_API dThreadingThreadPoolID dThreadingAllocateThreadPool(unsigned thread_count,
dsizeint stack_size, unsigned int ode_data_allocate_flags, void *reserved/*=NULL*/); dsizeint stack_size, unsigned int ode_data_allocate_flags, void *reserved/*=NULL*/);
/** /**
* @brief Commands an instance of built-in thread pool to serve a built-in multi-threaded * @brief Commands an instance of built-in thread pool to serve a built-in multi-threaded
* threading implementation. * threading implementation.
* *
* A pool can only serve one threading implementation at a time. * A pool can only serve one threading implementation at a time.
* Call @c dThreadingImplementationShutdownProcessing to release pool threads * Call @c dThreadingImplementationShutdownProcessing to release pool threads
* from implementation serving and make them idle. Pool threads must be released * from implementation serving and make them idle. Pool threads must be released
* from any implementations before pool is attempted to be deleted. * from any implementations before pool is attempted to be deleted.
* *
* This function waits for threads to register within implementation before returning. * This function waits for threads to register within implementation before returning.
* So, after the function call exits the implementation can be used immediately. * So, after the function call exits the implementation can be used immediately.
* *
* @param pool Thread pool ID to serve the implementation * @param pool Thread pool ID to serve the implementation
* @param impl Implementation ID of implementation to be served * @param impl Implementation ID of implementation to be served
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateThreadPool * @see dThreadingAllocateThreadPool
* @see dThreadingAllocateMultiThreadedImplementation * @see dThreadingAllocateMultiThreadedImplementation
* @see dThreadingImplementationShutdownProcessing * @see dThreadingImplementationShutdownProcessing
*/ */
ODE_API void dThreadingThreadPoolServeMultiThreadedImplementation(dThreadingThreadPoolID pool, dThreadingImplementationID impl); ODE_API void dThreadingThreadPoolServeMultiThreadedImplementation(dThreadingThreadPoolID pool, dThreadingImplementationID impl);
/** /**
* @brief Waits until all pool threads are released from threading implementation * @brief Waits until all pool threads are released from threading implementation
* they might be serving. * they might be serving.
* *
* The function can be used after a call to @c dThreadingImplementationShutdownProcessing * The function can be used after a call to @c dThreadingImplementationShutdownProcessing
* to make sure all the threads have already been released by threading implementation * to make sure all the threads have already been released by threading implementation
* and it can be deleted or it can be cleaned up for restart and served by another pool * and it can be deleted or it can be cleaned up for restart and served by another pool
* or this pool's threads can be used to serve another threading implementation. * or this pool's threads can be used to serve another threading implementation.
* *
* Note that is it not necessary to call this function before pool destruction * Note that is it not necessary to call this function before pool destruction
* since @c dThreadingFreeThreadPool performs similar wait operation implicitly on its own. * since @c dThreadingFreeThreadPool performs similar wait operation implicitly on its own.
* *
* It is OK to call this function even if pool was not serving any threading implementation * It is OK to call this function even if pool was not serving any threading implementation
* in which case the call exits immediately with minimal delay. * in which case the call exits immediately with minimal delay.
* *
* @param pool Thread pool ID to wait for * @param pool Thread pool ID to wait for
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateThreadPool * @see dThreadingAllocateThreadPool
* @see dThreadingImplementationShutdownProcessing * @see dThreadingImplementationShutdownProcessing
* @see dThreadingFreeThreadPool * @see dThreadingFreeThreadPool
*/ */
ODE_API void dThreadingThreadPoolWaitIdleState(dThreadingThreadPoolID pool); ODE_API void dThreadingThreadPoolWaitIdleState(dThreadingThreadPoolID pool);
/** /**
* @brief Deletes a built-in thread pool instance. * @brief Deletes a built-in thread pool instance.
* *
* The pool threads must be released from any implementations they might be serving * The pool threads must be released from any implementations they might be serving
* before this function is called. Otherwise the call is going to block * before this function is called. Otherwise the call is going to block
* and wait until pool's threads return. * and wait until pool's threads return.
* *
* @param pool Thread pool ID to delete * @param pool Thread pool ID to delete
* *
* @ingroup threading * @ingroup threading
* @see dThreadingAllocateThreadPool * @see dThreadingAllocateThreadPool
* @see dThreadingImplementationShutdownProcessing * @see dThreadingImplementationShutdownProcessing
*/ */
ODE_API void dThreadingFreeThreadPool(dThreadingThreadPoolID pool); ODE_API void dThreadingFreeThreadPool(dThreadingThreadPoolID pool);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* #ifndef _ODE_THREADING_IMPL_H_ */ #endif /* #ifndef _ODE_THREADING_IMPL_H_ */

@ -1,76 +1,76 @@
/************************************************************************* /*************************************************************************
* * * *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org * * All rights reserved. Email: russ@q12.org Web: www.q12.org *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: * * modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free * * (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at * * Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser * * your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the * * General Public License is included with this library in the *
* file LICENSE.TXT. * * file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in * * (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. * * the file LICENSE-BSD.TXT. *
* * * *
* This library is distributed in the hope that it will be useful, * * This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* * * *
*************************************************************************/ *************************************************************************/
#ifndef _ODE_TIMER_H_ #ifndef _ODE_TIMER_H_
#define _ODE_TIMER_H_ #define _ODE_TIMER_H_
#include <ode/odeconfig.h> #include <ode/odeconfig.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* stop watch objects */ /* stop watch objects */
typedef struct dStopwatch { typedef struct dStopwatch {
double time; /* total clock count */ double time; /* total clock count */
unsigned long cc[2]; /* clock count since last `start' */ unsigned long cc[2]; /* clock count since last `start' */
} dStopwatch; } dStopwatch;
ODE_API void dStopwatchReset (dStopwatch *); ODE_API void dStopwatchReset (dStopwatch *);
ODE_API void dStopwatchStart (dStopwatch *); ODE_API void dStopwatchStart (dStopwatch *);
ODE_API void dStopwatchStop (dStopwatch *); ODE_API void dStopwatchStop (dStopwatch *);
ODE_API double dStopwatchTime (dStopwatch *); /* returns total time in secs */ ODE_API double dStopwatchTime (dStopwatch *); /* returns total time in secs */
/* code timers */ /* code timers */
ODE_API void dTimerStart (const char *description); /* pass a static string here */ ODE_API void dTimerStart (const char *description); /* pass a static string here */
ODE_API void dTimerNow (const char *description); /* pass a static string here */ ODE_API void dTimerNow (const char *description); /* pass a static string here */
ODE_API void dTimerEnd(void); ODE_API void dTimerEnd(void);
/* print out a timer report. if `average' is nonzero, print out the average /* print out a timer report. if `average' is nonzero, print out the average
* time for each slot (this is only meaningful if the same start-now-end * time for each slot (this is only meaningful if the same start-now-end
* calls are being made repeatedly. * calls are being made repeatedly.
*/ */
ODE_API void dTimerReport (FILE *fout, int average); ODE_API void dTimerReport (FILE *fout, int average);
/* resolution */ /* resolution */
/* returns the timer ticks per second implied by the timing hardware or API. /* returns the timer ticks per second implied by the timing hardware or API.
* the actual timer resolution may not be this great. * the actual timer resolution may not be this great.
*/ */
ODE_API double dTimerTicksPerSecond(void); ODE_API double dTimerTicksPerSecond(void);
/* returns an estimate of the actual timer resolution, in seconds. this may /* returns an estimate of the actual timer resolution, in seconds. this may
* be greater than 1/ticks_per_second. * be greater than 1/ticks_per_second.
*/ */
ODE_API double dTimerResolution(void); ODE_API double dTimerResolution(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

@ -1,6 +1,6 @@
#ifndef _ODE_VERSION_H_ #ifndef _ODE_VERSION_H_
#define _ODE_VERSION_H_ #define _ODE_VERSION_H_
#define dODE_VERSION "0.15" #define dODE_VERSION "0.15"
#endif #endif

@ -1,133 +1,133 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL.h * \file SDL.h
* *
* Main include header for the SDL library * Main include header for the SDL library
*/ */
#ifndef SDL_h_ #ifndef SDL_h_
#define SDL_h_ #define SDL_h_
#include "SDL_main.h" #include "SDL_main.h"
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_assert.h" #include "SDL_assert.h"
#include "SDL_atomic.h" #include "SDL_atomic.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_clipboard.h" #include "SDL_clipboard.h"
#include "SDL_cpuinfo.h" #include "SDL_cpuinfo.h"
#include "SDL_endian.h" #include "SDL_endian.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_filesystem.h" #include "SDL_filesystem.h"
#include "SDL_gamecontroller.h" #include "SDL_gamecontroller.h"
#include "SDL_haptic.h" #include "SDL_haptic.h"
#include "SDL_hints.h" #include "SDL_hints.h"
#include "SDL_joystick.h" #include "SDL_joystick.h"
#include "SDL_loadso.h" #include "SDL_loadso.h"
#include "SDL_log.h" #include "SDL_log.h"
#include "SDL_messagebox.h" #include "SDL_messagebox.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_power.h" #include "SDL_power.h"
#include "SDL_render.h" #include "SDL_render.h"
#include "SDL_rwops.h" #include "SDL_rwops.h"
#include "SDL_shape.h" #include "SDL_shape.h"
#include "SDL_system.h" #include "SDL_system.h"
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_version.h" #include "SDL_version.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* As of version 0.5, SDL is loaded dynamically into the application */ /* As of version 0.5, SDL is loaded dynamically into the application */
/** /**
* \name SDL_INIT_* * \name SDL_INIT_*
* *
* These are the flags which may be passed to SDL_Init(). You should * These are the flags which may be passed to SDL_Init(). You should
* specify the subsystems which you will be using in your application. * specify the subsystems which you will be using in your application.
*/ */
/* @{ */ /* @{ */
#define SDL_INIT_TIMER 0x00000001u #define SDL_INIT_TIMER 0x00000001u
#define SDL_INIT_AUDIO 0x00000010u #define SDL_INIT_AUDIO 0x00000010u
#define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ #define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
#define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ #define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */
#define SDL_INIT_HAPTIC 0x00001000u #define SDL_INIT_HAPTIC 0x00001000u
#define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ #define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
#define SDL_INIT_EVENTS 0x00004000u #define SDL_INIT_EVENTS 0x00004000u
#define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */ #define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */
#define SDL_INIT_EVERYTHING ( \ #define SDL_INIT_EVERYTHING ( \
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \
) )
/* @} */ /* @} */
/** /**
* This function initializes the subsystems specified by \c flags * This function initializes the subsystems specified by \c flags
*/ */
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
/** /**
* This function initializes specific SDL subsystems * This function initializes specific SDL subsystems
* *
* Subsystem initialization is ref-counted, you must call * Subsystem initialization is ref-counted, you must call
* SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly
* shutdown a subsystem manually (or call SDL_Quit() to force shutdown). * shutdown a subsystem manually (or call SDL_Quit() to force shutdown).
* If a subsystem is already loaded then this call will * If a subsystem is already loaded then this call will
* increase the ref-count and return. * increase the ref-count and return.
*/ */
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
/** /**
* This function cleans up specific SDL subsystems * This function cleans up specific SDL subsystems
*/ */
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
/** /**
* This function returns a mask of the specified subsystems which have * This function returns a mask of the specified subsystems which have
* previously been initialized. * previously been initialized.
* *
* If \c flags is 0, it returns a mask of all initialized subsystems. * If \c flags is 0, it returns a mask of all initialized subsystems.
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
/** /**
* This function cleans up all initialized subsystems. You should * This function cleans up all initialized subsystems. You should
* call it upon all exit conditions. * call it upon all exit conditions.
*/ */
extern DECLSPEC void SDLCALL SDL_Quit(void); extern DECLSPEC void SDLCALL SDL_Quit(void);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_h_ */ #endif /* SDL_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

@ -1,291 +1,291 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef SDL_assert_h_ #ifndef SDL_assert_h_
#define SDL_assert_h_ #define SDL_assert_h_
#include "SDL_config.h" #include "SDL_config.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef SDL_ASSERT_LEVEL #ifndef SDL_ASSERT_LEVEL
#ifdef SDL_DEFAULT_ASSERT_LEVEL #ifdef SDL_DEFAULT_ASSERT_LEVEL
#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL #define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
#elif defined(_DEBUG) || defined(DEBUG) || \ #elif defined(_DEBUG) || defined(DEBUG) || \
(defined(__GNUC__) && !defined(__OPTIMIZE__)) (defined(__GNUC__) && !defined(__OPTIMIZE__))
#define SDL_ASSERT_LEVEL 2 #define SDL_ASSERT_LEVEL 2
#else #else
#define SDL_ASSERT_LEVEL 1 #define SDL_ASSERT_LEVEL 1
#endif #endif
#endif /* SDL_ASSERT_LEVEL */ #endif /* SDL_ASSERT_LEVEL */
/* /*
These are macros and not first class functions so that the debugger breaks These are macros and not first class functions so that the debugger breaks
on the assertion line and not in some random guts of SDL, and so each on the assertion line and not in some random guts of SDL, and so each
assert can have unique static variables associated with it. assert can have unique static variables associated with it.
*/ */
#if defined(_MSC_VER) #if defined(_MSC_VER)
/* Don't include intrin.h here because it contains C++ code */ /* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void); extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak() #define SDL_TriggerBreakpoint() __debugbreak()
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) #elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif defined(__386__) && defined(__WATCOMC__) #elif defined(__386__) && defined(__WATCOMC__)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } } #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) #elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
#include <signal.h> #include <signal.h>
#define SDL_TriggerBreakpoint() raise(SIGTRAP) #define SDL_TriggerBreakpoint() raise(SIGTRAP)
#else #else
/* How do we trigger breakpoints on this platform? */ /* How do we trigger breakpoints on this platform? */
#define SDL_TriggerBreakpoint() #define SDL_TriggerBreakpoint()
#endif #endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
# define SDL_FUNCTION __func__ # define SDL_FUNCTION __func__
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__)) #elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__))
# define SDL_FUNCTION __FUNCTION__ # define SDL_FUNCTION __FUNCTION__
#else #else
# define SDL_FUNCTION "???" # define SDL_FUNCTION "???"
#endif #endif
#define SDL_FILE __FILE__ #define SDL_FILE __FILE__
#define SDL_LINE __LINE__ #define SDL_LINE __LINE__
/* /*
sizeof (x) makes the compiler still parse the expression even without sizeof (x) makes the compiler still parse the expression even without
assertions enabled, so the code is always checked at compile time, but assertions enabled, so the code is always checked at compile time, but
doesn't actually generate code for it, so there are no side effects or doesn't actually generate code for it, so there are no side effects or
expensive checks at run time, just the constant size of what x WOULD be, expensive checks at run time, just the constant size of what x WOULD be,
which presumably gets optimized out as unused. which presumably gets optimized out as unused.
This also solves the problem of... This also solves the problem of...
int somevalue = blah(); int somevalue = blah();
SDL_assert(somevalue == 1); SDL_assert(somevalue == 1);
...which would cause compiles to complain that somevalue is unused if we ...which would cause compiles to complain that somevalue is unused if we
disable assertions. disable assertions.
*/ */
/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking /* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
this condition isn't constant. And looks like an owl's face! */ this condition isn't constant. And looks like an owl's face! */
#ifdef _MSC_VER /* stupid /W4 warnings. */ #ifdef _MSC_VER /* stupid /W4 warnings. */
#define SDL_NULL_WHILE_LOOP_CONDITION (0,0) #define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
#else #else
#define SDL_NULL_WHILE_LOOP_CONDITION (0) #define SDL_NULL_WHILE_LOOP_CONDITION (0)
#endif #endif
#define SDL_disabled_assert(condition) \ #define SDL_disabled_assert(condition) \
do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
typedef enum typedef enum
{ {
SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */
SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */
SDL_ASSERTION_ABORT, /**< Terminate the program. */ SDL_ASSERTION_ABORT, /**< Terminate the program. */
SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */
} SDL_AssertState; } SDL_AssertState;
typedef struct SDL_AssertData typedef struct SDL_AssertData
{ {
int always_ignore; int always_ignore;
unsigned int trigger_count; unsigned int trigger_count;
const char *condition; const char *condition;
const char *filename; const char *filename;
int linenum; int linenum;
const char *function; const char *function;
const struct SDL_AssertData *next; const struct SDL_AssertData *next;
} SDL_AssertData; } SDL_AssertData;
#if (SDL_ASSERT_LEVEL > 0) #if (SDL_ASSERT_LEVEL > 0)
/* Never call this directly. Use the SDL_assert* macros. */ /* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *, const char *,
const char *, int) const char *, int)
#if defined(__clang__) #if defined(__clang__)
#if __has_feature(attribute_analyzer_noreturn) #if __has_feature(attribute_analyzer_noreturn)
/* this tells Clang's static analysis that we're a custom assert function, /* this tells Clang's static analysis that we're a custom assert function,
and that the analyzer should assume the condition was always true past this and that the analyzer should assume the condition was always true past this
SDL_assert test. */ SDL_assert test. */
__attribute__((analyzer_noreturn)) __attribute__((analyzer_noreturn))
#endif #endif
#endif #endif
; ;
/* the do {} while(0) avoids dangling else problems: /* the do {} while(0) avoids dangling else problems:
if (x) SDL_assert(y); else blah(); if (x) SDL_assert(y); else blah();
... without the do/while, the "else" could attach to this macro's "if". ... without the do/while, the "else" could attach to this macro's "if".
We try to handle just the minimum we need here in a macro...the loop, We try to handle just the minimum we need here in a macro...the loop,
the static vars, and break points. The heavy lifting is handled in the static vars, and break points. The heavy lifting is handled in
SDL_ReportAssertion(), in SDL_assert.c. SDL_ReportAssertion(), in SDL_assert.c.
*/ */
#define SDL_enabled_assert(condition) \ #define SDL_enabled_assert(condition) \
do { \ do { \
while ( !(condition) ) { \ while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { \ static struct SDL_AssertData sdl_assert_data = { \
0, 0, #condition, 0, 0, 0, 0 \ 0, 0, #condition, 0, 0, 0, 0 \
}; \ }; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \ continue; /* go again. */ \
} else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
SDL_TriggerBreakpoint(); \ SDL_TriggerBreakpoint(); \
} \ } \
break; /* not retrying. */ \ break; /* not retrying. */ \
} \ } \
} while (SDL_NULL_WHILE_LOOP_CONDITION) } while (SDL_NULL_WHILE_LOOP_CONDITION)
#endif /* enabled assertions support code */ #endif /* enabled assertions support code */
/* Enable various levels of assertions. */ /* Enable various levels of assertions. */
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ #if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
# define SDL_assert(condition) SDL_disabled_assert(condition) # define SDL_assert(condition) SDL_disabled_assert(condition)
# define SDL_assert_release(condition) SDL_disabled_assert(condition) # define SDL_assert_release(condition) SDL_disabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
#elif SDL_ASSERT_LEVEL == 1 /* release settings. */ #elif SDL_ASSERT_LEVEL == 1 /* release settings. */
# define SDL_assert(condition) SDL_disabled_assert(condition) # define SDL_assert(condition) SDL_disabled_assert(condition)
# define SDL_assert_release(condition) SDL_enabled_assert(condition) # define SDL_assert_release(condition) SDL_enabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */ #elif SDL_ASSERT_LEVEL == 2 /* normal settings. */
# define SDL_assert(condition) SDL_enabled_assert(condition) # define SDL_assert(condition) SDL_enabled_assert(condition)
# define SDL_assert_release(condition) SDL_enabled_assert(condition) # define SDL_assert_release(condition) SDL_enabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ #elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */
# define SDL_assert(condition) SDL_enabled_assert(condition) # define SDL_assert(condition) SDL_enabled_assert(condition)
# define SDL_assert_release(condition) SDL_enabled_assert(condition) # define SDL_assert_release(condition) SDL_enabled_assert(condition)
# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) # define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
#else #else
# error Unknown assertion level. # error Unknown assertion level.
#endif #endif
/* this assertion is never disabled at any level. */ /* this assertion is never disabled at any level. */
#define SDL_assert_always(condition) SDL_enabled_assert(condition) #define SDL_assert_always(condition) SDL_enabled_assert(condition)
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
const SDL_AssertData* data, void* userdata); const SDL_AssertData* data, void* userdata);
/** /**
* \brief Set an application-defined assertion handler. * \brief Set an application-defined assertion handler.
* *
* This allows an app to show its own assertion UI and/or force the * This allows an app to show its own assertion UI and/or force the
* response to an assertion failure. If the app doesn't provide this, SDL * response to an assertion failure. If the app doesn't provide this, SDL
* will try to do the right thing, popping up a system-specific GUI dialog, * will try to do the right thing, popping up a system-specific GUI dialog,
* and probably minimizing any fullscreen windows. * and probably minimizing any fullscreen windows.
* *
* This callback may fire from any thread, but it runs wrapped in a mutex, so * This callback may fire from any thread, but it runs wrapped in a mutex, so
* it will only fire from one thread at a time. * it will only fire from one thread at a time.
* *
* Setting the callback to NULL restores SDL's original internal handler. * Setting the callback to NULL restores SDL's original internal handler.
* *
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()! * This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
* *
* Return SDL_AssertState value of how to handle the assertion failure. * Return SDL_AssertState value of how to handle the assertion failure.
* *
* \param handler Callback function, called when an assertion fails. * \param handler Callback function, called when an assertion fails.
* \param userdata A pointer passed to the callback as-is. * \param userdata A pointer passed to the callback as-is.
*/ */
extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
SDL_AssertionHandler handler, SDL_AssertionHandler handler,
void *userdata); void *userdata);
/** /**
* \brief Get the default assertion handler. * \brief Get the default assertion handler.
* *
* This returns the function pointer that is called by default when an * This returns the function pointer that is called by default when an
* assertion is triggered. This is an internal function provided by SDL, * assertion is triggered. This is an internal function provided by SDL,
* that is used for assertions when SDL_SetAssertionHandler() hasn't been * that is used for assertions when SDL_SetAssertionHandler() hasn't been
* used to provide a different function. * used to provide a different function.
* *
* \return The default SDL_AssertionHandler that is called when an assert triggers. * \return The default SDL_AssertionHandler that is called when an assert triggers.
*/ */
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);
/** /**
* \brief Get the current assertion handler. * \brief Get the current assertion handler.
* *
* This returns the function pointer that is called when an assertion is * This returns the function pointer that is called when an assertion is
* triggered. This is either the value last passed to * triggered. This is either the value last passed to
* SDL_SetAssertionHandler(), or if no application-specified function is * SDL_SetAssertionHandler(), or if no application-specified function is
* set, is equivalent to calling SDL_GetDefaultAssertionHandler(). * set, is equivalent to calling SDL_GetDefaultAssertionHandler().
* *
* \param puserdata Pointer to a void*, which will store the "userdata" * \param puserdata Pointer to a void*, which will store the "userdata"
* pointer that was passed to SDL_SetAssertionHandler(). * pointer that was passed to SDL_SetAssertionHandler().
* This value will always be NULL for the default handler. * This value will always be NULL for the default handler.
* If you don't care about this data, it is safe to pass * If you don't care about this data, it is safe to pass
* a NULL pointer to this function to ignore it. * a NULL pointer to this function to ignore it.
* \return The SDL_AssertionHandler that is called when an assert triggers. * \return The SDL_AssertionHandler that is called when an assert triggers.
*/ */
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);
/** /**
* \brief Get a list of all assertion failures. * \brief Get a list of all assertion failures.
* *
* Get all assertions triggered since last call to SDL_ResetAssertionReport(), * Get all assertions triggered since last call to SDL_ResetAssertionReport(),
* or the start of the program. * or the start of the program.
* *
* The proper way to examine this data looks something like this: * The proper way to examine this data looks something like this:
* *
* <code> * <code>
* const SDL_AssertData *item = SDL_GetAssertionReport(); * const SDL_AssertData *item = SDL_GetAssertionReport();
* while (item) { * while (item) {
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n",
* item->condition, item->function, item->filename, * item->condition, item->function, item->filename,
* item->linenum, item->trigger_count, * item->linenum, item->trigger_count,
* item->always_ignore ? "yes" : "no"); * item->always_ignore ? "yes" : "no");
* item = item->next; * item = item->next;
* } * }
* </code> * </code>
* *
* \return List of all assertions. * \return List of all assertions.
* \sa SDL_ResetAssertionReport * \sa SDL_ResetAssertionReport
*/ */
extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
/** /**
* \brief Reset the list of all assertion failures. * \brief Reset the list of all assertion failures.
* *
* Reset list of all assertions triggered. * Reset list of all assertions triggered.
* *
* \sa SDL_GetAssertionReport * \sa SDL_GetAssertionReport
*/ */
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
/* these had wrong naming conventions until 2.0.4. Please update your app! */ /* these had wrong naming conventions until 2.0.4. Please update your app! */
#define SDL_assert_state SDL_AssertState #define SDL_assert_state SDL_AssertState
#define SDL_assert_data SDL_AssertData #define SDL_assert_data SDL_AssertData
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_assert_h_ */ #endif /* SDL_assert_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

@ -1,274 +1,274 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_atomic.h * \file SDL_atomic.h
* *
* Atomic operations. * Atomic operations.
* *
* IMPORTANT: * IMPORTANT:
* If you are not an expert in concurrent lockless programming, you should * If you are not an expert in concurrent lockless programming, you should
* only be using the atomic lock and reference counting functions in this * only be using the atomic lock and reference counting functions in this
* file. In all other cases you should be protecting your data structures * file. In all other cases you should be protecting your data structures
* with full mutexes. * with full mutexes.
* *
* The list of "safe" functions to use are: * The list of "safe" functions to use are:
* SDL_AtomicLock() * SDL_AtomicLock()
* SDL_AtomicUnlock() * SDL_AtomicUnlock()
* SDL_AtomicIncRef() * SDL_AtomicIncRef()
* SDL_AtomicDecRef() * SDL_AtomicDecRef()
* *
* Seriously, here be dragons! * Seriously, here be dragons!
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
* *
* You can find out a little more about lockless programming and the * You can find out a little more about lockless programming and the
* subtle issues that can arise here: * subtle issues that can arise here:
* http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx
* *
* There's also lots of good information here: * There's also lots of good information here:
* http://www.1024cores.net/home/lock-free-algorithms * http://www.1024cores.net/home/lock-free-algorithms
* http://preshing.com/ * http://preshing.com/
* *
* These operations may or may not actually be implemented using * These operations may or may not actually be implemented using
* processor specific atomic operations. When possible they are * processor specific atomic operations. When possible they are
* implemented as true processor specific atomic operations. When that * implemented as true processor specific atomic operations. When that
* is not possible the are implemented using locks that *do* use the * is not possible the are implemented using locks that *do* use the
* available atomic operations. * available atomic operations.
* *
* All of the atomic operations that modify memory are full memory barriers. * All of the atomic operations that modify memory are full memory barriers.
*/ */
#ifndef SDL_atomic_h_ #ifndef SDL_atomic_h_
#define SDL_atomic_h_ #define SDL_atomic_h_
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_platform.h" #include "SDL_platform.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**
* \name SDL AtomicLock * \name SDL AtomicLock
* *
* The atomic locks are efficient spinlocks using CPU instructions, * The atomic locks are efficient spinlocks using CPU instructions,
* but are vulnerable to starvation and can spin forever if a thread * but are vulnerable to starvation and can spin forever if a thread
* holding a lock has been terminated. For this reason you should * holding a lock has been terminated. For this reason you should
* minimize the code executed inside an atomic lock and never do * minimize the code executed inside an atomic lock and never do
* expensive things like API or system calls while holding them. * expensive things like API or system calls while holding them.
* *
* The atomic locks are not safe to lock recursively. * The atomic locks are not safe to lock recursively.
* *
* Porting Note: * Porting Note:
* The spin lock functions and type are required and can not be * The spin lock functions and type are required and can not be
* emulated because they are used in the atomic emulation code. * emulated because they are used in the atomic emulation code.
*/ */
/* @{ */ /* @{ */
typedef int SDL_SpinLock; typedef int SDL_SpinLock;
/** /**
* \brief Try to lock a spin lock by setting it to a non-zero value. * \brief Try to lock a spin lock by setting it to a non-zero value.
* *
* \param lock Points to the lock. * \param lock Points to the lock.
* *
* \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
/** /**
* \brief Lock a spin lock by setting it to a non-zero value. * \brief Lock a spin lock by setting it to a non-zero value.
* *
* \param lock Points to the lock. * \param lock Points to the lock.
*/ */
extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
/** /**
* \brief Unlock a spin lock by setting it to 0. Always returns immediately * \brief Unlock a spin lock by setting it to 0. Always returns immediately
* *
* \param lock Points to the lock. * \param lock Points to the lock.
*/ */
extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
/* @} *//* SDL AtomicLock */ /* @} *//* SDL AtomicLock */
/** /**
* The compiler barrier prevents the compiler from reordering * The compiler barrier prevents the compiler from reordering
* reads and writes to globally visible variables across the call. * reads and writes to globally visible variables across the call.
*/ */
#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__) #if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
void _ReadWriteBarrier(void); void _ReadWriteBarrier(void);
#pragma intrinsic(_ReadWriteBarrier) #pragma intrinsic(_ReadWriteBarrier)
#define SDL_CompilerBarrier() _ReadWriteBarrier() #define SDL_CompilerBarrier() _ReadWriteBarrier()
#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) #elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ /* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") #define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
extern _inline void SDL_CompilerBarrier (void); extern _inline void SDL_CompilerBarrier (void);
#pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; #pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];
#else #else
#define SDL_CompilerBarrier() \ #define SDL_CompilerBarrier() \
{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); } { SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); }
#endif #endif
/** /**
* Memory barriers are designed to prevent reads and writes from being * Memory barriers are designed to prevent reads and writes from being
* reordered by the compiler and being seen out of order on multi-core CPUs. * reordered by the compiler and being seen out of order on multi-core CPUs.
* *
* A typical pattern would be for thread A to write some data and a flag, * A typical pattern would be for thread A to write some data and a flag,
* and for thread B to read the flag and get the data. In this case you * and for thread B to read the flag and get the data. In this case you
* would insert a release barrier between writing the data and the flag, * would insert a release barrier between writing the data and the flag,
* guaranteeing that the data write completes no later than the flag is * guaranteeing that the data write completes no later than the flag is
* written, and you would insert an acquire barrier between reading the * written, and you would insert an acquire barrier between reading the
* flag and reading the data, to ensure that all the reads associated * flag and reading the data, to ensure that all the reads associated
* with the flag have completed. * with the flag have completed.
* *
* In this pattern you should always see a release barrier paired with * In this pattern you should always see a release barrier paired with
* an acquire barrier and you should gate the data reads/writes with a * an acquire barrier and you should gate the data reads/writes with a
* single flag variable. * single flag variable.
* *
* For more information on these semantics, take a look at the blog post: * For more information on these semantics, take a look at the blog post:
* http://preshing.com/20120913/acquire-and-release-semantics * http://preshing.com/20120913/acquire-and-release-semantics
*/ */
extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);
extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory")
#elif defined(__GNUC__) && defined(__arm__) #elif defined(__GNUC__) && defined(__arm__)
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__)
#ifdef __thumb__ #ifdef __thumb__
/* The mcr instruction isn't available in thumb mode, use real functions */ /* The mcr instruction isn't available in thumb mode, use real functions */
#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() #define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction()
#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() #define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction()
#else #else
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
#endif /* __thumb__ */ #endif /* __thumb__ */
#else #else
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory")
#endif /* __GNUC__ && __arm__ */ #endif /* __GNUC__ && __arm__ */
#else #else
#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) #if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120))
/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */ /* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */
#include <mbarrier.h> #include <mbarrier.h>
#define SDL_MemoryBarrierRelease() __machine_rel_barrier() #define SDL_MemoryBarrierRelease() __machine_rel_barrier()
#define SDL_MemoryBarrierAcquire() __machine_acq_barrier() #define SDL_MemoryBarrierAcquire() __machine_acq_barrier()
#else #else
/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ /* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */
#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() #define SDL_MemoryBarrierRelease() SDL_CompilerBarrier()
#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() #define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier()
#endif #endif
#endif #endif
/** /**
* \brief A type representing an atomic integer value. It is a struct * \brief A type representing an atomic integer value. It is a struct
* so people don't accidentally use numeric operations on it. * so people don't accidentally use numeric operations on it.
*/ */
typedef struct { int value; } SDL_atomic_t; typedef struct { int value; } SDL_atomic_t;
/** /**
* \brief Set an atomic variable to a new value if it is currently an old value. * \brief Set an atomic variable to a new value if it is currently an old value.
* *
* \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
* *
* \note If you don't know what this function is for, you shouldn't use it! * \note If you don't know what this function is for, you shouldn't use it!
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval);
/** /**
* \brief Set an atomic variable to a value. * \brief Set an atomic variable to a value.
* *
* \return The previous value of the atomic variable. * \return The previous value of the atomic variable.
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
/** /**
* \brief Get the value of an atomic variable * \brief Get the value of an atomic variable
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
/** /**
* \brief Add to an atomic variable. * \brief Add to an atomic variable.
* *
* \return The previous value of the atomic variable. * \return The previous value of the atomic variable.
* *
* \note This same style can be used for any number operation * \note This same style can be used for any number operation
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
/** /**
* \brief Increment an atomic variable used as a reference count. * \brief Increment an atomic variable used as a reference count.
*/ */
#ifndef SDL_AtomicIncRef #ifndef SDL_AtomicIncRef
#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1) #define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1)
#endif #endif
/** /**
* \brief Decrement an atomic variable used as a reference count. * \brief Decrement an atomic variable used as a reference count.
* *
* \return SDL_TRUE if the variable reached zero after decrementing, * \return SDL_TRUE if the variable reached zero after decrementing,
* SDL_FALSE otherwise * SDL_FALSE otherwise
*/ */
#ifndef SDL_AtomicDecRef #ifndef SDL_AtomicDecRef
#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1) #define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1)
#endif #endif
/** /**
* \brief Set a pointer to a new value if it is currently an old value. * \brief Set a pointer to a new value if it is currently an old value.
* *
* \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise.
* *
* \note If you don't know what this function is for, you shouldn't use it! * \note If you don't know what this function is for, you shouldn't use it!
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval); extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval);
/** /**
* \brief Set a pointer to a value atomically. * \brief Set a pointer to a value atomically.
* *
* \return The previous value of the pointer. * \return The previous value of the pointer.
*/ */
extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v); extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);
/** /**
* \brief Get the value of a pointer atomically. * \brief Get the value of a pointer atomically.
*/ */
extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a); extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_atomic_h_ */ #endif /* SDL_atomic_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

File diff suppressed because it is too large Load Diff

@ -1,112 +1,112 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_bits.h * \file SDL_bits.h
* *
* Functions for fiddling with bits and bitmasks. * Functions for fiddling with bits and bitmasks.
*/ */
#ifndef SDL_bits_h_ #ifndef SDL_bits_h_
#define SDL_bits_h_ #define SDL_bits_h_
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**
* \file SDL_bits.h * \file SDL_bits.h
*/ */
/** /**
* Get the index of the most significant bit. Result is undefined when called * Get the index of the most significant bit. Result is undefined when called
* with 0. This operation can also be stated as "count leading zeroes" and * with 0. This operation can also be stated as "count leading zeroes" and
* "log base 2". * "log base 2".
* *
* \return Index of the most significant bit, or -1 if the value is 0. * \return Index of the most significant bit, or -1 if the value is 0.
*/ */
#if defined(__WATCOMC__) && defined(__386__) #if defined(__WATCOMC__) && defined(__386__)
extern _inline int _SDL_clz_watcom (Uint32); extern _inline int _SDL_clz_watcom (Uint32);
#pragma aux _SDL_clz_watcom = \ #pragma aux _SDL_clz_watcom = \
"bsr eax, eax" \ "bsr eax, eax" \
"xor eax, 31" \ "xor eax, 31" \
parm [eax] nomemory \ parm [eax] nomemory \
value [eax] \ value [eax] \
modify exact [eax] nomemory; modify exact [eax] nomemory;
#endif #endif
SDL_FORCE_INLINE int SDL_FORCE_INLINE int
SDL_MostSignificantBitIndex32(Uint32 x) SDL_MostSignificantBitIndex32(Uint32 x)
{ {
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
/* Count Leading Zeroes builtin in GCC. /* Count Leading Zeroes builtin in GCC.
* http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html
*/ */
if (x == 0) { if (x == 0) {
return -1; return -1;
} }
return 31 - __builtin_clz(x); return 31 - __builtin_clz(x);
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
if (x == 0) { if (x == 0) {
return -1; return -1;
} }
return 31 - _SDL_clz_watcom(x); return 31 - _SDL_clz_watcom(x);
#else #else
/* Based off of Bit Twiddling Hacks by Sean Eron Anderson /* Based off of Bit Twiddling Hacks by Sean Eron Anderson
* <seander@cs.stanford.edu>, released in the public domain. * <seander@cs.stanford.edu>, released in the public domain.
* http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
*/ */
const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
const int S[] = {1, 2, 4, 8, 16}; const int S[] = {1, 2, 4, 8, 16};
int msbIndex = 0; int msbIndex = 0;
int i; int i;
if (x == 0) { if (x == 0) {
return -1; return -1;
} }
for (i = 4; i >= 0; i--) for (i = 4; i >= 0; i--)
{ {
if (x & b[i]) if (x & b[i])
{ {
x >>= S[i]; x >>= S[i];
msbIndex |= S[i]; msbIndex |= S[i];
} }
} }
return msbIndex; return msbIndex;
#endif #endif
} }
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_bits_h_ */ #endif /* SDL_bits_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

@ -1,120 +1,120 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_blendmode.h * \file SDL_blendmode.h
* *
* Header file declaring the SDL_BlendMode enumeration * Header file declaring the SDL_BlendMode enumeration
*/ */
#ifndef SDL_blendmode_h_ #ifndef SDL_blendmode_h_
#define SDL_blendmode_h_ #define SDL_blendmode_h_
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**
* \brief The blend mode used in SDL_RenderCopy() and drawing operations. * \brief The blend mode used in SDL_RenderCopy() and drawing operations.
*/ */
typedef enum typedef enum
{ {
SDL_BLENDMODE_NONE = 0x00000000, /**< no blending SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
dstRGBA = srcRGBA */ dstRGBA = srcRGBA */
SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
dstA = srcA + (dstA * (1-srcA)) */ dstA = srcA + (dstA * (1-srcA)) */
SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending
dstRGB = (srcRGB * srcA) + dstRGB dstRGB = (srcRGB * srcA) + dstRGB
dstA = dstA */ dstA = dstA */
SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate
dstRGB = srcRGB * dstRGB dstRGB = srcRGB * dstRGB
dstA = dstA */ dstA = dstA */
SDL_BLENDMODE_INVALID = 0x7FFFFFFF SDL_BLENDMODE_INVALID = 0x7FFFFFFF
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
} SDL_BlendMode; } SDL_BlendMode;
/** /**
* \brief The blend operation used when combining source and destination pixel components * \brief The blend operation used when combining source and destination pixel components
*/ */
typedef enum typedef enum
{ {
SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */
SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */ SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */
SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */ SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */
} SDL_BlendOperation; } SDL_BlendOperation;
/** /**
* \brief The normalized factor used to multiply pixel components * \brief The normalized factor used to multiply pixel components
*/ */
typedef enum typedef enum
{ {
SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */
SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */
SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */ SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */
SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */ SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */
SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */ SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */ SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */
SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */ SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */
SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */
} SDL_BlendFactor; } SDL_BlendFactor;
/** /**
* \brief Create a custom blend mode, which may or may not be supported by a given renderer * \brief Create a custom blend mode, which may or may not be supported by a given renderer
* *
* \param srcColorFactor * \param srcColorFactor
* \param dstColorFactor * \param dstColorFactor
* \param colorOperation * \param colorOperation
* \param srcAlphaFactor * \param srcAlphaFactor
* \param dstAlphaFactor * \param dstAlphaFactor
* \param alphaOperation * \param alphaOperation
* *
* The result of the blend mode operation will be: * The result of the blend mode operation will be:
* dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor
* and * and
* dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor * dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor
*/ */
extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor,
SDL_BlendFactor dstColorFactor, SDL_BlendFactor dstColorFactor,
SDL_BlendOperation colorOperation, SDL_BlendOperation colorOperation,
SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor srcAlphaFactor,
SDL_BlendFactor dstAlphaFactor, SDL_BlendFactor dstAlphaFactor,
SDL_BlendOperation alphaOperation); SDL_BlendOperation alphaOperation);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_blendmode_h_ */ #endif /* SDL_blendmode_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

@ -1,71 +1,71 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_clipboard.h * \file SDL_clipboard.h
* *
* Include file for SDL clipboard handling * Include file for SDL clipboard handling
*/ */
#ifndef SDL_clipboard_h_ #ifndef SDL_clipboard_h_
#define SDL_clipboard_h_ #define SDL_clipboard_h_
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Function prototypes */ /* Function prototypes */
/** /**
* \brief Put UTF-8 text into the clipboard * \brief Put UTF-8 text into the clipboard
* *
* \sa SDL_GetClipboardText() * \sa SDL_GetClipboardText()
*/ */
extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
/** /**
* \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
* *
* \sa SDL_SetClipboardText() * \sa SDL_SetClipboardText()
*/ */
extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
/** /**
* \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty
* *
* \sa SDL_GetClipboardText() * \sa SDL_GetClipboardText()
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_clipboard_h_ */ #endif /* SDL_clipboard_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

@ -1,393 +1,393 @@
/* include/SDL_config.h. Generated from SDL_config.h.in by configure. */ /* include/SDL_config.h. Generated from SDL_config.h.in by configure. */
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef SDL_config_h_ #ifndef SDL_config_h_
#define SDL_config_h_ #define SDL_config_h_
/** /**
* \file SDL_config.h.in * \file SDL_config.h.in
* *
* This is a set of defines to configure the SDL features * This is a set of defines to configure the SDL features
*/ */
/* General platform specific identifiers */ /* General platform specific identifiers */
#include "SDL_platform.h" #include "SDL_platform.h"
/* Make sure that this isn't included by Visual C++ */ /* Make sure that this isn't included by Visual C++ */
#ifdef _MSC_VER #ifdef _MSC_VER
#error You should run hg revert SDL_config.h #error You should run hg revert SDL_config.h
#endif #endif
/* C language features */ /* C language features */
/* #undef const */ /* #undef const */
/* #undef inline */ /* #undef inline */
/* #undef volatile */ /* #undef volatile */
/* C datatypes */ /* C datatypes */
#ifdef __LP64__ #ifdef __LP64__
#define SIZEOF_VOIDP 8 #define SIZEOF_VOIDP 8
#else #else
#define SIZEOF_VOIDP 4 #define SIZEOF_VOIDP 4
#endif #endif
#define HAVE_GCC_ATOMICS 1 #define HAVE_GCC_ATOMICS 1
/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */ /* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
/* Comment this if you want to build without any C library requirements */ /* Comment this if you want to build without any C library requirements */
#define HAVE_LIBC 1 #define HAVE_LIBC 1
#if HAVE_LIBC #if HAVE_LIBC
/* Useful headers */ /* Useful headers */
#define STDC_HEADERS 1 #define STDC_HEADERS 1
#define HAVE_ALLOCA_H 1 #define HAVE_ALLOCA_H 1
#define HAVE_CTYPE_H 1 #define HAVE_CTYPE_H 1
#define HAVE_FLOAT_H 1 #define HAVE_FLOAT_H 1
#define HAVE_ICONV_H 1 #define HAVE_ICONV_H 1
#define HAVE_INTTYPES_H 1 #define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1 #define HAVE_LIMITS_H 1
#define HAVE_MALLOC_H 1 #define HAVE_MALLOC_H 1
#define HAVE_MATH_H 1 #define HAVE_MATH_H 1
#define HAVE_MEMORY_H 1 #define HAVE_MEMORY_H 1
#define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1 #define HAVE_STDARG_H 1
#define HAVE_STDINT_H 1 #define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1 #define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1 #define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1 #define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1 #define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1 #define HAVE_SYS_TYPES_H 1
#define HAVE_WCHAR_H 1 #define HAVE_WCHAR_H 1
/* #undef HAVE_PTHREAD_NP_H */ /* #undef HAVE_PTHREAD_NP_H */
/* #undef HAVE_LIBUNWIND_H */ /* #undef HAVE_LIBUNWIND_H */
/* C library functions */ /* C library functions */
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1 #define HAVE_ALLOCA 1
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ #ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1
#endif #endif
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_BCOPY 1 #define HAVE_BCOPY 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1
#define HAVE_MEMCPY 1 #define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1 #define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1 #define HAVE_MEMCMP 1
#define HAVE_WCSLEN 1 #define HAVE_WCSLEN 1
/* #undef HAVE_WCSLCPY */ /* #undef HAVE_WCSLCPY */
/* #undef HAVE_WCSLCAT */ /* #undef HAVE_WCSLCAT */
#define HAVE_WCSCMP 1 #define HAVE_WCSCMP 1
#define HAVE_STRLEN 1 #define HAVE_STRLEN 1
/* #undef HAVE_STRLCPY */ /* #undef HAVE_STRLCPY */
/* #undef HAVE_STRLCAT */ /* #undef HAVE_STRLCAT */
/* #undef HAVE__STRREV */ /* #undef HAVE__STRREV */
/* #undef HAVE__STRUPR */ /* #undef HAVE__STRUPR */
/* #undef HAVE__STRLWR */ /* #undef HAVE__STRLWR */
/* #undef HAVE_INDEX */ /* #undef HAVE_INDEX */
/* #undef HAVE_RINDEX */ /* #undef HAVE_RINDEX */
#define HAVE_STRCHR 1 #define HAVE_STRCHR 1
#define HAVE_STRRCHR 1 #define HAVE_STRRCHR 1
#define HAVE_STRSTR 1 #define HAVE_STRSTR 1
/* #undef HAVE_ITOA */ /* #undef HAVE_ITOA */
/* #undef HAVE__LTOA */ /* #undef HAVE__LTOA */
/* #undef HAVE__UITOA */ /* #undef HAVE__UITOA */
/* #undef HAVE__ULTOA */ /* #undef HAVE__ULTOA */
#define HAVE_STRTOL 1 #define HAVE_STRTOL 1
#define HAVE_STRTOUL 1 #define HAVE_STRTOUL 1
/* #undef HAVE__I64TOA */ /* #undef HAVE__I64TOA */
/* #undef HAVE__UI64TOA */ /* #undef HAVE__UI64TOA */
#define HAVE_STRTOLL 1 #define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1 #define HAVE_STRTOULL 1
#define HAVE_STRTOD 1 #define HAVE_STRTOD 1
#define HAVE_ATOI 1 #define HAVE_ATOI 1
#define HAVE_ATOF 1 #define HAVE_ATOF 1
#define HAVE_STRCMP 1 #define HAVE_STRCMP 1
#define HAVE_STRNCMP 1 #define HAVE_STRNCMP 1
/* #undef HAVE__STRICMP */ /* #undef HAVE__STRICMP */
#define HAVE_STRCASECMP 1 #define HAVE_STRCASECMP 1
/* #undef HAVE__STRNICMP */ /* #undef HAVE__STRNICMP */
#define HAVE_STRNCASECMP 1 #define HAVE_STRNCASECMP 1
/* #undef HAVE_SSCANF */ /* #undef HAVE_SSCANF */
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
/* #undef HAVE_SNPRINTF */ /* #undef HAVE_SNPRINTF */
#define HAVE_VSNPRINTF 1 #define HAVE_VSNPRINTF 1
#define HAVE_M_PI /**/ #define HAVE_M_PI /**/
#define HAVE_ATAN 1 #define HAVE_ATAN 1
#define HAVE_ATAN2 1 #define HAVE_ATAN2 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_CEIL 1 #define HAVE_CEIL 1
#define HAVE_COPYSIGN 1 #define HAVE_COPYSIGN 1
#define HAVE_COS 1 #define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_FABS 1 #define HAVE_FABS 1
#define HAVE_FLOOR 1 #define HAVE_FLOOR 1
#define HAVE_LOG 1 #define HAVE_LOG 1
#define HAVE_POW 1 #define HAVE_POW 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SIN 1 #define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1 #define HAVE_SQRT 1
#define HAVE_SQRTF 1 #define HAVE_SQRTF 1
#define HAVE_TAN 1 #define HAVE_TAN 1
#define HAVE_TANF 1 #define HAVE_TANF 1
#define HAVE_FOPEN64 1 #define HAVE_FOPEN64 1
#define HAVE_FSEEKO 1 #define HAVE_FSEEKO 1
#define HAVE_FSEEKO64 1 #define HAVE_FSEEKO64 1
#define HAVE_SIGACTION 1 #define HAVE_SIGACTION 1
#define HAVE_SA_SIGACTION 1 #define HAVE_SA_SIGACTION 1
#define HAVE_SETJMP 1 #define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1 #define HAVE_NANOSLEEP 1
#define HAVE_SYSCONF 1 #define HAVE_SYSCONF 1
/* #undef HAVE_SYSCTLBYNAME */ /* #undef HAVE_SYSCTLBYNAME */
#define HAVE_CLOCK_GETTIME 1 #define HAVE_CLOCK_GETTIME 1
/* #undef HAVE_GETPAGESIZE */ /* #undef HAVE_GETPAGESIZE */
#define HAVE_MPROTECT 1 #define HAVE_MPROTECT 1
#define HAVE_ICONV 1 #define HAVE_ICONV 1
#define HAVE_PTHREAD_SETNAME_NP 1 #define HAVE_PTHREAD_SETNAME_NP 1
/* #undef HAVE_PTHREAD_SET_NAME_NP */ /* #undef HAVE_PTHREAD_SET_NAME_NP */
#define HAVE_SEM_TIMEDWAIT 1 #define HAVE_SEM_TIMEDWAIT 1
#define HAVE_GETAUXVAL 1 #define HAVE_GETAUXVAL 1
#define HAVE_POLL 1 #define HAVE_POLL 1
#else #else
#define HAVE_STDARG_H 1 #define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1 #define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1 #define HAVE_STDINT_H 1
#endif /* HAVE_LIBC */ #endif /* HAVE_LIBC */
/* #undef HAVE_ALTIVEC_H */ /* #undef HAVE_ALTIVEC_H */
/* #undef HAVE_LIBUDEV_H */ /* #undef HAVE_LIBUDEV_H */
/* #undef HAVE_DBUS_DBUS_H */ /* #undef HAVE_DBUS_DBUS_H */
/* #undef HAVE_IBUS_IBUS_H */ /* #undef HAVE_IBUS_IBUS_H */
/* #undef HAVE_FCITX_FRONTEND_H */ /* #undef HAVE_FCITX_FRONTEND_H */
/* #undef HAVE_LIBSAMPLERATE_H */ /* #undef HAVE_LIBSAMPLERATE_H */
/* #undef HAVE_DDRAW_H */ /* #undef HAVE_DDRAW_H */
/* #undef HAVE_DINPUT_H */ /* #undef HAVE_DINPUT_H */
/* #undef HAVE_DSOUND_H */ /* #undef HAVE_DSOUND_H */
/* #undef HAVE_DXGI_H */ /* #undef HAVE_DXGI_H */
/* #undef HAVE_XINPUT_H */ /* #undef HAVE_XINPUT_H */
/* #undef HAVE_XINPUT_GAMEPAD_EX */ /* #undef HAVE_XINPUT_GAMEPAD_EX */
/* #undef HAVE_XINPUT_STATE_EX */ /* #undef HAVE_XINPUT_STATE_EX */
/* SDL internal assertion support */ /* SDL internal assertion support */
/* #undef SDL_DEFAULT_ASSERT_LEVEL */ /* #undef SDL_DEFAULT_ASSERT_LEVEL */
/* Allow disabling of core subsystems */ /* Allow disabling of core subsystems */
/* #undef SDL_ATOMIC_DISABLED */ /* #undef SDL_ATOMIC_DISABLED */
/* #undef SDL_AUDIO_DISABLED */ /* #undef SDL_AUDIO_DISABLED */
/* #undef SDL_CPUINFO_DISABLED */ /* #undef SDL_CPUINFO_DISABLED */
/* #undef SDL_EVENTS_DISABLED */ /* #undef SDL_EVENTS_DISABLED */
/* #undef SDL_FILE_DISABLED */ /* #undef SDL_FILE_DISABLED */
/* #undef SDL_JOYSTICK_DISABLED */ /* #undef SDL_JOYSTICK_DISABLED */
/* #undef SDL_HAPTIC_DISABLED */ /* #undef SDL_HAPTIC_DISABLED */
/* #undef SDL_LOADSO_DISABLED */ /* #undef SDL_LOADSO_DISABLED */
/* #undef SDL_RENDER_DISABLED */ /* #undef SDL_RENDER_DISABLED */
/* #undef SDL_THREADS_DISABLED */ /* #undef SDL_THREADS_DISABLED */
/* #undef SDL_TIMERS_DISABLED */ /* #undef SDL_TIMERS_DISABLED */
/* #undef SDL_VIDEO_DISABLED */ /* #undef SDL_VIDEO_DISABLED */
/* #undef SDL_POWER_DISABLED */ /* #undef SDL_POWER_DISABLED */
/* #undef SDL_FILESYSTEM_DISABLED */ /* #undef SDL_FILESYSTEM_DISABLED */
/* Enable various audio drivers */ /* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_ALSA 1 #define SDL_AUDIO_DRIVER_ALSA 1
#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC "libasound.so.2" #define SDL_AUDIO_DRIVER_ALSA_DYNAMIC "libasound.so.2"
/* #undef SDL_AUDIO_DRIVER_ANDROID */ /* #undef SDL_AUDIO_DRIVER_ANDROID */
/* #undef SDL_AUDIO_DRIVER_ARTS */ /* #undef SDL_AUDIO_DRIVER_ARTS */
/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_COREAUDIO */ /* #undef SDL_AUDIO_DRIVER_COREAUDIO */
#define SDL_AUDIO_DRIVER_DISK 1 #define SDL_AUDIO_DRIVER_DISK 1
/* #undef SDL_AUDIO_DRIVER_DSOUND */ /* #undef SDL_AUDIO_DRIVER_DSOUND */
#define SDL_AUDIO_DRIVER_DUMMY 1 #define SDL_AUDIO_DRIVER_DUMMY 1
/* #undef SDL_AUDIO_DRIVER_EMSCRIPTEN */ /* #undef SDL_AUDIO_DRIVER_EMSCRIPTEN */
/* #undef SDL_AUDIO_DRIVER_ESD */ /* #undef SDL_AUDIO_DRIVER_ESD */
/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */ /* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_HAIKU */ /* #undef SDL_AUDIO_DRIVER_HAIKU */
/* #undef SDL_AUDIO_DRIVER_JACK */ /* #undef SDL_AUDIO_DRIVER_JACK */
/* #undef SDL_AUDIO_DRIVER_JACK_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_JACK_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_NACL */ /* #undef SDL_AUDIO_DRIVER_NACL */
/* #undef SDL_AUDIO_DRIVER_NAS */ /* #undef SDL_AUDIO_DRIVER_NAS */
/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_NETBSD */ /* #undef SDL_AUDIO_DRIVER_NETBSD */
#define SDL_AUDIO_DRIVER_OSS 1 #define SDL_AUDIO_DRIVER_OSS 1
/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */ /* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
/* #undef SDL_AUDIO_DRIVER_PAUDIO */ /* #undef SDL_AUDIO_DRIVER_PAUDIO */
/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */ /* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */
/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_QSA */ /* #undef SDL_AUDIO_DRIVER_QSA */
/* #undef SDL_AUDIO_DRIVER_SNDIO */ /* #undef SDL_AUDIO_DRIVER_SNDIO */
/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */ /* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */ /* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
/* #undef SDL_AUDIO_DRIVER_WASAPI */ /* #undef SDL_AUDIO_DRIVER_WASAPI */
/* #undef SDL_AUDIO_DRIVER_WINMM */ /* #undef SDL_AUDIO_DRIVER_WINMM */
/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */ /* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
/* Enable various input drivers */ /* Enable various input drivers */
#define SDL_INPUT_LINUXEV 1 #define SDL_INPUT_LINUXEV 1
#define SDL_INPUT_LINUXKD 1 #define SDL_INPUT_LINUXKD 1
/* #undef SDL_INPUT_TSLIB */ /* #undef SDL_INPUT_TSLIB */
/* #undef SDL_JOYSTICK_HAIKU */ /* #undef SDL_JOYSTICK_HAIKU */
/* #undef SDL_JOYSTICK_DINPUT */ /* #undef SDL_JOYSTICK_DINPUT */
/* #undef SDL_JOYSTICK_XINPUT */ /* #undef SDL_JOYSTICK_XINPUT */
/* #undef SDL_JOYSTICK_DUMMY */ /* #undef SDL_JOYSTICK_DUMMY */
/* #undef SDL_JOYSTICK_IOKIT */ /* #undef SDL_JOYSTICK_IOKIT */
#define SDL_JOYSTICK_LINUX 1 #define SDL_JOYSTICK_LINUX 1
/* #undef SDL_JOYSTICK_ANDROID */ /* #undef SDL_JOYSTICK_ANDROID */
/* #undef SDL_JOYSTICK_WINMM */ /* #undef SDL_JOYSTICK_WINMM */
/* #undef SDL_JOYSTICK_USBHID */ /* #undef SDL_JOYSTICK_USBHID */
/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ /* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
/* #undef SDL_JOYSTICK_EMSCRIPTEN */ /* #undef SDL_JOYSTICK_EMSCRIPTEN */
/* #undef SDL_HAPTIC_DUMMY */ /* #undef SDL_HAPTIC_DUMMY */
#define SDL_HAPTIC_LINUX 1 #define SDL_HAPTIC_LINUX 1
/* #undef SDL_HAPTIC_IOKIT */ /* #undef SDL_HAPTIC_IOKIT */
/* #undef SDL_HAPTIC_DINPUT */ /* #undef SDL_HAPTIC_DINPUT */
/* #undef SDL_HAPTIC_XINPUT */ /* #undef SDL_HAPTIC_XINPUT */
/* Enable various shared object loading systems */ /* Enable various shared object loading systems */
#define SDL_LOADSO_DLOPEN 1 #define SDL_LOADSO_DLOPEN 1
/* #undef SDL_LOADSO_DUMMY */ /* #undef SDL_LOADSO_DUMMY */
/* #undef SDL_LOADSO_LDG */ /* #undef SDL_LOADSO_LDG */
/* #undef SDL_LOADSO_WINDOWS */ /* #undef SDL_LOADSO_WINDOWS */
/* Enable various threading systems */ /* Enable various threading systems */
#define SDL_THREAD_PTHREAD 1 #define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 #define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */ /* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
/* #undef SDL_THREAD_WINDOWS */ /* #undef SDL_THREAD_WINDOWS */
/* Enable various timer systems */ /* Enable various timer systems */
/* #undef SDL_TIMER_HAIKU */ /* #undef SDL_TIMER_HAIKU */
/* #undef SDL_TIMER_DUMMY */ /* #undef SDL_TIMER_DUMMY */
#define SDL_TIMER_UNIX 1 #define SDL_TIMER_UNIX 1
/* #undef SDL_TIMER_WINDOWS */ /* #undef SDL_TIMER_WINDOWS */
/* Enable various video drivers */ /* Enable various video drivers */
/* #undef SDL_VIDEO_DRIVER_HAIKU */ /* #undef SDL_VIDEO_DRIVER_HAIKU */
/* #undef SDL_VIDEO_DRIVER_COCOA */ /* #undef SDL_VIDEO_DRIVER_COCOA */
/* #undef SDL_VIDEO_DRIVER_DIRECTFB */ /* #undef SDL_VIDEO_DRIVER_DIRECTFB */
/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */ /* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_DUMMY 1
/* #undef SDL_VIDEO_DRIVER_WINDOWS */ /* #undef SDL_VIDEO_DRIVER_WINDOWS */
/* #undef SDL_VIDEO_DRIVER_WAYLAND */ /* #undef SDL_VIDEO_DRIVER_WAYLAND */
/* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ /* #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */ /* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */ /* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL */
/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */ /* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR */
/* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */ /* #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON */
/* #undef SDL_VIDEO_DRIVER_MIR */ /* #undef SDL_VIDEO_DRIVER_MIR */
/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */ /* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC */
/* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */ /* #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON */
#define SDL_VIDEO_DRIVER_X11 1 #define SDL_VIDEO_DRIVER_X11 1
/* #undef SDL_VIDEO_DRIVER_RPI */ /* #undef SDL_VIDEO_DRIVER_RPI */
/* #undef SDL_VIDEO_DRIVER_KMSDRM */ /* #undef SDL_VIDEO_DRIVER_KMSDRM */
/* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC */ /* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC */
/* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM */ /* #undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM */
/* #undef SDL_VIDEO_DRIVER_ANDROID */ /* #undef SDL_VIDEO_DRIVER_ANDROID */
/* #undef SDL_VIDEO_DRIVER_EMSCRIPTEN */ /* #undef SDL_VIDEO_DRIVER_EMSCRIPTEN */
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6" #define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"
/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR */ /* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR */
/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA */ /* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA */
/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */ /* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */
/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */ /* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */
/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS */ /* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS */
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "libXxf86vm.so.1" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "libXxf86vm.so.1"
/* #undef SDL_VIDEO_DRIVER_X11_XCURSOR */ /* #undef SDL_VIDEO_DRIVER_X11_XCURSOR */
#define SDL_VIDEO_DRIVER_X11_XDBE 1 #define SDL_VIDEO_DRIVER_X11_XDBE 1
/* #undef SDL_VIDEO_DRIVER_X11_XINERAMA */ /* #undef SDL_VIDEO_DRIVER_X11_XINERAMA */
/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2 */ /* #undef SDL_VIDEO_DRIVER_X11_XINPUT2 */
/* #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */ /* #undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH */
/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */ /* #undef SDL_VIDEO_DRIVER_X11_XRANDR */
/* #undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER */ /* #undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER */
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 #define SDL_VIDEO_DRIVER_X11_XSHAPE 1
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 #define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 #define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1
#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 #define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1
#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 #define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1
/* #undef SDL_VIDEO_DRIVER_NACL */ /* #undef SDL_VIDEO_DRIVER_NACL */
/* #undef SDL_VIDEO_DRIVER_VIVANTE */ /* #undef SDL_VIDEO_DRIVER_VIVANTE */
/* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */ /* #undef SDL_VIDEO_DRIVER_VIVANTE_VDK */
/* #undef SDL_VIDEO_DRIVER_QNX */ /* #undef SDL_VIDEO_DRIVER_QNX */
/* #undef SDL_VIDEO_RENDER_D3D */ /* #undef SDL_VIDEO_RENDER_D3D */
/* #undef SDL_VIDEO_RENDER_D3D11 */ /* #undef SDL_VIDEO_RENDER_D3D11 */
#define SDL_VIDEO_RENDER_OGL 1 #define SDL_VIDEO_RENDER_OGL 1
/* #undef SDL_VIDEO_RENDER_OGL_ES */ /* #undef SDL_VIDEO_RENDER_OGL_ES */
#define SDL_VIDEO_RENDER_OGL_ES2 1 #define SDL_VIDEO_RENDER_OGL_ES2 1
/* #undef SDL_VIDEO_RENDER_DIRECTFB */ /* #undef SDL_VIDEO_RENDER_DIRECTFB */
/* Enable OpenGL support */ /* Enable OpenGL support */
#define SDL_VIDEO_OPENGL 1 #define SDL_VIDEO_OPENGL 1
/* #undef SDL_VIDEO_OPENGL_ES */ /* #undef SDL_VIDEO_OPENGL_ES */
#define SDL_VIDEO_OPENGL_ES2 1 #define SDL_VIDEO_OPENGL_ES2 1
/* #undef SDL_VIDEO_OPENGL_BGL */ /* #undef SDL_VIDEO_OPENGL_BGL */
/* #undef SDL_VIDEO_OPENGL_CGL */ /* #undef SDL_VIDEO_OPENGL_CGL */
#define SDL_VIDEO_OPENGL_EGL 1 #define SDL_VIDEO_OPENGL_EGL 1
#define SDL_VIDEO_OPENGL_GLX 1 #define SDL_VIDEO_OPENGL_GLX 1
/* #undef SDL_VIDEO_OPENGL_WGL */ /* #undef SDL_VIDEO_OPENGL_WGL */
/* #undef SDL_VIDEO_OPENGL_OSMESA */ /* #undef SDL_VIDEO_OPENGL_OSMESA */
/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ /* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
/* Enable Vulkan support */ /* Enable Vulkan support */
#define SDL_VIDEO_VULKAN 1 #define SDL_VIDEO_VULKAN 1
/* Enable system power support */ /* Enable system power support */
#define SDL_POWER_LINUX 1 #define SDL_POWER_LINUX 1
/* #undef SDL_POWER_WINDOWS */ /* #undef SDL_POWER_WINDOWS */
/* #undef SDL_POWER_MACOSX */ /* #undef SDL_POWER_MACOSX */
/* #undef SDL_POWER_HAIKU */ /* #undef SDL_POWER_HAIKU */
/* #undef SDL_POWER_ANDROID */ /* #undef SDL_POWER_ANDROID */
/* #undef SDL_POWER_EMSCRIPTEN */ /* #undef SDL_POWER_EMSCRIPTEN */
/* #undef SDL_POWER_HARDWIRED */ /* #undef SDL_POWER_HARDWIRED */
/* Enable system filesystem support */ /* Enable system filesystem support */
/* #undef SDL_FILESYSTEM_HAIKU */ /* #undef SDL_FILESYSTEM_HAIKU */
/* #undef SDL_FILESYSTEM_COCOA */ /* #undef SDL_FILESYSTEM_COCOA */
/* #undef SDL_FILESYSTEM_DUMMY */ /* #undef SDL_FILESYSTEM_DUMMY */
#define SDL_FILESYSTEM_UNIX 1 #define SDL_FILESYSTEM_UNIX 1
/* #undef SDL_FILESYSTEM_WINDOWS */ /* #undef SDL_FILESYSTEM_WINDOWS */
/* #undef SDL_FILESYSTEM_NACL */ /* #undef SDL_FILESYSTEM_NACL */
/* #undef SDL_FILESYSTEM_ANDROID */ /* #undef SDL_FILESYSTEM_ANDROID */
/* #undef SDL_FILESYSTEM_EMSCRIPTEN */ /* #undef SDL_FILESYSTEM_EMSCRIPTEN */
/* Enable assembly routines */ /* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1 #define SDL_ASSEMBLY_ROUTINES 1
/* #undef SDL_ALTIVEC_BLITTERS */ /* #undef SDL_ALTIVEC_BLITTERS */
/* Enable ime support */ /* Enable ime support */
#define SDL_USE_IME 1 #define SDL_USE_IME 1
/* Enable dynamic udev support */ /* Enable dynamic udev support */
/* #undef SDL_UDEV_DYNAMIC */ /* #undef SDL_UDEV_DYNAMIC */
/* Enable dynamic libsamplerate support */ /* Enable dynamic libsamplerate support */
/* #undef SDL_LIBSAMPLERATE_DYNAMIC */ /* #undef SDL_LIBSAMPLERATE_DYNAMIC */
#endif /* SDL_config_h_ */ #endif /* SDL_config_h_ */

@ -1,176 +1,176 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_cpuinfo.h * \file SDL_cpuinfo.h
* *
* CPU feature detection for SDL. * CPU feature detection for SDL.
*/ */
#ifndef SDL_cpuinfo_h_ #ifndef SDL_cpuinfo_h_
#define SDL_cpuinfo_h_ #define SDL_cpuinfo_h_
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
/* Need to do this here because intrin.h has C++ code in it */ /* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
#ifdef __clang__ #ifdef __clang__
/* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */ /* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */
#undef __MMX__ #undef __MMX__
#undef __SSE__ #undef __SSE__
#undef __SSE2__ #undef __SSE2__
#else #else
#include <intrin.h> #include <intrin.h>
#ifndef _WIN64 #ifndef _WIN64
#define __MMX__ #define __MMX__
#define __3dNOW__ #define __3dNOW__
#endif #endif
#define __SSE__ #define __SSE__
#define __SSE2__ #define __SSE2__
#endif /* __clang__ */ #endif /* __clang__ */
#elif defined(__MINGW64_VERSION_MAJOR) #elif defined(__MINGW64_VERSION_MAJOR)
#include <intrin.h> #include <intrin.h>
#else #else
#ifdef __ALTIVEC__ #ifdef __ALTIVEC__
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
#include <altivec.h> #include <altivec.h>
#undef pixel #undef pixel
#endif #endif
#endif #endif
#ifdef __MMX__ #ifdef __MMX__
#include <mmintrin.h> #include <mmintrin.h>
#endif #endif
#ifdef __3dNOW__ #ifdef __3dNOW__
#include <mm3dnow.h> #include <mm3dnow.h>
#endif #endif
#ifdef __SSE__ #ifdef __SSE__
#include <xmmintrin.h> #include <xmmintrin.h>
#endif #endif
#ifdef __SSE2__ #ifdef __SSE2__
#include <emmintrin.h> #include <emmintrin.h>
#endif #endif
#ifdef __SSE3__ #ifdef __SSE3__
#include <pmmintrin.h> #include <pmmintrin.h>
#endif #endif
#endif #endif
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* This is a guess for the cacheline size used for padding. /* This is a guess for the cacheline size used for padding.
* Most x86 processors have a 64 byte cache line. * Most x86 processors have a 64 byte cache line.
* The 64-bit PowerPC processors have a 128 byte cache line. * The 64-bit PowerPC processors have a 128 byte cache line.
* We'll use the larger value to be generally safe. * We'll use the larger value to be generally safe.
*/ */
#define SDL_CACHELINE_SIZE 128 #define SDL_CACHELINE_SIZE 128
/** /**
* This function returns the number of CPU cores available. * This function returns the number of CPU cores available.
*/ */
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
/** /**
* This function returns the L1 cache line size of the CPU * This function returns the L1 cache line size of the CPU
* *
* This is useful for determining multi-threaded structure padding * This is useful for determining multi-threaded structure padding
* or SIMD prefetch sizes. * or SIMD prefetch sizes.
*/ */
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
/** /**
* This function returns true if the CPU has the RDTSC instruction. * This function returns true if the CPU has the RDTSC instruction.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
/** /**
* This function returns true if the CPU has AltiVec features. * This function returns true if the CPU has AltiVec features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
/** /**
* This function returns true if the CPU has MMX features. * This function returns true if the CPU has MMX features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
/** /**
* This function returns true if the CPU has 3DNow! features. * This function returns true if the CPU has 3DNow! features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
/** /**
* This function returns true if the CPU has SSE features. * This function returns true if the CPU has SSE features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
/** /**
* This function returns true if the CPU has SSE2 features. * This function returns true if the CPU has SSE2 features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
/** /**
* This function returns true if the CPU has SSE3 features. * This function returns true if the CPU has SSE3 features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
/** /**
* This function returns true if the CPU has SSE4.1 features. * This function returns true if the CPU has SSE4.1 features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
/** /**
* This function returns true if the CPU has SSE4.2 features. * This function returns true if the CPU has SSE4.2 features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
/** /**
* This function returns true if the CPU has AVX features. * This function returns true if the CPU has AVX features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
/** /**
* This function returns true if the CPU has AVX2 features. * This function returns true if the CPU has AVX2 features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
/** /**
* This function returns true if the CPU has NEON (ARM SIMD) features. * This function returns true if the CPU has NEON (ARM SIMD) features.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
/** /**
* This function returns the amount of RAM configured in the system, in MB. * This function returns the amount of RAM configured in the system, in MB.
*/ */
extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_cpuinfo_h_ */ #endif /* SDL_cpuinfo_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

File diff suppressed because it is too large Load Diff

@ -1,260 +1,260 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /**
* \file SDL_endian.h * \file SDL_endian.h
* *
* Functions for reading and writing endian-specific values * Functions for reading and writing endian-specific values
*/ */
#ifndef SDL_endian_h_ #ifndef SDL_endian_h_
#define SDL_endian_h_ #define SDL_endian_h_
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
/** /**
* \name The two types of endianness * \name The two types of endianness
*/ */
/* @{ */ /* @{ */
#define SDL_LIL_ENDIAN 1234 #define SDL_LIL_ENDIAN 1234
#define SDL_BIG_ENDIAN 4321 #define SDL_BIG_ENDIAN 4321
/* @} */ /* @} */
#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ #ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
#ifdef __linux__ #ifdef __linux__
#include <endian.h> #include <endian.h>
#define SDL_BYTEORDER __BYTE_ORDER #define SDL_BYTEORDER __BYTE_ORDER
#else /* __linux__ */ #else /* __linux__ */
#if defined(__hppa__) || \ #if defined(__hppa__) || \
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
(defined(__MIPS__) && defined(__MISPEB__)) || \ (defined(__MIPS__) && defined(__MISPEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
defined(__sparc__) defined(__sparc__)
#define SDL_BYTEORDER SDL_BIG_ENDIAN #define SDL_BYTEORDER SDL_BIG_ENDIAN
#else #else
#define SDL_BYTEORDER SDL_LIL_ENDIAN #define SDL_BYTEORDER SDL_LIL_ENDIAN
#endif #endif
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* !SDL_BYTEORDER */ #endif /* !SDL_BYTEORDER */
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**
* \file SDL_endian.h * \file SDL_endian.h
*/ */
#if defined(__GNUC__) && defined(__i386__) && \ #if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); __asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__GNUC__) && defined(__x86_64__)
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
int result; int result;
__asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
return (Uint16)result; return (Uint16)result;
} }
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc");
return x; return x;
} }
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint16 SDL_Swap16(Uint16); extern _inline Uint16 SDL_Swap16(Uint16);
#pragma aux SDL_Swap16 = \ #pragma aux SDL_Swap16 = \
"xchg al, ah" \ "xchg al, ah" \
parm [ax] \ parm [ax] \
modify [ax]; modify [ax];
#else #else
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
} }
#endif #endif
#if defined(__GNUC__) && defined(__i386__) #if defined(__GNUC__) && defined(__i386__)
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
__asm__("bswap %0": "=r"(x):"0"(x)); __asm__("bswap %0": "=r"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__GNUC__) && defined(__x86_64__)
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
__asm__("bswapl %0": "=r"(x):"0"(x)); __asm__("bswapl %0": "=r"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
Uint32 result; Uint32 result;
__asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x));
__asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x));
__asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x));
return result; return result;
} }
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__)
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
__asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc");
return x; return x;
} }
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint32 SDL_Swap32(Uint32); extern _inline Uint32 SDL_Swap32(Uint32);
#ifndef __SW_3 /* 486+ */ #ifndef __SW_3 /* 486+ */
#pragma aux SDL_Swap32 = \ #pragma aux SDL_Swap32 = \
"bswap eax" \ "bswap eax" \
parm [eax] \ parm [eax] \
modify [eax]; modify [eax];
#else /* 386-only */ #else /* 386-only */
#pragma aux SDL_Swap32 = \ #pragma aux SDL_Swap32 = \
"xchg al, ah" \ "xchg al, ah" \
"ror eax, 16" \ "ror eax, 16" \
"xchg al, ah" \ "xchg al, ah" \
parm [eax] \ parm [eax] \
modify [eax]; modify [eax];
#endif #endif
#else #else
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
((x >> 8) & 0x0000FF00) | (x >> 24))); ((x >> 8) & 0x0000FF00) | (x >> 24)));
} }
#endif #endif
#if defined(__GNUC__) && defined(__i386__) #if defined(__GNUC__) && defined(__i386__)
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
union union
{ {
struct struct
{ {
Uint32 a, b; Uint32 a, b;
} s; } s;
Uint64 u; Uint64 u;
} v; } v;
v.u = x; v.u = x;
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a),
"1"(v.s. "1"(v.s.
b)); b));
return v.u; return v.u;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__GNUC__) && defined(__x86_64__)
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
__asm__("bswapq %0": "=r"(x):"0"(x)); __asm__("bswapq %0": "=r"(x):"0"(x));
return x; return x;
} }
#else #else
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
Uint32 hi, lo; Uint32 hi, lo;
/* Separate into high and low 32-bit values and swap them */ /* Separate into high and low 32-bit values and swap them */
lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x >>= 32; x >>= 32;
hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x = SDL_Swap32(lo); x = SDL_Swap32(lo);
x <<= 32; x <<= 32;
x |= SDL_Swap32(hi); x |= SDL_Swap32(hi);
return (x); return (x);
} }
#endif #endif
SDL_FORCE_INLINE float SDL_FORCE_INLINE float
SDL_SwapFloat(float x) SDL_SwapFloat(float x)
{ {
union union
{ {
float f; float f;
Uint32 ui32; Uint32 ui32;
} swapper; } swapper;
swapper.f = x; swapper.f = x;
swapper.ui32 = SDL_Swap32(swapper.ui32); swapper.ui32 = SDL_Swap32(swapper.ui32);
return swapper.f; return swapper.f;
} }
/** /**
* \name Swap to native * \name Swap to native
* Byteswap item from the specified endianness to the native endianness. * Byteswap item from the specified endianness to the native endianness.
*/ */
/* @{ */ /* @{ */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN #if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SDL_SwapLE16(X) (X) #define SDL_SwapLE16(X) (X)
#define SDL_SwapLE32(X) (X) #define SDL_SwapLE32(X) (X)
#define SDL_SwapLE64(X) (X) #define SDL_SwapLE64(X) (X)
#define SDL_SwapFloatLE(X) (X) #define SDL_SwapFloatLE(X) (X)
#define SDL_SwapBE16(X) SDL_Swap16(X) #define SDL_SwapBE16(X) SDL_Swap16(X)
#define SDL_SwapBE32(X) SDL_Swap32(X) #define SDL_SwapBE32(X) SDL_Swap32(X)
#define SDL_SwapBE64(X) SDL_Swap64(X) #define SDL_SwapBE64(X) SDL_Swap64(X)
#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) #define SDL_SwapFloatBE(X) SDL_SwapFloat(X)
#else #else
#define SDL_SwapLE16(X) SDL_Swap16(X) #define SDL_SwapLE16(X) SDL_Swap16(X)
#define SDL_SwapLE32(X) SDL_Swap32(X) #define SDL_SwapLE32(X) SDL_Swap32(X)
#define SDL_SwapLE64(X) SDL_Swap64(X) #define SDL_SwapLE64(X) SDL_Swap64(X)
#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) #define SDL_SwapFloatLE(X) SDL_SwapFloat(X)
#define SDL_SwapBE16(X) (X) #define SDL_SwapBE16(X) (X)
#define SDL_SwapBE32(X) (X) #define SDL_SwapBE32(X) (X)
#define SDL_SwapBE64(X) (X) #define SDL_SwapBE64(X) (X)
#define SDL_SwapFloatBE(X) (X) #define SDL_SwapFloatBE(X) (X)
#endif #endif
/* @} *//* Swap to native */ /* @} *//* Swap to native */
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#include "close_code.h" #include "close_code.h"
#endif /* SDL_endian_h_ */ #endif /* SDL_endian_h_ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save