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 | |
… | |
… | |
463 | |
466 | |
464 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
467 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
465 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
468 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
466 | } |
469 | } |
467 | |
470 | |
|
|
471 | int |
|
|
472 | in_destruct () |
|
|
473 | CODE: |
|
|
474 | RETVAL = PL_main_cv == Nullcv; |
|
|
475 | OUTPUT: |
|
|
476 | RETVAL |
|
|
477 | |
468 | NV floor (NV x) |
478 | NV floor (NV x) |
469 | |
479 | |
470 | NV ceil (NV x) |
480 | NV ceil (NV x) |
471 | |
481 | |
472 | void |
482 | void |
… | |
… | |
502 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
512 | SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); |
503 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
513 | SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); |
504 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
514 | SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); |
505 | |
515 | |
506 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
516 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
|
|
517 | SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); |
|
|
518 | SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); |
507 | |
519 | |
508 | SDL_EnableUNICODE (1); |
520 | SDL_EnableUNICODE (1); |
509 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
521 | SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
510 | |
522 | |
511 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
523 | m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); |
… | |
… | |
624 | #endif |
636 | #endif |
625 | |
637 | |
626 | void |
638 | void |
627 | add_font (char *file) |
639 | add_font (char *file) |
628 | CODE: |
640 | CODE: |
629 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
641 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); |
630 | |
642 | |
631 | void |
643 | void |
632 | load_image_inline (SV *image_) |
644 | load_image_inline (SV *image_) |
633 | ALIAS: |
645 | ALIAS: |
634 | load_image_file = 1 |
646 | load_image_file = 1 |
… | |
… | |
676 | |
688 | |
677 | surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); |
689 | surface2 = SDL_ConvertSurface (surface, &fmt, SDL_SWSURFACE); |
678 | |
690 | |
679 | assert (surface2->pitch == surface2->w * 4); |
691 | assert (surface2->pitch == surface2->w * 4); |
680 | |
692 | |
|
|
693 | SDL_LockSurface (surface2); |
681 | EXTEND (SP, 5); |
694 | EXTEND (SP, 6); |
682 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
695 | PUSHs (sv_2mortal (newSViv (surface2->w))); |
683 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
696 | PUSHs (sv_2mortal (newSViv (surface2->h))); |
684 | SDL_LockSurface (surface2); |
|
|
685 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
697 | PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); |
686 | SDL_UnlockSurface (surface2); |
|
|
687 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
698 | PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); |
688 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
699 | PUSHs (sv_2mortal (newSViv (GL_RGBA))); |
689 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
700 | PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); |
|
|
701 | SDL_UnlockSurface (surface2); |
690 | |
702 | |
691 | SDL_FreeSurface (surface); |
703 | SDL_FreeSurface (surface); |
692 | SDL_FreeSurface (surface2); |
704 | SDL_FreeSurface (surface2); |
693 | } |
705 | } |
694 | |
706 | |
… | |
… | |
764 | default_font = self; |
776 | default_font = self; |
765 | |
777 | |
766 | MODULE = CFClient PACKAGE = CFClient::Layout |
778 | MODULE = CFClient PACKAGE = CFClient::Layout |
767 | |
779 | |
768 | void |
780 | void |
769 | clear_font_cache () |
781 | reset_glyph_cache () |
770 | CODE: |
782 | CODE: |
771 | pango_fc_font_map_cache_clear ((PangoFcFontMap *)opengl_fontmap); |
|
|
772 | tc_clear (); |
783 | tc_clear (); |
773 | |
784 | |
774 | CFClient::Layout |
785 | CFClient::Layout |
775 | new (SV *class, int type = 0) |
786 | new (SV *class) |
776 | CODE: |
787 | CODE: |
777 | New (0, RETVAL, 1, struct cf_layout); |
788 | New (0, RETVAL, 1, struct cf_layout); |
778 | |
789 | |
779 | RETVAL->pl = pango_layout_new (opengl_context); |
790 | RETVAL->pl = pango_layout_new (opengl_context); |
780 | RETVAL->r = 1.; |
791 | RETVAL->r = 1.; |
… | |
… | |
873 | if (run && shape_attr_p (run)) |
884 | if (run && shape_attr_p (run)) |
874 | { |
885 | { |
875 | PangoRectangle extents; |
886 | PangoRectangle extents; |
876 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
887 | pango_layout_iter_get_run_extents (iter, 0, &extents); |
877 | |
888 | |
|
|
889 | EXTEND (SP, 2); |
878 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); |
890 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.x)))); |
879 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); |
891 | PUSHs (sv_2mortal (newSViv (PANGO_PIXELS (extents.y)))); |
880 | } |
892 | } |
881 | } |
893 | } |
882 | while (pango_layout_iter_next_run (iter)); |
894 | while (pango_layout_iter_next_run (iter)); |
… | |
… | |
1907 | r *= a; |
1919 | r *= a; |
1908 | g *= a; |
1920 | g *= a; |
1909 | b *= a; |
1921 | b *= a; |
1910 | } |
1922 | } |
1911 | // microsoft visual "c" rounds instead of truncating... |
1923 | // microsoft visual "c" rounds instead of truncating... |
1912 | glColor4ub (MIN ((int)(r * 256.f), 255), |
1924 | glColor4f (r, g, b, a); |
1913 | MIN ((int)(g * 256.f), 255), |
|
|
1914 | MIN ((int)(b * 256.f), 255), |
|
|
1915 | MIN ((int)(a * 256.f), 255)); |
|
|
1916 | |
1925 | |
1917 | void glInterleavedArrays (int format, int stride, char *data) |
1926 | void glInterleavedArrays (int format, int stride, char *data) |
1918 | |
1927 | |
1919 | void glDrawElements (int mode, int count, int type, char *indices) |
1928 | void glDrawElements (int mode, int count, int type, char *indices) |
1920 | |
1929 | |