1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | #include <string.h> |
5 | #include <string.h> |
|
|
6 | #include <stdio.h> |
6 | |
7 | |
7 | #include <SDL.h> |
8 | #include <SDL.h> |
|
|
9 | #include <SDL_image.h> |
8 | #include <SDL_opengl.h> |
10 | #include <SDL_opengl.h> |
9 | |
11 | |
10 | #include <pango/pango.h> |
12 | #include <pango/pango.h> |
11 | #include <pango/pangofc-fontmap.h> |
13 | #include <pango/pangofc-fontmap.h> |
12 | #include <pango/pangoft2.h> |
14 | #include <pango/pangoft2.h> |
… | |
… | |
98 | FcPatternDestroy (pattern); |
100 | FcPatternDestroy (pattern); |
99 | pango_context_set_font_description (context, font); |
101 | pango_context_set_font_description (context, font); |
100 | } |
102 | } |
101 | |
103 | |
102 | void |
104 | void |
103 | wait_events (SV *rfd_, SV *wfd_) |
105 | load_image_inline (SV *image_) |
|
|
106 | ALIAS: |
|
|
107 | load_image_file = 1 |
104 | PPCODE: |
108 | PPCODE: |
105 | { |
109 | { |
|
|
110 | STRLEN image_len; |
|
|
111 | char *image = (char *)SvPVbyte (image_, image_len); |
|
|
112 | SDL_Surface *surface, *surface2; |
|
|
113 | SDL_PixelFormat fmt; |
|
|
114 | SDL_RWops *rw = ix |
|
|
115 | ? SDL_RWFromFile (image, "r") |
|
|
116 | : SDL_RWFromConstMem (image, image_len); |
|
|
117 | |
|
|
118 | if (!rw) |
|
|
119 | croak ("load_image: unable to open file"); |
|
|
120 | |
|
|
121 | surface = IMG_Load_RW (rw, 1); |
|
|
122 | if (!surface) |
|
|
123 | croak ("load_image: unable to read file"); |
|
|
124 | |
|
|
125 | fmt.palette = NULL; |
|
|
126 | fmt.BitsPerPixel = 32; |
|
|
127 | fmt.BytesPerPixel = 4; |
|
|
128 | fmt.Rmask = 0x000000ff; |
|
|
129 | fmt.Gmask = 0x0000ff00; |
|
|
130 | fmt.Bmask = 0x00ff0000; |
|
|
131 | fmt.Amask = 0xff000000; |
|
|
132 | fmt.Rloss = 0; |
|
|
133 | fmt.Gloss = 0; |
|
|
134 | fmt.Bloss = 0; |
|
|
135 | fmt.Aloss = 0; |
|
|
136 | fmt.Rshift = 0; |
|
|
137 | fmt.Gshift = 8; |
|
|
138 | fmt.Bshift = 16; |
|
|
139 | fmt.Ashift = 24; |
|
|
140 | fmt.colorkey = 0; |
|
|
141 | fmt.alpha = 0; |
|
|
142 | |
|
|
143 | surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); |
|
|
144 | |
|
|
145 | EXTEND (SP, 5); |
|
|
146 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
|
|
147 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
|
|
148 | SDL_LockSurface (surface2); |
|
|
149 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
|
|
150 | SDL_UnlockSurface (surface2); |
|
|
151 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
|
|
152 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
|
|
153 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV))); |
|
|
154 | |
|
|
155 | SDL_FreeSurface (surface); |
|
|
156 | SDL_FreeSurface (surface2); |
106 | } |
157 | } |
|
|
158 | |
|
|
159 | void |
|
|
160 | fatal (char *message) |
|
|
161 | CODE: |
|
|
162 | #ifdef WIN32 |
|
|
163 | MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); |
|
|
164 | #else |
|
|
165 | fprintf (stderr, "%s\n", message); |
|
|
166 | #endif |
|
|
167 | exit (1); |
107 | |
168 | |
108 | MODULE = CFClient PACKAGE = CFClient::Layout |
169 | MODULE = CFClient PACKAGE = CFClient::Layout |
109 | |
170 | |
110 | CFClient::Layout |
171 | CFClient::Layout |
111 | new (SV *class, int base_height = 10) |
172 | new (SV *class, int base_height = 10) |