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.8 by root, Sun Apr 9 01:19:15 2006 UTC vs.
Revision 1.12 by root, Mon Apr 10 22:16:33 2006 UTC

6 6
7#include <SDL.h> 7#include <SDL.h>
8#include <SDL_opengl.h> 8#include <SDL_opengl.h>
9 9
10#include <pango/pango.h> 10#include <pango/pango.h>
11#include <pango/pangofc-fontmap.h>
11#include <pango/pangoft2.h> 12#include <pango/pangoft2.h>
13
14#include <sys/types.h>
15#include <sys/socket.h>
16#include <netinet/in.h>
17#include <netinet/tcp.h>
12 18
13static PangoContext *context; 19static PangoContext *context;
14static PangoFontMap *fontmap; 20static PangoFontMap *fontmap;
15 21
16MODULE = Crossfire::Client PACKAGE = Crossfire::Client 22MODULE = Crossfire::Client PACKAGE = Crossfire::Client
17 23
24PROTOTYPES: ENABLE
25
18BOOT: 26BOOT:
19{ 27{
20 fontmap = pango_ft2_font_map_new (); 28 fontmap = pango_ft2_font_map_new ();
21 context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); 29 context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap);
22} 30}
31
32void
33lowdelay (int fd, int val = 1)
34 CODE:
35 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val));
23 36
24char * 37char *
25gl_version () 38gl_version ()
26 CODE: 39 CODE:
27 RETVAL = (char *)glGetString (GL_VERSION); 40 RETVAL = (char *)glGetString (GL_VERSION);
34 RETVAL = (char *)glGetString (GL_EXTENSIONS); 47 RETVAL = (char *)glGetString (GL_EXTENSIONS);
35 OUTPUT: 48 OUTPUT:
36 RETVAL 49 RETVAL
37 50
38void 51void
39add_font (char *file) 52set_font (char *file)
40 CODE: 53 CODE:
41 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
42
43void
44set_font (char *pango_font)
45 CODE:
46{ 54{
55 int count;
56 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count);
57 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */
47 PangoFontDescription *font = pango_font_description_from_string (pango_font); 58 PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0);
59 FcPatternDestroy (pattern);
48 pango_context_set_font_description (context, font); 60 pango_context_set_font_description (context, font);
49} 61}
50 62
51void 63void
52font_render (SV *text_, int height = 10) 64font_render (SV *text_, int height = 10)
88 EXTEND (SP, 3); 100 EXTEND (SP, 3);
89 PUSHs (sv_2mortal (newSViv (w))); 101 PUSHs (sv_2mortal (newSViv (w)));
90 PUSHs (sv_2mortal (newSViv (h))); 102 PUSHs (sv_2mortal (newSViv (h)));
91 PUSHs (sv_2mortal (retval)); 103 PUSHs (sv_2mortal (retval));
92} 104}
105
106MODULE = Crossfire::Client PACKAGE = Crossfire::Client::Texture
107
108void
109draw_quad (SV *self, double x, double y, double w = 0, double h = 0)
110 PROTOTYPE: $$$;$$
111 CODE:
112{
113 HV *hv = (HV *)SvRV (self);
114 double s = SvNV (*hv_fetch (hv, "s", 1, 1));
115 double t = SvNV (*hv_fetch (hv, "t", 1, 1));
116 int name = SvIV (*hv_fetch (hv, "name", 4, 1));
117
118 if (items < 5)
119 {
120 w = SvNV (*hv_fetch (hv, "width", 5, 1));
121 h = SvNV (*hv_fetch (hv, "height", 6, 1));
122 }
123
124 glBindTexture (GL_TEXTURE_2D, name);
125 glBegin (GL_QUADS);
126 glTexCoord2d (0, 0); glVertex2d (x , y );
127 glTexCoord2d (0, t); glVertex2d (x , y + h);
128 glTexCoord2d (s, t); glVertex2d (x + w, y + h);
129 glTexCoord2d (s, 0); glVertex2d (x + w, y );
130 glEnd ();
131}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines