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.38 by root, Fri Apr 14 23:32:28 2006 UTC vs.
Revision 1.39 by root, Sat Apr 15 00:04:58 2006 UTC

66 66
67typedef struct { 67typedef struct {
68 GLint name; 68 GLint name;
69 int w, h; 69 int w, h;
70 float s, t; 70 float s, t;
71 uint8_t r, g, b, a;
71} mapface; 72} mapface;
72 73
73typedef struct { 74typedef struct {
74 int16_t darkness; 75 int16_t darkness;
75 uint16_t face[3]; 76 uint16_t face[3];
242 fmt.colorkey = 0; 243 fmt.colorkey = 0;
243 fmt.alpha = 0; 244 fmt.alpha = 0;
244 245
245 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); 246 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
246 247
248 assert (surface2->pitch == surface2->w * 4);
249
247 EXTEND (SP, 5); 250 EXTEND (SP, 5);
248 PUSHs (sv_2mortal (newSViv (surface2->w))); 251 PUSHs (sv_2mortal (newSViv (surface2->w)));
249 PUSHs (sv_2mortal (newSViv (surface2->h))); 252 PUSHs (sv_2mortal (newSViv (surface2->h)));
250 SDL_LockSurface (surface2); 253 SDL_LockSurface (surface2);
251 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 254 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
254 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 257 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
255 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV))); 258 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_INT_8_8_8_8_REV)));
256 259
257 SDL_FreeSurface (surface); 260 SDL_FreeSurface (surface);
258 SDL_FreeSurface (surface2); 261 SDL_FreeSurface (surface2);
262}
263
264void
265average (int x, int y, uint32_t *data)
266 PPCODE:
267{
268 // only good for x * y < 32768
269 uint32_t r = 0, g = 0, b = 0, a = 0;
270
271 x = y = x * y;
272
273 assert (x < 32768);
274
275 while (x--)
276 {
277 uint32_t p = *data++;
278
279 r += (p ) & 255;
280 g += (p >> 8) & 255;
281 b += (p >> 16) & 255;
282 a += (p >> 24) & 255;
283 }
284
285 EXTEND (SP, 4);
286 PUSHs (sv_2mortal (newSViv (r * 255 / y)));
287 PUSHs (sv_2mortal (newSViv (g * 255 / y)));
288 PUSHs (sv_2mortal (newSViv (b * 255 / y)));
289 PUSHs (sv_2mortal (newSViv (a * 255 / y)));
259} 290}
260 291
261void 292void
262fatal (char *message) 293fatal (char *message)
263 CODE: 294 CODE:
454clear (CFClient::Map self) 485clear (CFClient::Map self)
455 CODE: 486 CODE:
456 map_clear (self); 487 map_clear (self);
457 488
458void 489void
459set_texture (CFClient::Map self, int face, int name, int w, int h, float s, float t) 490set_texture (CFClient::Map self, int face, int name, int w, int h, float s, float t, int r, int g, int b, int a)
460 CODE: 491 CODE:
461{ 492{
462 while (self->faces < face) 493 while (self->faces < face)
463 { 494 {
464 Append (mapface, self->face, self->faces, self->faces); 495 Append (mapface, self->face, self->faces, self->faces);
465 self->faces *= 2; 496 self->faces *= 2;
466 } 497 }
467 498
499 mapface *f = self->face + face;
500
468 self->face [face].name = name; 501 f->name = name;
469 self->face [face].w = w; 502 f->w = w;
470 self->face [face].h = h; 503 f->h = h;
471 self->face [face].s = s; 504 f->s = s;
472 self->face [face].t = t; 505 f->t = t;
506 f->r = r;
507 f->g = g;
508 f->b = b;
509 f->a = a;
473} 510}
474 511
475void 512void
476scroll (CFClient::Map self, int dx, int dy) 513scroll (CFClient::Map self, int dx, int dy)
477 CODE: 514 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines