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.128 by root, Wed Jul 5 03:01:01 2006 UTC vs.
Revision 1.131 by root, Thu Jul 13 01:54:18 2006 UTC

1#ifdef _WIN32 1#ifdef _WIN32
2# define WIN32_LEAN_AND_MEAN
2# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls 3# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls
3# include <malloc.h> 4# include <malloc.h>
4# include <windows.h> 5# include <windows.h>
5# pragma warning(disable:4244) 6# pragma warning(disable:4244)
6#endif 7#endif
7 8
8#include "EXTERN.h" 9#include "EXTERN.h"
9#include "perl.h" 10#include "perl.h"
10#include "XSUB.h" 11#include "XSUB.h"
12
13#ifdef _WIN32
14# undef pipe
15#endif
11 16
12#include <math.h> 17#include <math.h>
13#include <string.h> 18#include <string.h>
14#include <stdio.h> 19#include <stdio.h>
15#include <stdlib.h> 20#include <stdlib.h>
39 typedef unsigned int uint32_t; 44 typedef unsigned int uint32_t;
40 typedef signed char int8_t; 45 typedef signed char int8_t;
41 typedef signed short int16_t; 46 typedef signed short int16_t;
42 typedef signed int int32_t; 47 typedef signed int int32_t;
43#endif 48#endif
44
45#include "glext.h"
46 49
47#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ 50#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */
48 51
49#define FOW_DARKNESS 32 52#define FOW_DARKNESS 32
50 53
463 466
464 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 467 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
465 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 468 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
466} 469}
467 470
471int
472in_destruct ()
473 CODE:
474 RETVAL = PL_main_cv == Nullcv;
475 OUTPUT:
476 RETVAL
477
468NV floor (NV x) 478NV floor (NV x)
469 479
470NV ceil (NV x) 480NV ceil (NV x)
471 481
472void 482void
502 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 512 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
503 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 513 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
504 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 514 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
505 515
506 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 516 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
517 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
518 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
507 519
508 SDL_EnableUNICODE (1); 520 SDL_EnableUNICODE (1);
509 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 521 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
510 522
511 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 523 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
624#endif 636#endif
625 637
626void 638void
627add_font (char *file) 639add_font (char *file)
628 CODE: 640 CODE:
629 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ 641 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
630 642
631void 643void
632load_image_inline (SV *image_) 644load_image_inline (SV *image_)
633 ALIAS: 645 ALIAS:
634 load_image_file = 1 646 load_image_file = 1
676 688
677 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); 689 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
678 690
679 assert (surface2->pitch == surface2->w * 4); 691 assert (surface2->pitch == surface2->w * 4);
680 692
693 SDL_LockSurface (surface2);
681 EXTEND (SP, 5); 694 EXTEND (SP, 6);
682 PUSHs (sv_2mortal (newSViv (surface2->w))); 695 PUSHs (sv_2mortal (newSViv (surface2->w)));
683 PUSHs (sv_2mortal (newSViv (surface2->h))); 696 PUSHs (sv_2mortal (newSViv (surface2->h)));
684 SDL_LockSurface (surface2);
685 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 697 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
686 SDL_UnlockSurface (surface2);
687 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); 698 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
688 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 699 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
689 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 700 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
701 SDL_UnlockSurface (surface2);
690 702
691 SDL_FreeSurface (surface); 703 SDL_FreeSurface (surface);
692 SDL_FreeSurface (surface2); 704 SDL_FreeSurface (surface2);
693} 705}
694 706
764 default_font = self; 776 default_font = self;
765 777
766MODULE = CFClient PACKAGE = CFClient::Layout 778MODULE = CFClient PACKAGE = CFClient::Layout
767 779
768void 780void
769clear_font_cache () 781reset_glyph_cache ()
770 CODE: 782 CODE:
771 tc_clear (); 783 tc_clear ();
772 784
773CFClient::Layout 785CFClient::Layout
774new (SV *class) 786new (SV *class)
872 if (run && shape_attr_p (run)) 884 if (run && shape_attr_p (run))
873 { 885 {
874 PangoRectangle extents; 886 PangoRectangle extents;
875 pango_layout_iter_get_run_extents (iter, 0, &extents); 887 pango_layout_iter_get_run_extents (iter, 0, &extents);
876 888
889 EXTEND (SP, 2);
877 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); 890 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x))));
878 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); 891 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y))));
879 } 892 }
880 } 893 }
881 while (pango_layout_iter_next_run (iter)); 894 while (pango_layout_iter_next_run (iter));
1906 r *= a; 1919 r *= a;
1907 g *= a; 1920 g *= a;
1908 b *= a; 1921 b *= a;
1909 } 1922 }
1910 // microsoft visual "c" rounds instead of truncating... 1923 // microsoft visual "c" rounds instead of truncating...
1911 glColor4ub (MIN ((int)(r * 256.f), 255), 1924 glColor4f (r, g, b, a);
1912 MIN ((int)(g * 256.f), 255),
1913 MIN ((int)(b * 256.f), 255),
1914 MIN ((int)(a * 256.f), 255));
1915 1925
1916void glInterleavedArrays (int format, int stride, char *data) 1926void glInterleavedArrays (int format, int stride, char *data)
1917 1927
1918void glDrawElements (int mode, int count, int type, char *indices) 1928void glDrawElements (int mode, int count, int type, char *indices)
1919 1929

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines