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.124 by root, Tue Jul 4 23:23:31 2006 UTC vs.
Revision 1.149 by root, Sat Aug 19 04:03:15 2006 UTC

1#ifdef _WIN32 1#ifdef _WIN32
2# define WIN32_LEAN_AND_MEAN
2# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls 3# define _WIN32_WINNT 0x0500 // needed to get win2000 api calls
3# include <malloc.h> 4# include <malloc.h>
4# include <windows.h> 5# include <windows.h>
5# pragma warning(disable:4244) 6# pragma warning(disable:4244)
6#endif 7#endif
7 8
8#include "EXTERN.h" 9#include "EXTERN.h"
9#include "perl.h" 10#include "perl.h"
10#include "XSUB.h" 11#include "XSUB.h"
12
13#ifdef _WIN32
14# undef pipe
15#endif
11 16
12#include <math.h> 17#include <math.h>
13#include <string.h> 18#include <string.h>
14#include <stdio.h> 19#include <stdio.h>
15#include <stdlib.h> 20#include <stdlib.h>
40 typedef signed char int8_t; 45 typedef signed char int8_t;
41 typedef signed short int16_t; 46 typedef signed short int16_t;
42 typedef signed int int32_t; 47 typedef signed int int32_t;
43#endif 48#endif
44 49
45#include "glext.h"
46
47#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */ 50#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, objetc replacement character */
48 51
49#define FOW_DARKNESS 32 52#define FOW_DARKNESS 32
50 53
51#define MAP_EXTEND_X 32 54#define MAP_EXTEND_X 32
52#define MAP_EXTEND_Y 512 55#define MAP_EXTEND_Y 512
53 56
54#define MIN_FONT_HEIGHT 10 57#define MIN_FONT_HEIGHT 10
55 58
56#if 1 59#if 0
57# define PARACHUTE SDL_INIT_NOPARACHUTE 60# define PARACHUTE SDL_INIT_NOPARACHUTE
58#else 61#else
59# define PARACHUTE 0 62# define PARACHUTE 0
60#endif 63#endif
61 64
80 83
81#include "pango-font.c" 84#include "pango-font.c"
82#include "pango-fontmap.c" 85#include "pango-fontmap.c"
83#include "pango-render.c" 86#include "pango-render.c"
84 87
85typedef Mix_Chunk *CFClient__MixChunk; 88typedef Mix_Chunk *CFPlus__MixChunk;
86typedef Mix_Music *CFClient__MixMusic; 89typedef Mix_Music *CFPlus__MixMusic;
87 90
88typedef PangoFontDescription *CFClient__Font; 91typedef PangoFontDescription *CFPlus__Font;
89 92
90static int 93static int
91shape_attr_p (PangoLayoutRun *run) 94shape_attr_p (PangoLayoutRun *run)
92{ 95{
93 GSList *attrs = run->item->analysis.extra_attrs; 96 GSList *attrs = run->item->analysis.extra_attrs;
107 110
108typedef struct cf_layout { 111typedef struct cf_layout {
109 PangoLayout *pl; 112 PangoLayout *pl;
110 float r, g, b, a; // default color for rgba mode 113 float r, g, b, a; // default color for rgba mode
111 int base_height; 114 int base_height;
112 CFClient__Font font; 115 CFPlus__Font font;
113} *CFClient__Layout; 116} *CFPlus__Layout;
114 117
115static CFClient__Font default_font; 118static CFPlus__Font default_font;
116static PangoContext *opengl_context; 119static PangoContext *opengl_context;
117static PangoFontMap *opengl_fontmap; 120static PangoFontMap *opengl_fontmap;
118 121
119static void 122static void
120substitute_func (FcPattern *pattern, gpointer data) 123substitute_func (FcPattern *pattern, gpointer data)
121{ 124{
122 FcPatternAddBool (pattern, FC_HINTING, 1); 125 FcPatternAddBool (pattern, FC_HINTING, 1);
123#ifdef FC_HINT_STYLE 126#ifdef FC_HINT_STYLE
124 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL); 127 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL);
125#endif 128#endif
126#ifdef _WIN32
127 FcPatternAddBool (pattern, FC_AUTOHINT, 1);
128#else
129 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 129 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
130#endif
131} 130}
132 131
133static void 132static void
134layout_update_font (CFClient__Layout self) 133layout_update_font (CFPlus__Layout self)
135{ 134{
136 /* use a random scale factor to account for unknown descenders, 0.8 works 135 /* use a random scale factor to account for unknown descenders, 0.8 works
137 * reasonably well with bitstream vera 136 * reasonably well with bitstream vera
138 */ 137 */
139 PangoFontDescription *font = self->font ? self->font : default_font; 138 PangoFontDescription *font = self->font ? self->font : default_font;
143 142
144 pango_layout_set_font_description (self->pl, font); 143 pango_layout_set_font_description (self->pl, font);
145} 144}
146 145
147static void 146static void
148layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h)
149{ 148{
149 PangoRectangle rect;
150
151 // get_pixel_* wrongly rounds down
150 pango_layout_get_pixel_size (self->pl, w, h); 152 pango_layout_get_extents (self->pl, 0, &rect);
151 153
152 if (!*w) *w = 1; 154 rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE;
153 if (!*h) *h = 1; 155 rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE;
154 156
155 *w = (*w + 3) & ~3; 157 if (!rect.width) rect.width = 1;
158 if (!rect.height) rect.height = 1;
159
160 *w = rect.width;
161 *h = rect.height;
156} 162}
157 163
158typedef uint16_t mapface; 164typedef uint16_t mapface;
159 165
160typedef struct { 166typedef struct {
163 float s, t; 169 float s, t;
164 uint8_t r, g, b, a; 170 uint8_t r, g, b, a;
165} maptex; 171} maptex;
166 172
167typedef struct { 173typedef struct {
168 int16_t darkness; 174 uint16_t darkness;
169 mapface face[3]; 175 mapface face[3];
176 uint8_t stat_width, stat_hp;
170} mapcell; 177} mapcell;
171 178
172typedef struct { 179typedef struct {
173 int32_t c0, c1; 180 int32_t c0, c1;
174 mapcell *col; 181 mapcell *col;
183 int texs; 190 int texs;
184 maptex *tex; 191 maptex *tex;
185 192
186 int32_t rows; 193 int32_t rows;
187 maprow *row; 194 maprow *row;
188} *CFClient__Map; 195} *CFPlus__Map;
189 196
190static char * 197static char *
191prepend (char *ptr, int sze, int inc) 198prepend (char *ptr, int sze, int inc)
192{ 199{
193 char *p; 200 char *p;
211 218
212#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 219#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
213#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 220#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
214 221
215static maprow * 222static maprow *
216map_get_row (CFClient__Map self, int y) 223map_get_row (CFPlus__Map self, int y)
217{ 224{
218 if (0 > y) 225 if (0 > y)
219 { 226 {
220 int extend = - y + MAP_EXTEND_Y; 227 int extend = - y + MAP_EXTEND_Y;
221 Prepend (maprow, self->row, self->rows, extend); 228 Prepend (maprow, self->row, self->rows, extend);
259 266
260 return row->col + (x - row->c0); 267 return row->col + (x - row->c0);
261} 268}
262 269
263static mapcell * 270static mapcell *
264map_get_cell (CFClient__Map self, int x, int y) 271map_get_cell (CFPlus__Map self, int x, int y)
265{ 272{
266 return row_get_cell (map_get_row (self, y), x); 273 return row_get_cell (map_get_row (self, y), x);
267} 274}
268 275
269static void 276static void
270map_clear (CFClient__Map self) 277map_clear (CFPlus__Map self)
271{ 278{
272 int r; 279 int r;
273 280
274 for (r = 0; r < self->rows; r++) 281 for (r = 0; r < self->rows; r++)
275 Safefree (self->row[r].col); 282 Safefree (self->row[r].col);
283 self->row = 0; 290 self->row = 0;
284 self->rows = 0; 291 self->rows = 0;
285} 292}
286 293
287static void 294static void
288map_blank (CFClient__Map self, int x0, int y0, int w, int h) 295map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
289{ 296{
290 int x, y; 297 int x, y;
291 maprow *row; 298 maprow *row;
299 mapcell *cell;
292 300
293 for (y = y0; y < y0 + h; y++) 301 for (y = y0; y < y0 + h; y++)
294 if (y >= 0) 302 if (y >= 0)
295 { 303 {
296 if (y >= self->rows) 304 if (y >= self->rows)
302 if (x >= row->c0) 310 if (x >= row->c0)
303 { 311 {
304 if (x >= row->c1) 312 if (x >= row->c1)
305 break; 313 break;
306 314
307 row->col[x - row->c0].darkness = -1; 315 cell = row->col + x - row->c0;
316
317 cell->darkness = 0;
318 cell->stat_hp = 0;
308 } 319 }
309 } 320 }
310} 321}
311 322
312static void 323static void
350 n |= n >> 16; 361 n |= n >> 16;
351 362
352 return n + 1; 363 return n + 1;
353} 364}
354 365
355MODULE = CFClient PACKAGE = CFClient 366MODULE = CFPlus PACKAGE = CFPlus
356 367
357PROTOTYPES: ENABLE 368PROTOTYPES: ENABLE
358 369
359BOOT: 370BOOT:
360{ 371{
361 HV *stash = gv_stashpv ("CFClient", 1); 372 HV *stash = gv_stashpv ("CFPlus", 1);
362 static const struct { 373 static const struct {
363 const char *name; 374 const char *name;
364 IV iv; 375 IV iv;
365 } *civ, const_iv[] = { 376 } *civ, const_iv[] = {
366# define const_iv(name) { # name, (IV)name } 377# define const_iv(name) { # name, (IV)name }
467 478
468 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 479 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
469 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 480 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
470} 481}
471 482
483int
484in_destruct ()
485 CODE:
486 RETVAL = PL_main_cv == Nullcv;
487 OUTPUT:
488 RETVAL
489
472NV floor (NV x) 490NV floor (NV x)
473 491
474NV ceil (NV x) 492NV ceil (NV x)
475 493
476void 494void
506 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 524 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
507 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 525 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
508 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 526 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
509 527
510 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 528 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
529#if SDL_VERSION_ATLEAST(1,2,10)
530 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
531 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
532#endif
511 533
512 SDL_EnableUNICODE (1); 534 SDL_EnableUNICODE (1);
513 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 535 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
514 536
515 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 537 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
602 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0); 624 hv_store (hv, "data1", 5, newSViv ((IV)ev.user.data1), 0);
603 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0); 625 hv_store (hv, "data2", 5, newSViv ((IV)ev.user.data2), 0);
604 break; 626 break;
605 } 627 }
606 628
607 XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); 629 XPUSHs (sv_2mortal (sv_bless (newRV_noinc ((SV *)hv), gv_stashpv ("CFPlus::UI::Event", 1))));
608 } 630 }
609} 631}
610 632
611int 633int
612Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048) 634Mix_OpenAudio (int frequency = 48000, int format = MIX_DEFAULT_FORMAT, int channels = 1, int chunksize = 2048)
628#endif 650#endif
629 651
630void 652void
631add_font (char *file) 653add_font (char *file)
632 CODE: 654 CODE:
633 FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ 655 FcConfigAppFontAddFile (0, (const FcChar8 *)file);
634 656
635void 657void
636load_image_inline (SV *image_) 658load_image_inline (SV *image_)
637 ALIAS: 659 ALIAS:
638 load_image_file = 1 660 load_image_file = 1
680 702
681 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); 703 surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE);
682 704
683 assert (surface2->pitch == surface2->w * 4); 705 assert (surface2->pitch == surface2->w * 4);
684 706
707 SDL_LockSurface (surface2);
685 EXTEND (SP, 5); 708 EXTEND (SP, 6);
686 PUSHs (sv_2mortal (newSViv (surface2->w))); 709 PUSHs (sv_2mortal (newSViv (surface2->w)));
687 PUSHs (sv_2mortal (newSViv (surface2->h))); 710 PUSHs (sv_2mortal (newSViv (surface2->h)));
688 SDL_LockSurface (surface2);
689 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); 711 PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch)));
690 SDL_UnlockSurface (surface2);
691 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); 712 PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB)));
692 PUSHs (sv_2mortal (newSViv (GL_RGBA))); 713 PUSHs (sv_2mortal (newSViv (GL_RGBA)));
693 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); 714 PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE)));
715 SDL_UnlockSurface (surface2);
694 716
695 SDL_FreeSurface (surface); 717 SDL_FreeSurface (surface);
696 SDL_FreeSurface (surface2); 718 SDL_FreeSurface (surface2);
697} 719}
698 720
741void 763void
742_exit (int retval) 764_exit (int retval)
743 CODE: 765 CODE:
744 _exit (retval); 766 _exit (retval);
745 767
746MODULE = CFClient PACKAGE = CFClient::Font 768MODULE = CFPlus PACKAGE = CFPlus::Font
747 769
748CFClient::Font 770CFPlus::Font
749new_from_file (SV *class, char *path, int id = 0) 771new_from_file (SV *class, char *path, int id = 0)
750 CODE: 772 CODE:
751{ 773{
752 int count; 774 int count;
753 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count); 775 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)path, id, 0, &count);
756} 778}
757 OUTPUT: 779 OUTPUT:
758 RETVAL 780 RETVAL
759 781
760void 782void
761DESTROY (CFClient::Font self) 783DESTROY (CFPlus::Font self)
762 CODE: 784 CODE:
763 pango_font_description_free (self); 785 pango_font_description_free (self);
764 786
765void 787void
766make_default (CFClient::Font self) 788make_default (CFPlus::Font self)
767 CODE: 789 CODE:
768 default_font = self; 790 default_font = self;
769 791
770MODULE = CFClient PACKAGE = CFClient::Layout 792MODULE = CFPlus PACKAGE = CFPlus::Layout
771 793
772void 794void
773clear_font_cache () 795reset_glyph_cache ()
774 CODE: 796 CODE:
775 pango_fc_font_map_cache_clear ((PangoFcFontMap *)opengl_fontmap);
776 tc_clear (); 797 tc_clear ();
777 798
778CFClient::Layout 799CFPlus::Layout
779new (SV *class, int type = 0) 800new (SV *class)
780 CODE: 801 CODE:
781 New (0, RETVAL, 1, struct cf_layout); 802 New (0, RETVAL, 1, struct cf_layout);
782 803
783 RETVAL->pl = pango_layout_new (opengl_context); 804 RETVAL->pl = pango_layout_new (opengl_context);
784 RETVAL->r = 1.; 805 RETVAL->r = 1.;
792 layout_update_font (RETVAL); 813 layout_update_font (RETVAL);
793 OUTPUT: 814 OUTPUT:
794 RETVAL 815 RETVAL
795 816
796void 817void
797DESTROY (CFClient::Layout self) 818DESTROY (CFPlus::Layout self)
798 CODE: 819 CODE:
799 g_object_unref (self->pl); 820 g_object_unref (self->pl);
800 Safefree (self); 821 Safefree (self);
801 822
802void 823void
803set_text (CFClient::Layout self, SV *text_) 824set_text (CFPlus::Layout self, SV *text_)
804 CODE: 825 CODE:
805{ 826{
806 STRLEN textlen; 827 STRLEN textlen;
807 char *text = SvPVutf8 (text_, textlen); 828 char *text = SvPVutf8 (text_, textlen);
808 829
809 pango_layout_set_text (self->pl, text, textlen); 830 pango_layout_set_text (self->pl, text, textlen);
810} 831}
811 832
812void 833void
813set_markup (CFClient::Layout self, SV *text_) 834set_markup (CFPlus::Layout self, SV *text_)
814 CODE: 835 CODE:
815{ 836{
816 STRLEN textlen; 837 STRLEN textlen;
817 char *text = SvPVutf8 (text_, textlen); 838 char *text = SvPVutf8 (text_, textlen);
818 839
819 pango_layout_set_markup (self->pl, text, textlen); 840 pango_layout_set_markup (self->pl, text, textlen);
820} 841}
821 842
822void 843void
823set_shapes (CFClient::Layout self, ...) 844set_shapes (CFPlus::Layout self, ...)
824 CODE: 845 CODE:
825{ 846{
826 PangoAttrList *attrs = 0; 847 PangoAttrList *attrs = 0;
827 const char *text = pango_layout_get_text (self->pl); 848 const char *text = pango_layout_get_text (self->pl);
828 const char *pos = text; 849 const char *pos = text;
863 if (attrs) 884 if (attrs)
864 pango_layout_set_attributes (self->pl, attrs); 885 pango_layout_set_attributes (self->pl, attrs);
865} 886}
866 887
867void 888void
868get_shapes (CFClient::Layout self) 889get_shapes (CFPlus::Layout self)
869 PPCODE: 890 PPCODE:
870{ 891{
871 PangoLayoutIter *iter = pango_layout_get_iter (self->pl); 892 PangoLayoutIter *iter = pango_layout_get_iter (self->pl);
872 893
873 do 894 do
877 if (run && shape_attr_p (run)) 898 if (run && shape_attr_p (run))
878 { 899 {
879 PangoRectangle extents; 900 PangoRectangle extents;
880 pango_layout_iter_get_run_extents (iter, 0, &extents); 901 pango_layout_iter_get_run_extents (iter, 0, &extents);
881 902
903 EXTEND (SP, 2);
882 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); 904 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x))));
883 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); 905 PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y))));
884 } 906 }
885 } 907 }
886 while (pango_layout_iter_next_run (iter)); 908 while (pango_layout_iter_next_run (iter));
887 909
888 pango_layout_iter_free (iter); 910 pango_layout_iter_free (iter);
889} 911}
890 912
891int 913int
892has_wrapped (CFClient::Layout self) 914has_wrapped (CFPlus::Layout self)
893 CODE: 915 CODE:
894{ 916{
895 int lines = 1; 917 int lines = 1;
896 const char *text = pango_layout_get_text (self->pl); 918 const char *text = pango_layout_get_text (self->pl);
897 919
902} 924}
903 OUTPUT: 925 OUTPUT:
904 RETVAL 926 RETVAL
905 927
906SV * 928SV *
907get_text (CFClient::Layout self) 929get_text (CFPlus::Layout self)
908 CODE: 930 CODE:
909 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 931 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
910 sv_utf8_decode (RETVAL); 932 sv_utf8_decode (RETVAL);
911 OUTPUT: 933 OUTPUT:
912 RETVAL 934 RETVAL
913 935
914void 936void
915set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 937set_foreground (CFPlus::Layout self, float r, float g, float b, float a = 1.)
916 CODE: 938 CODE:
917 self->r = r; 939 self->r = r;
918 self->g = g; 940 self->g = g;
919 self->b = b; 941 self->b = b;
920 self->a = a; 942 self->a = a;
921 943
922void 944void
923set_font (CFClient::Layout self, CFClient::Font font = 0) 945set_font (CFPlus::Layout self, CFPlus::Font font = 0)
924 CODE: 946 CODE:
925 if (self->font != font) 947 if (self->font != font)
926 { 948 {
927 self->font = font; 949 self->font = font;
928 layout_update_font (self); 950 layout_update_font (self);
929 } 951 }
930 952
931void 953void
932set_height (CFClient::Layout self, int base_height) 954set_height (CFPlus::Layout self, int base_height)
933 CODE: 955 CODE:
934 if (self->base_height != base_height) 956 if (self->base_height != base_height)
935 { 957 {
936 self->base_height = base_height; 958 self->base_height = base_height;
937 layout_update_font (self); 959 layout_update_font (self);
938 } 960 }
939 961
940void 962void
941set_width (CFClient::Layout self, int max_width = -1) 963set_width (CFPlus::Layout self, int max_width = -1)
942 CODE: 964 CODE:
943 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); 965 pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE);
944 966
945void 967void
946set_indent (CFClient::Layout self, int indent) 968set_indent (CFPlus::Layout self, int indent)
947 CODE: 969 CODE:
948 pango_layout_set_indent (self->pl, indent * PANGO_SCALE); 970 pango_layout_set_indent (self->pl, indent * PANGO_SCALE);
949 971
950void 972void
951set_spacing (CFClient::Layout self, int spacing) 973set_spacing (CFPlus::Layout self, int spacing)
952 CODE: 974 CODE:
953 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); 975 pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE);
954 976
955void 977void
956set_ellipsise (CFClient::Layout self, int ellipsise) 978set_ellipsise (CFPlus::Layout self, int ellipsise)
957 CODE: 979 CODE:
958 pango_layout_set_ellipsize (self->pl, 980 pango_layout_set_ellipsize (self->pl,
959 ellipsise == 1 ? PANGO_ELLIPSIZE_START 981 ellipsise == 1 ? PANGO_ELLIPSIZE_START
960 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE 982 : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE
961 : ellipsise == 3 ? PANGO_ELLIPSIZE_END 983 : ellipsise == 3 ? PANGO_ELLIPSIZE_END
962 : PANGO_ELLIPSIZE_NONE 984 : PANGO_ELLIPSIZE_NONE
963 ); 985 );
964 986
965void 987void
966set_single_paragraph_mode (CFClient::Layout self, int spm) 988set_single_paragraph_mode (CFPlus::Layout self, int spm)
967 CODE: 989 CODE:
968 pango_layout_set_single_paragraph_mode (self->pl, !!spm); 990 pango_layout_set_single_paragraph_mode (self->pl, !!spm);
969 991
970void 992void
971size (CFClient::Layout self) 993size (CFPlus::Layout self)
972 PPCODE: 994 PPCODE:
973{ 995{
974 int w, h; 996 int w, h;
975 997
976 layout_get_pixel_size (self, &w, &h); 998 layout_get_pixel_size (self, &w, &h);
979 PUSHs (sv_2mortal (newSViv (w))); 1001 PUSHs (sv_2mortal (newSViv (w)));
980 PUSHs (sv_2mortal (newSViv (h))); 1002 PUSHs (sv_2mortal (newSViv (h)));
981} 1003}
982 1004
983int 1005int
984descent (CFClient::Layout self) 1006descent (CFPlus::Layout self)
985 CODE: 1007 CODE:
986{ 1008{
987 PangoRectangle rect; 1009 PangoRectangle rect;
988 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0); 1010 PangoLayoutLine *line = pango_layout_get_line (self->pl, 0);
989 pango_layout_line_get_pixel_extents (line, 0, &rect); 1011 pango_layout_line_get_pixel_extents (line, 0, &rect);
991} 1013}
992 OUTPUT: 1014 OUTPUT:
993 RETVAL 1015 RETVAL
994 1016
995int 1017int
996xy_to_index (CFClient::Layout self, int x, int y) 1018xy_to_index (CFPlus::Layout self, int x, int y)
997 CODE: 1019 CODE:
998{ 1020{
999 int index, trailing; 1021 int index, trailing;
1000 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); 1022 pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing);
1001 RETVAL = index; 1023 RETVAL = index;
1002} 1024}
1003 OUTPUT: 1025 OUTPUT:
1004 RETVAL 1026 RETVAL
1005 1027
1006void 1028void
1007cursor_pos (CFClient::Layout self, int index) 1029cursor_pos (CFPlus::Layout self, int index)
1008 PPCODE: 1030 PPCODE:
1009{ 1031{
1010 PangoRectangle strong_pos; 1032 PangoRectangle strong_pos;
1011 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); 1033 pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0);
1012 1034
1015 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1037 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1016 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1038 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1017} 1039}
1018 1040
1019void 1041void
1020render (CFClient::Layout self, float x, float y) 1042render (CFPlus::Layout self, float x, float y, int flags = 0)
1021 PPCODE: 1043 PPCODE:
1022 pango_opengl_render_layout_subpixel ( 1044 pango_opengl_render_layout_subpixel (
1023 self->pl, 1045 self->pl,
1024 x * PANGO_SCALE, y * PANGO_SCALE, 1046 x * PANGO_SCALE, y * PANGO_SCALE,
1025 self->r, self->g, self->b, self->a 1047 self->r, self->g, self->b, self->a,
1048 flags
1026 ); 1049 );
1027 1050
1028MODULE = CFClient PACKAGE = CFClient::Texture 1051MODULE = CFPlus PACKAGE = CFPlus::Texture
1029 1052
1030void 1053void
1031pad2pot (SV *data_, SV *w_, SV *h_) 1054pad2pot (SV *data_, SV *w_, SV *h_)
1032 CODE: 1055 CODE:
1033{ 1056{
1111 glDisable (GL_ALPHA_TEST); 1134 glDisable (GL_ALPHA_TEST);
1112 glDisable (GL_BLEND); 1135 glDisable (GL_BLEND);
1113 } 1136 }
1114} 1137}
1115 1138
1116MODULE = CFClient PACKAGE = CFClient::Map 1139MODULE = CFPlus PACKAGE = CFPlus::Map
1117 1140
1118CFClient::Map 1141CFPlus::Map
1119new (SV *class, int map_width, int map_height) 1142new (SV *class, int map_width, int map_height)
1120 CODE: 1143 CODE:
1121 New (0, RETVAL, 1, struct map); 1144 New (0, RETVAL, 1, struct map);
1122 RETVAL->x = 0; 1145 RETVAL->x = 0;
1123 RETVAL->y = 0; 1146 RETVAL->y = 0;
1133 RETVAL->row = 0; 1156 RETVAL->row = 0;
1134 OUTPUT: 1157 OUTPUT:
1135 RETVAL 1158 RETVAL
1136 1159
1137void 1160void
1138DESTROY (CFClient::Map self) 1161DESTROY (CFPlus::Map self)
1139 CODE: 1162 CODE:
1140{ 1163{
1141 map_clear (self); 1164 map_clear (self);
1142 Safefree (self->face); 1165 Safefree (self->face);
1143 Safefree (self->tex); 1166 Safefree (self->tex);
1144 Safefree (self); 1167 Safefree (self);
1145} 1168}
1146 1169
1147void 1170void
1148clear (CFClient::Map self) 1171clear (CFPlus::Map self)
1149 CODE: 1172 CODE:
1150 map_clear (self); 1173 map_clear (self);
1151 1174
1152void 1175void
1153set_face (CFClient::Map self, int face, int texid) 1176set_face (CFPlus::Map self, int face, int texid)
1154 CODE: 1177 CODE:
1155{ 1178{
1156 while (self->faces <= face) 1179 while (self->faces <= face)
1157 { 1180 {
1158 Append (mapface, self->face, self->faces, self->faces); 1181 Append (mapface, self->face, self->faces, self->faces);
1161 1184
1162 self->face [face] = texid; 1185 self->face [face] = texid;
1163} 1186}
1164 1187
1165void 1188void
1166set_texture (CFClient::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a) 1189set_texture (CFPlus::Map self, int texid, int name, int w, int h, float s, float t, int r, int g, int b, int a)
1167 CODE: 1190 CODE:
1168{ 1191{
1169 while (self->texs <= texid) 1192 while (self->texs <= texid)
1170 { 1193 {
1171 Append (maptex, self->tex, self->texs, self->texs); 1194 Append (maptex, self->tex, self->texs, self->texs);
1195 // from transparent color bleeding and ugly wrapping effects. 1218 // from transparent color bleeding and ugly wrapping effects.
1196 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1219 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1197} 1220}
1198 1221
1199int 1222int
1200ox (CFClient::Map self) 1223ox (CFPlus::Map self)
1201 ALIAS: 1224 ALIAS:
1202 oy = 1 1225 oy = 1
1203 x = 2 1226 x = 2
1204 y = 3 1227 y = 3
1205 w = 4 1228 w = 4
1216 } 1239 }
1217 OUTPUT: 1240 OUTPUT:
1218 RETVAL 1241 RETVAL
1219 1242
1220void 1243void
1221scroll (CFClient::Map self, int dx, int dy) 1244scroll (CFPlus::Map self, int dx, int dy)
1222 CODE: 1245 CODE:
1223{ 1246{
1224 if (dx > 0) 1247 if (dx > 0)
1225 map_blank (self, self->x, self->y, dx - 1, self->h); 1248 map_blank (self, self->x, self->y, dx - 1, self->h);
1226 else if (dx < 0) 1249 else if (dx < 0)
1242 self->y += MAP_EXTEND_Y; 1265 self->y += MAP_EXTEND_Y;
1243 } 1266 }
1244} 1267}
1245 1268
1246void 1269void
1247map1a_update (CFClient::Map self, SV *data_) 1270map1a_update (CFPlus::Map self, SV *data_, int extmap)
1248 CODE: 1271 CODE:
1249{ 1272{
1250 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1273 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1251 uint8_t *data_end = (uint8_t *)SvEND (data_); 1274 uint8_t *data_end = (uint8_t *)SvEND (data_);
1252 mapcell *cell; 1275 mapcell *cell;
1261 1284
1262 cell = map_get_cell (self, x, y); 1285 cell = map_get_cell (self, x, y);
1263 1286
1264 if (flags & 15) 1287 if (flags & 15)
1265 { 1288 {
1266 if (cell->darkness < 0) 1289 if (!cell->darkness)
1267 { 1290 {
1268 cell->darkness = 0; 1291 cell->darkness = 256;
1269 cell->face [0] = 0; 1292 cell->face [0] = 0;
1270 cell->face [1] = 0; 1293 cell->face [1] = 0;
1271 cell->face [2] = 0; 1294 cell->face [2] = 0;
1272 } 1295 }
1273 1296
1274 cell->darkness = flags & 8 ? *data++ : 255;
1275
1276 //TODO: don't trust server data to be in-range(!) 1297 //TODO: don't trust server data to be in-range(!)
1298
1299 if (flags & 8)
1300 {
1301 if (extmap)
1302 {
1303 uint8_t ext, cmd;
1304
1305 do
1306 {
1307 ext = *data++;
1308 cmd = ext & 0x3f;
1309
1310 if (cmd < 4)
1311 cell->darkness = 255 - ext * 64 + 1;
1312 else if (cmd == 5) // health
1313 {
1314 cell->stat_width = 1;
1315 cell->stat_hp = *data++;
1316 }
1317 else if (cmd == 6) // monster width
1318 cell->stat_width = *data++ + 1;
1319 else if (ext & 0x40) // unknown, multibyte => skip
1320 data += *data + 1;
1321 else
1322 data++;
1323 }
1324 while (ext & 0x80);
1325 }
1326 else
1327 cell->darkness = *data++ + 1;
1328 }
1277 1329
1278 if (flags & 4) 1330 if (flags & 4)
1279 { 1331 {
1280 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; 1332 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2;
1281 } 1333 }
1289 { 1341 {
1290 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1342 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1291 } 1343 }
1292 } 1344 }
1293 else 1345 else
1346 {
1294 cell->darkness = -1; 1347 cell->darkness = 0;
1348 cell->stat_hp = 0;
1349 }
1295 } 1350 }
1296} 1351}
1297 1352
1298SV * 1353SV *
1299mapmap (CFClient::Map self, int x0, int y0, int w, int h) 1354mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1300 CODE: 1355 CODE:
1301{ 1356{
1302 int x1, x; 1357 int x1, x;
1303 int y1, y; 1358 int y1, y;
1304 int z; 1359 int z;
1354} 1409}
1355 OUTPUT: 1410 OUTPUT:
1356 RETVAL 1411 RETVAL
1357 1412
1358void 1413void
1359draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1414draw (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1360 CODE: 1415 CODE:
1361{ 1416{
1362 int vx, vy; 1417 int vx, vy;
1363 int x, y, z; 1418 int x, y, z;
1364 int last_name; 1419 int last_name;
1399 { 1454 {
1400 mapcell *cell = row->col + (x + vx - row->c0); 1455 mapcell *cell = row->col + (x + vx - row->c0);
1401 1456
1402 face = cell->face [z]; 1457 face = cell->face [z];
1403 1458
1404 if (face) 1459 if (face && face < self->texs)
1405 { 1460 {
1406 maptex tex = self->tex [face]; 1461 maptex tex = self->tex [face];
1407 1462
1408 int px = (x + 1) * 32 - tex.w; 1463 int px = (x + 1) * 32 - tex.w;
1409 int py = (y + 1) * 32 - tex.h; 1464 int py = (y + 1) * 32 - tex.h;
1425 } 1480 }
1426 1481
1427 glEnd (); 1482 glEnd ();
1428 1483
1429 glDisable (GL_TEXTURE_2D); 1484 glDisable (GL_TEXTURE_2D);
1485
1486 // top layer: overlays such as the health bar
1487 for (y = 0; y < sh; y++)
1488 if (0 <= y + vy && y + vy < self->rows)
1489 {
1490 maprow *row = self->row + (y + vy);
1491
1492 for (x = 0; x < sw; x++)
1493 if (row->c0 <= x + vx && x + vx < row->c1)
1494 {
1495 mapcell *cell = row->col + (x + vx - row->c0);
1496
1497 int px = x * 32;
1498 int py = y * 32;
1499
1500 if (cell->stat_hp)
1501 {
1502 int width = cell->stat_width * 32;
1503 int thick = sh / 28 + 1 + cell->stat_width;
1504
1505 glColor4ub (0, 0, 0, 223);
1506 glRectf (px + 1, py,
1507 px + width - 1, py + thick + 2);
1508
1509 glColor4ub (cell->stat_hp, 255 - cell->stat_hp, 0, 223);
1510 glRectf (px + 2,
1511 py + 1,
1512 px + width - 2 - cell->stat_hp * (width - 4) / 255, py + thick + 1);
1513 }
1514 }
1515 }
1516
1430 glDisable (GL_BLEND); 1517 glDisable (GL_BLEND);
1431} 1518}
1432 1519
1433void 1520void
1434draw_magicmap (CFClient::Map self, int dx, int dy, int w, int h, unsigned char *data) 1521draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1435 CODE: 1522 CODE:
1436{ 1523{
1437 static float color[16][3] = { 1524 static float color[16][3] = {
1438 { 0.00F, 0.00F, 0.00F }, 1525 { 0.00F, 0.00F, 0.00F },
1439 { 1.00F, 1.00F, 1.00F }, 1526 { 1.00F, 1.00F, 1.00F },
1489 glDisable (GL_BLEND); 1576 glDisable (GL_BLEND);
1490 glDisable (GL_TEXTURE_2D); 1577 glDisable (GL_TEXTURE_2D);
1491} 1578}
1492 1579
1493void 1580void
1494fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) 1581fow_texture (CFPlus::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh)
1495 PPCODE: 1582 PPCODE:
1496{ 1583{
1497 int vx, vy; 1584 int vx, vy;
1498 int x, y; 1585 int x, y;
1499 int sw4 = (sw + 3) & ~3; 1586 int sw4 = (sw + 3) & ~3;
1515 for (x = 0; x < sw; x++) 1602 for (x = 0; x < sw; x++)
1516 if (row->c0 <= x + vx && x + vx < row->c1) 1603 if (row->c0 <= x + vx && x + vx < row->c1)
1517 { 1604 {
1518 mapcell *cell = row->col + (x + vx - row->c0); 1605 mapcell *cell = row->col + (x + vx - row->c0);
1519 1606
1520 darkness[y * sw4 + x] = cell->darkness < 0 1607 darkness[y * sw4 + x] = cell->darkness
1608 ? 255 - (cell->darkness - 1)
1521 ? 255 - FOW_DARKNESS 1609 : 255 - FOW_DARKNESS;
1522 : 255 - cell->darkness;
1523 } 1610 }
1524 } 1611 }
1525 1612
1526 EXTEND (SP, 3); 1613 EXTEND (SP, 3);
1527 PUSHs (sv_2mortal (newSViv (sw4))); 1614 PUSHs (sv_2mortal (newSViv (sw4)));
1528 PUSHs (sv_2mortal (newSViv (sh))); 1615 PUSHs (sv_2mortal (newSViv (sh)));
1529 PUSHs (darkness_sv); 1616 PUSHs (darkness_sv);
1530} 1617}
1531 1618
1532SV * 1619SV *
1533get_rect (CFClient::Map self, int x0, int y0, int w, int h) 1620get_rect (CFPlus::Map self, int x0, int y0, int w, int h)
1534 CODE: 1621 CODE:
1535{ 1622{
1536 int x, y, x1, y1; 1623 int x, y, x1, y1;
1537 SV *data_sv = newSV (w * h * 7 + 5); 1624 SV *data_sv = newSV (w * h * 7 + 5);
1538 uint8_t *data = (uint8_t *)SvPVX (data_sv); 1625 uint8_t *data = (uint8_t *)SvPVX (data_sv);
1600} 1687}
1601 OUTPUT: 1688 OUTPUT:
1602 RETVAL 1689 RETVAL
1603 1690
1604void 1691void
1605set_rect (CFClient::Map self, int x0, int y0, uint8_t *data) 1692set_rect (CFPlus::Map self, int x0, int y0, uint8_t *data)
1606 PPCODE: 1693 PPCODE:
1607{ 1694{
1608 int x, y, z; 1695 int x, y, z;
1609 int w, h; 1696 int w, h;
1610 int x1, y1; 1697 int x1, y1;
1642 1729
1643 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1730 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1644 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1731 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1645 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1732 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1646 1733
1647 if (cell->darkness <= 0) 1734 if (cell->darkness == 0)
1648 { 1735 {
1649 cell->darkness = -1; 1736 cell->darkness = 0;
1650 1737
1651 for (z = 0; z <= 2; z++) 1738 for (z = 0; z <= 2; z++)
1652 { 1739 {
1653 cell->face[z] = face[z]; 1740 cell->face[z] = face[z];
1654 1741
1659 } 1746 }
1660 } 1747 }
1661 } 1748 }
1662} 1749}
1663 1750
1664MODULE = CFClient PACKAGE = CFClient::MixChunk 1751MODULE = CFPlus PACKAGE = CFPlus::MixChunk
1665 1752
1666CFClient::MixChunk 1753CFPlus::MixChunk
1667new_from_file (SV *class, char *path) 1754new_from_file (SV *class, char *path)
1668 CODE: 1755 CODE:
1669 RETVAL = Mix_LoadWAV (path); 1756 RETVAL = Mix_LoadWAV (path);
1670 OUTPUT: 1757 OUTPUT:
1671 RETVAL 1758 RETVAL
1672 1759
1673void 1760void
1674DESTROY (CFClient::MixChunk self) 1761DESTROY (CFPlus::MixChunk self)
1675 CODE: 1762 CODE:
1676 Mix_FreeChunk (self); 1763 Mix_FreeChunk (self);
1677 1764
1678int 1765int
1679volume (CFClient::MixChunk self, int volume = -1) 1766volume (CFPlus::MixChunk self, int volume = -1)
1680 CODE: 1767 CODE:
1681 RETVAL = Mix_VolumeChunk (self, volume); 1768 RETVAL = Mix_VolumeChunk (self, volume);
1682 OUTPUT: 1769 OUTPUT:
1683 RETVAL 1770 RETVAL
1684 1771
1685int 1772int
1686play (CFClient::MixChunk self, int channel = -1, int loops = 0, int ticks = -1) 1773play (CFPlus::MixChunk self, int channel = -1, int loops = 0, int ticks = -1)
1687 CODE: 1774 CODE:
1688 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks); 1775 RETVAL = Mix_PlayChannelTimed (channel, self, loops, ticks);
1689 OUTPUT: 1776 OUTPUT:
1690 RETVAL 1777 RETVAL
1691 1778
1692MODULE = CFClient PACKAGE = CFClient::MixMusic 1779MODULE = CFPlus PACKAGE = CFPlus::MixMusic
1693 1780
1694int 1781int
1695volume (int volume = -1) 1782volume (int volume = -1)
1696 CODE: 1783 CODE:
1697 RETVAL = Mix_VolumeMusic (volume); 1784 RETVAL = Mix_VolumeMusic (volume);
1698 OUTPUT: 1785 OUTPUT:
1699 RETVAL 1786 RETVAL
1700 1787
1701CFClient::MixMusic 1788CFPlus::MixMusic
1702new_from_file (SV *class, char *path) 1789new_from_file (SV *class, char *path)
1703 CODE: 1790 CODE:
1704 RETVAL = Mix_LoadMUS (path); 1791 RETVAL = Mix_LoadMUS (path);
1705 OUTPUT: 1792 OUTPUT:
1706 RETVAL 1793 RETVAL
1707 1794
1708void 1795void
1709DESTROY (CFClient::MixMusic self) 1796DESTROY (CFPlus::MixMusic self)
1710 CODE: 1797 CODE:
1711 Mix_FreeMusic (self); 1798 Mix_FreeMusic (self);
1712 1799
1713int 1800int
1714play (CFClient::MixMusic self, int loops = -1) 1801play (CFPlus::MixMusic self, int loops = -1)
1715 CODE: 1802 CODE:
1716 RETVAL = Mix_PlayMusic (self, loops); 1803 RETVAL = Mix_PlayMusic (self, loops);
1717 OUTPUT: 1804 OUTPUT:
1718 RETVAL 1805 RETVAL
1719 1806
1720MODULE = CFClient PACKAGE = CFClient::OpenGL 1807MODULE = CFPlus PACKAGE = CFPlus::OpenGL
1721 1808
1722BOOT: 1809BOOT:
1723{ 1810{
1724 HV *stash = gv_stashpv ("CFClient::OpenGL", 1); 1811 HV *stash = gv_stashpv ("CFPlus::OpenGL", 1);
1725 static const struct { 1812 static const struct {
1726 const char *name; 1813 const char *name;
1727 IV iv; 1814 IV iv;
1728 } *civ, const_iv[] = { 1815 } *civ, const_iv[] = {
1729# define const_iv(name) { # name, (IV)name } 1816# define const_iv(name) { # name, (IV)name }
1792 const_iv (GL_SEPARABLE_2D), 1879 const_iv (GL_SEPARABLE_2D),
1793 const_iv (GL_CONVOLUTION_2D), 1880 const_iv (GL_CONVOLUTION_2D),
1794 const_iv (GL_CONVOLUTION_BORDER_MODE), 1881 const_iv (GL_CONVOLUTION_BORDER_MODE),
1795 const_iv (GL_CONSTANT_BORDER), 1882 const_iv (GL_CONSTANT_BORDER),
1796 const_iv (GL_LINES), 1883 const_iv (GL_LINES),
1884 const_iv (GL_LINE_STRIP),
1797 const_iv (GL_LINE_LOOP), 1885 const_iv (GL_LINE_LOOP),
1798 const_iv (GL_QUADS), 1886 const_iv (GL_QUADS),
1799 const_iv (GL_QUAD_STRIP), 1887 const_iv (GL_QUAD_STRIP),
1800 const_iv (GL_TRIANGLES), 1888 const_iv (GL_TRIANGLES),
1801 const_iv (GL_TRIANGLE_STRIP), 1889 const_iv (GL_TRIANGLE_STRIP),
1911 r *= a; 1999 r *= a;
1912 g *= a; 2000 g *= a;
1913 b *= a; 2001 b *= a;
1914 } 2002 }
1915 // microsoft visual "c" rounds instead of truncating... 2003 // microsoft visual "c" rounds instead of truncating...
1916 glColor4ub (MIN ((int)(r * 256.f), 255), 2004 glColor4f (r, g, b, a);
1917 MIN ((int)(g * 256.f), 255),
1918 MIN ((int)(b * 256.f), 255),
1919 MIN ((int)(a * 256.f), 255));
1920 2005
1921void glInterleavedArrays (int format, int stride, char *data) 2006void glInterleavedArrays (int format, int stride, char *data)
1922 2007
1923void glDrawElements (int mode, int count, int type, char *indices) 2008void glDrawElements (int mode, int count, int type, char *indices)
1924 2009
2001 2086
2002void glEndList () 2087void glEndList ()
2003 2088
2004void glCallList (int list) 2089void glCallList (int list)
2005 2090
2006

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines