Implemented showing selected entity in editor with a specific colour

dev
Shariq Shah 6 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
((string-equal system-type "windows-nt") ; Microsoft Windows
(progn
((c-mode .
((company-clang-arguments . ("-IW:/include"))
(flycheck-clang-include-path . ("W:/include")))
)
((c++-mode . ((mode . c))))
)
))
((string-equal system-type "gnu/linux") ; linux
(progn
((c-mode .
((company-clang-arguments . ("-I/mnt/Dev/Projects/symmetry/include"))
(flycheck-clang-include-path . ("/mnt/Dev/Projects/symmetry/include")))
)
((c++-mode . ((mode . c))))
)
)))
(cond
((string-equal system-type "windows-nt") ; Microsoft Windows
(progn
((c-mode .
((company-clang-arguments . ("-IW:/include"))
(flycheck-clang-include-path . ("W:/include")))
)
((c++-mode . ((mode . c))))
)
))
((string-equal system-type "gnu/linux") ; linux
(progn
((c-mode .
((company-clang-arguments . ("-I/mnt/Dev/Projects/symmetry/include"))
(flycheck-clang-include-path . ("/mnt/Dev/Projects/symmetry/include")))
)
((c++-mode . ((mode . c))))
)
)))

8
.gitignore vendored

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

1354
LICENSE

File diff suppressed because it is too large Load Diff

