Commit | Line | Data |
70fd0f8d |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
4 | |
5 | #ifndef aTHX_ |
6 | #define aTHX_ |
7 | #endif |
8 | |
9 | #include <SDL.h> |
10 | |
11 | MODULE = SDL::Video PACKAGE = SDL::Video PREFIX = video_ |
12 | |
13 | =for documentation |
14 | |
15 | The Following are XS bindings to the Video category in the SDL API v2.1.13 |
16 | |
17 | Describe on the SDL API site. |
18 | |
19 | See: L<http://www.libsdl.org/cgi/docwiki.cgi/SDL_API#head-813f033ec44914f267f32195aba7d9aff8c410c0> |
20 | |
21 | =cut |
22 | |
23 | SDL_Surface * |
95f5be30 |
24 | video_get_video_surface() |
25 | PREINIT: |
26 | char* CLASS = "SDL::Surface"; |
70fd0f8d |
27 | CODE: |
28 | RETVAL = SDL_GetVideoSurface(); |
29 | OUTPUT: |
30 | RETVAL |
31 | |
32 | |
20f544ea |
33 | SDL_VideoInfo* |
95f5be30 |
34 | video_get_video_info() |
20f544ea |
35 | PREINIT: |
36 | char* CLASS = "SDL::VideoInfo"; |
95f5be30 |
37 | CODE: |
babb07ed |
38 | RETVAL = (SDL_VideoInfo *) SDL_GetVideoInfo(); |
8a2411d0 |
39 | |
40 | OUTPUT: |
babb07ed |
41 | RETVAL |
8a2411d0 |
42 | |
7fa192d4 |
43 | SV * |
44 | video_video_driver_name( ) |
45 | |
8a2411d0 |
46 | CODE: |
7fa192d4 |
47 | char buffer[1024]; |
48 | if ( SDL_VideoDriverName(buffer, 1024) != NULL ) |
49 | { |
50 | RETVAL = newSVpv(buffer, 0); |
51 | } |
52 | else |
53 | XSRETURN_UNDEF; |
8a2411d0 |
54 | OUTPUT: |
55 | RETVAL |
7dda1934 |
56 | |
57 | AV* |
58 | list_modes ( format, flags ) |
59 | Uint32 flags |
60 | SDL_PixelFormat *format |
4510df28 |
61 | |
7dda1934 |
62 | CODE: |
63 | SDL_Rect **mode; |
64 | RETVAL = newAV(); |
65 | mode = SDL_ListModes(format,flags); |
66 | if (mode == (SDL_Rect**)-1 ) { |
67 | av_push(RETVAL,newSVpv("all",0)); |
68 | } else if (! mode ) { |
69 | av_push(RETVAL,newSVpv("none",0)); |
70 | } else { |
71 | for (;*mode;mode++) { |
72 | av_push(RETVAL,newSViv(PTR2IV(*mode))); |
73 | } |
74 | } |
75 | OUTPUT: |
76 | RETVAL |
77 | |
78 | |
218b5471 |
79 | int |
80 | video_video_mode_ok ( width, height, bpp, flags ) |
81 | int width |
82 | int height |
83 | int bpp |
84 | Uint32 flags |
85 | CODE: |
86 | RETVAL = SDL_VideoModeOK(width,height,bpp,flags); |
87 | OUTPUT: |
88 | RETVAL |
7dda1934 |
89 | |
bbe5d2f5 |
90 | |
91 | SDL_Surface * |
92 | video_set_video_mode ( width, height, bpp, flags ) |
93 | int width |
94 | int height |
95 | int bpp |
96 | Uint32 flags |
97 | PREINIT: |
98 | char* CLASS = "SDL::Surface"; |
99 | CODE: |
100 | RETVAL = SDL_SetVideoMode(width,height,bpp,flags); |
101 | OUTPUT: |
102 | RETVAL |
103 | |
104 | |
eaf32d63 |
105 | void |
106 | video_update_rect ( surface, x, y, w ,h ) |
107 | SDL_Surface *surface |
108 | int x |
109 | int y |
110 | int w |
111 | int h |
112 | CODE: |
113 | SDL_UpdateRect(surface,x,y,w,h); |
114 | |
115 | void |
116 | video_update_rects ( surface, ... ) |
117 | SDL_Surface *surface |
118 | CODE: |
119 | SDL_Rect *rects; |
120 | int num_rects,i; |
121 | if ( items < 2 ) return; |
122 | num_rects = items - 1; |
123 | rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items); |
124 | for(i=0;i<num_rects;i++) { |
125 | rects[i] = *(SDL_Rect *)SvIV((SV*)SvRV( ST(i + 1) )); |
126 | } |
127 | SDL_UpdateRects(surface,num_rects,rects); |
128 | safefree(rects); |
129 | |
7dda1934 |
130 | |
19f3ee7b |
131 | int |
132 | video_flip ( surface ) |
133 | SDL_Surface *surface |
134 | CODE: |
135 | RETVAL = SDL_Flip(surface); |
136 | OUTPUT: |
137 | RETVAL |
138 | |
2739f940 |
139 | int |
140 | video_set_colors ( surface, start, ... ) |
141 | SDL_Surface *surface |
142 | int start |
143 | CODE: |
144 | SDL_Color *colors,*temp; |
145 | int i, length; |
146 | if ( items < 3 ) { RETVAL = 0; goto all_done; } |
147 | length = items - 2; |
148 | colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1)); |
149 | for ( i = 0; i < length ; i++ ) { |
150 | temp = (SDL_Color *)SvIV(ST(i+2)); |
151 | colors[i].r = temp->r; |
152 | colors[i].g = temp->g; |
153 | colors[i].b = temp->b; |
154 | } |
155 | RETVAL = SDL_SetColors(surface, colors, start, length ); |
156 | safefree(colors); |
157 | |
158 | all_done: |
159 | OUTPUT: |
160 | RETVAL |
0a01cb9e |
161 | |
162 | |