/src/Core/objects/Palette.xs

http://github.com/PerlGameDev/SDL · Unknown · 60 lines · 49 code · 11 blank · 0 comment · 0 complexity · 56ab56a1c8d4f78146a561ac8c63442d MD5 · raw file

  1. #include "EXTERN.h"
  2. #include "perl.h"
  3. #include "XSUB.h"
  4. #include "ppport.h"
  5. #include "helper.h"
  6. #ifndef aTHX_
  7. #define aTHX_
  8. #endif
  9. #include <SDL.h>
  10. MODULE = SDL::Palette PACKAGE = SDL::Palette PREFIX = palette_
  11. =for documentation
  12. SDL_Palette -- Color palette for 8-bit pixel formats
  13. typedef struct{
  14. int ncolors;
  15. SDL_Color *colors
  16. } SDL_Palette;
  17. =cut
  18. int
  19. palette_ncolors ( palette )
  20. SDL_Palette *palette
  21. CODE:
  22. RETVAL = palette->ncolors;
  23. OUTPUT:
  24. RETVAL
  25. AV *
  26. palette_colors ( palette )
  27. SDL_Palette *palette
  28. CODE:
  29. RETVAL = (AV*)sv_2mortal((SV*)newAV());
  30. int i;
  31. for(i = 0; i < palette->ncolors; i++)
  32. av_push( RETVAL, cpy2bag( (SDL_Color *)(palette->colors + i), sizeof(SDL_Color *), sizeof(SDL_Color), "SDL::Color" ) );
  33. OUTPUT:
  34. RETVAL
  35. SV *
  36. palette_color_index ( palette, index )
  37. SDL_Palette *palette
  38. int index
  39. PREINIT:
  40. char * CLASS = "SDL::Color";
  41. CODE:
  42. RETVAL = cpy2bag( (SDL_Color *)(palette->colors + index), sizeof(SDL_Color *), sizeof(SDL_Color), "SDL::Color" );
  43. OUTPUT:
  44. RETVAL
  45. void
  46. palette_DESTROY ( bag )
  47. SV *bag
  48. CODE:
  49. objDESTROY(bag, safefree);