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.225 by root, Sat Aug 11 12:07:54 2007 UTC vs.
Revision 1.232 by root, Sun Aug 19 15:57:40 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;
715 715
716 if (RETVAL) 716 if (RETVAL)
717 { 717 {
718 av_clear (texture_av); 718 av_clear (texture_av);
719 719
720 SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); 720 SDL_WM_SetCaption ("Crossfire TRT Client " VERSION, "Crossfire TRT");
721#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); 721#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name);
722#include "glfunc.h" 722#include "glfunc.h"
723#undef GL_FUNC 723#undef GL_FUNC
724 } 724 }
725} 725}
1745{ 1745{
1746 int x, y, z; 1746 int x, y, z;
1747 1747
1748 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1748 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1749 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level 1749 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
1750 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) 1750 static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k)
1751 smooth_key skey; 1751 smooth_key skey;
1752 1752
1753 rc_t *rc = rc_alloc (); 1753 rc_t *rc = rc_alloc ();
1754 rc_key_t key; 1754 rc_key_t key;
1755 rc_array_t *arr; 1755 rc_array_t *arr;
1817 if (tile) 1817 if (tile)
1818 { 1818 {
1819 maptex tex = self->tex [tile]; 1819 maptex tex = self->tex [tile];
1820 int px, py; 1820 int px, py;
1821 1821
1822 // suppressing texture state switches here
1823 // is only moderately effective, but worth the extra effort
1824 if (key.texname != tex.name) 1822 if (key.texname != tex.name)
1825 { 1823 {
1826 if (!tex.name) 1824 if (!tex.name)
1827 tex = self->tex [2]; /* missing, replace by noface */ 1825 tex = self->tex [2]; /* missing, replace by noface */
1828 1826
1911 // go through all smoothlevels, lowest to highest, then draw. 1909 // go through all smoothlevels, lowest to highest, then draw.
1912 // this is basically counting sort 1910 // this is basically counting sort
1913 { 1911 {
1914 int w, b; 1912 int w, b;
1915 1913
1914 glEnable (GL_TEXTURE_2D);
1915 glBegin (GL_QUADS);
1916 for (w = 0; w < 256 / 32; ++w) 1916 for (w = 0; w < 256 / 32; ++w)
1917 { 1917 {
1918 uint32_t smask = smooth_level [w]; 1918 uint32_t smask = smooth_level [w];
1919 if (smask) 1919 if (smask)
1920 for (b = 0; b < 32; ++b) 1920 for (b = 0; b < 32; ++b)
1945 { 1945 {
1946 // this time avoiding texture state changes 1946 // this time avoiding texture state changes
1947 // save gobs of state changes. 1947 // save gobs of state changes.
1948 if (key.texname != tex.name) 1948 if (key.texname != tex.name)
1949 { 1949 {
1950 glEnd ();
1950 key.texname = tex.name; 1951 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
1951 arr = rc_array (rc, &key); 1952 glBegin (GL_QUADS);
1952 } 1953 }
1953 1954
1954 if (border) 1955 if (border)
1955 { 1956 {
1956 float ox = border * dx; 1957 float ox = border * dx;
1957 1958
1958 rc_t2f_v3f (arr, ox , 0.f , px , py , 0); 1959 glTexCoord2f (ox , 0.f ); glVertex2i (px , py );
1959 rc_t2f_v3f (arr, ox , dy , px , py + T, 0); 1960 glTexCoord2f (ox , dy ); glVertex2i (px , py + T);
1960 rc_t2f_v3f (arr, ox + dx, dy , px + T, py + T, 0); 1961 glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T);
1961 rc_t2f_v3f (arr, ox + dx, 0.f , px + T, py , 0); 1962 glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py );
1962 } 1963 }
1963 1964
1964 if (corner) 1965 if (corner)
1965 { 1966 {
1966 float ox = corner * dx; 1967 float ox = corner * dx;
1967 1968
1968 rc_t2f_v3f (arr, ox , dy , px , py , 0); 1969 glTexCoord2f (ox , dy ); glVertex2i (px , py );
1969 rc_t2f_v3f (arr, ox , dy * 2.f, px , py + T, 0); 1970 glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T);
1970 rc_t2f_v3f (arr, ox + dx, dy * 2.f, px + T, py + T, 0); 1971 glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T);
1971 rc_t2f_v3f (arr, ox + dx, dy , px + T, py , 0); 1972 glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py );
1972 } 1973 }
1973 } 1974 }
1974 } 1975 }
1975 } 1976 }
1976 } 1977 }
1977 } 1978 }
1979
1980 glEnd ();
1981 glDisable (GL_TEXTURE_2D);
1982 key.texname = -1;
1978 } 1983 }
1979 1984
1980 hv_clear (smooth); 1985 hv_clear (smooth);
1981 rc_draw (rc);
1982 rc_clear (rc);
1983 } 1986 }
1984 1987
1985 glDisable (GL_BLEND); 1988 glDisable (GL_BLEND);
1986 rc_free (rc); 1989 rc_free (rc);
1987 1990
2240 int x, y, z; 2243 int x, y, z;
2241 int w, h; 2244 int w, h;
2242 int x1, y1; 2245 int x1, y1;
2243 2246
2244 if (*data++ != 0) 2247 if (*data++ != 0)
2245 return; /* version mismatch */ 2248 XSRETURN_EMPTY; /* version mismatch */
2246 2249
2247 w = *data++ << 8; w |= *data++; 2250 w = *data++ << 8; w |= *data++;
2248 h = *data++ << 8; h |= *data++; 2251 h = *data++ << 8; h |= *data++;
2249 2252
2250 // we need to do this 'cause we don't keep an absolute coord system for rows 2253 // we need to do this 'cause we don't keep an absolute coord system for rows
2546 const_iv (GL_INTENSITY), 2549 const_iv (GL_INTENSITY),
2547 const_iv (GL_LUMINANCE), 2550 const_iv (GL_LUMINANCE),
2548 const_iv (GL_LUMINANCE_ALPHA), 2551 const_iv (GL_LUMINANCE_ALPHA),
2549 const_iv (GL_FLOAT), 2552 const_iv (GL_FLOAT),
2550 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), 2553 const_iv (GL_UNSIGNED_INT_8_8_8_8_REV),
2554 const_iv (GL_COMPRESSED_ALPHA_ARB),
2555 const_iv (GL_COMPRESSED_LUMINANCE_ARB),
2556 const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB),
2557 const_iv (GL_COMPRESSED_INTENSITY_ARB),
2558 const_iv (GL_COMPRESSED_RGB_ARB),
2559 const_iv (GL_COMPRESSED_RGBA_ARB),
2551 const_iv (GL_COMPILE), 2560 const_iv (GL_COMPILE),
2552 const_iv (GL_PROXY_TEXTURE_1D), 2561 const_iv (GL_PROXY_TEXTURE_1D),
2553 const_iv (GL_PROXY_TEXTURE_2D), 2562 const_iv (GL_PROXY_TEXTURE_2D),
2554 const_iv (GL_TEXTURE_1D), 2563 const_iv (GL_TEXTURE_1D),
2555 const_iv (GL_TEXTURE_2D), 2564 const_iv (GL_TEXTURE_2D),
2594 const_iv (GL_PERSPECTIVE_CORRECTION_HINT), 2603 const_iv (GL_PERSPECTIVE_CORRECTION_HINT),
2595 const_iv (GL_POINT_SMOOTH_HINT), 2604 const_iv (GL_POINT_SMOOTH_HINT),
2596 const_iv (GL_LINE_SMOOTH_HINT), 2605 const_iv (GL_LINE_SMOOTH_HINT),
2597 const_iv (GL_POLYGON_SMOOTH_HINT), 2606 const_iv (GL_POLYGON_SMOOTH_HINT),
2598 const_iv (GL_GENERATE_MIPMAP_HINT), 2607 const_iv (GL_GENERATE_MIPMAP_HINT),
2608 const_iv (GL_TEXTURE_COMPRESSION_HINT),
2599 const_iv (GL_FASTEST), 2609 const_iv (GL_FASTEST),
2600 const_iv (GL_DONT_CARE), 2610 const_iv (GL_DONT_CARE),
2601 const_iv (GL_NICEST), 2611 const_iv (GL_NICEST),
2602 const_iv (GL_V2F), 2612 const_iv (GL_V2F),
2603 const_iv (GL_V3F), 2613 const_iv (GL_V3F),
2611 2621
2612 texture_av = newAV (); 2622 texture_av = newAV ();
2613 AvREAL_off (texture_av); 2623 AvREAL_off (texture_av);
2614} 2624}
2615 2625
2626void
2627disable_GL_EXT_blend_func_separate ()
2628 CODE:
2629 gl.BlendFuncSeparate = 0;
2630 gl.BlendFuncSeparateEXT = 0;
2631
2616char * 2632char *
2617gl_vendor () 2633gl_vendor ()
2618 CODE: 2634 CODE:
2619 RETVAL = (char *)glGetString (GL_VENDOR); 2635 RETVAL = (char *)glGetString (GL_VENDOR);
2620 OUTPUT: 2636 OUTPUT:
2851 NV x, y, w, h; 2867 NV x, y, w, h;
2852 SV *draw_x_sv = GvSV (draw_x_gv); 2868 SV *draw_x_sv = GvSV (draw_x_gv);
2853 SV *draw_y_sv = GvSV (draw_y_gv); 2869 SV *draw_y_sv = GvSV (draw_y_gv);
2854 SV *draw_w_sv = GvSV (draw_w_gv); 2870 SV *draw_w_sv = GvSV (draw_w_gv);
2855 SV *draw_h_sv = GvSV (draw_h_gv); 2871 SV *draw_h_sv = GvSV (draw_h_gv);
2856 SV *hover;
2857 double draw_x, draw_y, draw_w, draw_h; 2872 double draw_x, draw_y;
2858 2873
2859 if (!SvROK (self)) 2874 if (!SvROK (self))
2860 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); 2875 croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self));
2861 2876
2862 hv = (HV *)SvRV (self); 2877 hv = (HV *)SvRV (self);
2890 { 2905 {
2891 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0); 2906 svp = hv_fetch (hv, "can_hover", sizeof ("can_hover") - 1, 0);
2892 2907
2893 if (svp && SvTRUE (*svp)) 2908 if (svp && SvTRUE (*svp))
2894 { 2909 {
2895 glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); 2910 glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f);
2896 glEnable (GL_BLEND); 2911 glEnable (GL_BLEND);
2897 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 2912 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
2898 glBegin (GL_QUADS); 2913 glBegin (GL_QUADS);
2899 glVertex2f (0, 0); 2914 glVertex2f (0, 0);
2900 glVertex2f (w, 0); 2915 glVertex2f (w, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines