PageRenderTime 73ms CodeModel.GetById 70ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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