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.226 by root, Sat Aug 11 13:05:58 2007 UTC vs.
Revision 1.235 by root, Tue Aug 28 01:23:47 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),
633 646
634NV floor (NV x) 647NV floor (NV x)
635 648
636NV ceil (NV x) 649NV ceil (NV x)
637 650
651IV minpot (UV n)
652
653IV popcount (UV n)
654
638void 655void
639pango_init () 656pango_init ()
640 CODE: 657 CODE:
641{ 658{
642 opengl_fontmap = pango_opengl_font_map_new (); 659 opengl_fontmap = pango_opengl_font_map_new ();
715 732
716 if (RETVAL) 733 if (RETVAL)
717 { 734 {
718 av_clear (texture_av); 735 av_clear (texture_av);
719 736
720 SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); 737 SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT");
721#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); 738#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name);
722#include "glfunc.h" 739#include "glfunc.h"
723#undef GL_FUNC 740#undef GL_FUNC
724 } 741 }
725} 742}
1346 1363
1347MODULE = CFPlus PACKAGE = CFPlus::Texture 1364MODULE = CFPlus PACKAGE = CFPlus::Texture
1348 1365
1349PROTOTYPES: ENABLE 1366PROTOTYPES: ENABLE
1350 1367
1351int minpot (int n)
1352
1353void 1368void
1354pad (SV *data_, int ow, int oh, int nw, int nh) 1369pad (SV *data_, int ow, int oh, int nw, int nh)
1355 CODE: 1370 CODE:
1356{ 1371{
1357 if ((nw != ow || nh != oh) && SvOK (data_)) 1372 if ((nw != ow || nh != oh) && SvOK (data_))
2243 int x, y, z; 2258 int x, y, z;
2244 int w, h; 2259 int w, h;
2245 int x1, y1; 2260 int x1, y1;
2246 2261
2247 if (*data++ != 0) 2262 if (*data++ != 0)
2248 return; /* version mismatch */ 2263 XSRETURN_EMPTY; /* version mismatch */
2249 2264
2250 w = *data++ << 8; w |= *data++; 2265 w = *data++ << 8; w |= *data++;
2251 h = *data++ << 8; h |= *data++; 2266 h = *data++ << 8; h |= *data++;
2252 2267
2253 // we need to do this 'cause we don't keep an absolute coord system for rows 2268 // we need to do this 'cause we don't keep an absolute coord system for rows
2549 const_iv (GL_INTENSITY), 2564 const_iv (GL_INTENSITY),
2550 const_iv (GL_LUMINANCE), 2565 const_iv (GL_LUMINANCE),
2551 const_iv (GL_LUMINANCE_ALPHA), 2566 const_iv (GL_LUMINANCE_ALPHA),
2552 const_iv (GL_FLOAT), 2567 const_iv (GL_FLOAT),
2553 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), 2568 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV),
2569 const_iv (GL_COMPRESSED_ALPHA_ARB),
2570 const_iv (GL_COMPRESSED_LUMINANCE_ARB),
2571 const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB),
2572 const_iv (GL_COMPRESSED_INTENSITY_ARB),
2573 const_iv (GL_COMPRESSED_RGB_ARB),
2574 const_iv (GL_COMPRESSED_RGBA_ARB),
2554 const_iv (GL_COMPILE), 2575 const_iv (GL_COMPILE),
2555 const_iv (GL_PROXY_TEXTURE_1D), 2576 const_iv (GL_PROXY_TEXTURE_1D),
2556 const_iv (GL_PROXY_TEXTURE_2D), 2577 const_iv (GL_PROXY_TEXTURE_2D),
2557 const_iv (GL_TEXTURE_1D), 2578 const_iv (GL_TEXTURE_1D),
2558 const_iv (GL_TEXTURE_2D), 2579 const_iv (GL_TEXTURE_2D),
2597 const_iv (GL_PERSPECTIVE_CORRECTION_HINT), 2618 const_iv (GL_PERSPECTIVE_CORRECTION_HINT),
2598 const_iv (GL_POINT_SMOOTH_HINT), 2619 const_iv (GL_POINT_SMOOTH_HINT),
2599 const_iv (GL_LINE_SMOOTH_HINT), 2620 const_iv (GL_LINE_SMOOTH_HINT),
2600 const_iv (GL_POLYGON_SMOOTH_HINT), 2621 const_iv (GL_POLYGON_SMOOTH_HINT),
2601 const_iv (GL_GENERATE_MIPMAP_HINT), 2622 const_iv (GL_GENERATE_MIPMAP_HINT),
2623 const_iv (GL_TEXTURE_COMPRESSION_HINT),
2602 const_iv (GL_FASTEST), 2624 const_iv (GL_FASTEST),
2603 const_iv (GL_DONT_CARE), 2625 const_iv (GL_DONT_CARE),
2604 const_iv (GL_NICEST), 2626 const_iv (GL_NICEST),
2605 const_iv (GL_V2F), 2627 const_iv (GL_V2F),
2606 const_iv (GL_V3F), 2628 const_iv (GL_V3F),
2614 2636
2615 texture_av = newAV (); 2637 texture_av = newAV ();
2616 AvREAL_off (texture_av); 2638 AvREAL_off (texture_av);
2617} 2639}
2618 2640
2641void
2642disable_GL_EXT_blend_func_separate ()
2643 CODE:
2644 gl.BlendFuncSeparate = 0;
2645 gl.BlendFuncSeparateEXT = 0;
2646
2619char * 2647char *
2620gl_vendor () 2648gl_vendor ()
2621 CODE: 2649 CODE:
2622 RETVAL = (char *)glGetString (GL_VENDOR); 2650 RETVAL = (char *)glGetString (GL_VENDOR);
2623 OUTPUT: 2651 OUTPUT:
2744 2772
2745void glRect (float x1, float y1, float x2, float y2) 2773void glRect (float x1, float y1, float x2, float y2)
2746 CODE: 2774 CODE:
2747 glRectf (x1, y1, x2, y2); 2775 glRectf (x1, y1, x2, y2);
2748 2776
2777void glRect_lineloop (float x1, float y1, float x2, float y2)
2778 CODE:
2779 glBegin (GL_LINE_LOOP);
2780 glVertex2f (x1, y1);
2781 glVertex2f (x2, y1);
2782 glVertex2f (x2, y2);
2783 glVertex2f (x1, y2);
2784 glEnd ();
2785
2749PROTOTYPES: ENABLE 2786PROTOTYPES: ENABLE
2750 2787
2751void glBegin (int mode) 2788void glBegin (int mode)
2752 2789
2753void glEnd () 2790void glEnd ()
2854 NV x, y, w, h; 2891 NV x, y, w, h;
2855 SV *draw_x_sv = GvSV (draw_x_gv); 2892 SV *draw_x_sv = GvSV (draw_x_gv);
2856 SV *draw_y_sv = GvSV (draw_y_gv); 2893 SV *draw_y_sv = GvSV (draw_y_gv);
2857 SV *draw_w_sv = GvSV (draw_w_gv); 2894 SV *draw_w_sv = GvSV (draw_w_gv);
2858 SV *draw_h_sv = GvSV (draw_h_gv); 2895 SV *draw_h_sv = GvSV (draw_h_gv);
2859 SV *hover;
2860 double draw_x, draw_y, draw_w, draw_h; 2896 double draw_x, draw_y;
2861 2897
2862 if (!SvROK (self)) 2898 if (!SvROK (self))
2863 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); 2899 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self));
2864 2900
2865 hv = (HV *)SvRV (self); 2901 hv = (HV *)SvRV (self);
2893 { 2929 {
2894 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); 2930 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0);
2895 2931
2896 if (svp && SvTRUE (*svp)) 2932 if (svp && SvTRUE (*svp))
2897 { 2933 {
2898 glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); 2934 glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f);
2899 glEnable (GL_BLEND); 2935 glEnable (GL_BLEND);
2900 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 2936 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
2901 glBegin (GL_QUADS); 2937 glBegin (GL_QUADS);
2902 glVertex2f (0, 0); 2938 glVertex2f (0, 0);
2903 glVertex2f (w, 0); 2939 glVertex2f (w, 0);
2906 glEnd (); 2942 glEnd ();
2907 glDisable (GL_BLEND); 2943 glDisable (GL_BLEND);
2908 } 2944 }
2909 } 2945 }
2910#if 0 2946#if 0
2911 if ($ENV{CFPLUS_DEBUG} & 1) { 2947 // draw borders, for debugging
2912 glPushMatrix; 2948 glPushMatrix ();
2913 glColor 1, 1, 0, 1; 2949 glColor4f (1., 1., 0., 1.);
2914 glTranslate 0.375, 0.375; 2950 glTranslatef (.5, .5, 0.);
2915 glBegin GL_LINE_LOOP; 2951 glBegin (GL_LINE_LOOP);
2916 glVertex 0 , 0; 2952 glVertex2f (0 , 0);
2917 glVertex $self->{w} - 1, 0; 2953 glVertex2f (w - 1, 0);
2918 glVertex $self->{w} - 1, $self->{h} - 1; 2954 glVertex2f (w - 1, h - 1);
2919 glVertex 0 , $self->{h} - 1; 2955 glVertex2f (0 , h - 1);
2920 glEnd; 2956 glEnd ();
2921 glPopMatrix; 2957 glPopMatrix ();
2922 #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
2923 }
2924#endif 2958#endif
2925 PUSHMARK (SP); 2959 PUSHMARK (SP);
2926 XPUSHs (self); 2960 XPUSHs (self);
2927 PUTBACK; 2961 PUTBACK;
2928 call_method ("_draw", G_VOID | G_DISCARD); 2962 call_method ("_draw", G_VOID | G_DISCARD);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines