CRM32Pro SDK
v5.22
|
IPrimitives. More...
IPrimitives.
Primitives interface system.
Public Member Functions | |
void | BoxColor (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned int color) |
Draw a filled rectangle. More... | |
void | BoxRGBA (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) |
Draw a filled rectangle. More... | |
void | CMYKtoRGB (unsigned char c, unsigned char m, unsigned char y, unsigned char k, unsigned char *r8, unsigned char *g8, unsigned char *b8) |
Color conversion: from CMYK to RGB. More... | |
void | Get16Pixel (SDL_Surface *surf, short x, short y, unsigned int *arraypixels, unsigned char alock=1) |
Get a packed of 16 pixels. It only works with 32bit modes. More... | |
int | GetCollisionMethod () |
Get current collision detection method. More... | |
unsigned int | GetPixel (SDL_Surface *surf, short x, short y, unsigned char alock=1) |
Get a single pixel. More... | |
void | HLineColor (SDL_Surface *surf, short x1, short x2, short y, unsigned int color) |
Draw a horinzontal line with bounce checking. More... | |
void | HLineRGBA (SDL_Surface *surf, short x1, short x2, short y, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) |
Draw a horinzontal line with bounce checking. More... | |
void | HSVtoRGB (float h, float s, float v, unsigned char *r8, unsigned char *g8, unsigned char *b8) |
Color conversion: from HSV to RGB. More... | |
void | LineColor (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned int color) |
Draw a line with bounce checking. More... | |
void | LineRGBA (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) |
Draw a line with bounce checking. More... | |
unsigned char | PixelCollision (SDL_Surface *s1, SDL_Rect *r1, SDL_Surface *s, SDL_Rect *r2, unsigned char debug=0, SDL_Rect *posr1=NULL, SDL_Rect *posr2=NULL) |
Customizable collision detection between two surfaces. More... | |
void | Put16Pixel (SDL_Surface *surf, short x, short y, unsigned int *arraypixels, unsigned char alock=1) |
Draw a pack of 16 pixels. It only works with 32bit modes. More... | |
void | PutPixelColor (SDL_Surface *surf, short x, short y, unsigned int color, unsigned char alock=1) |
Draw a single pixel with bounce checking. More... | |
void | PutPixelRGBA (SDL_Surface *surf, short x, short y, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255, unsigned char alock=1) |
Draw a single pixel with bounce checking. More... | |
void | RectangleColor (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned int color) |
Draw an outlined rectangle. More... | |
void | RectangleRGBA (SDL_Surface *surf, short x1, short y1, short x2, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) |
Draw an outlined rectangle. More... | |
void | RGBtoCMYK (unsigned char r8, unsigned char g8, unsigned char b8, unsigned char *c, unsigned char *m, unsigned char *y, unsigned char *k) |
Color conversion: from RGB to CMYK. More... | |
void | RGBtoHSV (unsigned char r8, unsigned char g8, unsigned char b8, float *h, float *s, float *v) |
Color conversion: from RGB to HSV. More... | |
void | RGBtoYCC (unsigned char r8, unsigned char g8, unsigned char b8, unsigned char *Y, unsigned char *Cb, unsigned char *Cr) |
Color conversion: from RGB to YCC. More... | |
void | RGBtoYUV (unsigned char r8, unsigned char g8, unsigned char b8, unsigned char *Y, unsigned char *U, unsigned char *V) |
Color conversion: from RGB to YUV. More... | |
void | SetCollisionMethod (int mode) |
Set the collision detection method. More... | |
void | VLineColor (SDL_Surface *surf, short x, short y1, short y2, unsigned int color) |
Draw a vertical line with bounce checking. More... | |
void | VLineRGBA (SDL_Surface *surf, short x, short y1, short y2, unsigned char r, unsigned char g, unsigned char b, unsigned char a=255) |
Draw a vertical line with bounce checking. More... | |
void | YCCtoRGB (unsigned char Y, unsigned char Cb, unsigned char Cr, unsigned char *r8, unsigned char *g8, unsigned char *b8) |
Color conversion: from YCC to RGB. More... | |
void | YUVtoRGB (unsigned char Y, unsigned char U, unsigned char V, unsigned char *r8, unsigned char *g8, unsigned char *b8) |
Color conversion: from YUV to RGB. More... | |
void CRM32Pro_IPrimitives::BoxColor | ( | SDL_Surface * | surf, |
short | x1, | ||
short | y1, | ||
short | x2, | ||
short | y2, | ||
unsigned int | color | ||
) |
Draw a filled rectangle.
Tests the clipping region and has support for cursor autorestore.
surf | surface to render the rectangle |
x1 | Desired start x position |
y1 | Desired start y |
x2 | Desired end x position |
y2 | Desired end y |
color | Packet(RGBA) pixel color |
void CRM32Pro_IPrimitives::BoxRGBA | ( | SDL_Surface * | surf, |
short | x1, | ||
short | y1, | ||
short | x2, | ||
short | y2, | ||
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a = 255 |
||
) |
Draw a filled rectangle.
Tests the clipping region and has support for cursor autorestore.
surf | surface to render the rectangle |
x1 | Desired start x position |
y1 | Desired start y |
x2 | Desired end x position |
y2 | Desired end y |
r | Red component |
g | Green component |
b | Blue component |
a | Alpha component. By default is 255. |
void CRM32Pro_IPrimitives::CMYKtoRGB | ( | unsigned char | c, |
unsigned char | m, | ||
unsigned char | y, | ||
unsigned char | k, | ||
unsigned char * | r8, | ||
unsigned char * | g8, | ||
unsigned char * | b8 | ||
) |
Color conversion: from CMYK to RGB.
c | cyan component |
m | magenta component |
y | yellow component |
k | key(black) component |
r8 | pointer to Red component |
g8 | pointer to Green component |
b8 | pointer to Blue component |
void CRM32Pro_IPrimitives::Get16Pixel | ( | SDL_Surface * | surf, |
short | x, | ||
short | y, | ||
unsigned int * | arraypixels, | ||
unsigned char | alock = 1 |
||
) |
Get a packed of 16 pixels. It only works with 32bit modes.
If you will access to the pixels surface to get the value of several pixels, you have to use alock=0 and
manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
If the given surface is an OpenGL texture (glSDL mode), it does nothing.
surf | surface to get the pixel |
x | x position on surface |
y | y position on surface |
arraypixels | pixel color array (packed integer with RGB) |
alock | by default is 1. Set to 1 means to lock the surface. Other value, means don't lock the surface. |
int CRM32Pro_IPrimitives::GetCollisionMethod | ( | ) |
Get current collision detection method.
unsigned int CRM32Pro_IPrimitives::GetPixel | ( | SDL_Surface * | surf, |
short | x, | ||
short | y, | ||
unsigned char | alock = 1 |
||
) |
Get a single pixel.
If you will access to a few pixels, the best way is to manually manage the lock calling to Lock() and UnLock() and using alock=0
With OpenGL modes (glSDL), it works but when surf is not CRM32Pro.screen, it will be slower as it has to download the texture to the system memory.
surf | surface to get the pixel |
x | x position on surface |
y | y position on surface |
alock | by default is 1. Set to 1 means to lock the surface. Other value, means don't lock the surface. |
void CRM32Pro_IPrimitives::HLineColor | ( | SDL_Surface * | surf, |
short | x1, | ||
short | x2, | ||
short | y, | ||
unsigned int | color | ||
) |
Draw a horinzontal line with bounce checking.
Tests the clipping region.
surf | surface to render the line |
x1 | Desired start x position |
x2 | Desired end y position |
y | Desired y position |
color | Packet(RGBA) pixel color |
void CRM32Pro_IPrimitives::HLineRGBA | ( | SDL_Surface * | surf, |
short | x1, | ||
short | x2, | ||
short | y, | ||
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a = 255 |
||
) |
Draw a horinzontal line with bounce checking.
Tests the clipping region.
surf | surface to render the line |
x1 | Desired start x position |
x2 | Desired end y position |
y | Desired y position |
r | Red component |
g | Green component |
b | Blue component |
a | Alpha component. By default is 255. |
void CRM32Pro_IPrimitives::HSVtoRGB | ( | float | h, |
float | s, | ||
float | v, | ||
unsigned char * | r8, | ||
unsigned char * | g8, | ||
unsigned char * | b8 | ||
) |
Color conversion: from HSV to RGB.
h | Hue component |
s | Saturation component |
v | Value component |
r8 | pointer to Red component |
g8 | pointer to Green component |
b8 | pointer to Blue component |
void CRM32Pro_IPrimitives::LineColor | ( | SDL_Surface * | surf, |
short | x1, | ||
short | y1, | ||
short | x2, | ||
short | y2, | ||
unsigned int | color | ||
) |
Draw a line with bounce checking.
Tests the clipping region.
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen
surf | surface to render the line |
x1 | Desired start x position |
y1 | Desired start y position |
x2 | Desired end x position |
y2 | Desired end y position |
color | Packet(RGBA) pixel color |
void CRM32Pro_IPrimitives::LineRGBA | ( | SDL_Surface * | surf, |
short | x1, | ||
short | y1, | ||
short | x2, | ||
short | y2, | ||
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a = 255 |
||
) |
Draw a line with bounce checking.
Tests the clipping region.
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen
surf | surface to render the line |
x1 | Desired start x position |
y1 | Desired start y position |
x2 | Desired end x position |
y2 | Desired end y position |
r | Red component |
g | Green component |
b | Blue component |
a | Alpha component. By default is 255. |
unsigned char CRM32Pro_IPrimitives::PixelCollision | ( | SDL_Surface * | surf1, |
SDL_Rect * | pos1, | ||
SDL_Surface * | surf2, | ||
SDL_Rect * | pos2, | ||
unsigned char | debug = 0 , |
||
SDL_Rect * | posr1 = NULL , |
||
SDL_Rect * | posr2 = NULL |
||
) |
Customizable collision detection between two surfaces.
You can modify the behaviour of the collision detection system using SetCollisionMethod(). First one, it tests a bounding box(BB) collision, if a collision of BB occurs, it will check for perfect pixel collision.
It could be slow if you are testing a lot of collisions. The advice is to use as less "external" colorkey around your sprite as possible to avoid to do a lot of pixel checking.
surf1 | surface A |
pos1 | rect with absolute position(x,y) and size(w,h) of surface A |
surf2 | surface B to test collision against surface A |
pos2 | rect with absolute (x,y) position and size of surface B |
debug | by default is 0 and it won't to render any debug information. Otherwise, will show collision bounding boxes. |
posr1 | NULL(by default) or a rect pointer with relative position(x,y) inside the surface A. |
posr2 | NULL(by default) or a rect pointer with relative position(x,y) inside the surface B. |
void CRM32Pro_IPrimitives::Put16Pixel | ( | SDL_Surface * | surf, |
short | x, | ||
short | y, | ||
unsigned int * | arraypixels, | ||
unsigned char | alock = 1 |
||
) |
Draw a pack of 16 pixels. It only works with 32bit modes.
Only supports 32bit depth color.
Also, it doesn't test the clipping region.
If you will access to the pixels surface to set the value of several pixels, you have to use alock=0 and
manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
If the given surface is an OpenGL texture (glSDL mode), it does nothing.
surf | surface to dump the pixel |
x | x position on surface |
y | y position on surface |
arraypixels | pixel color array (packed integer with RGB) |
alock | by default is 1. Set to 1 means to lock the surface. Other value, means don't lock the surface. |
void CRM32Pro_IPrimitives::PutPixelColor | ( | SDL_Surface * | surf, |
short | x, | ||
short | y, | ||
unsigned int | color, | ||
unsigned char | alock = 1 |
||
) |
Draw a single pixel with bounce checking.
Tests the clipping region.
If you will access to the pixels surface to set the value of several pixels, you may want to use alock=0 and manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen
surf | surface to render the pixel |
x | Desired x position |
y | Desired y position |
color | Packet(RGBA) pixel color |
alock | 1 to lock the surface. Other value, don't lock the surface. By default is 1. |
void CRM32Pro_IPrimitives::PutPixelRGBA | ( | SDL_Surface * | surf, |
short | x, | ||
short | y, | ||
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a = 255 , |
||
unsigned char | alock = 1 |
||
) |
Draw a single pixel with bounce checking.
Tests the clipping region.
If you will access to the pixels surface to set the value of several pixels, you may want to use alock=0 and manually, before your code, call to Lock(your_surface) and after your code, call to UnLock(your_surface).
With OpenGL modes (glSDL), it only works when surf is CRM32Pro.screen
surf | surface to render the pixel |
x | Desired x position |
y | Desired y position |
r | Red component |
g | Green component |
b | Blue component |
a | Alpha component. By default is 255. |
alock | 1 to lock the surface. Other value, don't lock the surface. By default is 1. |
void CRM32Pro_IPrimitives::RectangleColor | ( | SDL_Surface * | surf, |
short | x1, | ||
short | y1, | ||
short | x2, | ||
short | y2, | ||
unsigned int | color | ||
) |
Draw an outlined rectangle.
Tests the clipping region and has support for cursor autorestore.
surf | surface to render the rectangle |
x1 | Desired start x position |
y1 | Desired start y |
x2 | Desired end x position |
y2 | Desired end y |
color | Packet(RGBA) pixel color |
void CRM32Pro_IPrimitives::RectangleRGBA | ( | SDL_Surface * | surf, |
short | x1, | ||
short | y1, | ||
short | x2, | ||
short | y2, | ||
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a = 255 |
||
) |
Draw an outlined rectangle.
Tests the clipping region and has support for cursor autorestore.
surf | surface to render the rectangle |
x1 | Desired start x position |
y1 | Desired start y |
x2 | Desired end x position |
y2 | Desired end y |
r | Red component |
g | Green component |
b | Blue component |
a | Alpha component. By default is 255. |
void CRM32Pro_IPrimitives::RGBtoCMYK | ( | unsigned char | r8, |
unsigned char | g8, | ||
unsigned char | b8, | ||
unsigned char * | c, | ||
unsigned char * | m, | ||
unsigned char * | y, | ||
unsigned char * | k | ||
) |
Color conversion: from RGB to CMYK.
r8 | Red component |
g8 | Green component |
b8 | Blue component |
c | pointer to cyan component |
m | pointer to magenta component |
y | pointer to yellow component |
k | pointer to key(black) component |
void CRM32Pro_IPrimitives::RGBtoHSV | ( | unsigned char | r8, |
unsigned char | g8, | ||
unsigned char | b8, | ||
float * | h, | ||
float * | s, | ||
float * | v | ||
) |
Color conversion: from RGB to HSV.
r8 | Red component |
g8 | Green component |
b8 | Blue component |
h | pointer to Hue component |
s | pointer to Saturation component |
v | pointer to Value component |
void CRM32Pro_IPrimitives::RGBtoYCC | ( | unsigned char | r8, |
unsigned char | g8, | ||
unsigned char | b8, | ||
unsigned char * | Y, | ||
unsigned char * | Cb, | ||
unsigned char * | Cr | ||
) |
Color conversion: from RGB to YCC.
r8 | Red component |
g8 | Green component |
b8 | Blue component |
Y | pointer to luma component |
Cb | pointer to chrominance blue component |
Cr | pointer to chrominance red component |
void CRM32Pro_IPrimitives::RGBtoYUV | ( | unsigned char | r8, |
unsigned char | g8, | ||
unsigned char | b8, | ||
unsigned char * | Y, | ||
unsigned char * | U, | ||
unsigned char * | V | ||
) |
Color conversion: from RGB to YUV.
r8 | Red component |
g8 | Green component |
b8 | Blue component |
Y | pointer to luma component |
U | pointer to chrominance U component |
V | pointer to chrominance V component |
void CRM32Pro_IPrimitives::SetCollisionMethod | ( | int | mode | ) |
Set the collision detection method.
You can adjust the kind of accuracy Vs speed of the whole collision detection system.
By default, the mode is set to 1 for a perfect pixel collision.
mode | 0 to set a very fast boundingbox(less acurrate but extremely fast) 1 to set a perfect pixel collision(100% accurate but the slowest method) 2, 3, 4, .. to set the collision detection check each 2, 3, 4, ... pixels. |
void CRM32Pro_IPrimitives::VLineColor | ( | SDL_Surface * | surf, |
short | x, | ||
short | y1, | ||
short | y2, | ||
unsigned int | color | ||
) |
Draw a vertical line with bounce checking.
Tests the clipping region.
surf | surface to render the line |
x | Desired x position |
y1 | Desired start y position |
y2 | Desired end y position |
color | Packet(RGBA) pixel color |
void CRM32Pro_IPrimitives::VLineRGBA | ( | SDL_Surface * | surf, |
short | x, | ||
short | y1, | ||
short | y2, | ||
unsigned char | r, | ||
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | a = 255 |
||
) |
Draw a vertical line with bounce checking.
Tests the clipping region.
surf | surface to render the line |
x | Desired x position |
y1 | Desired start y position |
y2 | Desired end y position |
r | Red component |
g | Green component |
b | Blue component |
a | Alpha component. By default is 255. |
void CRM32Pro_IPrimitives::YCCtoRGB | ( | unsigned char | Y, |
unsigned char | Cb, | ||
unsigned char | Cr, | ||
unsigned char * | r8, | ||
unsigned char * | g8, | ||
unsigned char * | b8 | ||
) |
Color conversion: from YCC to RGB.
Y | luma component |
Cb | chrominance blue component |
Cr | chrominance red component |
r8 | pointer to Red component |
g8 | pointer to Green component |
b8 | pointer to Blue component |
void CRM32Pro_IPrimitives::YUVtoRGB | ( | unsigned char | Y, |
unsigned char | U, | ||
unsigned char | V, | ||
unsigned char * | r8, | ||
unsigned char * | g8, | ||
unsigned char * | b8 | ||
) |
Color conversion: from YUV to RGB.
Y | luma component |
U | chrominance U component |
V | chrominance V component |
r8 | pointer to Red component |
g8 | pointer to Green component |
b8 | pointer to Blue component |