ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.22 by root, Wed Apr 12 20:06:36 2006 UTC vs.
Revision 1.23 by root, Wed Apr 12 20:42:52 2006 UTC

3#include "XSUB.h" 3#include "XSUB.h"
4 4
5#include <string.h> 5#include <string.h>
6 6
7#include <SDL.h> 7#include <SDL.h>
8#include <SDL_image.h>
8#include <SDL_opengl.h> 9#include <SDL_opengl.h>
9 10
10#include <pango/pango.h> 11#include <pango/pango.h>
11#include <pango/pangofc-fontmap.h> 12#include <pango/pangofc-fontmap.h>
12#include <pango/pangoft2.h> 13#include <pango/pangoft2.h>
99 int count; 100 int count;
100 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); 101 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count);
101 PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); 102 PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0);
102 FcPatternDestroy (pattern); 103 FcPatternDestroy (pattern);
103 pango_context_set_font_description (context, font); 104 pango_context_set_font_description (context, font);
105}
106
107void
108load_image_inline (SV *image_)
109 ALIAS:
110 load_image_file = 1
111 PPCODE:
112{
113 STRLEN image_len;
114 char *image = (char *)SvPVbyte (image_, image_len);
115 SDL_Surface *surface, *surface2;
116 SDL_PixelFormat fmt;
117 SDL_RWops *rw = ix
118 ? SDL_RWFromFile (image, "r")
119 : SDL_RWFromConstMem (image, image_len);
120
121 if (!rw)
122 croak ("load_image: unable to open file");
123
124 surface = IMG_Load_RW (rw, 1);
125 if (!surface)
126 croak ("load_image: unable to read file");
127
128 fmt.palette = NULL;
129 fmt.BitsPerPixel = 32;
130 fmt.BytesPerPixel = 4;
131 fmt.Rmask = 0x000000ff;
132 fmt.Gmask = 0x0000ff00;
133 fmt.Bmask = 0x00ff0000;
134 fmt.Amask = 0xff000000;
135 fmt.Rloss = 0;
136 fmt.Gloss = 0;
137 fmt.Bloss = 0;
138 fmt.Aloss = 0;
139 fmt.Rshift = 0;
140 fmt.Gshift = 8;
141 fmt.Bshift = 16;
142 fmt.Ashift = 24;
143 fmt.colorkey = 0;
144 fmt.alpha = 0;
145
146 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
147
148 EXTEND (SP, 5);
149 PUSHs (sv_2mortal (newSViv (surface2->w)));
150 PUSHs (sv_2mortal (newSViv (surface2->h)));
151 SDL_LockSurface (surface2);
152 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
153 SDL_UnlockSurface (surface2);
154 PUSHs (sv_2mortal (newSViv (surface->format->Amask ? GL_RGBA : GL_RGB)));
155 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
156 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV)));
157
158 SDL_FreeSurface (surface);
159 SDL_FreeSurface (surface2);
104} 160}
105 161
106MODULE = CFClient PACKAGE = CFClient::Layout 162MODULE = CFClient PACKAGE = CFClient::Layout
107 163
108CFClient::Layout 164CFClient::Layout

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines