PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

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