@ -1,142 +1,142 @@
# Project Symmetry
## About
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 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:
| Library | Usage |
| ---------------------------------------------| --------------------------------------- |
| [SDL2](https://www.libsdl.org/) | Windowing, Input, Platform abstraction |
| [Soloud](http://sol.gfxile.net/soloud/) | 3d positional audio |
| [ODE](http://ode.org/) | Physics |
| [Nuklear](https://github.com/vurtun/nuklear) | In-game and editor UI |
| [GLAD](https://github.com/dav1dde/glad-web) | OpenGL Extension Loading |
## Building
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:
```shell
cd build
..\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.
-**Linux(Ubuntu)**: Execute the following in the project's root directory
```bash
cd build
../tools/genie gmake
```
This will generate makefiles in the *build/gmake* directory. Then,
```bash
cd gmake
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,
```bash
cd debug
./Symmetry
```
## License
All the code in this repository is under GPLv3, see LICENSE for more information
## File format specifications
- ### Entity
```bash
# Comment, Sample entity definition in file, paremeters left out are set to defaults
# Empty line at the end specifies end of entity definition
entity: "Something"
position: 0 0 0
scale: 1 1 1
rotation: 0 0 0 1
model: "suzanne.pamesh"
material: "blinn_phong"
diffuse_color: 1 0 0 1
diffuse_texture: "checkered.tga"
specular: 0.55
```
- ### Configuration Variables a.k.a cfg-vars
```bash
# Comment
render_width: 1024
render_height: 1024
debug_draw_enabled: true
fog_color: 0.5 0.2 0.2 1
# There can be comments or empty newlines in between unlike entity definitions
ambient_light: 0.1 0.1 0.1 1
msaa: true
msaa_levels: 8
```
- ### Keybindings
```bash
# All keys are parsed by comparing the output of SDL_GetKeyname
# Each line represents a keybinding
Move_Forward: W
# Multiple keys to a single binding are specified with commas
Move_Backward: S,Down
# Combinations are specified with a hyphen/dash
# When specifing combinations, modifiers(shift, alt, ctrl) always come before
# 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.
Quit: Left Ctrl-Q
# Single modifier keys are allowed but multiple modifier keys without corresponding
# non-modifier key are not allowed
Sprint: Left Shift
```
- ### Level/Scene
- Binary format with header attached at the top
- Save child entities first
- 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
should suffice. The problem is entity heirarchies. There are multiple approaches to
solve this problem.
- 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
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
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
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.
- 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
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.
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
file are immutable.
- 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
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.
- 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?
- ### Materials
*TODO*
- ### Mesh/Geometry
*TODO*
# Project Symmetry
## About
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 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:
| Library | Usage |
| ---------------------------------------------| --------------------------------------- |
| [SDL2](https://www.libsdl.org/) | Windowing, Input, Platform abstraction |
| [Soloud](http://sol.gfxile.net/soloud/) | 3d positional audio |
| [ODE](http://ode.org/) | Physics |
| [Nuklear](https://github.com/vurtun/nuklear) | In-game and editor UI |
| [GLAD](https://github.com/dav1dde/glad-web) | OpenGL Extension Loading |
## Building
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:
```shell
cd build
..\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.
-**Linux(Ubuntu)**: Execute the following in the project's root directory
```bash
cd build
../tools/genie gmake
```
This will generate makefiles in the *build/gmake* directory. Then,
```bash
cd gmake
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,
```bash
cd debug
./Symmetry
```
## License
All the code in this repository is under GPLv3, see LICENSE for more information
## File format specifications
- ### Entity
```bash
# Comment, Sample entity definition in file, paremeters left out are set to defaults
# Empty line at the end specifies end of entity definition
entity: "Something"
position: 0 0 0
scale: 1 1 1
rotation: 0 0 0 1
model: "suzanne.pamesh"
material: "blinn_phong"
diffuse_color: 1 0 0 1
diffuse_texture: "checkered.tga"
specular: 0.55
```
- ### Configuration Variables a.k.a cfg-vars
```bash
# Comment
render_width: 1024
render_height: 1024
debug_draw_enabled: true
fog_color: 0.5 0.2 0.2 1
# There can be comments or empty newlines in between unlike entity definitions
ambient_light: 0.1 0.1 0.1 1
msaa: true
msaa_levels: 8
```
- ### Keybindings
```bash
# All keys are parsed by comparing the output of SDL_GetKeyname
# Each line represents a keybinding
Move_Forward: W
# Multiple keys to a single binding are specified with commas
Move_Backward: S,Down
# Combinations are specified with a hyphen/dash
# When specifing combinations, modifiers(shift, alt, ctrl) always come before
# 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.
Quit: Left Ctrl-Q
# Single modifier keys are allowed but multiple modifier keys without corresponding
# non-modifier key are not allowed
Sprint: Left Shift
```
- ### Level/Scene
- Binary format with header attached at the top
- Save child entities first
- 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
should suffice. The problem is entity heirarchies. There are multiple approaches to
solve this problem.
- 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
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
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
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.
- 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
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.
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
file are immutable.
- 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
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.
- 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?
- ### Materials
*TODO*
- ### Mesh/Geometry
*TODO*

Binary file not shown.

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

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

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

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

@ -1,33 +1,33 @@
// Common inputs and outputs
in vec3 vPosition;
in vec3 vNormal;
in vec2 vUV;
out vec2 uv;
out vec3 normal;
out vec3 vertex;
// out vec3 vertCamSpace;
// out vec4 vertLightSpace;
// Common uniforms
uniform mat4 model_mat;
uniform mat4 inv_model_mat;
// uniform mat4 view_mat;
uniform mat4 mvp;
uniform mat4 lightVPMat;
vec4 transformPosition(vec3 position)
{
return mvp * vec4(vPosition, 1.0);
}
void setOutputs()
{
uv = vUV;
//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;
vertex = vec4(model_mat * vec4(vPosition, 1.0)).xyz;
// vertCamSpace = vec4(view_mat * vec4(vPosition, 1.0)).xyz;
// vertLightSpace = vec4((lightVPMat * model_mat) * vec4(vPosition, 1.0));
}
// Common inputs and outputs
in vec3 vPosition;
in vec3 vNormal;
in vec2 vUV;
out vec2 uv;
out vec3 normal;
out vec3 vertex;
// out vec3 vertCamSpace;
// out vec4 vertLightSpace;
// Common uniforms
uniform mat4 model_mat;
uniform mat4 inv_model_mat;
// uniform mat4 view_mat;
uniform mat4 mvp;
uniform mat4 lightVPMat;
vec4 transformPosition(vec3 position)
{
return mvp * vec4(vPosition, 1.0);
}
void setOutputs()
{
uv = vUV;
//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;
vertex = vec4(model_mat * vec4(vPosition, 1.0)).xyz;
// vertCamSpace = vec4(view_mat * vec4(vPosition, 1.0)).xyz;
// vertLightSpace = vec4((lightVPMat * model_mat) * vec4(vPosition, 1.0));
}

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

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

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

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

@ -1,16 +1,16 @@
//include version.glsl
in vec2 uv;
out vec4 frag_color;
uniform sampler2D albedo_map;
//uniform sampler2D light_map;
void main()
{
vec4 albedo_color = texture(albedo_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;
}
//include version.glsl
in vec2 uv;
out vec4 frag_color;
uniform sampler2D albedo_map;
//uniform sampler2D light_map;
void main()
{
vec4 albedo_color = texture(albedo_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;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File diff suppressed because it is too large Load Diff

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,118 +1,118 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_INTERNAL_H
#define SOLOUD_INTERNAL_H
#include "soloud.h"
namespace SoLoud
{
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// Deinterlace samples in a buffer. From 12121212 to 11112222
void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
// Interlace samples in a buffer. From 11112222 to 12121212
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
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
};
#define FOR_ALL_VOICES_PRE \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
lockAudioMutex(); \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = getVoiceFromHandle(*h_); \
if (ch != -1) \
{
#define FOR_ALL_VOICES_POST \
} \
h_++; \
} \
unlockAudioMutex();
#define FOR_ALL_VOICES_PRE_3D \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = (*h_ & 0xfff) - 1; \
if (ch != -1 && m3dData[ch].mHandle == *h_) \
{
#define FOR_ALL_VOICES_POST_3D \
} \
h_++; \
}
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_INTERNAL_H
#define SOLOUD_INTERNAL_H
#include "soloud.h"
namespace SoLoud
{
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// 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);
// Deinterlace samples in a buffer. From 12121212 to 11112222
void deinterlace_samples_float(const float *aSourceBuffer, float *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
// Interlace samples in a buffer. From 11112222 to 12121212
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
void interlace_samples_s16(const float *aSourceBuffer, short *aDestBuffer, unsigned int aSamples, unsigned int aChannels);
};
#define FOR_ALL_VOICES_PRE \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
lockAudioMutex(); \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = getVoiceFromHandle(*h_); \
if (ch != -1) \
{
#define FOR_ALL_VOICES_POST \
} \
h_++; \
} \
unlockAudioMutex();
#define FOR_ALL_VOICES_PRE_3D \
handle *h_ = NULL; \
handle th_[2] = { aVoiceHandle, 0 }; \
h_ = voiceGroupHandleToArray(aVoiceHandle); \
if (h_ == NULL) h_ = th_; \
while (*h_) \
{ \
int ch = (*h_ & 0xfff) - 1; \
if (ch != -1 && m3dData[ch].mHandle == *h_) \
{
#define FOR_ALL_VOICES_POST_3D \
} \
h_++; \
}
#endif

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

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

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

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

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

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

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

@ -1,108 +1,108 @@
/*
SoLoud audio engine
Copyright (c) 2015 Jari Komppa
VIC 6560/6561 sound chip emulator
Copyright (c) 2015 Petri Hakkinen
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_VIC_H
#define SOLOUD_VIC_H
#include "soloud.h"
/*
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.
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 fourth oscillator generates a noise waveform.
VIC-20 does not have per channel volume control, only global 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
with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0.
*/
namespace SoLoud
{
class Vic;
class VicInstance : public AudioSourceInstance
{
public:
VicInstance(Vic *aParent);
~VicInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded();
private:
Vic* m_parent;
unsigned int m_phase[4];
unsigned int m_noisePos;
};
class Vic : public AudioSource
{
public:
// VIC model
enum
{
PAL = 0,
NTSC,
};
// VIC sound registers
enum
{
BASS = 0,
ALTO,
SOPRANO,
NOISE,
MAX_REGS
};
Vic();
virtual ~Vic();
void setModel(int model);
int getModel() const;
void setRegister(int reg, unsigned char value) { m_regs[reg] = value; }
unsigned char getRegister(int reg) const { return m_regs[reg]; }
virtual AudioSourceInstance *createInstance();
private:
friend class VicInstance;
int m_model;
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
unsigned char m_regs[MAX_REGS];
unsigned char m_noise[8192];
};
};
#endif
/*
SoLoud audio engine
Copyright (c) 2015 Jari Komppa
VIC 6560/6561 sound chip emulator
Copyright (c) 2015 Petri Hakkinen
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_VIC_H
#define SOLOUD_VIC_H
#include "soloud.h"
/*
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.
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 fourth oscillator generates a noise waveform.
VIC-20 does not have per channel volume control, only global 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
with the following params: type = LOWPASS, sample rate = 44100, frequency = 1500, resonance = 2.0.
*/
namespace SoLoud
{
class Vic;
class VicInstance : public AudioSourceInstance
{
public:
VicInstance(Vic *aParent);
~VicInstance();
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded();
private:
Vic* m_parent;
unsigned int m_phase[4];
unsigned int m_noisePos;
};
class Vic : public AudioSource
{
public:
// VIC model
enum
{
PAL = 0,
NTSC,
};
// VIC sound registers
enum
{
BASS = 0,
ALTO,
SOPRANO,
NOISE,
MAX_REGS
};
Vic();
virtual ~Vic();
void setModel(int model);
int getModel() const;
void setRegister(int reg, unsigned char value) { m_regs[reg] = value; }
unsigned char getRegister(int reg) const { return m_regs[reg]; }
virtual AudioSourceInstance *createInstance();
private:
friend class VicInstance;
int m_model;
float m_clocks[4]; // base clock frequencies for oscillators, dependent on VIC model
unsigned char m_regs[MAX_REGS];
unsigned char m_noise[8192];
};
};
#endif

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

@ -1,83 +1,83 @@
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_WAVSTREAM_H
#define SOLOUD_WAVSTREAM_H
#include <stdio.h>
#include "soloud.h"
struct stb_vorbis;
namespace SoLoud
{
class WavStream;
class File;
class WavStreamInstance : public AudioSourceInstance
{
WavStream *mParent;
unsigned int mOffset;
File *mFile;
stb_vorbis *mOgg;
unsigned int mOggFrameSize;
unsigned int mOggFrameOffset;
float **mOggOutputs;
public:
WavStreamInstance(WavStream *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind();
virtual bool hasEnded();
virtual ~WavStreamInstance();
};
class WavStream : public AudioSource
{
result loadwav(File * fp);
result loadogg(File * fp);
public:
int mOgg;
char *mFilename;
File *mMemFile;
File *mStreamFile;
unsigned int mDataOffset;
unsigned int mBits;
unsigned int mSampleCount;
WavStream();
virtual ~WavStream();
result load(const char *aFilename);
result loadMem(unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true);
result loadToMem(const char *aFilename);
result loadFile(File *aFile);
result loadFileToMem(File *aFile);
virtual AudioSourceInstance *createInstance();
time getLength();
public:
result parse(File *aFile);
};
};
/*
SoLoud audio engine
Copyright (c) 2013-2015 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
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
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_WAVSTREAM_H
#define SOLOUD_WAVSTREAM_H
#include <stdio.h>
#include "soloud.h"
struct stb_vorbis;
namespace SoLoud
{
class WavStream;
class File;
class WavStreamInstance : public AudioSourceInstance
{
WavStream *mParent;
unsigned int mOffset;
File *mFile;
stb_vorbis *mOgg;
unsigned int mOggFrameSize;
unsigned int mOggFrameOffset;
float **mOggOutputs;
public:
WavStreamInstance(WavStream *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual result rewind();
virtual bool hasEnded();
virtual ~WavStreamInstance();
};
class WavStream : public AudioSource
{
result loadwav(File * fp);
result loadogg(File * fp);
public:
int mOgg;
char *mFilename;
File *mMemFile;
File *mStreamFile;
unsigned int mDataOffset;
unsigned int mBits;
unsigned int mSampleCount;
WavStream();
virtual ~WavStream();
result load(const char *aFilename);
result loadMem(unsigned char *aData, unsigned int aDataLen, bool aCopy = false, bool aTakeOwnership = true);
result loadToMem(const char *aFilename);
result loadFile(File *aFile);
result loadFileToMem(File *aFile);
virtual AudioSourceInstance *createInstance();
time getLength();
public:
result parse(File *aFile);
};
};
#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. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_COLLISION_SPACE_H_
#define _ODE_COLLISION_SPACE_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
struct dContactGeom;
/**
* @brief User callback for geom-geom collision testing.
*
* @param data The user data object, as passed to dSpaceCollide.
* @param o1 The first geom being tested.
* @param o2 The second geom being test.
*
* @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
* 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
* that those pairs should not interact.
*
* @ingroup collide
*/
typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space);
ODE_API dSpaceID dHashSpaceCreate (dSpaceID space);
ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
/* SAP */
/* Order XZY or ZXY usually works best, if your Y is up. */
#define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
#define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
#define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
#define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
#define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
#define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder );
ODE_API void dSpaceDestroy (dSpaceID);
ODE_API void dHashSpaceSetLevels (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 int dSpaceGetCleanup (dSpaceID space);
/**
* @brief Sets sublevel value for a space.
*
* 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
* 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 with greater sublevel are iterated, another space is passed into
* collision callback as a geometry itself. By default all the spaces are assigned
* zero sublevel.
*
* @note
* 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
* value if necessary.
*
* @param space the space to modify
* @param sublevel the sublevel value to be assigned
* @ingroup collide
* @see dSpaceGetSublevel
* @see dSpaceCollide2
*/
ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel);
/**
* @brief Gets sublevel value of a space.
*
* Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
* with another space. See @c dSpaceSetSublevel for more details.
*
* @param space the space to query
* @returns the sublevel value of the space
* @ingroup collide
* @see dSpaceSetSublevel
* @see dSpaceCollide2
*/
ODE_API int dSpaceGetSublevel (dSpaceID space);
/**
* @brief Sets manual cleanup flag for a space.
*
* 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
* case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag.
*
* Failure to set manual cleanup flag for a space may lead to some resources
* remaining leaked until the program exit.
*
* @param space the space to modify
* @param mode 1 for manual cleanup mode and 0 for default cleanup mode
* @ingroup collide
* @see dSpaceGetManualCleanup
* @see dInitODE2
*/
ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode);
/**
* @brief Get manual cleanup flag of a space.
*
* Manual cleanup flag marks a space space as eligible for manual thread data cleanup.
* See @c dSpaceSetManualCleanup for more details.
*
* @param space the space to query
* @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space
* @ingroup collide
* @see dSpaceSetManualCleanup
* @see dInitODE2
*/
ODE_API int dSpaceGetManualCleanup (dSpaceID space);
ODE_API void dSpaceAdd (dSpaceID, dGeomID);
ODE_API void dSpaceRemove (dSpaceID, dGeomID);
ODE_API int dSpaceQuery (dSpaceID, dGeomID);
ODE_API void dSpaceClean (dSpaceID);
ODE_API int dSpaceGetNumGeoms (dSpaceID);
ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i);
/**
* @brief Given a space, this returns its class.
*
* The ODE classes are:
* @li dSimpleSpaceClass
* @li dHashSpaceClass
* @li dSweepAndPruneSpaceClass
* @li dQuadTreeSpaceClass
* @li dFirstUserClass
* @li dLastUserClass
*
* The class id not defined by the user should be between
* dFirstSpaceClass and dLastSpaceClass.
*
* User-defined class will return their own number.
*
* @param space the space to query
* @returns The space class ID.
* @ingroup collide
*/
ODE_API int dSpaceGetClass(dSpaceID space);
#ifdef __cplusplus
}
#endif
#endif
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_COLLISION_SPACE_H_
#define _ODE_COLLISION_SPACE_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
struct dContactGeom;
/**
* @brief User callback for geom-geom collision testing.
*
* @param data The user data object, as passed to dSpaceCollide.
* @param o1 The first geom being tested.
* @param o2 The second geom being test.
*
* @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
* 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
* that those pairs should not interact.
*
* @ingroup collide
*/
typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
ODE_API dSpaceID dSimpleSpaceCreate (dSpaceID space);
ODE_API dSpaceID dHashSpaceCreate (dSpaceID space);
ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth);
/* SAP */
/* Order XZY or ZXY usually works best, if your Y is up. */
#define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4))
#define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4))
#define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4))
#define dSAP_AXES_YZX ((1)|(2<<2)|(0<<4))
#define dSAP_AXES_ZXY ((2)|(0<<2)|(1<<4))
#define dSAP_AXES_ZYX ((2)|(1<<2)|(0<<4))
ODE_API dSpaceID dSweepAndPruneSpaceCreate( dSpaceID space, int axisorder );
ODE_API void dSpaceDestroy (dSpaceID);
ODE_API void dHashSpaceSetLevels (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 int dSpaceGetCleanup (dSpaceID space);
/**
* @brief Sets sublevel value for a space.
*
* 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
* 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 with greater sublevel are iterated, another space is passed into
* collision callback as a geometry itself. By default all the spaces are assigned
* zero sublevel.
*
* @note
* 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
* value if necessary.
*
* @param space the space to modify
* @param sublevel the sublevel value to be assigned
* @ingroup collide
* @see dSpaceGetSublevel
* @see dSpaceCollide2
*/
ODE_API void dSpaceSetSublevel (dSpaceID space, int sublevel);
/**
* @brief Gets sublevel value of a space.
*
* Sublevel affects how the space is handled in dSpaceCollide2 when it is collided
* with another space. See @c dSpaceSetSublevel for more details.
*
* @param space the space to query
* @returns the sublevel value of the space
* @ingroup collide
* @see dSpaceSetSublevel
* @see dSpaceCollide2
*/
ODE_API int dSpaceGetSublevel (dSpaceID space);
/**
* @brief Sets manual cleanup flag for a space.
*
* 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
* case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag.
*
* Failure to set manual cleanup flag for a space may lead to some resources
* remaining leaked until the program exit.
*
* @param space the space to modify
* @param mode 1 for manual cleanup mode and 0 for default cleanup mode
* @ingroup collide
* @see dSpaceGetManualCleanup
* @see dInitODE2
*/
ODE_API void dSpaceSetManualCleanup (dSpaceID space, int mode);
/**
* @brief Get manual cleanup flag of a space.
*
* Manual cleanup flag marks a space space as eligible for manual thread data cleanup.
* See @c dSpaceSetManualCleanup for more details.
*
* @param space the space to query
* @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space
* @ingroup collide
* @see dSpaceSetManualCleanup
* @see dInitODE2
*/
ODE_API int dSpaceGetManualCleanup (dSpaceID space);
ODE_API void dSpaceAdd (dSpaceID, dGeomID);
ODE_API void dSpaceRemove (dSpaceID, dGeomID);
ODE_API int dSpaceQuery (dSpaceID, dGeomID);
ODE_API void dSpaceClean (dSpaceID);
ODE_API int dSpaceGetNumGeoms (dSpaceID);
ODE_API dGeomID dSpaceGetGeom (dSpaceID, int i);
/**
* @brief Given a space, this returns its class.
*
* The ODE classes are:
* @li dSimpleSpaceClass
* @li dHashSpaceClass
* @li dSweepAndPruneSpaceClass
* @li dQuadTreeSpaceClass
* @li dFirstUserClass
* @li dLastUserClass
*
* The class id not defined by the user should be between
* dFirstSpaceClass and dLastSpaceClass.
*
* User-defined class will return their own number.
*
* @param space the space to query
* @returns The space class ID.
* @ingroup collide
*/
ODE_API int dSpaceGetClass(dSpaceID space);
#ifdef __cplusplus
}
#endif
#endif

@ -1,316 +1,316 @@
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/*
* TriMesh code by Erwin de Vries.
*
* Trimesh data.
* This is where the actual vertexdata (pointers), and BV tree is stored.
* Vertices should be single precision!
* 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
* performance because some data has to be copied.
*/
#ifndef _ODE_COLLISION_TRIMESH_H_
#define _ODE_COLLISION_TRIMESH_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Data storage for triangle meshes.
*/
struct dxTriMeshData;
typedef struct dxTriMeshData* dTriMeshDataID;
typedef enum
{
dMTV__MIN,
dMTV_FIRST = dMTV__MIN,
dMTV_SECOND,
dMTV_THIRD,
dMTV__MAX,
} dMeshTriangleVertex;
/*
* These don't make much sense now, but they will later when we add more
* features.
*/
ODE_API dTriMeshDataID dGeomTriMeshDataCreate(void);
ODE_API void dGeomTriMeshDataDestroy(dTriMeshDataID g);
/*
* The values of data_id that can be used with dGeomTriMeshDataSet/dGeomTriMeshDataGet
*/
enum
{
dTRIMESHDATA__MIN,
dTRIMESHDATA_FACE_NORMALS = dTRIMESHDATA__MIN,
dTRIMESHDATA_USE_FLAGS,
dTRIMESHDATA__MAX,
#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.
TRIMESH_FACE_NORMALS = dTRIMESHDATA_FACE_NORMALS,
#endif
};
/*
* The flags of the dTRIMESHDATA_USE_FLAGS data elements
*/
enum
{
dMESHDATAUSE_EDGE1 = 0x01,
dMESHDATAUSE_EDGE2 = 0x02,
dMESHDATAUSE_EDGE3 = 0x04,
dMESHDATAUSE_VERTEX1 = 0x08,
dMESHDATAUSE_VERTEX2 = 0x10,
dMESHDATAUSE_VERTEX3 = 0x20,
};
/*
* Set and get the TriMeshData additional data
* Note: The data is NOT COPIED on assignment
*/
ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void *in_data);
ODE_API void *dGeomTriMeshDataGet(dTriMeshDataID g, int data_id);
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
* accurate collision response. These functions get and set that transform.
* It is stored per geom instance, rather than per dTriMeshDataID.
*/
ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, const dMatrix4 last_trans );
ODE_API const dReal* dGeomTriMeshGetLastTransform( dGeomID g );
/*
* Build a TriMesh data object with single precision vertex data.
*/
ODE_API void dGeomTriMeshDataBuildSingle(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride);
/* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride,
const void* Normals);
/*
* Build a TriMesh data object with double precision vertex data.
*/
ODE_API void dGeomTriMeshDataBuildDouble(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride);
/* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride,
const void* Normals);
/*
* Simple build. Single/double precision based on dSINGLE/dDOUBLE!
*/
ODE_API void dGeomTriMeshDataBuildSimple(dTriMeshDataID g,
const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount);
/* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g,
const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount,
const int* Normals);
/*
* Data preprocessing build request flags.
*/
enum
{
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_FACE_ANGLES, // Used to aid trimesh-convex collisions; memory requirements depend on extra data
dTRIDATAPREPROCESS_BUILD__MAX,
};
/*
* Data preprocessing extra values for dTRIDATAPREPROCESS_BUILD_FACE_ANGLES.
*/
enum
{
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_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__MAX,
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.
*
* buildRequestFlags is a bitmask of 1U << dTRIDATAPREPROCESS_BUILD_...
* 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
* (only the elements indexed by positions of raised bits are examined;
* defaults are assumed if the pointer is NULL)
*
* 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]*/);
/*
* Obsolete. Equivalent to calling dGeomTriMeshDataPreprocess2(g, (1U << dTRIDATAPREPROCESS_BUILD_CONCAVE_EDGES), NULL)
*/
ODE_API int dGeomTriMeshDataPreprocess(dTriMeshDataID g);
/*
* 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.
*/
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);
/*
* Per triangle callback. Allows the user to say if he wants a collision with
* a particular triangle.
*/
typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
ODE_API void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback);
ODE_API dTriCallback* dGeomTriMeshGetCallback(dGeomID g);
/*
* Per object callback. Allows the user to get the list of triangles in 1
* shot. Maybe we should remove this one.
*/
typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
ODE_API void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback);
ODE_API dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g);
/*
* Ray callback.
* 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
* to determine if a collision should occur.
*/
typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
ODE_API void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback);
ODE_API dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g);
/*
* Triangle merging callback.
* 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
* user to determine attributes of original triangles used as sources for a
* merged contact.
*/
typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
ODE_API void dGeomTriMeshSetTriMergeCallback(dGeomID g, dTriTriMergeCallback* Callback);
ODE_API dTriTriMergeCallback* dGeomTriMeshGetTriMergeCallback(dGeomID g);
/*
* Trimesh class
* Construction. Callbacks are optional.
*/
ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
ODE_API void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data);
ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g);
/* enable/disable/check temporal coherence*/
ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable);
ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass);
/*
* Clears the internal temporal coherence caches. When a geom has its
* 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.
* We should be able to do this automagically.
*/
ODE_API void dGeomTriMeshClearTCCache(dGeomID g);
/*
* returns the TriMeshDataID
*/
ODE_API dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g);
/*
* Gets a triangle.
*/
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
* coordinates.
*/
ODE_API void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
/*
This is how the strided data works:
struct StridedVertex{
dVector3 Vertex;
// Userdata
};
int VertexStride = sizeof(StridedVertex);
struct StridedTri{
int Indices[3];
// Userdata
};
int TriStride = sizeof(StridedTri);
*/
ODE_API int dGeomTriMeshGetTriangleCount (dGeomID g);
ODE_API void dGeomTriMeshDataUpdate(dTriMeshDataID g);
#ifdef __cplusplus
}
#endif
#endif /* _ODE_COLLISION_TRIMESH_H_ */
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/*
* TriMesh code by Erwin de Vries.
*
* Trimesh data.
* This is where the actual vertexdata (pointers), and BV tree is stored.
* Vertices should be single precision!
* 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
* performance because some data has to be copied.
*/
#ifndef _ODE_COLLISION_TRIMESH_H_
#define _ODE_COLLISION_TRIMESH_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Data storage for triangle meshes.
*/
struct dxTriMeshData;
typedef struct dxTriMeshData* dTriMeshDataID;
typedef enum
{
dMTV__MIN,
dMTV_FIRST = dMTV__MIN,
dMTV_SECOND,
dMTV_THIRD,
dMTV__MAX,
} dMeshTriangleVertex;
/*
* These don't make much sense now, but they will later when we add more
* features.
*/
ODE_API dTriMeshDataID dGeomTriMeshDataCreate(void);
ODE_API void dGeomTriMeshDataDestroy(dTriMeshDataID g);
/*
* The values of data_id that can be used with dGeomTriMeshDataSet/dGeomTriMeshDataGet
*/
enum
{
dTRIMESHDATA__MIN,
dTRIMESHDATA_FACE_NORMALS = dTRIMESHDATA__MIN,
dTRIMESHDATA_USE_FLAGS,
dTRIMESHDATA__MAX,
#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.
TRIMESH_FACE_NORMALS = dTRIMESHDATA_FACE_NORMALS,
#endif
};
/*
* The flags of the dTRIMESHDATA_USE_FLAGS data elements
*/
enum
{
dMESHDATAUSE_EDGE1 = 0x01,
dMESHDATAUSE_EDGE2 = 0x02,
dMESHDATAUSE_EDGE3 = 0x04,
dMESHDATAUSE_VERTEX1 = 0x08,
dMESHDATAUSE_VERTEX2 = 0x10,
dMESHDATAUSE_VERTEX3 = 0x20,
};
/*
* Set and get the TriMeshData additional data
* Note: The data is NOT COPIED on assignment
*/
ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void *in_data);
ODE_API void *dGeomTriMeshDataGet(dTriMeshDataID g, int data_id);
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
* accurate collision response. These functions get and set that transform.
* It is stored per geom instance, rather than per dTriMeshDataID.
*/
ODE_API void dGeomTriMeshSetLastTransform( dGeomID g, const dMatrix4 last_trans );
ODE_API const dReal* dGeomTriMeshGetLastTransform( dGeomID g );
/*
* Build a TriMesh data object with single precision vertex data.
*/
ODE_API void dGeomTriMeshDataBuildSingle(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride);
/* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildSingle1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride,
const void* Normals);
/*
* Build a TriMesh data object with double precision vertex data.
*/
ODE_API void dGeomTriMeshDataBuildDouble(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride);
/* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildDouble1(dTriMeshDataID g,
const void* Vertices, int VertexStride, int VertexCount,
const void* Indices, int IndexCount, int TriStride,
const void* Normals);
/*
* Simple build. Single/double precision based on dSINGLE/dDOUBLE!
*/
ODE_API void dGeomTriMeshDataBuildSimple(dTriMeshDataID g,
const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount);
/* same again with a normals array (used as trimesh-trimesh optimization) */
ODE_API void dGeomTriMeshDataBuildSimple1(dTriMeshDataID g,
const dReal* Vertices, int VertexCount,
const dTriIndex* Indices, int IndexCount,
const int* Normals);
/*
* Data preprocessing build request flags.
*/
enum
{
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_FACE_ANGLES, // Used to aid trimesh-convex collisions; memory requirements depend on extra data
dTRIDATAPREPROCESS_BUILD__MAX,
};
/*
* Data preprocessing extra values for dTRIDATAPREPROCESS_BUILD_FACE_ANGLES.
*/
enum
{
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_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__MAX,
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.
*
* buildRequestFlags is a bitmask of 1U << dTRIDATAPREPROCESS_BUILD_...
* 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
* (only the elements indexed by positions of raised bits are examined;
* defaults are assumed if the pointer is NULL)
*
* 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]*/);
/*
* Obsolete. Equivalent to calling dGeomTriMeshDataPreprocess2(g, (1U << dTRIDATAPREPROCESS_BUILD_CONCAVE_EDGES), NULL)
*/
ODE_API int dGeomTriMeshDataPreprocess(dTriMeshDataID g);
/*
* 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.
*/
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);
/*
* Per triangle callback. Allows the user to say if he wants a collision with
* a particular triangle.
*/
typedef int dTriCallback(dGeomID TriMesh, dGeomID RefObject, int TriangleIndex);
ODE_API void dGeomTriMeshSetCallback(dGeomID g, dTriCallback* Callback);
ODE_API dTriCallback* dGeomTriMeshGetCallback(dGeomID g);
/*
* Per object callback. Allows the user to get the list of triangles in 1
* shot. Maybe we should remove this one.
*/
typedef void dTriArrayCallback(dGeomID TriMesh, dGeomID RefObject, const int* TriIndices, int TriCount);
ODE_API void dGeomTriMeshSetArrayCallback(dGeomID g, dTriArrayCallback* ArrayCallback);
ODE_API dTriArrayCallback* dGeomTriMeshGetArrayCallback(dGeomID g);
/*
* Ray callback.
* 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
* to determine if a collision should occur.
*/
typedef int dTriRayCallback(dGeomID TriMesh, dGeomID Ray, int TriangleIndex, dReal u, dReal v);
ODE_API void dGeomTriMeshSetRayCallback(dGeomID g, dTriRayCallback* Callback);
ODE_API dTriRayCallback* dGeomTriMeshGetRayCallback(dGeomID g);
/*
* Triangle merging callback.
* 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
* user to determine attributes of original triangles used as sources for a
* merged contact.
*/
typedef int dTriTriMergeCallback(dGeomID TriMesh, int FirstTriangleIndex, int SecondTriangleIndex);
ODE_API void dGeomTriMeshSetTriMergeCallback(dGeomID g, dTriTriMergeCallback* Callback);
ODE_API dTriTriMergeCallback* dGeomTriMeshGetTriMergeCallback(dGeomID g);
/*
* Trimesh class
* Construction. Callbacks are optional.
*/
ODE_API dGeomID dCreateTriMesh(dSpaceID space, dTriMeshDataID Data, dTriCallback* Callback, dTriArrayCallback* ArrayCallback, dTriRayCallback* RayCallback);
ODE_API void dGeomTriMeshSetData(dGeomID g, dTriMeshDataID Data);
ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g);
/* enable/disable/check temporal coherence*/
ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable);
ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass);
/*
* Clears the internal temporal coherence caches. When a geom has its
* 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.
* We should be able to do this automagically.
*/
ODE_API void dGeomTriMeshClearTCCache(dGeomID g);
/*
* returns the TriMeshDataID
*/
ODE_API dTriMeshDataID dGeomTriMeshGetTriMeshDataID(dGeomID g);
/*
* Gets a triangle.
*/
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
* coordinates.
*/
ODE_API void dGeomTriMeshGetPoint(dGeomID g, int Index, dReal u, dReal v, dVector3 Out);
/*
This is how the strided data works:
struct StridedVertex{
dVector3 Vertex;
// Userdata
};
int VertexStride = sizeof(StridedVertex);
struct StridedTri{
int Indices[3];
// Userdata
};
int TriStride = sizeof(StridedTri);
*/
ODE_API int dGeomTriMeshGetTriangleCount (dGeomID g);
ODE_API void dGeomTriMeshDataUpdate(dTriMeshDataID g);
#ifdef __cplusplus
}
#endif
#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. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_COMPATIBILITY_H_
#define _ODE_COMPATIBILITY_H_
/*
* ODE's backward compatibility system ensures that as ODE's API
* evolves, user code will not break.
*/
/*
* These new rotation function names are more consistent with the
* rest of the API.
*/
#define dQtoR(q,R) dRfromQ((R),(q))
#define dRtoQ(R,q) dQfromR((q),(R))
#define dWtoDQ(w,q,dq) dDQfromW((dq),(w),(q))
#endif
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_COMPATIBILITY_H_
#define _ODE_COMPATIBILITY_H_
/*
* ODE's backward compatibility system ensures that as ODE's API
* evolves, user code will not break.
*/
/*
* These new rotation function names are more consistent with the
* rest of the API.
*/
#define dQtoR(q,R) dRfromQ((R),(q))
#define dRtoQ(R,q) dQfromR((q),(R))
#define dWtoDQ(w,q,dq) dDQfromW((dq),(w),(q))
#endif

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

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

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

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

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

