|
#define | oslAbs(x) (((x)<0)?(-(x)):(x)) |
|
#define | oslMin(x, y) (((x)<(y))?(x):(y)) |
|
#define | oslMax(x, y) (((x)>(y))?(x):(y)) |
|
#define | oslMinMax(x, min, max) ((x) < (max) ? ((x) > (min) ? (x) : (min)) : (max)) |
|
#define | oslNumberof(n) (sizeof(n)/sizeof(*(n))) |
|
Main OSLib section. Contains the main routines to initialize and terminate the library.
#define oslAbs |
( |
|
x | ) |
(((x)<0)?(-(x)):(x)) |
Returns the absolute value of a number (that is, the positive part of the number).
#define oslMin |
( |
|
x, |
|
|
|
y |
|
) |
| (((x)<(y))?(x):(y)) |
Returns the smallest value between the two.
#define oslMax |
( |
|
x, |
|
|
|
y |
|
) |
| (((x)>(y))?(x):(y)) |
Returns the greatest value between the two.
#define oslMinMax |
( |
|
x, |
|
|
|
min, |
|
|
|
max |
|
) |
| ((x) < (max) ? ((x) > (min) ? (x) : (min)) : (max)) |
Returns a value clamped between a minimum and maximum.
int addColor(int colValue, int addValue) {
colValue =
oslMinMax(colValue + addValue, 0, 255);
return colValue;
}
#define oslNumberof |
( |
|
n | ) |
(sizeof(n)/sizeof(*(n))) |
Returns the number of objects in an array.
{
"ram:/file1.jpg", (
void*)file1_jpg, file1_jpg_size, &
VF_MEMORY},
{
"ram:/file2.png", (
void*)file2_png, file2_png_size, &
VF_MEMORY},
};
float oslSin |
( |
float |
angle, |
|
|
float |
dist |
|
) |
| |
Calculates the sine of an angle in degrees multiplicated by a radius. Returns the result as a float. oslSin and oslCos use the VFPU to compute the result, and thus it's very fast and very precise.
- Parameters
-
angle | Angle in degrees (360° means a full circle) |
dist | Radius of the circle |
- Returns
- sin(angle * PI / 180) * dist
float cX, cY;
float cSpeed;
float cAngle;
float oslCos |
( |
float |
angle, |
|
|
float |
dist |
|
) |
| |
Calculates the cosine of an angle in degrees multiplicated by a radius. Returns the result as a float.
- Parameters
-
angle | Angle in degrees (360° means a full circle) |
dist | Radius of the circle |
- Returns
- cos(angle * PI / 180) * dist
int oslSini |
( |
int |
angle, |
|
|
int |
dist |
|
) |
| |
Returns the sine of an angle in degrees (0 to 360) multiplicated by an integer radius. Returns the result as an integer. These routines use a precalculated lookup table to compute the result. Don't think oslSini and oslCosi are much faster than oslSin and oslCos, it's not the case.
int angle = 40, radius = 20;
int oslCosi |
( |
int |
angle, |
|
|
int |
dist |
|
) |
| |
Returns the cosine of an angle in degrees (0 to 360) multiplicated by an integer radius. Returns the result as an integer.
int oslGetNextPower2 |
( |
int |
val | ) |
|
Returns the next (upper) power of two of a number.