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.227 by root, Mon Aug 13 14:15:09 2007 UTC vs.
Revision 1.240 by root, Wed Dec 26 18:09:30 2007 UTC

203 203
204typedef uint16_t tileid; 204typedef uint16_t tileid;
205typedef uint16_t faceid; 205typedef uint16_t faceid;
206 206
207typedef struct { 207typedef struct {
208 int name; 208 GLuint name;
209 int w, h; 209 int w, h;
210 float s, t; 210 float s, t;
211 uint8_t r, g, b, a; 211 uint8_t r, g, b, a;
212 tileid smoothtile; 212 tileid smoothtile;
213 uint8_t smoothlevel; 213 uint8_t smoothlevel;
438 n |= n >> 4; 438 n |= n >> 4;
439 n |= n >> 8; 439 n |= n >> 8;
440 n |= n >> 16; 440 n |= n >> 16;
441 441
442 return n + 1; 442 return n + 1;
443}
444
445static unsigned int
446popcount (unsigned int n)
447{
448 n -= (n >> 1) & 0x55555555U;
449 n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U);
450 n = ((n >> 4) + n) & 0x0f0f0f0fU;
451 n *= 0x01010101U;
452
453 return n >> 24;
443} 454}
444 455
445/* SDL should provide this, really. */ 456/* SDL should provide this, really. */
446#define SDLK_MODIFIER_MIN 300 457#define SDLK_MODIFIER_MIN 300
447#define SDLK_MODIFIER_MAX 314 458#define SDLK_MODIFIER_MAX 314
525 536
526 const_iv (SDL_APPINPUTFOCUS), 537 const_iv (SDL_APPINPUTFOCUS),
527 const_iv (SDL_APPMOUSEFOCUS), 538 const_iv (SDL_APPMOUSEFOCUS),
528 const_iv (SDL_APPACTIVE), 539 const_iv (SDL_APPACTIVE),
529 540
541 const_iv (SDLK_FIRST),
542 const_iv (SDLK_LAST),
530 const_iv (SDLK_KP0), 543 const_iv (SDLK_KP0),
531 const_iv (SDLK_KP1), 544 const_iv (SDLK_KP1),
532 const_iv (SDLK_KP2), 545 const_iv (SDLK_KP2),
533 const_iv (SDLK_KP3), 546 const_iv (SDLK_KP3),
534 const_iv (SDLK_KP4), 547 const_iv (SDLK_KP4),
606 const_iv (KMOD_LMETA), 619 const_iv (KMOD_LMETA),
607 const_iv (KMOD_RMETA), 620 const_iv (KMOD_RMETA),
608 const_iv (KMOD_NUM), 621 const_iv (KMOD_NUM),
609 const_iv (KMOD_CAPS), 622 const_iv (KMOD_CAPS),
610 const_iv (KMOD_MODE), 623 const_iv (KMOD_MODE),
624
625 const_iv (MIX_DEFAULT_FORMAT),
611# undef const_iv 626# undef const_iv
612 }; 627 };
613 628
614 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 629 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
615 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 630 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
632 RETVAL 647 RETVAL
633 648
634NV floor (NV x) 649NV floor (NV x)
635 650
636NV ceil (NV x) 651NV ceil (NV x)
652
653IV minpot (UV n)
654
655IV popcount (UV n)
637 656
638void 657void
639pango_init () 658pango_init ()
640 CODE: 659 CODE:
641{ 660{
681 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 700 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
682 701
683 if (m && m != (SDL_Rect **)-1) 702 if (m && m != (SDL_Rect **)-1)
684 while (*m) 703 while (*m)
685 { 704 {
686 if ((*m)->w >= 640 && (*m)->h >= 480) 705 if ((*m)->w >= 800 && (*m)->h >= 600)
687 { 706 {
688 AV *av = newAV (); 707 AV *av = newAV ();
689 av_push (av, newSViv ((*m)->w)); 708 av_push (av, newSViv ((*m)->w));
690 av_push (av, newSViv ((*m)->h)); 709 av_push (av, newSViv ((*m)->h));
691 av_push (av, newSViv (rgb)); 710 av_push (av, newSViv (rgb));
715 734
716 if (RETVAL) 735 if (RETVAL)
717 { 736 {
718 av_clear (texture_av); 737 av_clear (texture_av);
719 738
720 SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); 739 SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra");
721#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); 740#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name);
722#include "glfunc.h" 741#include "glfunc.h"
723#undef GL_FUNC 742#undef GL_FUNC
724 } 743 }
725} 744}
811 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1)))); 830 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
812 } 831 }
813} 832}
814 833
815int 834int
816Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) 835Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096)
817 POSTCALL: 836 POSTCALL:
818 Mix_HookMusicFinished (music_finished); 837 Mix_HookMusicFinished (music_finished);
819 Mix_ChannelFinished (channel_finished); 838 Mix_ChannelFinished (channel_finished);
839
840void
841Mix_QuerySpec ()
842 PPCODE:
843{
844 int freq, channels;
845 Uint16 format;
846
847 if (Mix_QuerySpec (&freq, &format, &channels))
848 {
849 EXTEND (SP, 3);
850 PUSHs (sv_2mortal (newSViv (freq)));
851 PUSHs (sv_2mortal (newSViv (format)));
852 PUSHs (sv_2mortal (newSViv (channels)));
853 }
854}
820 855
821void 856void
822Mix_CloseAudio () 857Mix_CloseAudio ()
823 858
824int 859int
958void 993void
959error (char *message) 994error (char *message)
960 CODE: 995 CODE:
961 fprintf (stderr, "ERROR: %s\n", message); 996 fprintf (stderr, "ERROR: %s\n", message);
962#ifdef _WIN32 997#ifdef _WIN32
963 MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); 998 MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR);
964#endif 999#endif
965 1000
966void 1001void
967fatal (char *message) 1002fatal (char *message)
968 CODE: 1003 CODE:
969 fprintf (stderr, "FATAL: %s\n", message); 1004 fprintf (stderr, "FATAL: %s\n", message);
970#ifdef _WIN32 1005#ifdef _WIN32
971 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); 1006 MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR);
972#endif 1007#endif
973 _exit (1); 1008 _exit (1);
974 1009
975void 1010void
976_exit (int retval = 0) 1011_exit (int retval = 0)
1020MODULE = CFPlus PACKAGE = CFPlus::Layout 1055MODULE = CFPlus PACKAGE = CFPlus::Layout
1021 1056
1022PROTOTYPES: DISABLE 1057PROTOTYPES: DISABLE
1023 1058
1024void 1059void
1025reset_glyph_cache () 1060glyph_cache_backup ()
1026 PROTOTYPE: 1061 PROTOTYPE:
1027 CODE: 1062 CODE:
1063 tc_backup ();
1064
1065void
1066glyph_cache_restore ()
1067 PROTOTYPE:
1068 CODE:
1028 tc_clear (); 1069 tc_restore ();
1029 1070
1030CFPlus::Layout 1071CFPlus::Layout
1031new (SV *class) 1072new (SV *class)
1032 CODE: 1073 CODE:
1033 New (0, RETVAL, 1, struct cf_layout); 1074 New (0, RETVAL, 1, struct cf_layout);
1345} 1386}
1346 1387
1347MODULE = CFPlus PACKAGE = CFPlus::Texture 1388MODULE = CFPlus PACKAGE = CFPlus::Texture
1348 1389
1349PROTOTYPES: ENABLE 1390PROTOTYPES: ENABLE
1350
1351int minpot (int n)
1352 1391
1353void 1392void
1354pad (SV *data_, int ow, int oh, int nw, int nh) 1393pad (SV *data_, int ow, int oh, int nw, int nh)
1355 CODE: 1394 CODE:
1356{ 1395{
2549 const_iv (GL_INTENSITY), 2588 const_iv (GL_INTENSITY),
2550 const_iv (GL_LUMINANCE), 2589 const_iv (GL_LUMINANCE),
2551 const_iv (GL_LUMINANCE_ALPHA), 2590 const_iv (GL_LUMINANCE_ALPHA),
2552 const_iv (GL_FLOAT), 2591 const_iv (GL_FLOAT),
2553 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), 2592 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV),
2593 const_iv (GL_COMPRESSED_ALPHA_ARB),
2594 const_iv (GL_COMPRESSED_LUMINANCE_ARB),
2595 const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB),
2596 const_iv (GL_COMPRESSED_INTENSITY_ARB),
2597 const_iv (GL_COMPRESSED_RGB_ARB),
2598 const_iv (GL_COMPRESSED_RGBA_ARB),
2554 const_iv (GL_COMPILE), 2599 const_iv (GL_COMPILE),
2555 const_iv (GL_PROXY_TEXTURE_1D), 2600 const_iv (GL_PROXY_TEXTURE_1D),
2556 const_iv (GL_PROXY_TEXTURE_2D), 2601 const_iv (GL_PROXY_TEXTURE_2D),
2557 const_iv (GL_TEXTURE_1D), 2602 const_iv (GL_TEXTURE_1D),
2558 const_iv (GL_TEXTURE_2D), 2603 const_iv (GL_TEXTURE_2D),
2597 const_iv (GL_PERSPECTIVE_CORRECTION_HINT), 2642 const_iv (GL_PERSPECTIVE_CORRECTION_HINT),
2598 const_iv (GL_POINT_SMOOTH_HINT), 2643 const_iv (GL_POINT_SMOOTH_HINT),
2599 const_iv (GL_LINE_SMOOTH_HINT), 2644 const_iv (GL_LINE_SMOOTH_HINT),
2600 const_iv (GL_POLYGON_SMOOTH_HINT), 2645 const_iv (GL_POLYGON_SMOOTH_HINT),
2601 const_iv (GL_GENERATE_MIPMAP_HINT), 2646 const_iv (GL_GENERATE_MIPMAP_HINT),
2647 const_iv (GL_TEXTURE_COMPRESSION_HINT),
2602 const_iv (GL_FASTEST), 2648 const_iv (GL_FASTEST),
2603 const_iv (GL_DONT_CARE), 2649 const_iv (GL_DONT_CARE),
2604 const_iv (GL_NICEST), 2650 const_iv (GL_NICEST),
2605 const_iv (GL_V2F), 2651 const_iv (GL_V2F),
2606 const_iv (GL_V3F), 2652 const_iv (GL_V3F),
2614 2660
2615 texture_av = newAV (); 2661 texture_av = newAV ();
2616 AvREAL_off (texture_av); 2662 AvREAL_off (texture_av);
2617} 2663}
2618 2664
2665void
2666disable_GL_EXT_blend_func_separate ()
2667 CODE:
2668 gl.BlendFuncSeparate = 0;
2669 gl.BlendFuncSeparateEXT = 0;
2670
2619char * 2671char *
2620gl_vendor () 2672gl_vendor ()
2621 CODE: 2673 CODE:
2622 RETVAL = (char *)glGetString (GL_VENDOR); 2674 RETVAL = (char *)glGetString (GL_VENDOR);
2623 OUTPUT: 2675 OUTPUT:
2744 2796
2745void glRect (float x1, float y1, float x2, float y2) 2797void glRect (float x1, float y1, float x2, float y2)
2746 CODE: 2798 CODE:
2747 glRectf (x1, y1, x2, y2); 2799 glRectf (x1, y1, x2, y2);
2748 2800
2801void glRect_lineloop (float x1, float y1, float x2, float y2)
2802 CODE:
2803 glBegin (GL_LINE_LOOP);
2804 glVertex2f (x1, y1);
2805 glVertex2f (x2, y1);
2806 glVertex2f (x2, y2);
2807 glVertex2f (x1, y2);
2808 glEnd ();
2809
2749PROTOTYPES: ENABLE 2810PROTOTYPES: ENABLE
2750 2811
2751void glBegin (int mode) 2812void glBegin (int mode)
2752 2813
2753void glEnd () 2814void glEnd ()
2854 NV x, y, w, h; 2915 NV x, y, w, h;
2855 SV *draw_x_sv = GvSV (draw_x_gv); 2916 SV *draw_x_sv = GvSV (draw_x_gv);
2856 SV *draw_y_sv = GvSV (draw_y_gv); 2917 SV *draw_y_sv = GvSV (draw_y_gv);
2857 SV *draw_w_sv = GvSV (draw_w_gv); 2918 SV *draw_w_sv = GvSV (draw_w_gv);
2858 SV *draw_h_sv = GvSV (draw_h_gv); 2919 SV *draw_h_sv = GvSV (draw_h_gv);
2859 SV *hover;
2860 double draw_x, draw_y, draw_w, draw_h; 2920 double draw_x, draw_y;
2861 2921
2862 if (!SvROK (self)) 2922 if (!SvROK (self))
2863 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); 2923 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self));
2864 2924
2865 hv = (HV *)SvRV (self); 2925 hv = (HV *)SvRV (self);
2893 { 2953 {
2894 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); 2954 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0);
2895 2955
2896 if (svp && SvTRUE (*svp)) 2956 if (svp && SvTRUE (*svp))
2897 { 2957 {
2898 glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); 2958 glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f);
2899 glEnable (GL_BLEND); 2959 glEnable (GL_BLEND);
2900 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 2960 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
2901 glBegin (GL_QUADS); 2961 glBegin (GL_QUADS);
2902 glVertex2f (0, 0); 2962 glVertex2f (0, 0);
2903 glVertex2f (w, 0); 2963 glVertex2f (w, 0);
2906 glEnd (); 2966 glEnd ();
2907 glDisable (GL_BLEND); 2967 glDisable (GL_BLEND);
2908 } 2968 }
2909 } 2969 }
2910#if 0 2970#if 0
2911 if ($ENV{CFPLUS_DEBUG} & 1) { 2971 // draw borders, for debugging
2912 glPushMatrix; 2972 glPushMatrix ();
2913 glColor 1, 1, 0, 1; 2973 glColor4f (1., 1., 0., 1.);
2914 glTranslate 0.375, 0.375; 2974 glTranslatef (.5, .5, 0.);
2915 glBegin GL_LINE_LOOP; 2975 glBegin (GL_LINE_LOOP);
2916 glVertex 0 , 0; 2976 glVertex2f (0 , 0);
2917 glVertex $self->{w} - 1, 0; 2977 glVertex2f (w - 1, 0);
2918 glVertex $self->{w} - 1, $self->{h} - 1; 2978 glVertex2f (w - 1, h - 1);
2919 glVertex 0 , $self->{h} - 1; 2979 glVertex2f (0 , h - 1);
2920 glEnd; 2980 glEnd ();
2921 glPopMatrix; 2981 glPopMatrix ();
2922 #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
2923 }
2924#endif 2982#endif
2925 PUSHMARK (SP); 2983 PUSHMARK (SP);
2926 XPUSHs (self); 2984 XPUSHs (self);
2927 PUTBACK; 2985 PUTBACK;
2928 call_method ("_draw", G_VOID | G_DISCARD); 2986 call_method ("_draw", G_VOID | G_DISCARD);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines