--- deliantra/Deliantra-Client/Client.xs 2006/06/03 23:47:46 1.102 +++ deliantra/Deliantra-Client/Client.xs 2006/06/04 23:05:05 1.103 @@ -50,20 +50,22 @@ #define MIN_FONT_HEIGHT 10 -#define GL_CALL(type,func,args) \ - { \ - static int init_; \ - static type fptr_; \ - \ - if (!init_) \ - { \ - init_ = 1; \ - fptr_ = (type)SDL_GL_GetProcAddress (# func); \ - } \ - \ - if (fptr_) \ - fptr_ args; \ - } +static struct +{ +#define GL_FUNC(ptr,name) ptr name; +#include "glfunc.h" +#undef GL_FUNC +} gl; + +static void gl_BlendFuncSeparate (GLenum sa, GLenum da, GLenum saa, GLenum daa) +{ + if (gl.BlendFuncSeparate) + gl.BlendFuncSeparate (sa, da, saa, daa); + else if (gl.BlendFuncSeparateEXT) + gl.BlendFuncSeparateEXT (sa, da, saa, daa); + else + glBlendFunc (sa, da); +} typedef Mix_Chunk *CFClient__MixChunk; typedef Mix_Music *CFClient__MixMusic; @@ -481,7 +483,13 @@ RETVAL = !!SDL_SetVideoMode ( w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0) ); - SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); + if (RETVAL) + { + SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); +# define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); +# include "glfunc.h" +# undef GL_FUNC + } OUTPUT: RETVAL @@ -712,7 +720,7 @@ new (SV *class, int rgba = 0) CODE: #if _WIN32 - //rgba = 0;//D make stext nicer, breaks TextView + //rgba = 0;//D makes text nicer, breaks TextView #endif New (0, RETVAL, 1, struct cf_layout); @@ -979,7 +987,13 @@ if (ix) { glEnable (GL_BLEND); - glBlendFunc (ix == 1 ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + if (ix == 2) + glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + else + gl_BlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, + GL_ONE_MINUS_DST_ALPHA, GL_ONE); + glEnable (GL_ALPHA_TEST); glAlphaFunc (GL_GREATER, 0.01f); } @@ -1648,6 +1662,10 @@ void glBlendFunc (int sfactor, int dfactor) +void glBlendFuncSeparate (int sa, int da, int saa, int daa) + CODE: + gl_BlendFuncSeparate (sa, da, saa, daa); + void glDepthMask (int flag) void glLogicOp (int opcode) @@ -1690,7 +1708,15 @@ void glColor (float r, float g, float b, float a = 1.0) PROTOTYPE: @ + ALIAS: + glColor_premultiply = 1 CODE: + if (ix) + { + r *= a; + g *= a; + b *= a; + } // microsoft visual "c" rounds instead of truncating... glColor4ub (MIN ((int)(r * 256.f), 255), MIN ((int)(g * 256.f), 255), @@ -1728,17 +1754,18 @@ void glConvolutionParameter (int target, int pname, float params) CODE: - GL_CALL (PFNGLCONVOLUTIONPARAMETERFEXTPROC, glConvolutionParameterf, (target, pname, params)); + if (gl.ConvolutionParameterf) + gl.ConvolutionParameterf (target, pname, params); void glConvolutionFilter2D (int target, int internalformat, int width, int height, int format, int type, char *data) CODE: - GL_CALL (PFNGLCONVOLUTIONFILTER2DEXTPROC, glConvolutionFilter2D, - (target, internalformat, width, height, format, type, data)); + if (gl.ConvolutionFilter2D) + gl.ConvolutionFilter2D (target, internalformat, width, height, format, type, data); void glSeparableFilter2D (int target, int internalformat, int width, int height, int format, int type, char *row, char *column) CODE: - GL_CALL (PFNGLSEPARABLEFILTER2DEXTPROC, glSeparableFilter2D, - (target, internalformat, width, height, format, type, row, column)); + if (gl.SeparableFilter2D) + gl.SeparableFilter2D (target, internalformat, width, height, format, type, row, column); void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data)