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.201 by root, Tue Jul 17 17:39:06 2007 UTC vs.
Revision 1.203 by root, Thu Jul 19 13:45:16 2007 UTC

26#include <string.h> 26#include <string.h>
27#include <stdio.h> 27#include <stdio.h>
28#include <stdlib.h> 28#include <stdlib.h>
29 29
30#include <SDL.h> 30#include <SDL.h>
31#include <SDL_thread.h>
31#include <SDL_endian.h> 32#include <SDL_endian.h>
32#include <SDL_image.h> 33#include <SDL_image.h>
33#include <SDL_mixer.h> 34#include <SDL_mixer.h>
34#include <SDL_opengl.h> 35#include <SDL_opengl.h>
35 36
1257MODULE = CFPlus PACKAGE = CFPlus::Texture 1258MODULE = CFPlus PACKAGE = CFPlus::Texture
1258 1259
1259int minpot (int n) 1260int minpot (int n)
1260 1261
1261void 1262void
1262pad2pot (SV *data_, SV *w_, SV *h_) 1263pad (SV *data_, int ow, int oh, int nw, int nh)
1263 CODE: 1264 CODE:
1264{ 1265{
1265 int ow = SvIV (w_); 1266 if ((nw != ow || nh != oh) && SvOK (data_))
1266 int oh = SvIV (h_);
1267
1268 if (ow && oh)
1269 { 1267 {
1270 int nw = minpot (ow);
1271 int nh = minpot (oh);
1272
1273 if (nw != ow || nh != oh)
1274 {
1275 if (SvOK (data_))
1276 {
1277 STRLEN datalen; 1268 STRLEN datalen;
1278 char *data = SvPVbyte (data_, datalen); 1269 char *data = SvPVbyte (data_, datalen);
1279 int bpp = datalen / (ow * oh); 1270 int bpp = datalen / (ow * oh);
1280 SV *result_ = sv_2mortal (newSV (nw * nh * bpp)); 1271 SV *result_ = sv_2mortal (newSV (nw * nh * bpp));
1281 1272
1282 SvPOK_only (result_); 1273 SvPOK_only (result_);
1283 SvCUR_set (result_, nw * nh * bpp); 1274 SvCUR_set (result_, nw * nh * bpp);
1284 1275
1285 memset (SvPVX (result_), 0, nw * nh * bpp); 1276 memset (SvPVX (result_), 0, nw * nh * bpp);
1286 while (oh--) 1277 while (oh--)
1287 memcpy (SvPVX (result_) + oh * nw * bpp, data + oh * ow * bpp, ow * bpp); 1278 memcpy (SvPVX (result_) + oh * nw * bpp, data + oh * ow * bpp, ow * bpp);
1288 1279
1289 sv_setsv (data_, result_); 1280 sv_setsv (data_, result_);
1290 }
1291
1292 sv_setiv (w_, nw);
1293 sv_setiv (h_, nh);
1294 }
1295 } 1281 }
1296} 1282}
1297 1283
1298void 1284void
1299draw_quad (SV *self, float x, float y, float w = 0., float h = 0.) 1285draw_quad (SV *self, float x, float y, float w = 0., float h = 0.)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines