… | |
… | |
15 | |
15 | |
16 | #include <sys/types.h> |
16 | #include <sys/types.h> |
17 | #include <sys/socket.h> |
17 | #include <sys/socket.h> |
18 | #include <netinet/in.h> |
18 | #include <netinet/in.h> |
19 | #include <netinet/tcp.h> |
19 | #include <netinet/tcp.h> |
|
|
20 | |
|
|
21 | #include <inttypes.h> |
20 | |
22 | |
21 | static PangoContext *context; |
23 | static PangoContext *context; |
22 | static PangoFontMap *fontmap; |
24 | static PangoFontMap *fontmap; |
23 | |
25 | |
24 | typedef struct cf_layout { |
26 | typedef struct cf_layout { |
… | |
… | |
52 | |
54 | |
53 | *w = (*w + 3) & ~3; |
55 | *w = (*w + 3) & ~3; |
54 | if (!*w) *w = 1; |
56 | if (!*w) *w = 1; |
55 | if (!*h) *h = 1; |
57 | if (!*h) *h = 1; |
56 | } |
58 | } |
|
|
59 | |
|
|
60 | typedef struct { |
|
|
61 | uint16_t face[3]; |
|
|
62 | uint8_t darkness; |
|
|
63 | uint8_t padding; |
|
|
64 | } mapcell; |
|
|
65 | |
|
|
66 | typedef struct { |
|
|
67 | uint32_t cols; |
|
|
68 | mapcell *col; |
|
|
69 | } maprow; |
|
|
70 | |
|
|
71 | typedef struct map { |
|
|
72 | int x, y, w, h; |
|
|
73 | int faces; |
|
|
74 | GLint *face; |
|
|
75 | |
|
|
76 | uint32_t rows; |
|
|
77 | maprow *row; |
|
|
78 | } *CFClient__Map; |
57 | |
79 | |
58 | MODULE = CFClient PACKAGE = CFClient |
80 | MODULE = CFClient PACKAGE = CFClient |
59 | |
81 | |
60 | PROTOTYPES: ENABLE |
82 | PROTOTYPES: ENABLE |
61 | |
83 | |
… | |
… | |
301 | glTexCoord2d (0, t); glVertex2d (x , y + h); |
323 | glTexCoord2d (0, t); glVertex2d (x , y + h); |
302 | glTexCoord2d (s, t); glVertex2d (x + w, y + h); |
324 | glTexCoord2d (s, t); glVertex2d (x + w, y + h); |
303 | glTexCoord2d (s, 0); glVertex2d (x + w, y ); |
325 | glTexCoord2d (s, 0); glVertex2d (x + w, y ); |
304 | glEnd (); |
326 | glEnd (); |
305 | } |
327 | } |
|
|
328 | |
|
|
329 | MODULE = CFClient PACKAGE = CFClient::Map |
|
|
330 | |
|
|
331 | CFClient::Map |
|
|
332 | new (SV *class, int map_width, int map_height) |
|
|
333 | CODE: |
|
|
334 | New (0, RETVAL, 1, struct map); |
|
|
335 | RETVAL->x = 0; |
|
|
336 | RETVAL->y = 0; |
|
|
337 | RETVAL->w = map_width; |
|
|
338 | RETVAL->h = map_height; |
|
|
339 | RETVAL->faces = 0; |
|
|
340 | RETVAL->face = 0; |
|
|
341 | |
|
|
342 | RETVAL->rows = 0; |
|
|
343 | RETVAL->row = 0; |
|
|
344 | OUTPUT: |
|
|
345 | RETVAL |
|
|
346 | |
|
|
347 | void |
|
|
348 | DESTROY (CFClient::Map self) |
|
|
349 | CODE: |
|
|
350 | { |
|
|
351 | int r, c; |
|
|
352 | |
|
|
353 | Safefree (self->face); |
|
|
354 | for (r = 0; r < self->rows; r++) |
|
|
355 | { |
|
|
356 | maprow *row = self->row + r; |
|
|
357 | if (!row) |
|
|
358 | continue; |
|
|
359 | |
|
|
360 | Safefree (row->col); |
|
|
361 | } |
|
|
362 | |
|
|
363 | Safefree (self->row); |
|
|
364 | Safefree (self); |
|
|
365 | } |
|
|
366 | |