--- deliantra/Deliantra-Client/Client.xs 2007/08/13 14:15:09 1.227 +++ deliantra/Deliantra-Client/Client.xs 2007/12/26 18:09:30 1.240 @@ -205,7 +205,7 @@ typedef uint16_t faceid; typedef struct { - int name; + GLuint name; int w, h; float s, t; uint8_t r, g, b, a; @@ -442,6 +442,17 @@ return n + 1; } +static unsigned int +popcount (unsigned int n) +{ + n -= (n >> 1) & 0x55555555U; + n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U); + n = ((n >> 4) + n) & 0x0f0f0f0fU; + n *= 0x01010101U; + + return n >> 24; +} + /* SDL should provide this, really. */ #define SDLK_MODIFIER_MIN 300 #define SDLK_MODIFIER_MAX 314 @@ -527,6 +538,8 @@ const_iv (SDL_APPMOUSEFOCUS), const_iv (SDL_APPACTIVE), + const_iv (SDLK_FIRST), + const_iv (SDLK_LAST), const_iv (SDLK_KP0), const_iv (SDLK_KP1), const_iv (SDLK_KP2), @@ -608,6 +621,8 @@ const_iv (KMOD_NUM), const_iv (KMOD_CAPS), const_iv (KMOD_MODE), + + const_iv (MIX_DEFAULT_FORMAT), # undef const_iv }; @@ -635,6 +650,10 @@ NV ceil (NV x) +IV minpot (UV n) + +IV popcount (UV n) + void pango_init () CODE: @@ -683,7 +702,7 @@ if (m && m != (SDL_Rect **)-1) while (*m) { - if ((*m)->w >= 640 && (*m)->h >= 480) + if ((*m)->w >= 800 && (*m)->h >= 600) { AV *av = newAV (); av_push (av, newSViv ((*m)->w)); @@ -717,7 +736,7 @@ { av_clear (texture_av); - SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); + SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); #include "glfunc.h" #undef GL_FUNC @@ -813,12 +832,28 @@ } int -Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 1024) +Mix_OpenAudio (int frequency = 44100, int format = MIX_DEFAULT_FORMAT, int channels = 2, int chunksize = 4096) POSTCALL: Mix_HookMusicFinished (music_finished); Mix_ChannelFinished (channel_finished); void +Mix_QuerySpec () + PPCODE: +{ + int freq, channels; + Uint16 format; + + if (Mix_QuerySpec (&freq, &format, &channels)) + { + EXTEND (SP, 3); + PUSHs (sv_2mortal (newSViv (freq))); + PUSHs (sv_2mortal (newSViv (format))); + PUSHs (sv_2mortal (newSViv (channels))); + } +} + +void Mix_CloseAudio () int @@ -960,7 +995,7 @@ CODE: fprintf (stderr, "ERROR: %s\n", message); #ifdef _WIN32 - MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); + MessageBox (0, message, "Deliantra Client Error", MB_OK | MB_ICONERROR); #endif void @@ -968,7 +1003,7 @@ CODE: fprintf (stderr, "FATAL: %s\n", message); #ifdef _WIN32 - MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); + MessageBox (0, message, "Deliantra Client Fatal Error", MB_OK | MB_ICONERROR); #endif _exit (1); @@ -1022,10 +1057,16 @@ PROTOTYPES: DISABLE void -reset_glyph_cache () +glyph_cache_backup () PROTOTYPE: CODE: - tc_clear (); + tc_backup (); + +void +glyph_cache_restore () + PROTOTYPE: + CODE: + tc_restore (); CFPlus::Layout new (SV *class) @@ -1348,8 +1389,6 @@ PROTOTYPES: ENABLE -int minpot (int n) - void pad (SV *data_, int ow, int oh, int nw, int nh) CODE: @@ -2551,6 +2590,12 @@ const_iv (GL_LUMINANCE_ALPHA), const_iv (GL_FLOAT), const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), + const_iv (GL_COMPRESSED_ALPHA_ARB), + const_iv (GL_COMPRESSED_LUMINANCE_ARB), + const_iv (GL_COMPRESSED_LUMINANCE_ALPHA_ARB), + const_iv (GL_COMPRESSED_INTENSITY_ARB), + const_iv (GL_COMPRESSED_RGB_ARB), + const_iv (GL_COMPRESSED_RGBA_ARB), const_iv (GL_COMPILE), const_iv (GL_PROXY_TEXTURE_1D), const_iv (GL_PROXY_TEXTURE_2D), @@ -2599,6 +2644,7 @@ const_iv (GL_LINE_SMOOTH_HINT), const_iv (GL_POLYGON_SMOOTH_HINT), const_iv (GL_GENERATE_MIPMAP_HINT), + const_iv (GL_TEXTURE_COMPRESSION_HINT), const_iv (GL_FASTEST), const_iv (GL_DONT_CARE), const_iv (GL_NICEST), @@ -2616,6 +2662,12 @@ AvREAL_off (texture_av); } +void +disable_GL_EXT_blend_func_separate () + CODE: + gl.BlendFuncSeparate = 0; + gl.BlendFuncSeparateEXT = 0; + char * gl_vendor () CODE: @@ -2746,6 +2798,15 @@ CODE: glRectf (x1, y1, x2, y2); +void glRect_lineloop (float x1, float y1, float x2, float y2) + CODE: + glBegin (GL_LINE_LOOP); + glVertex2f (x1, y1); + glVertex2f (x2, y1); + glVertex2f (x2, y2); + glVertex2f (x1, y2); + glEnd (); + PROTOTYPES: ENABLE void glBegin (int mode) @@ -2856,8 +2917,7 @@ SV *draw_y_sv = GvSV (draw_y_gv); SV *draw_w_sv = GvSV (draw_w_gv); SV *draw_h_sv = GvSV (draw_h_gv); - SV *hover; - double draw_x, draw_y, draw_w, draw_h; + double draw_x, draw_y; if (!SvROK (self)) croak ("CFPlus::Base::draw: %s not a reference", SvPV_nolen (self)); @@ -2895,7 +2955,7 @@ if (svp && SvTRUE (*svp)) { - glColor4f (1*0.2f, 0.8*0.2f, 0.5*0.2f, 0.2f); + glColor4f (1.0f * 0.2f, 0.8f * 0.2f, 0.5f * 0.2f, 0.2f); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBegin (GL_QUADS); @@ -2908,19 +2968,17 @@ } } #if 0 - if ($ENV{CFPLUS_DEBUG} & 1) { - glPushMatrix; - glColor 1, 1, 0, 1; - glTranslate 0.375, 0.375; - glBegin GL_LINE_LOOP; - glVertex 0 , 0; - glVertex $self->{w} - 1, 0; - glVertex $self->{w} - 1, $self->{h} - 1; - glVertex 0 , $self->{h} - 1; - glEnd; - glPopMatrix; - #CFPlus::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; - } + // draw borders, for debugging + glPushMatrix (); + glColor4f (1., 1., 0., 1.); + glTranslatef (.5, .5, 0.); + glBegin (GL_LINE_LOOP); + glVertex2f (0 , 0); + glVertex2f (w - 1, 0); + glVertex2f (w - 1, h - 1); + glVertex2f (0 , h - 1); + glEnd (); + glPopMatrix (); #endif PUSHMARK (SP); XPUSHs (self);