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.285 by root, Sat Dec 20 19:45:49 2008 UTC vs.
Revision 1.293 by root, Thu Dec 17 02:49:38 2009 UTC

81#define expect_false(expr) expect ((expr) != 0, 0) 81#define expect_false(expr) expect ((expr) != 0, 0)
82#define expect_true(expr) expect ((expr) != 0, 1) 82#define expect_true(expr) expect ((expr) != 0, 1)
83 83
84#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 84#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
85 85
86#define FOW_DARKNESS 16 86#define FOW_DARKNESS 64
87 87
88#define MAP_EXTEND_X 32 88#define MAP_EXTEND_X 32
89#define MAP_EXTEND_Y 512 89#define MAP_EXTEND_Y 512
90 90
91#define MIN_FONT_HEIGHT 10 91#define MIN_FONT_HEIGHT 10
1658 glDisable (GL_ALPHA_TEST); 1658 glDisable (GL_ALPHA_TEST);
1659 glDisable (GL_BLEND); 1659 glDisable (GL_BLEND);
1660 } 1660 }
1661} 1661}
1662 1662
1663void
1664draw_fow_texture (float intensity, int name1, float s1, float t1, float w1, float h1)
1665 PROTOTYPE: @
1666 CODE:
1667{
1668 glEnable (GL_TEXTURE_2D);
1669 glEnable (GL_BLEND);
1670 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1671 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1672
1673 glColor4f (intensity, intensity, intensity, 0.9);
1674 glPushMatrix ();
1675 glScalef (1./3, 1./3, 1.);
1676
1677 glBindTexture (GL_TEXTURE_2D, name1);
1678
1679 glBegin (GL_QUADS);
1680 glTexCoord2f ( 0, 0); glVertex2f ( 0, 0);
1681 glTexCoord2f ( 0, t1); glVertex2f ( 0, h1);
1682 glTexCoord2f (s1, t1); glVertex2f (w1, h1);
1683 glTexCoord2f (s1, 0); glVertex2f (w1, 0);
1684 glEnd ();
1685
1686 glPopMatrix ();
1687
1688 glDisable (GL_TEXTURE_2D);
1689 glDisable (GL_BLEND);
1690}
1691
1663IV texture_valid_2d (GLint internalformat, GLsizei w, GLsizei h, GLenum format, GLenum type) 1692IV texture_valid_2d (GLint internalformat, GLsizei w, GLsizei h, GLenum format, GLenum type)
1664 CODE: 1693 CODE:
1665{ 1694{
1666 GLint width; 1695 GLint width;
1667 glTexImage2D (GL_PROXY_TEXTURE_2D, 0, internalformat, w, h, 0, format, type, 0); 1696 glTexImage2D (GL_PROXY_TEXTURE_2D, 0, internalformat, w, h, 0, format, type, 0);
2016 rc_key_t key; 2045 rc_key_t key;
2017 rc_array_t *arr, *arr_hidden; 2046 rc_array_t *arr, *arr_hidden;
2018 2047
2019 pl_tex.name = 0; 2048 pl_tex.name = 0;
2020 2049
2021 // thats current max. sorry. 2050 // that's current max. sorry.
2022 if (sw > 255) sw = 255; 2051 if (sw > 255) sw = 255;
2023 if (sh > 255) sh = 255; 2052 if (sh > 255) sh = 255;
2024 2053
2025 // clear key, in case of extra padding 2054 // clear key, in case of extra padding
2026 memset (&skey, 0, sizeof (skey)); 2055 memset (&skey, 0, sizeof (skey));
2174 if (cell->flags & 1) 2203 if (cell->flags & 1)
2175 { 2204 {
2176 rc_key_t key_ov = key; 2205 rc_key_t key_ov = key;
2177 maptex tex = self->tex [TEXID_SPEECH]; 2206 maptex tex = self->tex [TEXID_SPEECH];
2178 rc_array_t *arr; 2207 rc_array_t *arr;
2208 int px = x * T + T * 2 / 32;
2209 int py = y * T - T * 6 / 32;
2179 2210
2180 key_ov.texname = tex.name; 2211 key_ov.texname = tex.name;
2181 arr = rc_array (rc_ov, &key_ov); 2212 arr = rc_array (rc_ov, &key_ov);
2182
2183 int px = x * T + T * 2 / 32;
2184 int py = y * T - T * 6 / 32;
2185 2213
2186 rc_t2f_v3f (arr, 0 , 0 , px , py , 0); 2214 rc_t2f_v3f (arr, 0 , 0 , px , py , 0);
2187 rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0); 2215 rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0);
2188 rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0); 2216 rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0);
2189 rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0); 2217 rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0);
2367 }; 2395 };
2368 2396
2369 int x, y; 2397 int x, y;
2370 2398
2371 glEnable (GL_TEXTURE_2D); 2399 glEnable (GL_TEXTURE_2D);
2400 /* GL_REPLACE would be correct, as we don't need to modulate alpha,
2401 * but the nvidia driver (185.18.14) mishandles alpha textures
2402 * ansd takes the colour from god knows where instead of using
2403 * Cp. MODULATE results in the same colour, but slightly different
2404 * alpha, but atcually gives us the correct colour with nvidia.
2405 */
2372 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 2406 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
2373 glEnable (GL_BLEND); 2407 glEnable (GL_BLEND);
2374 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 2408 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2375 glBegin (GL_QUADS); 2409 glBegin (GL_QUADS);
2376 2410
2377 for (y = 0; y < h; y++) 2411 for (y = 0; y < h; y++)
2384 float *c = color [m & 15]; 2418 float *c = color [m & 15];
2385 2419
2386 float tx1 = m & 0x40 ? 0.5 : 0.; 2420 float tx1 = m & 0x40 ? 0.5 : 0.;
2387 float tx2 = tx1 + 0.5; 2421 float tx2 = tx1 + 0.5;
2388 2422
2389 glColor4f (c[0], c[1], c[2], 0.75); 2423 glColor4f (c[0], c[1], c[2], 1);
2390 glTexCoord2f (tx1, 0.); glVertex2i (x , y ); 2424 glTexCoord2f (tx1, 0.); glVertex2i (x , y );
2391 glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1); 2425 glTexCoord2f (tx1, 1.); glVertex2i (x , y + 1);
2392 glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1); 2426 glTexCoord2f (tx2, 1.); glVertex2i (x + 1, y + 1);
2393 glTexCoord2f (tx2, 0.); glVertex2i (x + 1, y ); 2427 glTexCoord2f (tx2, 0.); glVertex2i (x + 1, y );
2394 } 2428 }
2853 } *civ, const_iv[] = { 2887 } *civ, const_iv[] = {
2854# define const_iv(name) { # name, (IV)name } 2888# define const_iv(name) { # name, (IV)name }
2855 const_iv (GL_VENDOR), 2889 const_iv (GL_VENDOR),
2856 const_iv (GL_VERSION), 2890 const_iv (GL_VERSION),
2857 const_iv (GL_EXTENSIONS), 2891 const_iv (GL_EXTENSIONS),
2892 const_iv (GL_MAX_TEXTURE_UNITS),
2858 const_iv (GL_COLOR_MATERIAL), 2893 const_iv (GL_COLOR_MATERIAL),
2859 const_iv (GL_SMOOTH), 2894 const_iv (GL_SMOOTH),
2860 const_iv (GL_FLAT), 2895 const_iv (GL_FLAT),
2861 const_iv (GL_DITHER), 2896 const_iv (GL_DITHER),
2862 const_iv (GL_BLEND), 2897 const_iv (GL_BLEND),
2874 const_iv (GL_ZERO), 2909 const_iv (GL_ZERO),
2875 const_iv (GL_SRC_ALPHA), 2910 const_iv (GL_SRC_ALPHA),
2876 const_iv (GL_DST_ALPHA), 2911 const_iv (GL_DST_ALPHA),
2877 const_iv (GL_ONE_MINUS_SRC_ALPHA), 2912 const_iv (GL_ONE_MINUS_SRC_ALPHA),
2878 const_iv (GL_ONE_MINUS_DST_ALPHA), 2913 const_iv (GL_ONE_MINUS_DST_ALPHA),
2914 const_iv (GL_SRC_COLOR),
2915 const_iv (GL_DST_COLOR),
2916 const_iv (GL_ONE_MINUS_SRC_COLOR),
2917 const_iv (GL_ONE_MINUS_DST_COLOR),
2879 const_iv (GL_SRC_ALPHA_SATURATE), 2918 const_iv (GL_SRC_ALPHA_SATURATE),
2880 const_iv (GL_RGB), 2919 const_iv (GL_RGB),
2881 const_iv (GL_RGBA), 2920 const_iv (GL_RGBA),
2882 const_iv (GL_RGBA4), 2921 const_iv (GL_RGBA4),
2883 const_iv (GL_RGBA8), 2922 const_iv (GL_RGBA8),
2951 const_iv (GL_NICEST), 2990 const_iv (GL_NICEST),
2952 const_iv (GL_V2F), 2991 const_iv (GL_V2F),
2953 const_iv (GL_V3F), 2992 const_iv (GL_V3F),
2954 const_iv (GL_T2F_V3F), 2993 const_iv (GL_T2F_V3F),
2955 const_iv (GL_T2F_N3F_V3F), 2994 const_iv (GL_T2F_N3F_V3F),
2995 const_iv (GL_FUNC_ADD),
2996 const_iv (GL_FUNC_SUBTRACT),
2997 const_iv (GL_FUNC_REVERSE_SUBTRACT),
2956# undef const_iv 2998# undef const_iv
2957 }; 2999 };
2958 3000
2959 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 3001 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
2960 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 3002 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
2967disable_GL_EXT_blend_func_separate () 3009disable_GL_EXT_blend_func_separate ()
2968 CODE: 3010 CODE:
2969 gl.BlendFuncSeparate = 0; 3011 gl.BlendFuncSeparate = 0;
2970 gl.BlendFuncSeparateEXT = 0; 3012 gl.BlendFuncSeparateEXT = 0;
2971 3013
3014void
3015apple_nvidia_bug (int enable)
3016
2972char * 3017char *
2973gl_vendor () 3018gl_vendor ()
2974 CODE: 3019 CODE:
2975 RETVAL = (char *)glGetString (GL_VENDOR); 3020 RETVAL = (char *)glGetString (GL_VENDOR);
2976 OUTPUT: 3021 OUTPUT:
3024void glBlendFunc (int sfactor, int dfactor) 3069void glBlendFunc (int sfactor, int dfactor)
3025 3070
3026void glBlendFuncSeparate (int sa, int da, int saa, int daa) 3071void glBlendFuncSeparate (int sa, int da, int saa, int daa)
3027 CODE: 3072 CODE:
3028 gl_BlendFuncSeparate (sa, da, saa, daa); 3073 gl_BlendFuncSeparate (sa, da, saa, daa);
3074
3075# void glBlendEquation (int se)
3029 3076
3030void glDepthMask (int flag) 3077void glDepthMask (int flag)
3031 3078
3032void glLogicOp (int opcode) 3079void glLogicOp (int opcode)
3033 3080

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines