--- deliantra/Deliantra-Client/Client.xs 2006/05/15 00:25:14 1.83 +++ deliantra/Deliantra-Client/Client.xs 2006/06/03 23:47:46 1.102 @@ -445,14 +445,15 @@ SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 1); + SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15); + SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute (SDL_GL_ACCUM_RED_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute (SDL_GL_BUFFER_SIZE, 15); - SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 0); SDL_EnableUNICODE (1); SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); @@ -471,6 +472,9 @@ } } +char * +SDL_GetError () + int SDL_SetVideoMode (int w, int h, int fullscreen) CODE: @@ -484,6 +488,9 @@ void SDL_GL_SwapBuffers () +char * +SDL_GetKeyName (int sym) + void SDL_PollEvent () PPCODE: @@ -511,6 +518,8 @@ break; case SDL_MOUSEMOTION: + hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); + hv_store (hv, "state", 5, newSViv (ev.motion.state), 0); hv_store (hv, "x", 1, newSViv (ev.motion.x), 0); hv_store (hv, "y", 1, newSViv (ev.motion.y), 0); @@ -520,6 +529,8 @@ case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: + hv_store (hv, "mod", 3, newSViv (SDL_GetModState ()), 0); + hv_store (hv, "button", 6, newSViv (ev.button.button), 0); hv_store (hv, "state", 5, newSViv (ev.button.state), 0); hv_store (hv, "x", 1, newSViv (ev.button.x), 0); @@ -556,20 +567,6 @@ setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); #endif -char * -gl_version () - CODE: - RETVAL = (char *)glGetString (GL_VERSION); - OUTPUT: - RETVAL - -char * -gl_extensions () - CODE: - RETVAL = (char *)glGetString (GL_EXTENSIONS); - OUTPUT: - RETVAL - void add_font (char *file) CODE: @@ -671,19 +668,17 @@ 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); +#ifdef _WIN32 + MessageBox (0, message, "Crossfire+ Error", MB_OK | MB_ICONERROR); #endif void fatal (char *message) CODE: -#ifdef _WIN32 - MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); -#else fprintf (stderr, "FATAL: %s\n", message); +#ifdef _WIN32 + MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); #endif exit (1); @@ -716,6 +711,9 @@ CFClient::Layout new (SV *class, int rgba = 0) CODE: +#if _WIN32 + //rgba = 0;//D make stext nicer, breaks TextView +#endif New (0, RETVAL, 1, struct cf_layout); RETVAL->pl = pango_layout_new (rgba ? cairo_context : ft2_context); @@ -805,6 +803,31 @@ pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); void +set_indent (CFClient::Layout self, int indent) + CODE: + pango_layout_set_indent (self->pl, indent * PANGO_SCALE); + +void +set_spacing (CFClient::Layout self, int spacing) + CODE: + pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); + +void +set_ellipsise (CFClient::Layout self, int ellipsise) + CODE: + pango_layout_set_ellipsize (self->pl, + ellipsise == 1 ? PANGO_ELLIPSIZE_START + : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE + : ellipsise == 3 ? PANGO_ELLIPSIZE_END + : PANGO_ELLIPSIZE_NONE + ); + +void +set_single_paragraph_mode (CFClient::Layout self, int spm) + CODE: + pango_layout_set_single_paragraph_mode (self->pl, !!spm); + +void size (CFClient::Layout self) PPCODE: { @@ -880,6 +903,18 @@ { uint32_t rgba = *p; rgba = (rgba >> 24) | (rgba << 8); +#if 0 +#ifdef _WIN32 + {//D + uint8_t r = rgba >> 24; + uint8_t g = rgba >> 16; + uint8_t b = rgba >> 8; + uint8_t a = rgba >> 0; + + rgba = (rgba & 0xffffff00) | a; + } +#endif +#endif rgba = SDL_SwapBE32 (rgba); *p++ = rgba; } @@ -934,7 +969,6 @@ float s = SvNV (*hv_fetch (hv, "s", 1, 1)); float t = SvNV (*hv_fetch (hv, "t", 1, 1)); int name = SvIV (*hv_fetch (hv, "name", 4, 1)); - int wrap_mode = SvIV (*hv_fetch (hv, "wrap_mode", 9, 1)); if (items < 5) { @@ -946,16 +980,12 @@ { glEnable (GL_BLEND); glBlendFunc (ix == 1 ? GL_SRC_ALPHA : GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_ALPHA_TEST); + glAlphaFunc (GL_GREATER, 0.01f); } glBindTexture (GL_TEXTURE_2D, name); - if (wrap_mode) - { - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } - glBegin (GL_QUADS); glTexCoord2f (0, 0); glVertex2f (x , y ); glTexCoord2f (0, t); glVertex2f (x , y + h); @@ -964,7 +994,10 @@ glEnd (); if (ix) - glDisable (GL_BLEND); + { + glDisable (GL_ALPHA_TEST); + glDisable (GL_BLEND); + } } MODULE = CFClient PACKAGE = CFClient::Map @@ -1038,17 +1071,34 @@ tex->b = b; tex->a = a; } + + // somewhat hackish, but for textures that require it, it really + // improves the look, and most others don't suffer. + glBindTexture (GL_TEXTURE_2D, name); + //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + // use uglier nearest interpolation because linear suffers + // from transparent color bleeding and ugly wrapping effects. + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } int ox (CFClient::Map self) ALIAS: oy = 1 + x = 2 + y = 3 + w = 4 + h = 5 CODE: switch (ix) { case 0: RETVAL = self->ox; break; case 1: RETVAL = self->oy; break; + case 2: RETVAL = self->x; break; + case 3: RETVAL = self->y; break; + case 4: RETVAL = self->w; break; + case 5: RETVAL = self->h; break; } OUTPUT: RETVAL @@ -1485,7 +1535,12 @@ const_iv (GL_FLAT), const_iv (GL_DITHER), const_iv (GL_BLEND), + const_iv (GL_CULL_FACE), const_iv (GL_SCISSOR_TEST), + const_iv (GL_DEPTH_TEST), + const_iv (GL_ALPHA_TEST), + const_iv (GL_NORMALIZE), + const_iv (GL_RESCALE_NORMAL), const_iv (GL_AND), const_iv (GL_ONE), const_iv (GL_ZERO), @@ -1496,8 +1551,12 @@ const_iv (GL_RGB), const_iv (GL_RGBA), const_iv (GL_UNSIGNED_BYTE), + const_iv (GL_UNSIGNED_SHORT), + const_iv (GL_UNSIGNED_INT), const_iv (GL_ALPHA), + const_iv (GL_INTENSITY), const_iv (GL_LUMINANCE), + const_iv (GL_LUMINANCE_ALPHA), const_iv (GL_FLOAT), const_iv (GL_UNSIGNED_INT_8_8_8_8_REV), const_iv (GL_COMPILE), @@ -1509,8 +1568,9 @@ const_iv (GL_TEXTURE_ENV_MODE), const_iv (GL_TEXTURE_WRAP_S), const_iv (GL_TEXTURE_WRAP_T), - const_iv (GL_CLAMP), const_iv (GL_REPEAT), + const_iv (GL_CLAMP), + const_iv (GL_CLAMP_TO_EDGE), const_iv (GL_NEAREST), const_iv (GL_LINEAR), const_iv (GL_NEAREST_MIPMAP_NEAREST), @@ -1521,6 +1581,7 @@ const_iv (GL_MODULATE), const_iv (GL_DECAL), const_iv (GL_REPLACE), + const_iv (GL_DEPTH_BUFFER_BIT), const_iv (GL_COLOR_BUFFER_BIT), const_iv (GL_PROJECTION), const_iv (GL_MODELVIEW), @@ -1530,10 +1591,18 @@ const_iv (GL_CONVOLUTION_BORDER_MODE), const_iv (GL_CONSTANT_BORDER), const_iv (GL_LINES), - const_iv (GL_QUADS), const_iv (GL_LINE_LOOP), + const_iv (GL_QUADS), + const_iv (GL_QUAD_STRIP), + const_iv (GL_TRIANGLES), + const_iv (GL_TRIANGLE_STRIP), + const_iv (GL_TRIANGLE_FAN), const_iv (GL_PERSPECTIVE_CORRECTION_HINT), const_iv (GL_FASTEST), + const_iv (GL_V2F), + const_iv (GL_V3F), + const_iv (GL_T2F_V3F), + const_iv (GL_T2F_N3F_V3F), # undef const_iv }; @@ -1541,6 +1610,27 @@ newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); } +char * +gl_vendor () + CODE: + RETVAL = (char *)glGetString (GL_VENDOR); + OUTPUT: + RETVAL + +char * +gl_version () + CODE: + RETVAL = (char *)glGetString (GL_VERSION); + OUTPUT: + RETVAL + +char * +gl_extensions () + CODE: + RETVAL = (char *)glGetString (GL_EXTENSIONS); + OUTPUT: + RETVAL + int glGetError () void glClear (int mask) @@ -1558,6 +1648,8 @@ void glBlendFunc (int sfactor, int dfactor) +void glDepthMask (int flag) + void glLogicOp (int opcode) void glColorMask (int red, int green, int blue, int alpha) @@ -1570,7 +1662,10 @@ void glLoadIdentity () -# near and far are due to microsofts buggy c compiler +# near_ and far_ are due to microsofts buggy "c" compiler +void glFrustum (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) @@ -1596,10 +1691,22 @@ void glColor (float r, float g, float b, float a = 1.0) PROTOTYPE: @ CODE: - glColor4ub (MIN ((int)(r * 255.f), 255), - MIN ((int)(g * 255.f), 255), - MIN ((int)(b * 255.f), 255), - MIN ((int)(a * 255.f), 255)); + // microsoft visual "c" rounds instead of truncating... + glColor4ub (MIN ((int)(r * 256.f), 255), + MIN ((int)(g * 256.f), 255), + MIN ((int)(b * 256.f), 255), + MIN ((int)(a * 256.f), 255)); + +void glInterleavedArrays (int format, int stride, char *data) + +void glDrawElements (int mode, int count, int type, char *indices) + +# 1.2 void glDrawRangeElements (int mode, int start, int end + +void glRasterPos (float x, float y, float z = 0.) + CODE: + glRasterPos3f (0, 0, z); + glBitmap (0, 0, 0, 0, x, y, 0); void glVertex (float x, float y, float z = 0.) CODE: @@ -1637,9 +1744,7 @@ 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 glDrawPixels (int width, int height, int format, int type, char *pixels) void glCopyPixels (int x, int y, int width, int height, int type = GL_COLOR) @@ -1676,3 +1781,4 @@ void glCallList (int list) +