PageRenderTime 23ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Core/objects/Cursor.xs

http://github.com/PerlGameDev/SDL
Unknown | 67 lines | 57 code | 10 blank | 0 comment | 0 complexity | ed2c82b1116fb9f76f1cd222dafa0e03 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. #include "EXTERN.h"
  2. #include "perl.h"
  3. #include "XSUB.h"
  4. #include "ppport.h"
  5. #ifndef aTHX_
  6. #define aTHX_
  7. #endif
  8. #include <SDL.h>
  9. MODULE = SDL::Cursor PACKAGE = SDL::Cursor PREFIX = cursor_
  10. =for documentation
  11. SDL_Cursor -- Cursor object
  12. =cut
  13. SDL_Cursor *
  14. cursor_new(CLASS, data, mask, w, h, x ,y )
  15. char* CLASS
  16. AV* data
  17. AV* mask
  18. int w
  19. int h
  20. int x
  21. int y
  22. CODE:
  23. int len = av_len(data);
  24. Uint8 *_data = (Uint8 *)safemalloc(sizeof(Uint8)*(len));
  25. Uint8 *_mask = (Uint8 *)safemalloc(sizeof(Uint8)*(len));
  26. int i;
  27. for ( i = 0; i < len + 1; i++ )
  28. {
  29. SV ** temp1 = av_fetch(data,i,0);
  30. SV ** temp2 = av_fetch(mask,i,0);
  31. if( temp1 != NULL)
  32. {
  33. _data[i] = (Uint8)SvIV( *temp1 );
  34. }
  35. else
  36. {
  37. _data[i] = 0;
  38. }
  39. if( temp2 != NULL)
  40. {
  41. _mask[i] = (Uint8)SvIV( *temp2 );
  42. }
  43. else
  44. {
  45. _mask[i] = 0;
  46. }
  47. }
  48. RETVAL = SDL_CreateCursor(_data, _mask, w, h, x, y);
  49. safefree(_data);
  50. safefree(_mask);
  51. OUTPUT:
  52. RETVAL
  53. void
  54. cursor_DESTROY(self)
  55. SDL_Cursor *self
  56. CODE:
  57. SDL_FreeCursor(self);