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.296 by root, Mon Dec 21 23:52:34 2009 UTC vs.
Revision 1.302 by root, Tue Apr 20 10:53:11 2010 UTC

41#include <SDL_opengl.h> 41#include <SDL_opengl.h>
42 42
43/* work around os x broken headers */ 43/* work around os x broken headers */
44#ifdef __MACOSX__ 44#ifdef __MACOSX__
45typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); 45typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
46typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
47typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
46#endif 48#endif
47 49
48#define PANGO_ENABLE_BACKEND 50#define PANGO_ENABLE_BACKEND
49#define G_DISABLE_CAST_CHECKS 51#define G_DISABLE_CAST_CHECKS
50 52
97 99
98#define KMOD_LRAM 0x10000 // our extension 100#define KMOD_LRAM 0x10000 // our extension
99 101
100#define TEXID_SPEECH 1 102#define TEXID_SPEECH 1
101#define TEXID_NOFACE 2 103#define TEXID_NOFACE 2
102#define TEXID_HIDDEN 3
103 104
104static AV *texture_av; 105static AV *texture_av;
105 106
106static struct 107static struct
107{ 108{
929 930
930 SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); 931 SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra");
931#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); 932#define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name);
932#include "glfunc.h" 933#include "glfunc.h"
933#undef GL_FUNC 934#undef GL_FUNC
935
936 if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB;
937 if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB;
934 } 938 }
935} 939}
936 OUTPUT: 940 OUTPUT:
937 RETVAL 941 RETVAL
938 942
1671void 1675void
1672draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1) 1676draw_fow_texture (float intensity, int hidden_tex, int name1, uint8_t *data1, float s, float t, int w, int h, float blend = 0.f, int dx = 0, int dy = 0, int name2 = 0, uint8_t *data2 = data1)
1673 PROTOTYPE: @ 1677 PROTOTYPE: @
1674 CODE: 1678 CODE:
1675{ 1679{
1680 glEnable (GL_BLEND);
1681 glBlendFunc (intensity ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1676 glEnable (GL_TEXTURE_2D); 1682 glEnable (GL_TEXTURE_2D);
1677 glEnable (GL_BLEND);
1678 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1679 glBindTexture (GL_TEXTURE_2D, name1); 1683 glBindTexture (GL_TEXTURE_2D, name1);
1680 1684
1681 glColor3f (intensity, intensity, intensity); 1685 glColor3f (intensity, intensity, intensity);
1682 glPushMatrix (); 1686 glPushMatrix ();
1683 glScalef (1./3, 1./3, 1.); 1687 glScalef (1./3, 1./3, 1.);
1698 glBindTexture (GL_TEXTURE_2D, name2); 1702 glBindTexture (GL_TEXTURE_2D, name2);
1699 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); 1703 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
1700 1704
1701 /* rgb == rgb(glcolor) */ 1705 /* rgb == rgb(glcolor) */
1702 glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); 1706 glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
1703 glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); 1707 glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
1704 glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); 1708 glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
1705 1709
1706 /* alpha = interpolate t0, t1 by env_alpha */ 1710 /* alpha = interpolate t0, t1 by env_alpha */
1707 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color); 1711 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, env_color);
1708 1712
2141 int pl_x, pl_y; 2145 int pl_x, pl_y;
2142 maptex pl_tex; 2146 maptex pl_tex;
2143 rc_t *rc = rc_alloc (); 2147 rc_t *rc = rc_alloc ();
2144 rc_t *rc_ov = rc_alloc (); 2148 rc_t *rc_ov = rc_alloc ();
2145 rc_key_t key; 2149 rc_key_t key;
2146 rc_array_t *arr, *arr_hidden; 2150 rc_array_t *arr;
2147 2151
2148 pl_tex.name = 0; 2152 pl_tex.name = 0;
2149 2153
2150 // that's current max. sorry. 2154 // that's current max. sorry.
2151 if (sw > 255) sw = 255; 2155 if (sw > 255) sw = 255;
2188 } 2192 }
2189 2193
2190 glEnable (GL_BLEND); 2194 glEnable (GL_BLEND);
2191 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 2195 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2192 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 2196 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2193
2194 key.texname = self->tex [TEXID_HIDDEN].name;
2195 arr_hidden = rc_array (rc_ov, &key);
2196 2197
2197 for (z = 0; z <= 2; z++) 2198 for (z = 0; z <= 2; z++)
2198 { 2199 {
2199 memset (smooth_level, 0, sizeof (smooth_level)); 2200 memset (smooth_level, 0, sizeof (smooth_level));
2200 key.texname = -1; 2201 key.texname = -1;
2797 if (RETVAL < 0) 2798 if (RETVAL < 0)
2798 { 2799 {
2799 RETVAL = Mix_GroupOldest (-1); 2800 RETVAL = Mix_GroupOldest (-1);
2800 2801
2801 if (RETVAL < 0) 2802 if (RETVAL < 0)
2803 {
2804 // happens sometimes, maybe it just stopped playing(?)
2805 RETVAL = Mix_GroupAvailable (-1);
2806
2807 if (RETVAL < 0)
2802 XSRETURN_UNDEF; 2808 XSRETURN_UNDEF;
2803 2809 }
2810 else
2804 Mix_HaltChannel (RETVAL); 2811 Mix_HaltChannel (RETVAL);
2805 } 2812 }
2806 2813
2807 Mix_UnregisterAllEffects (RETVAL); 2814 Mix_UnregisterAllEffects (RETVAL);
2808 Mix_Volume (RETVAL, 128); 2815 Mix_Volume (RETVAL, 128);
2809} 2816}
2868 Mix_SetReverseStereo (self, flip); 2875 Mix_SetReverseStereo (self, flip);
2869 2876
2870MODULE = Deliantra::Client PACKAGE = DC::MixChunk 2877MODULE = Deliantra::Client PACKAGE = DC::MixChunk
2871 2878
2872PROTOTYPES: DISABLE 2879PROTOTYPES: DISABLE
2880
2881void
2882decoders ()
2883 PPCODE:
2884#if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10
2885 int i, num = Mix_GetNumChunkDecoders ();
2886 EXTEND (SP, num);
2887 for (i = 0; i < num; ++i)
2888 PUSHs (sv_2mortal (newSVpv (Mix_GetChunkDecoder (i), 0)));
2889#else
2890 XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0)));
2891#endif
2873 2892
2874DC::MixChunk 2893DC::MixChunk
2875new (SV *class, DC::RW rwops) 2894new (SV *class, DC::RW rwops)
2876 CODE: 2895 CODE:
2877 RETVAL = Mix_LoadWAV_RW (rwops, 1); 2896 RETVAL = Mix_LoadWAV_RW (rwops, 1);
2910 OUTPUT: 2929 OUTPUT:
2911 RETVAL 2930 RETVAL
2912 2931
2913MODULE = Deliantra::Client PACKAGE = DC::MixMusic 2932MODULE = Deliantra::Client PACKAGE = DC::MixMusic
2914 2933
2934void
2935decoders ()
2936 PPCODE:
2937#if SDL_MIXER_MAJOR_VERSION > 1 || SDL_MIXER_MINOR_VERSION > 2 || SDL_MIXER_PATCHLEVEL >= 10
2938 int i, num = Mix_GetNumMusicDecoders ();
2939 EXTEND (SP, num);
2940 for (i = 0; i < num; ++i)
2941 PUSHs (sv_2mortal (newSVpv (Mix_GetMusicDecoder (i), 0)));
2942#else
2943 XPUSHs (sv_2mortal (newSVpv ("(sdl mixer too old)", 0)));
2944#endif
2945
2915int 2946int
2916volume (int volume = -1) 2947volume (int volume = -1)
2917 PROTOTYPE: ;$ 2948 PROTOTYPE: ;$
2918 CODE: 2949 CODE:
2919 if (items > 0) 2950 if (items > 0)
2929 2960
2930void 2961void
2931halt () 2962halt ()
2932 CODE: 2963 CODE:
2933 Mix_HaltMusic (); 2964 Mix_HaltMusic ();
2965
2966int
2967playing ()
2968 CODE:
2969 RETVAL = Mix_PlayingMusic ();
2970 OUTPUT:
2971 RETVAL
2934 2972
2935DC::MixMusic 2973DC::MixMusic
2936new (SV *class, DC::RW rwops) 2974new (SV *class, DC::RW rwops)
2937 CODE: 2975 CODE:
2938 RETVAL = Mix_LoadMUS_RW (rwops); 2976 RETVAL = Mix_LoadMUS_RW (rwops);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines