--- deliantra/Deliantra-Client/Client.xs 2006/04/24 06:05:33 1.63 +++ deliantra/Deliantra-Client/Client.xs 2006/04/30 09:21:47 1.70 @@ -44,6 +44,21 @@ #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; \ + } + typedef Mix_Chunk *CFClient__MixChunk; typedef Mix_Music *CFClient__MixMusic; @@ -444,6 +459,7 @@ { HV *hv = newHV (); hv_store (hv, "type", 4, newSViv (ev.type), 0); + switch (ev.type) { case SDL_KEYDOWN: @@ -473,6 +489,7 @@ hv_store (hv, "state", 5, newSViv (ev.button.state), 0); hv_store (hv, "x", 1, newSViv (ev.button.x), 0); hv_store (hv, "y", 1, newSViv (ev.button.y), 0); + break; } XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); @@ -606,6 +623,15 @@ } void +error (char *message) + CODE: +#ifdef _WIN32 + MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); +#else + fprintf (stderr, "ERROR: %s\n", message); +#endif + +void fatal (char *message) CODE: #ifdef _WIN32 @@ -618,11 +644,11 @@ MODULE = CFClient PACKAGE = CFClient::Font CFClient::Font -new_from_file (SV *class, char *path) +new_from_file (SV *class, char *path, int id = 0) CODE: { int count; - FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, 0, 0, &count); + FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); RETVAL = pango_fc_font_description_from_pattern (pattern, 0); FcPatternDestroy (pattern); } @@ -1326,14 +1352,19 @@ const_iv (GL_COLOR_MATERIAL), const_iv (GL_SMOOTH), const_iv (GL_FLAT), + const_iv (GL_DITHER), const_iv (GL_BLEND), + const_iv (GL_SCISSOR_TEST), const_iv (GL_AND), + const_iv (GL_ONE), + const_iv (GL_ZERO), const_iv (GL_SRC_ALPHA), + const_iv (GL_SRC_ALPHA_SATURATE), const_iv (GL_ONE_MINUS_SRC_ALPHA), + const_iv (GL_ONE_MINUS_DST_ALPHA), const_iv (GL_RGB), const_iv (GL_RGBA), const_iv (GL_UNSIGNED_BYTE), - const_iv (GL_ALPHA4), const_iv (GL_ALPHA), const_iv (GL_FLOAT), const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), @@ -1355,13 +1386,14 @@ const_iv (GL_NEAREST_MIPMAP_LINEAR), const_iv (GL_LINEAR_MIPMAP_LINEAR), const_iv (GL_GENERATE_MIPMAP), - const_iv (GL_LINEAR), const_iv (GL_MODULATE), + const_iv (GL_DECAL), const_iv (GL_REPLACE), const_iv (GL_COLOR_BUFFER_BIT), const_iv (GL_PROJECTION), const_iv (GL_MODELVIEW), const_iv (GL_COLOR_LOGIC_OP), + const_iv (GL_SEPARABLE_2D), const_iv (GL_CONVOLUTION_2D), const_iv (GL_CONVOLUTION_BORDER_MODE), const_iv (GL_CONSTANT_BORDER), @@ -1396,6 +1428,8 @@ void glLogicOp (int opcode) +void glColorMask (int red, int green, int blue, int alpha) + void glMatrixMode (int mode) void glPushMatrix () @@ -1404,10 +1438,13 @@ void glLoadIdentity () -void glOrtho (double left, double right, double bottom, double top, double near, double far) +# near and far are due to microsofts buggy c compiler +void glOrtho (double left, double right, double bottom, double top, double near_, double far_) void glViewport (int x, int y, int width, int height) +void glScissor (int x, int y, int width, int height) + void glTranslate (float x, float y, float z = 0.) CODE: glTranslatef (x, y, z); @@ -1427,7 +1464,7 @@ void glColor (float r, float g, float b, float a = 1.0) PROTOTYPE: @ CODE: - glColor4f (r, g, b, a); + glColor4ub (r * 255., g * 255., b * 255., a * 255.); void glVertex (float x, float y, float z = 0.) CODE: @@ -1449,14 +1486,28 @@ void glConvolutionParameter (int target, int pname, float params) CODE: - glConvolutionParameterf (target, pname, params); + GL_CALL (PFNGLCONVOLUTIONPARAMETERFEXTPROC, glConvolutionParameterf, (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)); + +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)); void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, char *data) void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) +void glRasterPos (int x, int y) + CODE: + glRasterPos2i (x, y); + +void glCopyPixels (int x, int y, int width, int height, int type = GL_COLOR) + int glGenTexture () CODE: {