@ -1,200 +1,200 @@
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/* optimized and unoptimized vector and matrix functions */
#ifndef _ODE_MATRIX_H_
#define _ODE_MATRIX_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
/* 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 dSetValue (dReal *a, int n, dReal value);
/* 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).
*/
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.
* 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
* than calling dDot() for all of the combinations separately.
*/
/* NOT INCLUDED in the library for now.
void dMultidot2 (const dReal *a0, const dReal *a1,
const dReal *b, dReal *outsum, int n);
*/
/* matrix multiplication. all matrices are stored in standard row format.
* the digit refers to the argument that is transposed:
* 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)
* 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
* 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 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);
/* 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
* will be such that L*L'=A. return 1 on success and 0 on failure (on failure
* the matrix is not positive definite).
*/
ODE_API int dFactorCholesky (dReal *A, int n);
/* 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.
*/
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
* Ainv. this is not especially fast. this returns 1 on success (A was
* positive definite) or 0 on failure (not PD).
*/
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).
* 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
* is not positive definite. A is stored by rows. A is not altered.
*/
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
* the diagonal, and D is diagonal.
* 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
* written) and the reciprocal of the diagonal elements of D are written into
* d.
*/
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,
* and x,b are n*1. b is overwritten with x.
* the leading dimension of L is `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,
* and x,b are n*1. b is overwritten with x.
* the leading dimension of L is `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)
*/
ODE_API void dScaleVector (dReal *a, const dReal *d, int n);
/* The function is an alias for @c dScaleVector.
* 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);
/* 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
* D, solve L*D*L'*x=b where x,b are n*1. x overwrites b.
* the leading dimension of L is `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
* factorization L2*D2*L2' of A plus the following "top left" matrix:
*
* [ b a' ] <-- b is a[0]
* [ a 0 ] <-- a is a[1..n-1]
*
* - 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.
* - d has size n. d contains the reciprocal diagonal elements of D.
* - a has size n.
* 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.
*/
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
* factorization for row and column `r' removed.
* - A has size n1*n1, its leading dimension in nskip. A is symmetric and
* positive definite. only the lower triangle of A is referenced.
* A itself may actually be an array of row pointers.
* - 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.
* - 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
* must be in the range 0..n1-1.
* - 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
* dimension. the last row and column of L, and the last element of d, are
* undefined on exit.
*
* 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,
int n1, int n2, int r, int nskip);
/* 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
* dimension. the last row and column of A are untouched on exit.
*/
ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r);
#ifdef __cplusplus
}
#endif
#endif
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/* optimized and unoptimized vector and matrix functions */
#ifndef _ODE_MATRIX_H_
#define _ODE_MATRIX_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
/* 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 dSetValue (dReal *a, int n, dReal value);
/* 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).
*/
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.
* 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
* than calling dDot() for all of the combinations separately.
*/
/* NOT INCLUDED in the library for now.
void dMultidot2 (const dReal *a0, const dReal *a1,
const dReal *b, dReal *outsum, int n);
*/
/* matrix multiplication. all matrices are stored in standard row format.
* the digit refers to the argument that is transposed:
* 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)
* 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
* 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 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);
/* 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
* will be such that L*L'=A. return 1 on success and 0 on failure (on failure
* the matrix is not positive definite).
*/
ODE_API int dFactorCholesky (dReal *A, int n);
/* 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.
*/
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
* Ainv. this is not especially fast. this returns 1 on success (A was
* positive definite) or 0 on failure (not PD).
*/
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).
* 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
* is not positive definite. A is stored by rows. A is not altered.
*/
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
* the diagonal, and D is diagonal.
* 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
* written) and the reciprocal of the diagonal elements of D are written into
* d.
*/
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,
* and x,b are n*1. b is overwritten with x.
* the leading dimension of L is `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,
* and x,b are n*1. b is overwritten with x.
* the leading dimension of L is `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)
*/
ODE_API void dScaleVector (dReal *a, const dReal *d, int n);
/* The function is an alias for @c dScaleVector.
* 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);
/* 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
* D, solve L*D*L'*x=b where x,b are n*1. x overwrites b.
* the leading dimension of L is `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
* factorization L2*D2*L2' of A plus the following "top left" matrix:
*
* [ b a' ] <-- b is a[0]
* [ a 0 ] <-- a is a[1..n-1]
*
* - 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.
* - d has size n. d contains the reciprocal diagonal elements of D.
* - a has size n.
* 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.
*/
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
* factorization for row and column `r' removed.
* - A has size n1*n1, its leading dimension in nskip. A is symmetric and
* positive definite. only the lower triangle of A is referenced.
* A itself may actually be an array of row pointers.
* - 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.
* - 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
* must be in the range 0..n1-1.
* - 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
* dimension. the last row and column of L, and the last element of d, are
* undefined on exit.
*
* 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,
int n1, int n2, int r, int nskip);
/* 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
* dimension. the last row and column of A are untouched on exit.
*/
ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r);
#ifdef __cplusplus
}
#endif
#endif

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

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

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

@ -1,215 +1,215 @@
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_ODECONFIG_H_
#define _ODE_ODECONFIG_H_
/* Pull in the standard headers */
#include <stddef.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <ode/precision.h>
#if defined(ODE_DLL) || defined(ODE_LIB)
#define __ODE__
#endif
/* Define a DLL export symbol for those platforms that need it */
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
#if defined(ODE_DLL)
#define ODE_API __declspec(dllexport)
#elif !defined(ODE_LIB)
#define ODE_DLL_API __declspec(dllimport)
#endif
#endif
#if !defined(ODE_API)
#define ODE_API
#endif
#if defined(_MSC_VER)
# define ODE_API_DEPRECATED __declspec(deprecated)
#elif defined (__GNUC__) && ( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) )
# define ODE_API_DEPRECATED __attribute__((__deprecated__))
#else
# define ODE_API_DEPRECATED
#endif
#define ODE_PURE_INLINE static __inline
#define ODE_INLINE __inline
#if defined(__cplusplus)
#define ODE_EXTERN_C extern "C"
#else
#define ODE_EXTERN_C
#endif
#if defined(__GNUC__)
#define ODE_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER)
#define ODE_NORETURN __declspec(noreturn)
#else // #if !defined(_MSC_VER)
#define ODE_NORETURN
#endif // #if !defined(__GNUC__)
/* Well-defined common data types...need to define for 64 bit systems */
#if defined(__aarch64__)
#include <stdint.h>
typedef int64_t dint64;
typedef uint64_t duint64;
typedef int32_t dint32;
typedef uint32_t duint32;
typedef int16_t dint16;
typedef uint16_t duint16;
typedef int8_t dint8;
typedef uint8_t duint8;
typedef intptr_t dintptr;
typedef uintptr_t duintptr;
typedef ptrdiff_t ddiffint;
typedef size_t dsizeint;
#elif defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)
#define X86_64_SYSTEM 1
#if defined(_MSC_VER)
typedef __int64 dint64;
typedef unsigned __int64 duint64;
#else
#if defined(_LP64)
typedef long dint64;
typedef unsigned long duint64;
#else
typedef long long dint64;
typedef unsigned long long duint64;
#endif
#endif
typedef int dint32;
typedef unsigned int duint32;
typedef short dint16;
typedef unsigned short duint16;
typedef signed char dint8;
typedef unsigned char duint8;
typedef dint64 dintptr;
typedef duint64 duintptr;
typedef dint64 ddiffint;
typedef duint64 dsizeint;
#else
#if defined(_MSC_VER)
typedef __int64 dint64;
typedef unsigned __int64 duint64;
#else
typedef long long dint64;
typedef unsigned long long duint64;
#endif
typedef int dint32;
typedef unsigned int duint32;
typedef short dint16;
typedef unsigned short duint16;
typedef signed char dint8;
typedef unsigned char duint8;
typedef dint32 dintptr;
typedef duint32 duintptr;
typedef dint32 ddiffint;
typedef duint32 dsizeint;
#endif
/* Define the dInfinity macro */
#ifdef INFINITY
#ifdef dSINGLE
#define dInfinity ((float)INFINITY)
#else
#define dInfinity ((double)INFINITY)
#endif
#elif defined(HUGE_VAL)
#ifdef dSINGLE
#ifdef HUGE_VALF
#define dInfinity HUGE_VALF
#else
#define dInfinity ((float)HUGE_VAL)
#endif
#else
#define dInfinity HUGE_VAL
#endif
#else
#ifdef dSINGLE
#define dInfinity ((float)(1.0/0.0))
#else
#define dInfinity (1.0/0.0)
#endif
#endif
/* Define the dNaN macro */
#if defined(NAN)
#define dNaN NAN
#elif defined(__GNUC__)
#define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; })
#elif defined(__cplusplus)
union _dNaNUnion
{
_dNaNUnion(): m_ui(0x7FC00000) {}
duint32 m_ui;
float m_f;
};
#define dNaN (_dNaNUnion().m_f)
#else
#ifdef dSINGLE
#define dNaN ((float)(dInfinity - dInfinity))
#else
#define dNaN (dInfinity - dInfinity)
#endif
#endif
/* Visual C does not define these functions */
#if defined(_MSC_VER)
#define _ode_copysignf(x, y) ((float)_copysign(x, y))
#define _ode_copysign(x, y) _copysign(x, y)
#define _ode_nextafterf(x, y) _nextafterf(x, y)
#define _ode_nextafter(x, y) _nextafter(x, y)
#if !defined(_WIN64) && defined(dSINGLE)
#define _ODE__NEXTAFTERF_REQUIRED
ODE_EXTERN_C float _nextafterf(float x, float y);
#endif
#else
#define _ode_copysignf(x, y) copysignf(x, y)
#define _ode_copysign(x, y) copysign(x, y)
#define _ode_nextafterf(x, y) nextafterf(x, y)
#define _ode_nextafter(x, y) nextafter(x, y)
#endif
#endif
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_ODECONFIG_H_
#define _ODE_ODECONFIG_H_
/* Pull in the standard headers */
#include <stddef.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <ode/precision.h>
#if defined(ODE_DLL) || defined(ODE_LIB)
#define __ODE__
#endif
/* Define a DLL export symbol for those platforms that need it */
#if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
#if defined(ODE_DLL)
#define ODE_API __declspec(dllexport)
#elif !defined(ODE_LIB)
#define ODE_DLL_API __declspec(dllimport)
#endif
#endif
#if !defined(ODE_API)
#define ODE_API
#endif
#if defined(_MSC_VER)
# define ODE_API_DEPRECATED __declspec(deprecated)
#elif defined (__GNUC__) && ( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) )
# define ODE_API_DEPRECATED __attribute__((__deprecated__))
#else
# define ODE_API_DEPRECATED
#endif
#define ODE_PURE_INLINE static __inline
#define ODE_INLINE __inline
#if defined(__cplusplus)
#define ODE_EXTERN_C extern "C"
#else
#define ODE_EXTERN_C
#endif
#if defined(__GNUC__)
#define ODE_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER)
#define ODE_NORETURN __declspec(noreturn)
#else // #if !defined(_MSC_VER)
#define ODE_NORETURN
#endif // #if !defined(__GNUC__)
/* Well-defined common data types...need to define for 64 bit systems */
#if defined(__aarch64__)
#include <stdint.h>
typedef int64_t dint64;
typedef uint64_t duint64;
typedef int32_t dint32;
typedef uint32_t duint32;
typedef int16_t dint16;
typedef uint16_t duint16;
typedef int8_t dint8;
typedef uint8_t duint8;
typedef intptr_t dintptr;
typedef uintptr_t duintptr;
typedef ptrdiff_t ddiffint;
typedef size_t dsizeint;
#elif defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)
#define X86_64_SYSTEM 1
#if defined(_MSC_VER)
typedef __int64 dint64;
typedef unsigned __int64 duint64;
#else
#if defined(_LP64)
typedef long dint64;
typedef unsigned long duint64;
#else
typedef long long dint64;
typedef unsigned long long duint64;
#endif
#endif
typedef int dint32;
typedef unsigned int duint32;
typedef short dint16;
typedef unsigned short duint16;
typedef signed char dint8;
typedef unsigned char duint8;
typedef dint64 dintptr;
typedef duint64 duintptr;
typedef dint64 ddiffint;
typedef duint64 dsizeint;
#else
#if defined(_MSC_VER)
typedef __int64 dint64;
typedef unsigned __int64 duint64;
#else
typedef long long dint64;
typedef unsigned long long duint64;
#endif
typedef int dint32;
typedef unsigned int duint32;
typedef short dint16;
typedef unsigned short duint16;
typedef signed char dint8;
typedef unsigned char duint8;
typedef dint32 dintptr;
typedef duint32 duintptr;
typedef dint32 ddiffint;
typedef duint32 dsizeint;
#endif
/* Define the dInfinity macro */
#ifdef INFINITY
#ifdef dSINGLE
#define dInfinity ((float)INFINITY)
#else
#define dInfinity ((double)INFINITY)
#endif
#elif defined(HUGE_VAL)
#ifdef dSINGLE
#ifdef HUGE_VALF
#define dInfinity HUGE_VALF
#else
#define dInfinity ((float)HUGE_VAL)
#endif
#else
#define dInfinity HUGE_VAL
#endif
#else
#ifdef dSINGLE
#define dInfinity ((float)(1.0/0.0))
#else
#define dInfinity (1.0/0.0)
#endif
#endif
/* Define the dNaN macro */
#if defined(NAN)
#define dNaN NAN
#elif defined(__GNUC__)
#define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; })
#elif defined(__cplusplus)
union _dNaNUnion
{
_dNaNUnion(): m_ui(0x7FC00000) {}
duint32 m_ui;
float m_f;
};
#define dNaN (_dNaNUnion().m_f)
#else
#ifdef dSINGLE
#define dNaN ((float)(dInfinity - dInfinity))
#else
#define dNaN (dInfinity - dInfinity)
#endif
#endif
/* Visual C does not define these functions */
#if defined(_MSC_VER)
#define _ode_copysignf(x, y) ((float)_copysign(x, y))
#define _ode_copysign(x, y) _copysign(x, y)
#define _ode_nextafterf(x, y) _nextafterf(x, y)
#define _ode_nextafter(x, y) _nextafter(x, y)
#if !defined(_WIN64) && defined(dSINGLE)
#define _ODE__NEXTAFTERF_REQUIRED
ODE_EXTERN_C float _nextafterf(float x, float y);
#endif
#else
#define _ode_copysignf(x, y) copysignf(x, y)
#define _ode_copysign(x, y) copysign(x, y)
#define _ode_nextafterf(x, y) nextafterf(x, y)
#define _ode_nextafter(x, y) nextafter(x, y)
#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. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/* C++ interface for new collision API */
#ifndef _ODE_ODECPP_COLLISION_H_
#define _ODE_ODECPP_COLLISION_H_
#ifdef __cplusplus
//#include <ode/error.h>
//namespace ode {
class dGeom {
// intentionally undefined, don't use these
dGeom (dGeom &);
void operator= (dGeom &);
protected:
dGeomID _id;
dGeom()
{ _id = 0; }
public:
~dGeom()
{ if (_id) dGeomDestroy (_id); }
dGeomID id() const
{ return _id; }
operator dGeomID() const
{ return _id; }
void destroy() {
if (_id) dGeomDestroy (_id);
_id = 0;
}
int getClass() const
{ return dGeomGetClass (_id); }
dSpaceID getSpace() const
{ return dGeomGetSpace (_id); }
void setData (void *data)
{ dGeomSetData (_id,data); }
void *getData() const
{ return dGeomGetData (_id); }
void setBody (dBodyID b)
{ dGeomSetBody (_id,b); }
dBodyID getBody() const
{ return dGeomGetBody (_id); }
void setPosition (dReal x, dReal y, dReal z)
{ dGeomSetPosition (_id,x,y,z); }
const dReal * getPosition() const
{ return dGeomGetPosition (_id); }
void setRotation (const dMatrix3 R)
{ dGeomSetRotation (_id,R); }
const dReal * getRotation() const
{ return dGeomGetRotation (_id); }
void setQuaternion (const dQuaternion quat)
{ dGeomSetQuaternion (_id,quat); }
void getQuaternion (dQuaternion quat) const
{ dGeomGetQuaternion (_id,quat); }
void getAABB (dReal aabb[6]) const
{ dGeomGetAABB (_id, aabb); }
int isSpace()
{ return dGeomIsSpace (_id); }
void setCategoryBits (unsigned long bits)
{ dGeomSetCategoryBits (_id, bits); }
void setCollideBits (unsigned long bits)
{ dGeomSetCollideBits (_id, bits); }
unsigned long getCategoryBits()
{ return dGeomGetCategoryBits (_id); }
unsigned long getCollideBits()
{ return dGeomGetCollideBits (_id); }
void enable()
{ dGeomEnable (_id); }
void disable()
{ dGeomDisable (_id); }
int isEnabled()
{ return dGeomIsEnabled (_id); }
void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetRelPointPos (_id, px, py, pz, result); }
void getRelPointPos (const dVector3 p, dVector3 result) const
{ getRelPointPos (p[0], p[1], p[2], result); }
void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetPosRelPoint (_id, px, py, pz, result); }
void getPosRelPoint (const dVector3 p, dVector3 result) const
{ getPosRelPoint (p[0], p[1], p[2], result); }
void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorToWorld (_id, px, py, pz, result); }
void vectorToWorld (const dVector3 p, dVector3 result) const
{ vectorToWorld (p[0], p[1], p[2], result); }
void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorFromWorld (_id, px, py, pz, result); }
void vectorFromWorld (const dVector3 p, dVector3 result) const
{ vectorFromWorld (p[0], p[1], p[2], result); }
void collide2 (dGeomID g, void *data, dNearCallback *callback)
{ dSpaceCollide2 (_id,g,data,callback); }
};
class dSpace : public dGeom {
// intentionally undefined, don't use these
dSpace (dSpace &);
void operator= (dSpace &);
protected:
// the default constructor is protected so that you
// can't instance this class. you must instance one
// of its subclasses instead.
dSpace () { _id = 0; }
public:
dSpaceID id() const
{ return (dSpaceID) _id; }
operator dSpaceID() const
{ return (dSpaceID) _id; }
void setCleanup (int mode)
{ dSpaceSetCleanup (id(), mode); }
int getCleanup()
{ return dSpaceGetCleanup (id()); }
void add (dGeomID x)
{ dSpaceAdd (id(), x); }
void remove (dGeomID x)
{ dSpaceRemove (id(), x); }
int query (dGeomID x)
{ return dSpaceQuery (id(),x); }
int getNumGeoms()
{ return dSpaceGetNumGeoms (id()); }
dGeomID getGeom (int i)
{ return dSpaceGetGeom (id(),i); }
void collide (void *data, dNearCallback *callback)
{ dSpaceCollide (id(),data,callback); }
};
class dSimpleSpace : public dSpace {
// intentionally undefined, don't use these
dSimpleSpace (dSimpleSpace &);
void operator= (dSimpleSpace &);
public:
dSimpleSpace ()
{ _id = (dGeomID) dSimpleSpaceCreate (0); }
dSimpleSpace (dSpace &space)
{ _id = (dGeomID) dSimpleSpaceCreate (space.id()); }
dSimpleSpace (dSpaceID space)
{ _id = (dGeomID) dSimpleSpaceCreate (space); }
};
class dHashSpace : public dSpace {
// intentionally undefined, don't use these
dHashSpace (dHashSpace &);
void operator= (dHashSpace &);
public:
dHashSpace ()
{ _id = (dGeomID) dHashSpaceCreate (0); }
dHashSpace (dSpace &space)
{ _id = (dGeomID) dHashSpaceCreate (space.id()); }
dHashSpace (dSpaceID space)
{ _id = (dGeomID) dHashSpaceCreate (space); }
void setLevels (int minlevel, int maxlevel)
{ dHashSpaceSetLevels (id(),minlevel,maxlevel); }
};
class dQuadTreeSpace : public dSpace {
// intentionally undefined, don't use these
dQuadTreeSpace (dQuadTreeSpace &);
void operator= (dQuadTreeSpace &);
public:
dQuadTreeSpace (const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (0,center,extents,depth); }
dQuadTreeSpace (dSpace &space, const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (space.id(),center,extents,depth); }
dQuadTreeSpace (dSpaceID space, const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
};
class dSphere : public dGeom {
// intentionally undefined, don't use these
dSphere (dSphere &);
void operator= (dSphere &);
public:
dSphere () { }
dSphere (dReal radius)
{ _id = dCreateSphere (0, radius); }
dSphere (dSpace &space, dReal radius)
{ _id = dCreateSphere (space.id(), radius); }
dSphere (dSpaceID space, dReal radius)
{ _id = dCreateSphere (space, radius); }
void create (dSpaceID space, dReal radius) {
if (_id) dGeomDestroy (_id);
_id = dCreateSphere (space, radius);
}
void setRadius (dReal radius)
{ dGeomSphereSetRadius (_id, radius); }
dReal getRadius() const
{ return dGeomSphereGetRadius (_id); }
};
class dBox : public dGeom {
// intentionally undefined, don't use these
dBox (dBox &);
void operator= (dBox &);
public:
dBox () { }
dBox (dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (0,lx,ly,lz); }
dBox (dSpace &space, dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (space,lx,ly,lz); }
dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (space,lx,ly,lz); }
void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
if (_id) dGeomDestroy (_id);
_id = dCreateBox (space,lx,ly,lz);
}
void setLengths (dReal lx, dReal ly, dReal lz)
{ dGeomBoxSetLengths (_id, lx, ly, lz); }
void getLengths (dVector3 result) const
{ dGeomBoxGetLengths (_id,result); }
};
class dPlane : public dGeom {
// intentionally undefined, don't use these
dPlane (dPlane &);
void operator= (dPlane &);
public:
dPlane() { }
dPlane (dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (0,a,b,c,d); }
dPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (space.id(),a,b,c,d); }
dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (space,a,b,c,d); }
void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
if (_id) dGeomDestroy (_id);
_id = dCreatePlane (space,a,b,c,d);
}
void setParams (dReal a, dReal b, dReal c, dReal d)
{ dGeomPlaneSetParams (_id, a, b, c, d); }
void getParams (dVector4 result) const
{ dGeomPlaneGetParams (_id,result); }
};
class dCapsule : public dGeom {
// intentionally undefined, don't use these
dCapsule (dCapsule &);
void operator= (dCapsule &);
public:
dCapsule() { }
dCapsule (dReal radius, dReal length)
{ _id = dCreateCapsule (0,radius,length); }
dCapsule (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCapsule (space.id(),radius,length); }
dCapsule (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCapsule (space,radius,length); }
void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateCapsule (space,radius,length);
}
void setParams (dReal radius, dReal length)
{ dGeomCapsuleSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const
{ dGeomCapsuleGetParams (_id,radius,length); }
};
class dCylinder : public dGeom {
// intentionally undefined, don't use these
dCylinder (dCylinder &);
void operator= (dCylinder &);
public:
dCylinder() { }
dCylinder (dReal radius, dReal length)
{ _id = dCreateCylinder (0,radius,length); }
dCylinder (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCylinder (space.id(),radius,length); }
dCylinder (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCylinder (space,radius,length); }
void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateCylinder (space,radius,length);
}
void setParams (dReal radius, dReal length)
{ dGeomCylinderSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const
{ dGeomCylinderGetParams (_id,radius,length); }
};
class dRay : public dGeom {
// intentionally undefined, don't use these
dRay (dRay &);
void operator= (dRay &);
public:
dRay() { }
dRay (dReal length)
{ _id = dCreateRay (0,length); }
dRay (dSpace &space, dReal length)
{ _id = dCreateRay (space.id(),length); }
dRay (dSpaceID space, dReal length)
{ _id = dCreateRay (space,length); }
void create (dSpaceID space, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateRay (space,length);
}
void setLength (dReal length)
{ dGeomRaySetLength (_id, length); }
dReal getLength()
{ return dGeomRayGetLength (_id); }
void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
{ dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
void get (dVector3 start, dVector3 dir)
{ dGeomRayGet (_id, start, dir); }
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4996 )
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
ODE_API_DEPRECATED
void setParams (int firstContact, int backfaceCull)
{ dGeomRaySetParams (_id, firstContact, backfaceCull); }
ODE_API_DEPRECATED
void getParams (int *firstContact, int *backfaceCull)
{ dGeomRayGetParams (_id, firstContact, backfaceCull); }
#ifdef WIN32
#pragma warning( pop )
#else
#pragma GCC diagnostic pop
#endif
void setBackfaceCull (int backfaceCull)
{ dGeomRaySetBackfaceCull (_id, backfaceCull); }
int getBackfaceCull()
{ return dGeomRayGetBackfaceCull (_id); }
void setFirstContact (int firstContact)
{ dGeomRaySetFirstContact (_id, firstContact); }
int getFirstContact()
{ return dGeomRayGetFirstContact (_id); }
void setClosestHit (int closestHit)
{ dGeomRaySetClosestHit (_id, closestHit); }
int getClosestHit()
{ return dGeomRayGetClosestHit (_id); }
};
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4996 )
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
class ODE_API_DEPRECATED dGeomTransform : public dGeom {
// intentionally undefined, don't use these
dGeomTransform (dGeomTransform &);
void operator= (dGeomTransform &);
public:
dGeomTransform() { }
dGeomTransform (dSpace &space)
{ _id = dCreateGeomTransform (space.id()); }
dGeomTransform (dSpaceID space)
{ _id = dCreateGeomTransform (space); }
void create (dSpaceID space=0) {
if (_id) dGeomDestroy (_id);
_id = dCreateGeomTransform (space);
}
void setGeom (dGeomID geom)
{ dGeomTransformSetGeom (_id, geom); }
dGeomID getGeom() const
{ return dGeomTransformGetGeom (_id); }
void setCleanup (int mode)
{ dGeomTransformSetCleanup (_id,mode); }
int getCleanup ()
{ return dGeomTransformGetCleanup (_id); }
void setInfo (int mode)
{ dGeomTransformSetInfo (_id,mode); }
int getInfo()
{ return dGeomTransformGetInfo (_id); }
};
#ifdef WIN32
#pragma warning( pop )
#else
#pragma GCC diagnostic pop
#endif
//}
#endif
#endif
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/* C++ interface for new collision API */
#ifndef _ODE_ODECPP_COLLISION_H_
#define _ODE_ODECPP_COLLISION_H_
#ifdef __cplusplus
//#include <ode/error.h>
//namespace ode {
class dGeom {
// intentionally undefined, don't use these
dGeom (dGeom &);
void operator= (dGeom &);
protected:
dGeomID _id;
dGeom()
{ _id = 0; }
public:
~dGeom()
{ if (_id) dGeomDestroy (_id); }
dGeomID id() const
{ return _id; }
operator dGeomID() const
{ return _id; }
void destroy() {
if (_id) dGeomDestroy (_id);
_id = 0;
}
int getClass() const
{ return dGeomGetClass (_id); }
dSpaceID getSpace() const
{ return dGeomGetSpace (_id); }
void setData (void *data)
{ dGeomSetData (_id,data); }
void *getData() const
{ return dGeomGetData (_id); }
void setBody (dBodyID b)
{ dGeomSetBody (_id,b); }
dBodyID getBody() const
{ return dGeomGetBody (_id); }
void setPosition (dReal x, dReal y, dReal z)
{ dGeomSetPosition (_id,x,y,z); }
const dReal * getPosition() const
{ return dGeomGetPosition (_id); }
void setRotation (const dMatrix3 R)
{ dGeomSetRotation (_id,R); }
const dReal * getRotation() const
{ return dGeomGetRotation (_id); }
void setQuaternion (const dQuaternion quat)
{ dGeomSetQuaternion (_id,quat); }
void getQuaternion (dQuaternion quat) const
{ dGeomGetQuaternion (_id,quat); }
void getAABB (dReal aabb[6]) const
{ dGeomGetAABB (_id, aabb); }
int isSpace()
{ return dGeomIsSpace (_id); }
void setCategoryBits (unsigned long bits)
{ dGeomSetCategoryBits (_id, bits); }
void setCollideBits (unsigned long bits)
{ dGeomSetCollideBits (_id, bits); }
unsigned long getCategoryBits()
{ return dGeomGetCategoryBits (_id); }
unsigned long getCollideBits()
{ return dGeomGetCollideBits (_id); }
void enable()
{ dGeomEnable (_id); }
void disable()
{ dGeomDisable (_id); }
int isEnabled()
{ return dGeomIsEnabled (_id); }
void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetRelPointPos (_id, px, py, pz, result); }
void getRelPointPos (const dVector3 p, dVector3 result) const
{ getRelPointPos (p[0], p[1], p[2], result); }
void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomGetPosRelPoint (_id, px, py, pz, result); }
void getPosRelPoint (const dVector3 p, dVector3 result) const
{ getPosRelPoint (p[0], p[1], p[2], result); }
void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorToWorld (_id, px, py, pz, result); }
void vectorToWorld (const dVector3 p, dVector3 result) const
{ vectorToWorld (p[0], p[1], p[2], result); }
void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const
{ dGeomVectorFromWorld (_id, px, py, pz, result); }
void vectorFromWorld (const dVector3 p, dVector3 result) const
{ vectorFromWorld (p[0], p[1], p[2], result); }
void collide2 (dGeomID g, void *data, dNearCallback *callback)
{ dSpaceCollide2 (_id,g,data,callback); }
};
class dSpace : public dGeom {
// intentionally undefined, don't use these
dSpace (dSpace &);
void operator= (dSpace &);
protected:
// the default constructor is protected so that you
// can't instance this class. you must instance one
// of its subclasses instead.
dSpace () { _id = 0; }
public:
dSpaceID id() const
{ return (dSpaceID) _id; }
operator dSpaceID() const
{ return (dSpaceID) _id; }
void setCleanup (int mode)
{ dSpaceSetCleanup (id(), mode); }
int getCleanup()
{ return dSpaceGetCleanup (id()); }
void add (dGeomID x)
{ dSpaceAdd (id(), x); }
void remove (dGeomID x)
{ dSpaceRemove (id(), x); }
int query (dGeomID x)
{ return dSpaceQuery (id(),x); }
int getNumGeoms()
{ return dSpaceGetNumGeoms (id()); }
dGeomID getGeom (int i)
{ return dSpaceGetGeom (id(),i); }
void collide (void *data, dNearCallback *callback)
{ dSpaceCollide (id(),data,callback); }
};
class dSimpleSpace : public dSpace {
// intentionally undefined, don't use these
dSimpleSpace (dSimpleSpace &);
void operator= (dSimpleSpace &);
public:
dSimpleSpace ()
{ _id = (dGeomID) dSimpleSpaceCreate (0); }
dSimpleSpace (dSpace &space)
{ _id = (dGeomID) dSimpleSpaceCreate (space.id()); }
dSimpleSpace (dSpaceID space)
{ _id = (dGeomID) dSimpleSpaceCreate (space); }
};
class dHashSpace : public dSpace {
// intentionally undefined, don't use these
dHashSpace (dHashSpace &);
void operator= (dHashSpace &);
public:
dHashSpace ()
{ _id = (dGeomID) dHashSpaceCreate (0); }
dHashSpace (dSpace &space)
{ _id = (dGeomID) dHashSpaceCreate (space.id()); }
dHashSpace (dSpaceID space)
{ _id = (dGeomID) dHashSpaceCreate (space); }
void setLevels (int minlevel, int maxlevel)
{ dHashSpaceSetLevels (id(),minlevel,maxlevel); }
};
class dQuadTreeSpace : public dSpace {
// intentionally undefined, don't use these
dQuadTreeSpace (dQuadTreeSpace &);
void operator= (dQuadTreeSpace &);
public:
dQuadTreeSpace (const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (0,center,extents,depth); }
dQuadTreeSpace (dSpace &space, const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (space.id(),center,extents,depth); }
dQuadTreeSpace (dSpaceID space, const dVector3 center, const dVector3 extents, int depth)
{ _id = (dGeomID) dQuadTreeSpaceCreate (space,center,extents,depth); }
};
class dSphere : public dGeom {
// intentionally undefined, don't use these
dSphere (dSphere &);
void operator= (dSphere &);
public:
dSphere () { }
dSphere (dReal radius)
{ _id = dCreateSphere (0, radius); }
dSphere (dSpace &space, dReal radius)
{ _id = dCreateSphere (space.id(), radius); }
dSphere (dSpaceID space, dReal radius)
{ _id = dCreateSphere (space, radius); }
void create (dSpaceID space, dReal radius) {
if (_id) dGeomDestroy (_id);
_id = dCreateSphere (space, radius);
}
void setRadius (dReal radius)
{ dGeomSphereSetRadius (_id, radius); }
dReal getRadius() const
{ return dGeomSphereGetRadius (_id); }
};
class dBox : public dGeom {
// intentionally undefined, don't use these
dBox (dBox &);
void operator= (dBox &);
public:
dBox () { }
dBox (dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (0,lx,ly,lz); }
dBox (dSpace &space, dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (space,lx,ly,lz); }
dBox (dSpaceID space, dReal lx, dReal ly, dReal lz)
{ _id = dCreateBox (space,lx,ly,lz); }
void create (dSpaceID space, dReal lx, dReal ly, dReal lz) {
if (_id) dGeomDestroy (_id);
_id = dCreateBox (space,lx,ly,lz);
}
void setLengths (dReal lx, dReal ly, dReal lz)
{ dGeomBoxSetLengths (_id, lx, ly, lz); }
void getLengths (dVector3 result) const
{ dGeomBoxGetLengths (_id,result); }
};
class dPlane : public dGeom {
// intentionally undefined, don't use these
dPlane (dPlane &);
void operator= (dPlane &);
public:
dPlane() { }
dPlane (dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (0,a,b,c,d); }
dPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (space.id(),a,b,c,d); }
dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d)
{ _id = dCreatePlane (space,a,b,c,d); }
void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) {
if (_id) dGeomDestroy (_id);
_id = dCreatePlane (space,a,b,c,d);
}
void setParams (dReal a, dReal b, dReal c, dReal d)
{ dGeomPlaneSetParams (_id, a, b, c, d); }
void getParams (dVector4 result) const
{ dGeomPlaneGetParams (_id,result); }
};
class dCapsule : public dGeom {
// intentionally undefined, don't use these
dCapsule (dCapsule &);
void operator= (dCapsule &);
public:
dCapsule() { }
dCapsule (dReal radius, dReal length)
{ _id = dCreateCapsule (0,radius,length); }
dCapsule (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCapsule (space.id(),radius,length); }
dCapsule (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCapsule (space,radius,length); }
void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateCapsule (space,radius,length);
}
void setParams (dReal radius, dReal length)
{ dGeomCapsuleSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const
{ dGeomCapsuleGetParams (_id,radius,length); }
};
class dCylinder : public dGeom {
// intentionally undefined, don't use these
dCylinder (dCylinder &);
void operator= (dCylinder &);
public:
dCylinder() { }
dCylinder (dReal radius, dReal length)
{ _id = dCreateCylinder (0,radius,length); }
dCylinder (dSpace &space, dReal radius, dReal length)
{ _id = dCreateCylinder (space.id(),radius,length); }
dCylinder (dSpaceID space, dReal radius, dReal length)
{ _id = dCreateCylinder (space,radius,length); }
void create (dSpaceID space, dReal radius, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateCylinder (space,radius,length);
}
void setParams (dReal radius, dReal length)
{ dGeomCylinderSetParams (_id, radius, length); }
void getParams (dReal *radius, dReal *length) const
{ dGeomCylinderGetParams (_id,radius,length); }
};
class dRay : public dGeom {
// intentionally undefined, don't use these
dRay (dRay &);
void operator= (dRay &);
public:
dRay() { }
dRay (dReal length)
{ _id = dCreateRay (0,length); }
dRay (dSpace &space, dReal length)
{ _id = dCreateRay (space.id(),length); }
dRay (dSpaceID space, dReal length)
{ _id = dCreateRay (space,length); }
void create (dSpaceID space, dReal length) {
if (_id) dGeomDestroy (_id);
_id = dCreateRay (space,length);
}
void setLength (dReal length)
{ dGeomRaySetLength (_id, length); }
dReal getLength()
{ return dGeomRayGetLength (_id); }
void set (dReal px, dReal py, dReal pz, dReal dx, dReal dy, dReal dz)
{ dGeomRaySet (_id, px, py, pz, dx, dy, dz); }
void get (dVector3 start, dVector3 dir)
{ dGeomRayGet (_id, start, dir); }
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4996 )
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
ODE_API_DEPRECATED
void setParams (int firstContact, int backfaceCull)
{ dGeomRaySetParams (_id, firstContact, backfaceCull); }
ODE_API_DEPRECATED
void getParams (int *firstContact, int *backfaceCull)
{ dGeomRayGetParams (_id, firstContact, backfaceCull); }
#ifdef WIN32
#pragma warning( pop )
#else
#pragma GCC diagnostic pop
#endif
void setBackfaceCull (int backfaceCull)
{ dGeomRaySetBackfaceCull (_id, backfaceCull); }
int getBackfaceCull()
{ return dGeomRayGetBackfaceCull (_id); }
void setFirstContact (int firstContact)
{ dGeomRaySetFirstContact (_id, firstContact); }
int getFirstContact()
{ return dGeomRayGetFirstContact (_id); }
void setClosestHit (int closestHit)
{ dGeomRaySetClosestHit (_id, closestHit); }
int getClosestHit()
{ return dGeomRayGetClosestHit (_id); }
};
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4996 )
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
class ODE_API_DEPRECATED dGeomTransform : public dGeom {
// intentionally undefined, don't use these
dGeomTransform (dGeomTransform &);
void operator= (dGeomTransform &);
public:
dGeomTransform() { }
dGeomTransform (dSpace &space)
{ _id = dCreateGeomTransform (space.id()); }
dGeomTransform (dSpaceID space)
{ _id = dCreateGeomTransform (space); }
void create (dSpaceID space=0) {
if (_id) dGeomDestroy (_id);
_id = dCreateGeomTransform (space);
}
void setGeom (dGeomID geom)
{ dGeomTransformSetGeom (_id, geom); }
dGeomID getGeom() const
{ return dGeomTransformGetGeom (_id); }
void setCleanup (int mode)
{ dGeomTransformSetCleanup (_id,mode); }
int getCleanup ()
{ return dGeomTransformGetCleanup (_id); }
void setInfo (int mode)
{ dGeomTransformSetInfo (_id,mode); }
int getInfo()
{ return dGeomTransformGetInfo (_id); }
};
#ifdef WIN32
#pragma warning( pop )
#else
#pragma GCC diagnostic pop
#endif
//}
#endif
#endif

@ -1,236 +1,236 @@
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/* Library initialization/finalization functions. */
#ifndef _ODE_ODEINIT_H_
#define _ODE_ODEINIT_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ************************************************************************ */
/* Library initialization */
/**
* @defgroup init Library Initialization
*
* Library initialization functions prepare ODE internal data structures for use
* and release allocated resources after ODE is not needed any more.
*/
/**
* @brief Library initialization flags.
*
* These flags define ODE library initialization options.
*
* @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.
* 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
* remain not freed for some time after the thread exits. The resources may be
* released when one of other threads calls @c dAllocateODEDataForThread. Ultimately,
* 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
* or on library closure with @c dCloseODE.
*
* With manual thread data cleanup mode every collision space object must be
* explicitly switched to manual cleanup mode with @c dSpaceSetManualCleanup
* after creation. See description of the function for more details.
*
* If @c dInitFlagManualThreadCleanup was not specified during initialization,
* calls to @c dCleanupODEAllDataForThread are not allowed.
*
* @see dInitODE2
* @see dAllocateODEDataForThread
* @see dSpaceSetManualCleanup
* @see dCloseODE
* @ingroup init
*/
enum dInitODEFlags {
dInitFlagManualThreadCleanup = 0x00000001 /*@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call*/
};
/**
* @brief Initializes ODE library.
*
* @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
* @code
* dInitODE2(0);
* dAllocateODEDataForThread(dAllocateMaskAll);
* @endcode
*
* @see dInitODE2
* @see dAllocateODEDataForThread
* @ingroup init
*/
ODE_API void dInitODE(void);
/**
* @brief Initializes ODE library.
* @param uiInitFlags Initialization options bitmask
* @return A nonzero if initialization succeeded and zero otherwise.
*
* 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
* closed with a call to @c dCloseODE.
*
* The @a uiInitFlags parameter specifies initialization options to be used. These
* can be combination of zero or more @c dInitODEFlags flags.
*
* @note
* If @c dInitFlagManualThreadCleanup flag is used for initialization,
* @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.
*
* @see dInitODEFlags
* @see dCloseODE
* @see dSpaceSetManualCleanup
* @ingroup init
*/
ODE_API int dInitODE2(unsigned int uiInitFlags/*=0*/);
/**
* @brief ODE data allocation flags.
*
* These flags are used to indicate which data is to be pre-allocated in call to
* @c dAllocateODEDataForThread.
*
* @c dAllocateFlagBasicData tells to allocate the basic data set required for
* normal library operation. This flag is equal to zero and is always implicitly
* included.
*
* @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
* in advance. If collision detection is not going to be used, it is not necessary
* to specify this flag.
*
* @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.
* 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
* applications should use explicit flags they need rather than allocating everything.
*
* @see dAllocateODEDataForThread
* @ingroup init
*/
enum dAllocateODEDataFlags {
dAllocateFlagBasicData = 0, /*@< Allocate basic data required for library to operate*/
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.*/
};
/**
* @brief Allocate thread local data to allow the thread calling ODE.
* @param uiAllocateFlags Allocation options bitmask.
* @return A nonzero if allocation succeeded and zero otherwise.
*
* 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
* current thread along with optional data required for particular ODE subsystems.
*
* @a uiAllocateFlags parameter can contain zero or more flags from @c dAllocateODEDataFlags
* enumerated type. Multiple calls with different allocation flags are allowed.
* 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
* data the library can not operate without.
*
* 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
* flags when more system resources are available.
*
* @see dAllocateODEDataFlags
* @see dCleanupODEAllDataForThread
* @ingroup init
*/
ODE_API int dAllocateODEDataForThread(unsigned int uiAllocateFlags);
/**
* @brief Free thread local data that was allocated for current thread.
*
* 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.
* 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
* being used to release resources allocated for all the current subsystems and
* possibly proceed with data pre-allocation for other subsystems.
*
* The function can safely be called several times in a row. The function can be
* called without prior invocation of @c dAllocateODEDataForThread. The function
* 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
* all the thread local resources that might be allocated for all the threads that
* were using ODE.
*
* If library was initialized without @c dInitFlagManualThreadCleanup flag
* @c dCleanupODEAllDataForThread must not be called.
*
* @see dAllocateODEDataForThread
* @see dInitODE2
* @see dCloseODE
* @ingroup init
*/
ODE_API void dCleanupODEAllDataForThread();
/**
* @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 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
* that were using ODE.
*
* @c dCloseODE is a paired function for @c dInitODE2 and must only be called
* after successful library initialization.
*
* @note Important!
* 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
* @c dCleanupODEAllDataForThread after @c dCloseODE.
*
* @see dInitODE2
* @see dCleanupODEAllDataForThread
* @ingroup init
*/
ODE_API void dCloseODE(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _ODE_ODEINIT_H_ */
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/* Library initialization/finalization functions. */
#ifndef _ODE_ODEINIT_H_
#define _ODE_ODEINIT_H_
#include <ode/common.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ************************************************************************ */
/* Library initialization */
/**
* @defgroup init Library Initialization
*
* Library initialization functions prepare ODE internal data structures for use
* and release allocated resources after ODE is not needed any more.
*/
/**
* @brief Library initialization flags.
*
* These flags define ODE library initialization options.
*
* @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.
* 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
* remain not freed for some time after the thread exits. The resources may be
* released when one of other threads calls @c dAllocateODEDataForThread. Ultimately,
* 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
* or on library closure with @c dCloseODE.
*
* With manual thread data cleanup mode every collision space object must be
* explicitly switched to manual cleanup mode with @c dSpaceSetManualCleanup
* after creation. See description of the function for more details.
*
* If @c dInitFlagManualThreadCleanup was not specified during initialization,
* calls to @c dCleanupODEAllDataForThread are not allowed.
*
* @see dInitODE2
* @see dAllocateODEDataForThread
* @see dSpaceSetManualCleanup
* @see dCloseODE
* @ingroup init
*/
enum dInitODEFlags {
dInitFlagManualThreadCleanup = 0x00000001 /*@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call*/
};
/**
* @brief Initializes ODE library.
*
* @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
* @code
* dInitODE2(0);
* dAllocateODEDataForThread(dAllocateMaskAll);
* @endcode
*
* @see dInitODE2
* @see dAllocateODEDataForThread
* @ingroup init
*/
ODE_API void dInitODE(void);
/**
* @brief Initializes ODE library.
* @param uiInitFlags Initialization options bitmask
* @return A nonzero if initialization succeeded and zero otherwise.
*
* 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
* closed with a call to @c dCloseODE.
*
* The @a uiInitFlags parameter specifies initialization options to be used. These
* can be combination of zero or more @c dInitODEFlags flags.
*
* @note
* If @c dInitFlagManualThreadCleanup flag is used for initialization,
* @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.
*
* @see dInitODEFlags
* @see dCloseODE
* @see dSpaceSetManualCleanup
* @ingroup init
*/
ODE_API int dInitODE2(unsigned int uiInitFlags/*=0*/);
/**
* @brief ODE data allocation flags.
*
* These flags are used to indicate which data is to be pre-allocated in call to
* @c dAllocateODEDataForThread.
*
* @c dAllocateFlagBasicData tells to allocate the basic data set required for
* normal library operation. This flag is equal to zero and is always implicitly
* included.
*
* @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
* in advance. If collision detection is not going to be used, it is not necessary
* to specify this flag.
*
* @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.
* 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
* applications should use explicit flags they need rather than allocating everything.
*
* @see dAllocateODEDataForThread
* @ingroup init
*/
enum dAllocateODEDataFlags {
dAllocateFlagBasicData = 0, /*@< Allocate basic data required for library to operate*/
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.*/
};
/**
* @brief Allocate thread local data to allow the thread calling ODE.
* @param uiAllocateFlags Allocation options bitmask.
* @return A nonzero if allocation succeeded and zero otherwise.
*
* 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
* current thread along with optional data required for particular ODE subsystems.
*
* @a uiAllocateFlags parameter can contain zero or more flags from @c dAllocateODEDataFlags
* enumerated type. Multiple calls with different allocation flags are allowed.
* 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
* data the library can not operate without.
*
* 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
* flags when more system resources are available.
*
* @see dAllocateODEDataFlags
* @see dCleanupODEAllDataForThread
* @ingroup init
*/
ODE_API int dAllocateODEDataForThread(unsigned int uiAllocateFlags);
/**
* @brief Free thread local data that was allocated for current thread.
*
* 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.
* 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
* being used to release resources allocated for all the current subsystems and
* possibly proceed with data pre-allocation for other subsystems.
*
* The function can safely be called several times in a row. The function can be
* called without prior invocation of @c dAllocateODEDataForThread. The function
* 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
* all the thread local resources that might be allocated for all the threads that
* were using ODE.
*
* If library was initialized without @c dInitFlagManualThreadCleanup flag
* @c dCleanupODEAllDataForThread must not be called.
*
* @see dAllocateODEDataForThread
* @see dInitODE2
* @see dCloseODE
* @ingroup init
*/
ODE_API void dCleanupODEAllDataForThread();
/**
* @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 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
* that were using ODE.
*
* @c dCloseODE is a paired function for @c dInitODE2 and must only be called
* after successful library initialization.
*
* @note Important!
* 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
* @c dCleanupODEAllDataForThread after @c dCloseODE.
*
* @see dInitODE2
* @see dCleanupODEAllDataForThread
* @ingroup init
*/
ODE_API void dCloseODE(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#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. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_ODEMATH_LEGACY_H_
#define _ODE_ODEMATH_LEGACY_H_
/*
* These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that
* might still be using them.
*/
/*
* General purpose vector operations with other vectors or constants.
*/
#define dOP(a,op,b,c) do { \
(a)[0] = ((b)[0]) op ((c)[0]); \
(a)[1] = ((b)[1]) op ((c)[1]); \
(a)[2] = ((b)[2]) op ((c)[2]); \
} while (0)
#define dOPC(a,op,b,c) do { \
(a)[0] = ((b)[0]) op (c); \
(a)[1] = ((b)[1]) op (c); \
(a)[2] = ((b)[2]) op (c); \
} while (0)
#define dOPE(a,op,b) do {\
(a)[0] op ((b)[0]); \
(a)[1] op ((b)[1]); \
(a)[2] op ((b)[2]); \
} while (0)
#define dOPEC(a,op,c) do { \
(a)[0] op (c); \
(a)[1] op (c); \
(a)[2] op (c); \
} while (0)
/* Define an equation with operators
* For example this function can be used to replace
* <PRE>
* for (int i=0; i<3; ++i)
* a[i] += b[i] + c[i];
* </PRE>
*/
#define dOPE2(a,op1,b,op2,c) do { \
(a)[0] op1 ((b)[0]) op2 ((c)[0]); \
(a)[1] op1 ((b)[1]) op2 ((c)[1]); \
(a)[2] op1 ((b)[2]) op2 ((c)[2]); \
} while (0)
#define dLENGTHSQUARED(a) dCalcVectorLengthSquare3(a)
#define dLENGTH(a) dCalcVectorLength3(a)
#define dDISTANCE(a, b) dCalcPointsDistance3(a, b)
#define dDOT(a, b) dCalcVectorDot3(a, b)
#define dDOT13(a, b) dCalcVectorDot3_13(a, b)
#define dDOT31(a, b) dCalcVectorDot3_31(a, b)
#define dDOT33(a, b) dCalcVectorDot3_33(a, b)
#define dDOT14(a, b) dCalcVectorDot3_14(a, b)
#define dDOT41(a, b) dCalcVectorDot3_41(a, b)
#define dDOT44(a, b) dCalcVectorDot3_44(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.
* dCROSS() means dCROSS111. `op' is normally `=', but you can set it to
* +=, -= etc to get other effects.
*/
#define dCROSS(a,op,b,c) \
do { \
(a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \
(a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \
(a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \
} while(0)
#define dCROSSpqr(a,op,b,c,p,q,r) \
do { \
(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)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \
} while(0)
#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 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 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 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.
* 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!
* if (plus,minus) is (+,-) then a positive version will be written.
* if (plus,minus) is (-,+) then a negative version will be written.
*/
#define dCROSSMAT(A,a,skip,plus,minus) \
do { \
(A)[1] = minus (a)[2]; \
(A)[2] = plus (a)[1]; \
(A)[(skip)+0] = plus (a)[2]; \
(A)[(skip)+2] = minus (a)[0]; \
(A)[2*(skip)+0] = minus (a)[1]; \
(A)[2*(skip)+1] = plus (a)[0]; \
} while(0)
/*
Note: NEVER call any of these functions/macros with the same variable for A and C,
it is not equivalent to A*=B.
*/
#define dMULTIPLY0_331(A, B, C) dMultiply0_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_333(A, B, C) dMultiply0_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 dMULTIPLYADD0_331(A, B, C) dMultiplyAdd0_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_333(A, B, C) dMultiplyAdd0_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)
/*
* These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that
* might still be using them.
*/
#endif /* #ifndef _ODE_ODEMATH_LEGACY_H_ */
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
#ifndef _ODE_ODEMATH_LEGACY_H_
#define _ODE_ODEMATH_LEGACY_H_
/*
* These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that
* might still be using them.
*/
/*
* General purpose vector operations with other vectors or constants.
*/
#define dOP(a,op,b,c) do { \
(a)[0] = ((b)[0]) op ((c)[0]); \
(a)[1] = ((b)[1]) op ((c)[1]); \
(a)[2] = ((b)[2]) op ((c)[2]); \
} while (0)
#define dOPC(a,op,b,c) do { \
(a)[0] = ((b)[0]) op (c); \
(a)[1] = ((b)[1]) op (c); \
(a)[2] = ((b)[2]) op (c); \
} while (0)
#define dOPE(a,op,b) do {\
(a)[0] op ((b)[0]); \
(a)[1] op ((b)[1]); \
(a)[2] op ((b)[2]); \
} while (0)
#define dOPEC(a,op,c) do { \
(a)[0] op (c); \
(a)[1] op (c); \
(a)[2] op (c); \
} while (0)
/* Define an equation with operators
* For example this function can be used to replace
* <PRE>
* for (int i=0; i<3; ++i)
* a[i] += b[i] + c[i];
* </PRE>
*/
#define dOPE2(a,op1,b,op2,c) do { \
(a)[0] op1 ((b)[0]) op2 ((c)[0]); \
(a)[1] op1 ((b)[1]) op2 ((c)[1]); \
(a)[2] op1 ((b)[2]) op2 ((c)[2]); \
} while (0)
#define dLENGTHSQUARED(a) dCalcVectorLengthSquare3(a)
#define dLENGTH(a) dCalcVectorLength3(a)
#define dDISTANCE(a, b) dCalcPointsDistance3(a, b)
#define dDOT(a, b) dCalcVectorDot3(a, b)
#define dDOT13(a, b) dCalcVectorDot3_13(a, b)
#define dDOT31(a, b) dCalcVectorDot3_31(a, b)
#define dDOT33(a, b) dCalcVectorDot3_33(a, b)
#define dDOT14(a, b) dCalcVectorDot3_14(a, b)
#define dDOT41(a, b) dCalcVectorDot3_41(a, b)
#define dDOT44(a, b) dCalcVectorDot3_44(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.
* dCROSS() means dCROSS111. `op' is normally `=', but you can set it to
* +=, -= etc to get other effects.
*/
#define dCROSS(a,op,b,c) \
do { \
(a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \
(a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \
(a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \
} while(0)
#define dCROSSpqr(a,op,b,c,p,q,r) \
do { \
(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)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \
} while(0)
#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 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 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 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.
* 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!
* if (plus,minus) is (+,-) then a positive version will be written.
* if (plus,minus) is (-,+) then a negative version will be written.
*/
#define dCROSSMAT(A,a,skip,plus,minus) \
do { \
(A)[1] = minus (a)[2]; \
(A)[2] = plus (a)[1]; \
(A)[(skip)+0] = plus (a)[2]; \
(A)[(skip)+2] = minus (a)[0]; \
(A)[2*(skip)+0] = minus (a)[1]; \
(A)[2*(skip)+1] = plus (a)[0]; \
} while(0)
/*
Note: NEVER call any of these functions/macros with the same variable for A and C,
it is not equivalent to A*=B.
*/
#define dMULTIPLY0_331(A, B, C) dMultiply0_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_333(A, B, C) dMultiply0_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 dMULTIPLYADD0_331(A, B, C) dMultiplyAdd0_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_333(A, B, C) dMultiplyAdd0_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)
/*
* These macros are not used any more inside of ODE
* They are kept for backward compatibility with external code that
* might still be using them.
*/
#endif /* #ifndef _ODE_ODEMATH_LEGACY_H_ */

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

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

@ -1,412 +1,412 @@
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* Threading support header file. *
* Copyright (C) 2011-2012 Oleh Derevenko. All rights reserved. *
* e-mail: odar@eleks.com (change all "a" to "e") *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/*
* ODE threading support interfaces
*/
#ifndef _ODE_THREADING_H_
#define _ODE_THREADING_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>
#ifdef __cplusplus
extern "C" {
#endif
struct dxThreadingImplementation;
typedef struct dxThreadingImplementation *dThreadingImplementationID;
typedef unsigned dmutexindex_t;
struct dxMutexGroup;
typedef struct dxMutexGroup *dMutexGroupID;
#define dTHREADING_THREAD_COUNT_UNLIMITED 0U
/**
* @brief Allocates a group of muteces.
*
* The Mutex allocated do not need to support recursive locking.
*
* The Mutex names are provided to aid in debugging and thread state tracking.
*
* @param impl Threading implementation ID
* @param Mutex_count Number of Mutex to create
* @Mutex_names_ptr Pointer to optional Mutex names array to be associated with individual Mutex
* @returns MutexGroup ID or NULL if error occurred.
*
* @ingroup threading
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction
*/
typedef dMutexGroupID dMutexGroupAllocFunction (dThreadingImplementationID impl, dmutexindex_t Mutex_count, const char *const *Mutex_names_ptr/*=NULL*/);
/**
* @brief Deletes a group of muteces.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to deallocate
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction
*/
typedef void dMutexGroupFreeFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group);
/**
* @brief Locks a mutex in a group of muteces.
*
* The function is to block execution until requested mutex can be locked.
*
* Note: Mutex provided may not support recursive locking. Calling this function
* while mutex is already locked by current thread will result in unpredictable behavior.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to use for locking
* @param mutex_index The index of mutex to be locked (0..Mutex_count - 1)
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexUnlockFunction
*/
typedef void dMutexGroupMutexLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);
/**
* @brief Attempts to lock a mutex in a group of muteces.
*
* The function is to lock the requested mutex if it is unoccupied or
* immediately return failure if mutex is already locked by other thread.
*
* Note: Mutex provided may not support recursive locking. Calling this function
* while mutex is already locked by current thread will result in unpredictable behavior.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to use for locking
* @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)
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction
*/
/* typedef int dMutexGroupMutexTryLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);*/
/**
* @brief Unlocks a mutex in a group of muteces.
*
* The function is to unlock the given mutex provided it had been locked before.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to use for unlocking
* @param mutex_index The index of mutex to be unlocked (0..Mutex_count - 1)
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction
*/
typedef void dMutexGroupMutexUnlockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);
struct dxCallReleasee;
typedef struct dxCallReleasee *dCallReleaseeID;
struct dxCallWait;
typedef struct dxCallWait *dCallWaitID;
typedef dsizeint ddependencycount_t;
typedef ddiffint ddependencychange_t;
typedef dsizeint dcallindex_t;
typedef int dThreadedCallFunction(void *call_context, dcallindex_t instance_index,
dCallReleaseeID this_releasee);
typedef struct dxThreadedWaitTime
{
time_t wait_sec;
unsigned long wait_nsec;
} dThreadedWaitTime;
/**
* @brief Allocates a Wait ID that can be used to wait for a call.
*
* @param impl Threading implementation ID
* @returns Wait ID or NULL if error occurred
*
* @ingroup threading
* @see dThreadedCallWaitResetFunction
* @see dThreadedCallWaitFreeFunction
* @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction
*/
typedef dCallWaitID dThreadedCallWaitAllocFunction(dThreadingImplementationID impl);
/**
* @brief Resets a Wait ID so that it could be used to wait for another call.
*
* @param impl Threading implementation ID
* @param call_wait Wait ID to reset
*
* @ingroup threading
* @see dThreadedCallWaitAllocFunction
* @see dThreadedCallWaitFreeFunction
* @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction
*/
typedef void dThreadedCallWaitResetFunction(dThreadingImplementationID impl, dCallWaitID call_wait);
/**
* @brief Frees a Wait ID.
*
* @param impl Threading implementation ID
* @param call_wait Wait ID to delete
*
* @ingroup threading
* @see dThreadedCallWaitAllocFunction
* @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction
*/
typedef void dThreadedCallWaitFreeFunction(dThreadingImplementationID impl, dCallWaitID call_wait);
/**
* @brief Post a function to be called in another thread.
*
* A call is scheduled to be executed asynchronously.
*
* 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.
* 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
* 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
* 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
* is not zero (i.e. if any dependencies are expected at all). The call is not going
* to start until all its dependencies complete.
*
* In case if number of dependencies is unknown in advance 1 can be passed on call
* scheduling. Then @c dThreadedCallDependenciesCountAlterFunction can be used to
* add one more extra dependencies before scheduling each subcall. And then, after
* all sub-calls had been scheduled, @c dThreadedCallDependenciesCountAlterFunction
* 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
* 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
* been started (with parameter received in @c dThreadedCallFunction).
* 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
* 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.
*
* 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.
*
* 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.
*
* 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
* anticipated, avoided and worked around by implementation.
*
* @param impl Threading implementation ID
* @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
* @param out_post_releasee Optional pointer to variable to receive releasee ID
* associated with the call
* @param dependencies_count Number of dependencies that are going to reference
* this call as dependent releasee
* @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_func Pointer to function to be called
* @param call_context Context 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)
*
* @ingroup threading
* @see dThreadedCallWaitFunction
* @see dThreadedCallDependenciesCountAlterFunction
* @see dThreadingImplResourcesForCallsPreallocateFunction
*/
typedef void dThreadedCallPostFunction(dThreadingImplementationID impl, int *out_summary_fault/*=NULL*/,
dCallReleaseeID *out_post_releasee/*=NULL*/, ddependencycount_t dependencies_count, dCallReleaseeID dependent_releasee/*=NULL*/,
dCallWaitID call_wait/*=NULL*/,
dThreadedCallFunction *call_func, void *call_context, dcallindex_t instance_index,
const char *call_name/*=NULL*/);
/**
* @brief Add or remove extra dependencies from call that has been scheduled
* or is in process of execution.
*
* 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
* 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
* this function, the call is free to start executing immediately.
*
* After the call execution had been started, any additional dependencies can only
* be added from the call function itself!
*
* @param impl Threading implementation ID
* @param target_releasee ID of releasee to apply dependencies count change to
* @param dependencies_count_change Number of dependencies to add or remove
*
* @ingroup threading
* @see dThreadedCallPostFunction
*/
typedef void dThreadedCallDependenciesCountAlterFunction(dThreadingImplementationID impl, dCallReleaseeID target_releasee,
ddependencychange_t dependencies_count_change);
/**
* @brief Wait for a posted call to complete.
*
* Function blocks until a call identified by @a call_wait completes or
* timeout elapses.
*
* 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
* increasing worker thread count to avoid starvation. Use call dependencies
* 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
* 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
* 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
* 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.
*
* @param impl Threading implementation ID
* @param out_wait_status Optional pointer to variable to receive 1 if waiting succeeded
* 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 timeout_time_ptr Optional pointer to time specification the wait must not
* last longer than (pass NULL for infinite timeout)
* @param wait_name Optional name to be associated with the wait (for debugging and state tracking)
*
* @ingroup threading
* @see dThreadedCallPostFunction
*/
typedef void dThreadedCallWaitFunction(dThreadingImplementationID impl, int *out_wait_status/*=NULL*/,
dCallWaitID call_wait, const dThreadedWaitTime *timeout_time_ptr/*=NULL*/,
const char *wait_name/*=NULL*/);
/**
* @brief Retrieve number of active threads that serve the implementation.
*
* @param impl Threading implementation ID
* @returns Number of active threads
*
* @ingroup threading
*/
typedef unsigned dThreadingImplThreadCountRetrieveFunction(dThreadingImplementationID impl);
/**
* @brief Preallocate resources to handle posted calls.
*
* 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
* 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
* in library code and dependencies between them.
*
* @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.
*
* 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.
*
* @param impl Threading implementation ID
* @param max_simultaneous_calls_estimate An estimated number of calls that can be posted simultaneously
* @returns 1 or 0 to indicate success or failure
*
* @ingroup threading
* @see dThreadedCallPostFunction
*/
typedef int dThreadingImplResourcesForCallsPreallocateFunction(dThreadingImplementationID impl,
ddependencycount_t max_simultaneous_calls_estimate);
/**
* @brief An interface structure with function pointers to be provided by threading implementation.
*/
typedef struct dxThreadingFunctionsInfo
{
unsigned struct_size;
dMutexGroupAllocFunction *alloc_mutex_group;
dMutexGroupFreeFunction *free_mutex_group;
dMutexGroupMutexLockFunction *lock_group_mutex;
dMutexGroupMutexUnlockFunction *unlock_group_mutex;
dThreadedCallWaitAllocFunction *alloc_call_wait;
dThreadedCallWaitResetFunction *reset_call_wait;
dThreadedCallWaitFreeFunction *free_call_wait;
dThreadedCallPostFunction *post_call;
dThreadedCallDependenciesCountAlterFunction *alter_call_dependencies_count;
dThreadedCallWaitFunction *wait_call;
dThreadingImplThreadCountRetrieveFunction *retrieve_thread_count;
dThreadingImplResourcesForCallsPreallocateFunction *preallocate_resources_for_calls;
/*
* Beware of Jon Watte's anger if you dare to uncomment this!
* May cryptic text below be you a warning!
* Стародавні легенди розказують, що кожного сміливця, хто наважиться порушити табу
* і відкрити заборонений код, спіткає страшне прокляття і він відразу почне робити
* одні лиш помилки.
*
* dMutexGroupMutexTryLockFunction *trylock_group_mutex;
*/
} dThreadingFunctionsInfo;
#ifdef __cplusplus
}
#endif
#endif /* #ifndef _ODE_THREADING_H_ */
/*************************************************************************
* *
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
* All rights reserved. Email: russ@q12.org Web: www.q12.org *
* *
* Threading support header file. *
* Copyright (C) 2011-2012 Oleh Derevenko. All rights reserved. *
* e-mail: odar@eleks.com (change all "a" to "e") *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of EITHER: *
* (1) The GNU Lesser General Public License as published by the Free *
* Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. The text of the GNU Lesser *
* General Public License is included with this library in the *
* file LICENSE.TXT. *
* (2) The BSD-style license that is included with this library in *
* the file LICENSE-BSD.TXT. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
* LICENSE.TXT and LICENSE-BSD.TXT for more details. *
* *
*************************************************************************/
/*
* ODE threading support interfaces
*/
#ifndef _ODE_THREADING_H_
#define _ODE_THREADING_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>
#ifdef __cplusplus
extern "C" {
#endif
struct dxThreadingImplementation;
typedef struct dxThreadingImplementation *dThreadingImplementationID;
typedef unsigned dmutexindex_t;
struct dxMutexGroup;
typedef struct dxMutexGroup *dMutexGroupID;
#define dTHREADING_THREAD_COUNT_UNLIMITED 0U
/**
* @brief Allocates a group of muteces.
*
* The Mutex allocated do not need to support recursive locking.
*
* The Mutex names are provided to aid in debugging and thread state tracking.
*
* @param impl Threading implementation ID
* @param Mutex_count Number of Mutex to create
* @Mutex_names_ptr Pointer to optional Mutex names array to be associated with individual Mutex
* @returns MutexGroup ID or NULL if error occurred.
*
* @ingroup threading
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction
*/
typedef dMutexGroupID dMutexGroupAllocFunction (dThreadingImplementationID impl, dmutexindex_t Mutex_count, const char *const *Mutex_names_ptr/*=NULL*/);
/**
* @brief Deletes a group of muteces.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to deallocate
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction
*/
typedef void dMutexGroupFreeFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group);
/**
* @brief Locks a mutex in a group of muteces.
*
* The function is to block execution until requested mutex can be locked.
*
* Note: Mutex provided may not support recursive locking. Calling this function
* while mutex is already locked by current thread will result in unpredictable behavior.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to use for locking
* @param mutex_index The index of mutex to be locked (0..Mutex_count - 1)
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexUnlockFunction
*/
typedef void dMutexGroupMutexLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);
/**
* @brief Attempts to lock a mutex in a group of muteces.
*
* The function is to lock the requested mutex if it is unoccupied or
* immediately return failure if mutex is already locked by other thread.
*
* Note: Mutex provided may not support recursive locking. Calling this function
* while mutex is already locked by current thread will result in unpredictable behavior.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to use for locking
* @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)
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction
* @see dMutexGroupMutexUnlockFunction
*/
/* typedef int dMutexGroupMutexTryLockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);*/
/**
* @brief Unlocks a mutex in a group of muteces.
*
* The function is to unlock the given mutex provided it had been locked before.
*
* @param impl Threading implementation ID
* @param mutex_group Mutex group to use for unlocking
* @param mutex_index The index of mutex to be unlocked (0..Mutex_count - 1)
*
* @ingroup threading
* @see dMutexGroupAllocFunction
* @see dMutexGroupFreeFunction
* @see dMutexGroupMutexLockFunction
*/
typedef void dMutexGroupMutexUnlockFunction (dThreadingImplementationID impl, dMutexGroupID mutex_group, dmutexindex_t mutex_index);
struct dxCallReleasee;
typedef struct dxCallReleasee *dCallReleaseeID;
struct dxCallWait;
typedef struct dxCallWait *dCallWaitID;
typedef dsizeint ddependencycount_t;
typedef ddiffint ddependencychange_t;
typedef dsizeint dcallindex_t;
typedef int dThreadedCallFunction(void *call_context, dcallindex_t instance_index,
dCallReleaseeID this_releasee);
typedef struct dxThreadedWaitTime
{
time_t wait_sec;
unsigned long wait_nsec;
} dThreadedWaitTime;
/**
* @brief Allocates a Wait ID that can be used to wait for a call.
*
* @param impl Threading implementation ID
* @returns Wait ID or NULL if error occurred
*
* @ingroup threading
* @see dThreadedCallWaitResetFunction
* @see dThreadedCallWaitFreeFunction
* @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction
*/
typedef dCallWaitID dThreadedCallWaitAllocFunction(dThreadingImplementationID impl);
/**
* @brief Resets a Wait ID so that it could be used to wait for another call.
*
* @param impl Threading implementation ID
* @param call_wait Wait ID to reset
*
* @ingroup threading
* @see dThreadedCallWaitAllocFunction
* @see dThreadedCallWaitFreeFunction
* @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction
*/
typedef void dThreadedCallWaitResetFunction(dThreadingImplementationID impl, dCallWaitID call_wait);
/**
* @brief Frees a Wait ID.
*
* @param impl Threading implementation ID
* @param call_wait Wait ID to delete
*
* @ingroup threading
* @see dThreadedCallWaitAllocFunction
* @see dThreadedCallPostFunction
* @see dThreadedCallWaitFunction
*/
typedef void dThreadedCallWaitFreeFunction(dThreadingImplementationID impl, dCallWaitID call_wait);
/**
* @brief Post a function to be called in another thread.
*
* A call is scheduled to be executed asynchronously.
*
* 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.
* 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
* 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
* 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
* is not zero (i.e. if any dependencies are expected at all). The call is not going
* to start until all its dependencies complete.
*
* In case if number of dependencies is unknown in advance 1 can be passed on call
* scheduling. Then @c dThreadedCallDependenciesCountAlterFunction can be used to
* add one more extra dependencies before scheduling each subcall. And then, after
* all sub-calls had been scheduled, @c dThreadedCallDependenciesCountAlterFunction
* 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
* 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
* been started (with parameter received in @c dThreadedCallFunction).
* 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
* 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.
*
* 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.
*
* 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.
*
* 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
* anticipated, avoided and worked around by implementation.
*
* @param impl Threading implementation ID
* @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
* @param out_post_releasee Optional pointer to variable to receive releasee ID
* associated with the call
* @param dependencies_count Number of dependencies that are going to reference
* this call as dependent releasee
* @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_func Pointer to function to be called
* @param call_context Context 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)
*
* @ingroup threading
* @see dThreadedCallWaitFunction
* @see dThreadedCallDependenciesCountAlterFunction
* @see dThreadingImplResourcesForCallsPreallocateFunction
*/
typedef void dThreadedCallPostFunction(dThreadingImplementationID impl, int *out_summary_fault/*=NULL*/,
dCallReleaseeID *out_post_releasee/*=NULL*/, ddependencycount_t dependencies_count, dCallReleaseeID dependent_releasee/*=NULL*/,
dCallWaitID call_wait/*=NULL*/,
dThreadedCallFunction *call_func, void *call_context, dcallindex_t instance_index,
const char *call_name/*=NULL*/);
/**
* @brief Add or remove extra dependencies from call that has been scheduled
* or is in process of execution.
*
* 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
* 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
* this function, the call is free to start executing immediately.
*
* After the call execution had been started, any additional dependencies can only
* be added from the call function itself!
*
* @param impl Threading implementation ID
* @param target_releasee ID of releasee to apply dependencies count change to
* @param dependencies_count_change Number of dependencies to add or remove
*
* @ingroup threading
* @see dThreadedCallPostFunction
*/
typedef void dThreadedCallDependenciesCountAlterFunction(dThreadingImplementationID impl, dCallReleaseeID target_releasee,
ddependencychange_t dependencies_count_change);
/**
* @brief Wait for a posted call to complete.
*
* Function blocks until a call identified by @a call_wait completes or
* timeout elapses.
*
* 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
* increasing worker thread count to avoid starvation. Use call dependencies
* 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
* 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
* 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
* 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.
*
* @param impl Threading implementation ID
* @param out_wait_status Optional pointer to variable to receive 1 if waiting succeeded
* 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 timeout_time_ptr Optional pointer to time specification the wait must not
* last longer than (pass NULL for infinite timeout)
* @param wait_name Optional name to be associated with the wait (for debugging and state tracking)
*
* @ingroup threading
* @see dThreadedCallPostFunction
*/
typedef void dThreadedCallWaitFunction(dThreadingImplementationID impl, int *out_wait_status/*=NULL*/,
dCallWaitID call_wait, const dThreadedWaitTime *timeout_time_ptr/*=NULL*/,
const char *wait_name/*=NULL*/);
/**
* @brief Retrieve number of active threads that serve the implementation.
*
* @param impl Threading implementation ID
* @returns Number of active threads
*
* @ingroup threading
*/
typedef unsigned dThreadingImplThreadCountRetrieveFunction(dThreadingImplementationID impl);
/**
* @brief Preallocate resources to handle posted calls.
*
* 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
* 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
* in library code and dependencies between them.
*
* @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.
*
* 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.
*
* @param impl Threading implementation ID
* @param max_simultaneous_calls_estimate An estimated number of calls that can be posted simultaneously
* @returns 1 or 0 to indicate success or failure
*
* @ingroup threading
* @see dThreadedCallPostFunction
*/
typedef int dThreadingImplResourcesForCallsPreallocateFunction(dThreadingImplementationID impl,
ddependencycount_t max_simultaneous_calls_estimate);
/**
* @brief An interface structure with function pointers to be provided by threading implementation.
*/
typedef struct dxThreadingFunctionsInfo
{
unsigned struct_size;
dMutexGroupAllocFunction *alloc_mutex_group;
dMutexGroupFreeFunction *free_mutex_group;
dMutexGroupMutexLockFunction *lock_group_mutex;
dMutexGroupMutexUnlockFunction *unlock_group_mutex;
dThreadedCallWaitAllocFunction *alloc_call_wait;
dThreadedCallWaitResetFunction *reset_call_wait;
dThreadedCallWaitFreeFunction *free_call_wait;
dThreadedCallPostFunction *post_call;
dThreadedCallDependenciesCountAlterFunction *alter_call_dependencies_count;
dThreadedCallWaitFunction *wait_call;
dThreadingImplThreadCountRetrieveFunction *retrieve_thread_count;
dThreadingImplResourcesForCallsPreallocateFunction *preallocate_resources_for_calls;
/*
* Beware of Jon Watte's anger if you dare to uncomment this!
* May cryptic text below be you a warning!
* Стародавні легенди розказують, що кожного сміливця, хто наважиться порушити табу
* і відкрити заборонений код, спіткає страшне прокляття і він відразу почне робити
* одні лиш помилки.
*
* dMutexGroupMutexTryLockFunction *trylock_group_mutex;
*/
} dThreadingFunctionsInfo;
#ifdef __cplusplus
}
#endif
#endif /* #ifndef _ODE_THREADING_H_ */

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

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

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

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

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

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

File diff suppressed because it is too large Load Diff

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

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

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

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

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

File diff suppressed because it is too large Load Diff

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