1. SDL

$Log: flx_sdl.pak,v $ Revision 1.23 2006/07/25 04:15:40 idadesub maks sure all the tests are sorted Revision 1.22 2006/07/09 17:45:35 skaller More listings.. Revision 1.21 2006/06/22 12:44:25 skaller Split gc off into separate library. Revision 1.20 2006/06/19 03:10:50 idadesub making sure that the sdl package is compiled before sdl_driver, as sdl_driver needs the libraries the sdl package produces Revision 1.19 2006/06/11 19:38:14 idadesub added support a c compiler as well the builders have been massively refactored to reduce code duplication renamed some functions and arguments to be clearer on intent eliminated empty "except:" clauses. It's possible I'm not catching all the right exceptions though. fixed a couple bugs Revision 1.18 2006/06/09 19:06:14 idadesub modified to use flx_arun instead of the non-existing flx_sdl_run Revision 1.17 2006/05/21 13:59:39 skaller Basic TRE package now built in core, including unit tests. Revision 1.16 2006/05/18 08:59:57 skaller Fixed make script so static link tests work. It's a hack, static link now requires async to work (the version that doesn't is clobbered .. the make system provides no way to named the object file different from the input source file). Revision 1.15 2006/05/18 03:23:41 skaller update drivers with hack. Known to be bugged, sorry, but without these updates the system won't build at all. Static linked programs using async will not work. Revision 1.14 2006/05/06 20:05:46 idadesub made sure to load the sdl config in sdl_driver Revision 1.13 2006/03/25 01:27:31 skaller Add more stuff to gmp library binding. Start phasing config. Revision 1.12 2006/03/14 18:23:43 skaller Automatic rebuilding Revision 1.11 2006/03/06 13:16:17 skaller Fix library builds so exports and imports are properly distinguished on a library by library basis. Revision 1.10 2006/03/06 08:17:06 idadesub modified to support opengl on the mac. this allows sdl202 and sdl205 to compile, and run. However, 206, 208, and 209 still error out Revision 1.9 2006/03/04 07:28:20 skaller Decouple flx_run from faio and demux, except for hook creator. Revision 1.8 2006/03/03 21:11:11 skaller Misc fiddling with build system. Start on expression term unification for user defined reductions. Revision 1.7 2006/03/03 11:14:00 skaller Add quotation handling for flx_pkgconfig, changed config script to quote sdl-config --libs and sdl-config --static-libs. A bit of a hack, but should fix OSX build problem which requires a -framework argument to be stuck on the front of framework objects. Revision 1.6 2006/03/01 13:43:17 skaller COnfig packages now seem to work on Linux. Added dependency on libflx to flx_pthread. Revision 1.5 2006/02/28 02:07:13 skaller Refactor demux into demux + pthread. Revision 1.4 2006/02/25 20:38:12 skaller Upgrade flx_pkgconfig Revision 1.3 2006/02/24 15:40:15 skaller Enhance flx_pkgconfig Revision 1.2 2006/02/24 03:15:01 rfistman added flx_sdl_run Revision 1.1 2006/02/23 17:06:08 skaller Refactor build system. Revision 1.29 2006/02/23 06:19:46 skaller Split off some test from flx.pak, need to keep open files under ulimit. Revision 1.28 2006/02/22 06:02:26 skaller Merge. Revision 1.27 2006/02/22 05:52:23 rfistman added sdl package's dependence on libfaio, libflx and libdemux Revision 1.26 2006/02/22 04:53:18 skaller sdl package requirement on libfaio added. Add new type to the compiler, d --> c, which is C function type. Revision 1.25 2006/02/19 05:29:15 skaller Fiddle with SDL/GL support stuff. Revision 1.24 2006/02/18 16:30:48 skaller More work on new package manager. Revision 1.23 2006/02/15 10:54:09 skaller Build time packaging system. Revision 1.22 2006/02/09 21:05:33 skaller Fixed sdl to use polling. Revision 1.21 2006/02/09 07:42:10 skaller Try event polling for sdl100, SDL doesn't support threads reading events on Windows .. Revision 1.20 2006/02/06 11:59:15 skaller Sdl stuff: Add more event blocking whilst doing video Revision 1.19 2006/02/04 11:55:42 skaller sdl100 increase sound buffer from 512 to 2048, hope Windows sound quality improves. Add Escape for sdl100 so we can exit it without going thru all 16 frames. Revision 1.18 2006/01/31 07:54:31 skaller Fix sdl206, make sleep_request SDL_EXTERN Revision 1.17 2006/01/30 08:58:19 skaller Add package support to flx script Revision 1.16 2006/01/30 01:09:07 skaller more open GL lessons Revision 1.15 2006/01/29 04:37:29 skaller Fix various stuffs. Revision 1.14 2006/01/25 18:39:55 skaller Add mutex to protect SDL event source. Deploy in sdl110. Fix bug in rtl, was allocating an slist_t but telling the gc the shape was an slist_node_t, gc now runs and checks in sdl110. Revision 1.13 2006/01/25 06:37:27 skaller Move all header statements in SDL stuff inside modules so the #includes aren't triggered unless something in the module is actually used. Revision 1.12 2006/01/25 00:34:40 rfistman removed a few outstanding references to SDL_image fixed a tiny typo in flx_use.ipk got rid of superfluous private fn in faio. Revision 1.11 2006/01/24 19:15:49 skaller Add openGL test sdl110. Currently crashes in gc. Add async request counter to driver. Add configuration hack for openGL. Revision 1.10 2006/01/24 03:03:13 skaller Fix bug generating offsets for a cstruct. Upgrade tut121b expected output to handle new symbol .-> (which is just C's ->, we can't use the symbol -> because it means 'function' in the type language and has the wrong precedence there) Added opengl binding. Revision 1.9 2006/01/23 13:35:03 skaller Remove wrong tail call optimisation, replacing tail call with jump. This is correct but not allowed at inlinling stage. Revision 1.8 2006/01/21 17:02:13 skaller SDL sound with Felix callback, and asynchronous multiplexor for timeout/keypress example. COOL! Revision 1.7 2006/01/19 17:26:45 skaller Add sound to SDL example. Fix serious bug in synchronous channel I/O operations. Revision 1.6 2006/01/18 14:52:14 skaller Wrapped SDL event source, test case in tut/examples/sdl100 Revision 1.5 2006/01/18 05:50:04 rfistman turned sdl_event thing into a driver request Revision 1.4 2006/01/09 16:32:03 skaller Integrate SDL tests, provide initial SDL event demux. Revision 1.3 2006/01/08 08:56:44 skaller Change rtl name for MACOSX to libflx_dynamic.dylib Revision 1.2 2006/01/08 00:25:14 skaller Minor fix to sdl stuff
Start python section to cpkgs/target/sdl.py[1 /1 ]
     1: #line 197 "./lpsrc/flx_sdl.pak"
     2: execfile("config"+os.sep+"config.py")
     3: try:
     4:   cload(globals(),"sdl")
     5: except:
     6:   result,SDL_VERSION = gs("sdl-config --version")
     7:   if result == None:
     8:     print "SDL SUPPORTED, version ",SDL_VERSION
     9:     HAVE_SDL = 1
    10:     result,SDL_CFLAGS = gs("sdl-config --cflags")
    11:     result,SDL_LIBS = gs("sdl-config --libs")
    12:     result,SDL_STATIC_LIBS = gs("sdl-config --static-libs")
    13: 
    14:     fname = "config" + os.sep + "sdl.fpc"
    15:     if not file_exists(fname):
    16:       print "Creating config/sdl.fpc"
    17:       f = open (fname,"w")
    18:       f.write("Name: SDL\n")
    19:       f.write("Description: Simple Direct Media Layer\n")
    20:       f.write("Version: "+SDL_VERSION+"\n")
    21:       f.write("cflags: "+SDL_CFLAGS+"\n")
    22:       f.write("requires_dlibs: '"+SDL_LIBS+"'\n")
    23:       f.write("requires_slibs: '"+SDL_STATIC_LIBS+"'\n")
    24:       f.write("flx_requires_driver: flx_arun\n")
    25:       f.close()
    26:     fname = "config" + os.sep + "gl.fpc"
    27:     if not file_exists(fname):
    28:       print "Creating config/gl.fpc"
    29:       f = open (fname,"w")
    30:       f.write("Name: OpenGL\n")
    31:       f.write("Description: open GL graphics\n")
    32:       if MACOSX:
    33:         f.write("provides_dlib: -framework OpenGL\n")
    34:         f.write("provides_slib: -framework OpenGL\n")
    35:       else:
    36:         f.write("provides_dlib: -lGL\n")
    37:         f.write("provides_slib: -lGL\n")
    38:       f.close()
    39:     fname = "config" + os.sep + "glu.fpc"
    40:     if not file_exists(fname):
    41:       print "Creating config/glu.fpc"
    42:       f = open (fname,"w")
    43:       f.write("Name: GLU\n")
    44:       f.write("Description: GLU graphics \n")
    45:       if MACOSX:
    46:         f.write("provides_dlib: -framework OpenGL\n")
    47:         f.write("provides_slib: -framework OpenGL\n")
    48:       else:
    49:         f.write("provides_dlib: -lGLU\n")
    50:         f.write("provides_slib: -lGLU\n")
    51:       f.write("Requires: gl\n")
    52:       f.close()
    53:     fname = "config" + os.sep + "glut.fpc"
    54:     if not file_exists(fname):
    55:       print "Creating config/glut.fpc"
    56:       f = open (fname,"w")
    57:       f.write("Name: GLUT\n")
    58:       f.write("Description: GLUT graphics\n")
    59:       if MACOSX:
    60:         f.write("provides_dlib: -framework GLUT\n")
    61:         f.write("provides_slib: -framework GLUT\n")
    62:       else:
    63:         f.write("provides_dlib: -lglut\n")
    64:         f.write("provides_slib: -lglut\n")
    65:       f.write("Requires: gl glu\n")
    66:       f.close()
    67:   else:
    68:     HAVE_SDL = 0
    69:     SDL_VERSION = "None"
    70:     SDL_CFLAGS = ""
    71:     SDL_LIBS = ""
    72:     SDL_STATIC_LIBS = ""
    73:     print "SDL NOT SUPPORTED"
    74:   print "SDL cpkgs/target/sdl.py"
    75:   f = cwrite("sdl")
    76:   pa(f,locals(),"HAVE_SDL")
    77:   pa(f,locals(),"SDL_VERSION")
    78:   pa(f,locals(),"SDL_CFLAGS")
    79:   pa(f,locals(),"SDL_LIBS")
    80:   pa(f,locals(),"SDL_STATIC_LIBS")
    81:   pa(f,locals(),"HAVE_OPENGL")
    82:   f.close()
    83:   cload(globals(),"sdl")
    84: 
End python section to cpkgs/target/sdl.py[1]
Start python section to spkgs/sdl.py[1 /1 ]
     1: #line 282 "./lpsrc/flx_sdl.pak"
     2: execfile("cpkgs"+os.sep+"target"+os.sep+"sdl.py")
     3: if HAVE_SDL:
     4:   SDL_FAIO_CPPS = [
     5:     "faio/faio_sdl_event",             # any platform with SDL
     6:   ]
     7: 
     8:   # flags are compiler natives switches
     9:   # not to be confused with platform independent lists
    10:   # of libraries, include files, paths, etc
    11:   cflags = SDL_CFLAGS
    12:   dflags = SDL_LIBS
    13:   sflags = SDL_STATIC_LIBS
    14: 
    15:   cpp_cpps = SDL_FAIO_CPPS
    16:   pkg_requires = ['faio']
    17:   rtl_interfaces = ['faio/faio_sdl_event.hpp']
    18:   lib_requires = ['libfaio', 'libdemux','libflx_pthread','libflx']
    19:   demos = glob.glob('tut'+os.sep+'examples'+os.sep+'sdl*.flx')
    20:   demos.sort()
    21: 
    22: iscr_source = ['lpsrc/flx_sdl.pak']
    23: build_macro = "SDL"
    24: weaver_directory = "doc/sdl/"
    25: 
End python section to spkgs/sdl.py[1]
Start python section to spkgs/sdl_drivers.py[1 /1 ]
     1: #line 308 "./lpsrc/flx_sdl.pak"
     2: execfile("cpkgs"+os.sep+"target"+os.sep+"sdl.py")
     3: if HAVE_SDL:
     4:   DRIVERS = [
     5:     ('static','rtl/flx_arun','bin/flx_arun',[]),
     6:     ('dynamic','rtl/flx_arun','bin/flx_arun',[]),
     7:   ]
     8:   DRLIBS = [
     9:    'libsdl',
    10:    'libflx_async',
    11:    'libfaio',
    12:    'libdemux',
    13:    'libflx_pthread',
    14:    'libflx',
    15:    'libflx_gc',
    16:    ]
    17: 
    18:   drivers = DRIVERS
    19:   drivers_require_libs = DRLIBS
    20:   pkg_requires = ['flx_rtl','flx_async','faio','demux','flx_pthread','sdl']
    21:   cflags = SDL_CFLAGS
    22:   dflags = SDL_LIBS
    23:   sflags = SDL_STATIC_LIBS
    24: 
    25: 
End python section to spkgs/sdl_drivers.py[1]
Start felix section to lib/SDL/SDL_opengl.flx[1 /1 ]
     1: #line 334 "./lpsrc/flx_sdl.pak"
     2: 
     3: header '#include "SDL_opengl.h"';
     4: 
     5: include "GL/gl_lib";
     6: include "GL/glu_lib";
     7: 
     8: module SDL_opengl_h
     9: {
    10:   inherit GL_gl_h;
    11:   inherit GL_glu_h;
    12: }
    13: 
End felix section to lib/SDL/SDL_opengl.flx[1]
Start felix section to lib/SDL/SDL.flx[1 /1 ]
     1: #line 348 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_h
     3: //Timestamp     : 2006/1/6 2:5:23 UTC
     4: //Timestamp     : 2006/1/6 13:5:23 (local)
     5: //Raw Header    : SDL.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_INIT_EVERYTHING   0x0000FFFF
    13: //#define SDL_INIT_EVENTTHREAD  0x01000000      /* Not supported on all OS's */
    14: //#define SDL_INIT_NOPARACHUTE  0x00100000      /* Don't catch fatal signals */
    15: //#define SDL_INIT_JOYSTICK     0x00000200
    16: //#define SDL_INIT_CDROM                0x00000100
    17: //#define SDL_INIT_VIDEO                0x00000020
    18: //#define SDL_INIT_AUDIO                0x00000010
    19: //#define       SDL_INIT_TIMER          0x00000001
    20: //#define _SDL_H
    21: 
    22: module SDL_h
    23: {
    24:   requires package "sdl";
    25:   header '#include "SDL.h"';
    26:   open C_hack;
    27: 
    28:   const SDL_INIT_EVERYTHING: uint32;
    29:   const SDL_INIT_EVENTTHREAD: uint32;
    30:   const SDL_INIT_NOPARACHUTE: uint32;
    31:   const SDL_INIT_JOYSTICK: uint32;
    32:   const SDL_INIT_CDROM : uint32;
    33:   const SDL_INIT_VIDEO: uint32;
    34:   const SDL_INIT_AUDIO: uint32;
    35:   const SDL_INIT_TIMER: uint32;
    36: 
    37:   //PROCEDURES
    38:   proc SDL_Quit: 1;
    39:   proc SDL_QuitSubSystem: uint32;
    40: 
    41:   //FUNCTIONS
    42:   fun SDL_Init: uint32 -> int;
    43:   fun SDL_InitSubSystem: uint32 -> int;
    44:   fun SDL_WasInit: uint32 -> uint32;
    45: }
End felix section to lib/SDL/SDL.flx[1]
Start felix section to lib/SDL/SDL_active.flx[1 /1 ]
     1: #line 394 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_active_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_active.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_APPACTIVE         0x04            /* The application is active */
    13: //#define SDL_APPINPUTFOCUS     0x02            /* The app has input focus */
    14: //#define SDL_APPMOUSEFOCUS     0x01            /* The app has mouse coverage */
    15: //#define _SDL_active_h
    16: 
    17: module SDL_active_h
    18: {
    19:   requires package "sdl";
    20:   header '#include "SDL_active.h"';
    21:   open C_hack;
    22: 
    23:   //FUNCTIONS
    24:   fun SDL_GetAppState: 1 -> uint8;
    25: }
End felix section to lib/SDL/SDL_active.flx[1]
Start felix section to lib/SDL/SDL_audio.flx[1 /1 ]
     1: #line 420 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_audio_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_audio.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: 
    13: //INCLUDES
    14: include"SDL/SDL_rwops";
    15: 
    16: module SDL_audio_h
    17: {
    18:   requires package "sdl";
    19:   header '#include "SDL_audio.h"';
    20:   open C_hack;
    21:   open SDL_rwops_h;
    22: 
    23:   const SDL_MIX_MAXVOLUME : int;
    24:   const AUDIO_S16MSB : uint16;
    25:   const AUDIO_U16MSB : uint16;
    26:   const AUDIO_S16LSB : uint16;
    27:   const AUDIO_U16LSB : uint16;
    28:   const AUDIO_S16SYS : uint16;
    29:   const AUDIO_U16SYS : uint16;
    30:   const AUDIO_S16 : uint16;
    31:   const AUDIO_U16 : uint16;
    32:   const AUDIO_S8 : uint16;
    33:   const AUDIO_U8 : uint16;
    34: 
    35:   //ABSTRACT TYPES
    36:   type SDL_audiostatus = 'SDL_audiostatus';
    37:   fun eq:SDL_audiostatus * SDL_audiostatus -> bool = "$1==$2";
    38: 
    39:   //CSTRUCTS
    40:   cstruct SDL_AudioCVT {
    41:     needed: int;
    42:     src_format: uint16;
    43:     dst_format: uint16;
    44:     rate_incr: double;
    45:     buf: ptr[uint8];
    46:     len: int;
    47:     len_cvt: int;
    48:     len_mult: int;
    49:     len_ratio: double;
    50:     filters: ptr[SDL_audio_h_cft_2];
    51:     filter_index: int;
    52:   }
    53:   cstruct SDL_AudioSpec {
    54:     freq: int;
    55:     format: uint16;
    56:     channels: uint8;
    57:     silence: uint8;
    58:     samples: uint16;
    59:     padding: uint16;
    60:     size: uint32;
    61:     callback_: SDL_audio_h_cft_1;
    62:     userdata: address;
    63:   }
    64: 
    65:   fun get_callback: SDL_AudioSpec -> SDL_audio_h_cft_1 = "$1.callback";
    66:   fun get_callback: lvalue[SDL_AudioSpec] -> lvalue[SDL_audio_h_cft_1] = "$1.callback";
    67: 
    68:   //C FUNCTION POINTER TYPES
    69:   header '''typedef void (*SDL_audio_h_cft_2)(struct SDL_AudioCVT *,  Uint16);''';
    70:   type SDL_audio_h_cft_2 = 'SDL_audio_h_cft_2';
    71: 
    72:   header '''typedef void (*SDL_audio_h_cft_1)(void *,  Uint8 *, int);''';
    73:   type SDL_audio_h_cft_1 = 'SDL_audio_h_cft_1';
    74: 
    75:   typedef flx_audio_callback_arg_t = ptr[uint8] * int;
    76:   typedef flx_audio_callback_t = flx_audio_callback_arg_t -> void;
    77:   export type (flx_audio_callback_t) as "flx_audio_callback_t";
    78:   export type (flx_audio_callback_arg_t) as "flx_audio_callback_arg_t";
    79: 
    80:   header """
    81:     void SDL_audio_callback(void *obj, Uint8 *stream, int len);
    82:   """;
    83: 
    84:   body """
    85:     // audio callback thunk
    86:     void SDL_audio_callback(void *obj, Uint8 *stream, int len) {
    87:       flx_audio_callback_t callback = (flx_audio_callback_t)obj;
    88:       flx::rtl::con_t *p =
    89:         callback->
    90:         clone()->
    91:         call(0,flx_audio_callback_arg_t(stream,len))
    92:       ;
    93:       while(p) p = p->resume();
    94:     }
    95:   """;
    96: 
    97: // not working yet
    98: //  callback proc SDL_audio_callback: SDL_audio_callback * ptr[uint8] * int;
    99: 
   100:   //STRUCT or UNION TAG ALIASES
   101: 
   102:   /*
   103:   //TYPE ALIASES
   104:   typedef _struct_SDL_AudioSpec = SDL_AudioSpec;
   105:   typedef _struct_SDL_AudioCVT = SDL_AudioCVT;
   106:   */
   107: 
   108:   //ENUMERATION CONSTANTS
   109:   const SDL_AUDIO_PAUSED: SDL_audiostatus = 'SDL_AUDIO_PAUSED';
   110:   const SDL_AUDIO_STOPPED: SDL_audiostatus = 'SDL_AUDIO_STOPPED';
   111:   const SDL_AUDIO_PLAYING: SDL_audiostatus = 'SDL_AUDIO_PLAYING';
   112: 
   113:   //PROCEDURES
   114:   proc SDL_AudioQuit: 1;
   115:   proc SDL_CloseAudio: 1;
   116:   proc SDL_FreeWAV: ptr[uint8];
   117:   proc SDL_LockAudio: 1;
   118:   proc SDL_MixAudio: ptr[uint8] * cptr[uint8] * uint32 * int;
   119:   proc SDL_PauseAudio: int;
   120:   proc SDL_UnlockAudio: 1;
   121: 
   122:   //FUNCTIONS
   123:   fun SDL_AudioDriverName: ptr[char] * int -> ptr[char];
   124:   fun SDL_AudioInit: cptr[char] -> int;
   125:   fun SDL_BuildAudioCVT: ptr[SDL_AudioCVT] * uint16 * uint8 * int * uint16 * uint8 * int -> int;
   126:   fun SDL_ConvertAudio: ptr[SDL_AudioCVT] -> int;
   127:   fun SDL_GetAudioStatus: 1 -> SDL_audiostatus;
   128:   fun SDL_LoadWAV_RW: ptr[SDL_RWops] * int * ptr[SDL_AudioSpec] * ptr[ptr[uint8]] * ptr[uint32] -> ptr[SDL_AudioSpec];
   129:   fun SDL_OpenAudio: ptr[SDL_AudioSpec] * ptr[SDL_AudioSpec] -> int;
   130:   fun SDL_LoadWAV: cptr[char] * ptr[SDL_AudioSpec] * ptr[ptr[uint8]] * ptr[uint32] -> ptr[SDL_AudioSpec];
   131: }
   132: 
End felix section to lib/SDL/SDL_audio.flx[1]
Start felix section to lib/SDL/SDL_cdrom.flx[1 /1 ]
     1: #line 553 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_cdrom_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_cdrom.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define MSF_TO_FRAMES(M, S, F)        ((M)*60*CD_FPS+(S)*CD_FPS+(F))
    13: //#define FRAMES_TO_MSF(f, M,S,F)       {                                       \
    14: //#define CD_FPS        75
    15: //#define CD_INDRIVE(status)    ((int)status > 0)
    16: //#define SDL_DATA_TRACK        0x04
    17: //#define SDL_AUDIO_TRACK       0x00
    18: //#define SDL_MAX_TRACKS        99
    19: //#define _SDL_cdrom_h
    20: 
    21: module SDL_cdrom_h
    22: {
    23:   requires package "sdl";
    24:   header '#include "SDL_cdrom.h"';
    25:   open C_hack;
    26: 
    27:   //ABSTRACT TYPES
    28:   type CDstatus = 'CDstatus';
    29: 
    30:   //CSTRUCTS
    31:   cstruct SDL_CD {
    32:     id: int;
    33:     status: CDstatus;
    34:     numtracks: int;
    35:     cur_track: int;
    36:     cur_frame: int;
    37:     track: ptr[SDL_CDtrack];
    38:   }
    39:   cstruct SDL_CDtrack {
    40:     id: uint8;
    41:     type_: uint8;
    42:     unused: uint16;
    43:     length: uint32;
    44:     offset: uint32;
    45:   }
    46: 
    47:   //STRUCT or UNION TAG ALIASES
    48: 
    49:   /*
    50:   //TYPE ALIASES
    51:   typedef _struct_SDL_CD = SDL_CD;
    52:   typedef _struct_SDL_CDtrack = SDL_CDtrack;
    53:   */
    54: 
    55:   //ENUMERATION CONSTANTS
    56:   const CD_TRAYEMPTY: int = 'CD_TRAYEMPTY';
    57:   const CD_PLAYING: int = 'CD_PLAYING';
    58:   const CD_ERROR: int = 'CD_ERROR';
    59:   const CD_PAUSED: int = 'CD_PAUSED';
    60:   const CD_STOPPED: int = 'CD_STOPPED';
    61: 
    62:   //PROCEDURES
    63:   proc SDL_CDClose: ptr[SDL_CD];
    64: 
    65:   //FUNCTIONS
    66:   fun SDL_CDEject: ptr[SDL_CD] -> int;
    67:   fun SDL_CDName: int -> cptr[char];
    68:   fun SDL_CDNumDrives: 1 -> int;
    69:   fun SDL_CDOpen: int -> ptr[SDL_CD];
    70:   fun SDL_CDPause: ptr[SDL_CD] -> int;
    71:   fun SDL_CDPlay: ptr[SDL_CD] * int * int -> int;
    72:   fun SDL_CDPlayTracks: ptr[SDL_CD] * int * int * int * int -> int;
    73:   fun SDL_CDResume: ptr[SDL_CD] -> int;
    74:   fun SDL_CDStatus: ptr[SDL_CD] -> CDstatus;
    75:   fun SDL_CDStop: ptr[SDL_CD] -> int;
    76: }
End felix section to lib/SDL/SDL_cdrom.flx[1]
Start felix section to lib/SDL/SDL_error.flx[1 /1 ]
     1: #line 630 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_error_h
     3: //Timestamp     : 2006/1/6 2:1:27 UTC
     4: //Timestamp     : 2006/1/6 13:1:27 (local)
     5: //Raw Header    : SDL_error.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_OutOfMemory()     SDL_Error(SDL_ENOMEM)
    13: //#define _SDL_error_h
    14: 
    15: module SDL_error_h
    16: {
    17:   requires package "sdl";
    18:   header '#include "SDL_error.h"';
    19:   open C_hack;
    20: 
    21:   //ABSTRACT TYPES
    22:   type SDL_errorcode = 'SDL_errorcode';
    23: 
    24:   //ENUMERATION CONSTANTS
    25:   const SDL_EFSEEK: int = 'SDL_EFSEEK';
    26:   const SDL_ENOMEM: int = 'SDL_ENOMEM';
    27:   const SDL_LASTERROR: int = 'SDL_LASTERROR';
    28:   const SDL_EFREAD: int = 'SDL_EFREAD';
    29:   const SDL_EFWRITE: int = 'SDL_EFWRITE';
    30: 
    31:   //PROCEDURES
    32:   proc SDL_ClearError: 1;
    33:   proc SDL_Error: SDL_errorcode;
    34:   proc SDL_SetError[t]: t;
    35: 
    36:   //FUNCTIONS
    37:   fun SDL_GetError: 1 -> ptr[char];
    38: }
End felix section to lib/SDL/SDL_error.flx[1]
Start felix section to lib/SDL/SDL_events.flx[1 /1 ]
     1: #line 669 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_events_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_events.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_ENABLE     1
    13: //#define SDL_DISABLE    0
    14: //#define SDL_IGNORE     0
    15: //#define SDL_QUERY     -1
    16: //#define SDL_ALLEVENTS         0xFFFFFFFF
    17: //#define SDL_EVENTMASK(X)      (1<<(X))
    18: //#define _SDL_events_h
    19: 
    20: //INCLUDES
    21: include"SDL/SDL_keyboard";
    22: 
    23: module SDL_events_h
    24: {
    25:   requires package "sdl";
    26:   header '#include "SDL_events.h"';
    27:   open C_hack;
    28:   open SDL_keyboard_h;
    29: 
    30:   //ABSTRACT TYPES
    31:   type SDL_eventaction = 'SDL_eventaction';
    32: 
    33:   //CSTRUCTS
    34:   cstruct SDL_SysWMEvent {
    35:     type_: uint8;
    36:     msg: ptr[SDL_SysWMmsg];
    37:   }
    38:   cstruct SDL_ResizeEvent {
    39:     type_: uint8;
    40:     w: int;
    41:     h: int;
    42:   }
    43:   cstruct SDL_KeyboardEvent {
    44:     type_: uint8;
    45:     which: uint8;
    46:     state: uint8;
    47:     keysym: SDL_keysym;
    48:   }
    49:   cstruct SDL_JoyBallEvent {
    50:     type_: uint8;
    51:     which: uint8;
    52:     ball: uint8;
    53:     xrel: int16;
    54:     yrel: int16;
    55:   }
    56:   cstruct SDL_JoyHatEvent {
    57:     type_: uint8;
    58:     which: uint8;
    59:     hat: uint8;
    60:     value: uint8;
    61:   }
    62:   cstruct SDL_ExposeEvent {
    63:     type_: uint8;
    64:   }
    65:   cstruct SDL_MouseButtonEvent {
    66:     type_: uint8;
    67:     which: uint8;
    68:     button: uint8;
    69:     state: uint8;
    70:     x: uint16;
    71:     y: uint16;
    72:   }
    73:   cstruct SDL_MouseMotionEvent {
    74:     type_: uint8;
    75:     which: uint8;
    76:     state: uint8;
    77:     x: uint16;
    78:     y: uint16;
    79:     xrel: int16;
    80:     yrel: int16;
    81:   }
    82:   cstruct SDL_JoyButtonEvent {
    83:     type_: uint8;
    84:     which: uint8;
    85:     button: uint8;
    86:     state: uint8;
    87:   }
    88:   cstruct SDL_QuitEvent {
    89:     type_: uint8;
    90:   }
    91:   cstruct SDL_JoyAxisEvent {
    92:     type_: uint8;
    93:     which: uint8;
    94:     axis: uint8;
    95:     value: int16;
    96:   }
    97:   cstruct SDL_UserEvent {
    98:     type_: uint8;
    99:     code_: int;
   100:     data1: address;
   101:     data2: address;
   102:   }
   103:   cstruct SDL_ActiveEvent {
   104:     type_: uint8;
   105:     gain: uint8;
   106:     state: uint8;
   107:   }
   108: 
   109:   // This is ACTUALLY a C union .. but the syntax is the same
   110:   // as for a struct .. so we can model it with a struct
   111:   cstruct SDL_Event = {
   112:     //type_ : uint8; // type is a keyword ..
   113:     active : SDL_ActiveEvent;
   114:     key : SDL_KeyboardEvent;
   115:     motion: SDL_MouseMotionEvent;
   116:     button: SDL_MouseButtonEvent;
   117:     jaxis : SDL_JoyAxisEvent;
   118:     jball : SDL_JoyBallEvent;
   119:     jhat : SDL_JoyHatEvent;
   120:     jbutton : SDL_JoyButtonEvent;
   121:     resize : SDL_ResizeEvent;
   122:     expose : SDL_ExposeEvent;
   123:     quit: SDL_QuitEvent;
   124:     user : SDL_UserEvent;
   125:     syswm : SDL_SysWMEvent;
   126:   }
   127: 
   128:   // use name type_ instead of type ..
   129:   fun get_type_:SDL_Event -> uint8 = "$1.type";
   130: 
   131:   //C FUNCTION POINTER TYPES
   132:   header '''typedef int (*SDL_events_h_cft_1)(SDL_Event const *);''';
   133:   type SDL_events_h_cft_1 = 'SDL_events_h_cft_1';
   134: 
   135:   //PURE INCOMPLETE TYPES
   136:   type _struct_SDL_SysWMmsg = 'struct SDL_SysWMmsg'; //local
   137: 
   138:   //STRUCT or UNION TAG ALIASES
   139:   typedef SDL_SysWMmsg = _struct_SDL_SysWMmsg;
   140: 
   141:   typedef SDL_EventMasks = int;
   142:   typedef SDL_EventFilter = SDL_events_h_cft_1;
   143:   typedef SDL_Events = int;
   144: 
   145:   // Weird
   146:   const SDL_PEEKEVENT: uint8 = 'SDL_PEEKEVENT';
   147:   const SDL_GETEVENT: uint8 = 'SDL_GETEVENT';
   148:   const SDL_ADDEVENT: uint8 = 'SDL_ADDEVENT';
   149:   const SDL_NUMEVENTS: uint8 = 'SDL_NUMEVENTS';
   150: 
   151:   //EVENTS
   152:   const SDL_MOUSEBUTTONUP: uint8 = 'SDL_MOUSEBUTTONUP';
   153:   const SDL_MOUSEBUTTONDOWN: uint8 = 'SDL_MOUSEBUTTONDOWN';
   154:   const SDL_KEYUP: uint8 = 'SDL_KEYUP';
   155:   const SDL_JOYBALLMOTION: uint8 = 'SDL_JOYBALLMOTION';
   156:   const SDL_NOEVENT: uint8 = 'SDL_NOEVENT';
   157:   const SDL_JOYAXISMOTION: uint8 = 'SDL_JOYAXISMOTION';
   158:   const SDL_QUIT: uint8 = 'SDL_QUIT';
   159:   const SDL_VIDEORESIZE: uint8 = 'SDL_VIDEORESIZE';
   160:   const SDL_JOYBUTTONDOWN: uint8 = 'SDL_JOYBUTTONDOWN';
   161:   const SDL_KEYDOWN: uint8 = 'SDL_KEYDOWN';
   162:   const SDL_JOYBUTTONUP: uint8 = 'SDL_JOYBUTTONUP';
   163:   const SDL_SYSWMEVENT: uint8 = 'SDL_SYSWMEVENT';
   164:   const SDL_USEREVENT: uint8 = 'SDL_USEREVENT';
   165:   const SDL_JOYHATMOTION: uint8 = 'SDL_JOYHATMOTION';
   166:   const SDL_ACTIVEEVENT: uint8 = 'SDL_ACTIVEEVENT';
   167:   const SDL_VIDEOEXPOSE: uint8 = 'SDL_VIDEOEXPOSE';
   168:   const SDL_MOUSEMOTION: uint8 = 'SDL_MOUSEMOTION';
   169: 
   170:   // reserved
   171:   const SDL_EVENT_RESERVED2: uint8 = 'SDL_EVENT_RESERVED2';
   172:   const SDL_EVENT_RESERVED3: uint8 = 'SDL_EVENT_RESERVED3';
   173:   const SDL_EVENT_RESERVED4: uint8 = 'SDL_EVENT_RESERVED4';
   174:   const SDL_EVENT_RESERVED5: uint8 = 'SDL_EVENT_RESERVED5';
   175:   const SDL_EVENT_RESERVED6: uint8 = 'SDL_EVENT_RESERVED6';
   176:   const SDL_EVENT_RESERVED7: uint8 = 'SDL_EVENT_RESERVED7';
   177:   const SDL_EVENT_RESERVEDA: uint8 = 'SDL_EVENT_RESERVEDA';
   178:   const SDL_EVENT_RESERVEDB: uint8 = 'SDL_EVENT_RESERVEDB';
   179: 
   180:   // MASKS
   181:   // Joystick
   182:   const SDL_JOYBUTTONDOWNMASK: uint8 = 'SDL_JOYBUTTONDOWNMASK';
   183:   const SDL_JOYBUTTONUPMASK: uint8 = 'SDL_JOYBUTTONUPMASK';
   184:   const SDL_JOYHATMOTIONMASK: uint8 = 'SDL_JOYHATMOTIONMASK';
   185:   const SDL_JOYAXISMOTIONMASK: uint8 = 'SDL_JOYAXISMOTIONMASK';
   186:   const SDL_JOYBALLMOTIONMASK: uint8 = 'SDL_JOYBALLMOTIONMASK';
   187:   const SDL_JOYEVENTMASK: uint8 = 'SDL_JOYEVENTMASK';
   188: 
   189:   // mouse
   190:   const SDL_MOUSEMOTIONMASK: uint8 = 'SDL_MOUSEMOTIONMASK';
   191:   const SDL_MOUSEEVENTMASK: uint8 = 'SDL_MOUSEEVENTMASK';
   192:   const SDL_MOUSEBUTTONUPMASK: uint8 = 'SDL_MOUSEBUTTONUPMASK';
   193:   const SDL_MOUSEBUTTONDOWNMASK: uint8 = 'SDL_MOUSEBUTTONDOWNMASK';
   194: 
   195:   // video
   196:   const SDL_VIDEORESIZEMASK: uint8 = 'SDL_VIDEORESIZEMASK';
   197:   const SDL_ACTIVEEVENTMASK: uint8 = 'SDL_ACTIVEEVENTMASK';
   198:   const SDL_SYSWMEVENTMASK: uint8 = 'SDL_SYSWMEVENTMASK';
   199:   const SDL_VIDEOEXPOSEMASK: uint8 = 'SDL_VIDEOEXPOSEMASK';
   200: 
   201:   // keyboard
   202:   const SDL_KEYDOWNMASK: uint8 = 'SDL_KEYDOWNMASK';
   203:   const SDL_KEYUPMASK: uint8 = 'SDL_KEYUPMASK';
   204:   const SDL_QUITMASK: uint8 = 'SDL_QUITMASK';
   205: 
   206:   //PROCEDURES
   207:   proc SDL_PumpEvents: 1;
   208:   proc SDL_SetEventFilter: SDL_events_h_cft_1;
   209: 
   210:   //FUNCTIONS
   211:   fun SDL_EventState: uint8 * int -> uint8;
   212:   fun SDL_GetEventFilter: 1 -> SDL_EventFilter;
   213:   fun SDL_PeepEvents: ptr[SDL_Event] * int * SDL_eventaction * uint32 -> int;
   214:   fun SDL_PollEvent: ptr[SDL_Event] -> int;
   215:   fun SDL_PushEvent: ptr[SDL_Event] -> int;
   216:   fun SDL_WaitEvent: ptr[SDL_Event] -> int;
   217: }
End felix section to lib/SDL/SDL_events.flx[1]
Start felix section to lib/SDL/SDL_joystick.flx[1 /1 ]
     1: #line 887 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_joystick_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_joystick.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_HAT_LEFTDOWN      (SDL_HAT_LEFT|SDL_HAT_DOWN)
    13: //#define SDL_HAT_LEFTUP                (SDL_HAT_LEFT|SDL_HAT_UP)
    14: //#define SDL_HAT_RIGHTDOWN     (SDL_HAT_RIGHT|SDL_HAT_DOWN)
    15: //#define SDL_HAT_RIGHTUP               (SDL_HAT_RIGHT|SDL_HAT_UP)
    16: //#define SDL_HAT_LEFT          0x08
    17: //#define SDL_HAT_DOWN          0x04
    18: //#define SDL_HAT_RIGHT         0x02
    19: //#define SDL_HAT_UP            0x01
    20: //#define SDL_HAT_CENTERED      0x00
    21: //#define _SDL_joystick_h
    22: 
    23: module SDL_joystick_h
    24: {
    25:   requires package "sdl";
    26:   header '#include "SDL_joystick.h"';
    27:   open C_hack;
    28: 
    29:   //PURE INCOMPLETE TYPES
    30:   type _struct__SDL_Joystick = 'struct _SDL_Joystick'; //local
    31: 
    32:   //STRUCT or UNION TAG ALIASES
    33:   typedef SDL_Joystick = _struct__SDL_Joystick;
    34: 
    35:   //PROCEDURES
    36:   proc SDL_JoystickClose: ptr[SDL_Joystick];
    37:   proc SDL_JoystickUpdate: 1;
    38: 
    39:   //FUNCTIONS
    40:   fun SDL_JoystickEventState: int -> int;
    41:   fun SDL_JoystickGetAxis: ptr[SDL_Joystick] * int -> int16;
    42:   fun SDL_JoystickGetBall: ptr[SDL_Joystick] * int * ptr[int] * ptr[int] -> int;
    43:   fun SDL_JoystickGetButton: ptr[SDL_Joystick] * int -> uint8;
    44:   fun SDL_JoystickGetHat: ptr[SDL_Joystick] * int -> uint8;
    45:   fun SDL_JoystickIndex: ptr[SDL_Joystick] -> int;
    46:   fun SDL_JoystickName: int -> cptr[char];
    47:   fun SDL_JoystickNumAxes: ptr[SDL_Joystick] -> int;
    48:   fun SDL_JoystickNumBalls: ptr[SDL_Joystick] -> int;
    49:   fun SDL_JoystickNumButtons: ptr[SDL_Joystick] -> int;
    50:   fun SDL_JoystickNumHats: ptr[SDL_Joystick] -> int;
    51:   fun SDL_JoystickOpen: int -> ptr[SDL_Joystick];
    52:   fun SDL_JoystickOpened: int -> int;
    53:   fun SDL_NumJoysticks: 1 -> int;
    54: }
End felix section to lib/SDL/SDL_joystick.flx[1]
Start felix section to lib/SDL/SDL_keyboard.flx[1 /1 ]
     1: #line 942 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_keyboard_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_keyboard.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_DEFAULT_REPEAT_INTERVAL   30
    13: //#define SDL_DEFAULT_REPEAT_DELAY      500
    14: //#define SDL_ALL_HOTKEYS               0xFFFFFFFF
    15: //#define _SDL_keyboard_h
    16: 
    17: //INCLUDES
    18: include"SDL/SDL_keysym";
    19: 
    20: module SDL_keyboard_h
    21: {
    22:   requires package "sdl";
    23:   header '#include "SDL_keyboard.h"';
    24:   open C_hack;
    25:   open SDL_keysym_h;
    26: 
    27:   //CSTRUCTS
    28:   cstruct SDL_keysym {
    29:     scancode: uint8;
    30:     sym: SDLKey;
    31:     mod: SDLMod;
    32:     unicode: uint16;
    33:   }
    34: 
    35:   //STRUCT or UNION TAG ALIASES
    36: 
    37:   /*
    38:   //TYPE ALIASES
    39:   typedef _struct_SDL_keysym = SDL_keysym;
    40:   */
    41: 
    42:   //PROCEDURES
    43:   proc SDL_SetModState: SDLMod;
    44: 
    45:   //FUNCTIONS
    46:   fun SDL_EnableKeyRepeat: int * int -> int;
    47:   fun SDL_EnableUNICODE: int -> int;
    48:   fun SDL_GetKeyName: SDLKey -> ptr[char];
    49:   fun SDL_GetKeyState: ptr[int] -> ptr[uint8];
    50:   fun SDL_GetModState: 1 -> SDLMod;
    51: }
End felix section to lib/SDL/SDL_keyboard.flx[1]
Start felix section to lib/SDL/SDL_keysym.flx[1 /1 ]
     1: #line 994 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_keysym_h
     3: //Timestamp     : 2006/1/6 2:1:27 UTC
     4: //Timestamp     : 2006/1/6 13:1:27 (local)
     5: //Raw Header    : SDL_keysym.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define KMOD_META     (KMOD_LMETA|KMOD_RMETA)
    13: //#define KMOD_ALT      (KMOD_LALT|KMOD_RALT)
    14: //#define KMOD_SHIFT    (KMOD_LSHIFT|KMOD_RSHIFT)
    15: //#define KMOD_CTRL     (KMOD_LCTRL|KMOD_RCTRL)
    16: //#define _SDL_keysym_h
    17: 
    18: module SDL_keysym_h
    19: {
    20:   requires package "sdl";
    21:   header '#include "SDL_keysym.h"';
    22:   open C_hack;
    23: 
    24:   //ABSTRACT TYPES
    25:   type SDLKey = 'SDLKey';
    26:   type SDLMod = 'SDLMod';
    27: 
    28:   //ENUMERATION CONSTANTS
    29:   const SDLK_WORLD_1: SDLKey = 'SDLK_WORLD_1';
    30:   const SDLK_POWER: SDLKey = 'SDLK_POWER';
    31:   const SDLK_SLASH: SDLKey = 'SDLK_SLASH';
    32:   const SDLK_WORLD_2: SDLKey = 'SDLK_WORLD_2';
    33:   const SDLK_WORLD_3: SDLKey = 'SDLK_WORLD_3';
    34:   const SDLK_F1: SDLKey = 'SDLK_F1';
    35:   const SDLK_WORLD_4: SDLKey = 'SDLK_WORLD_4';
    36:   const SDLK_WORLD_20: SDLKey = 'SDLK_WORLD_20';
    37:   const SDLK_F2: SDLKey = 'SDLK_F2';
    38:   const SDLK_WORLD_5: SDLKey = 'SDLK_WORLD_5';
    39:   const SDLK_WORLD_21: SDLKey = 'SDLK_WORLD_21';
    40:   const SDLK_F3: SDLKey = 'SDLK_F3';
    41:   const SDLK_KP_EQUALS: SDLKey = 'SDLK_KP_EQUALS';
    42:   const SDLK_WORLD_6: SDLKey = 'SDLK_WORLD_6';
    43:   const SDLK_LEFT: SDLKey = 'SDLK_LEFT';
    44:   const SDLK_WORLD_22: SDLKey = 'SDLK_WORLD_22';
    45:   const SDLK_F4: SDLKey = 'SDLK_F4';
    46:   const SDLK_WORLD_7: SDLKey = 'SDLK_WORLD_7';
    47:   const SDLK_WORLD_23: SDLKey = 'SDLK_WORLD_23';
    48:   const SDLK_UNDO: SDLKey = 'SDLK_UNDO';
    49:   const SDLK_F5: SDLKey = 'SDLK_F5';
    50:   const SDLK_WORLD_8: SDLKey = 'SDLK_WORLD_8';
    51:   const SDLK_WORLD_24: SDLKey = 'SDLK_WORLD_24';
    52:   const SDLK_F6: SDLKey = 'SDLK_F6';
    53:   const SDLK_WORLD_9: SDLKey = 'SDLK_WORLD_9';
    54:   const SDLK_WORLD_25: SDLKey = 'SDLK_WORLD_25';
    55:   const SDLK_F7: SDLKey = 'SDLK_F7';
    56:   const SDLK_WORLD_26: SDLKey = 'SDLK_WORLD_26';
    57:   const SDLK_F8: SDLKey = 'SDLK_F8';
    58:   const SDLK_WORLD_27: SDLKey = 'SDLK_WORLD_27';
    59:   const SDLK_F9: SDLKey = 'SDLK_F9';
    60:   const SDLK_LEFTPAREN: SDLKey = 'SDLK_LEFTPAREN';
    61:   const SDLK_WORLD_28: SDLKey = 'SDLK_WORLD_28';
    62:   const SDLK_WORLD_29: SDLKey = 'SDLK_WORLD_29';
    63:   const SDLK_KP_ENTER: SDLKey = 'SDLK_KP_ENTER';
    64:   const SDLK_CAPSLOCK: SDLKey = 'SDLK_CAPSLOCK';
    65:   const SDLK_WORLD_30: SDLKey = 'SDLK_WORLD_30';
    66:   const SDLK_WORLD_31: SDLKey = 'SDLK_WORLD_31';
    67:   const SDLK_COMMA: SDLKey = 'SDLK_COMMA';
    68:   const SDLK_WORLD_32: SDLKey = 'SDLK_WORLD_32';
    69:   const SDLK_HASH: SDLKey = 'SDLK_HASH';
    70:   const SDLK_SPACE: SDLKey = 'SDLK_SPACE';
    71:   const SDLK_WORLD_33: SDLKey = 'SDLK_WORLD_33';
    72:   const SDLK_WORLD_34: SDLKey = 'SDLK_WORLD_34';
    73:   const SDLK_WORLD_35: SDLKey = 'SDLK_WORLD_35';
    74:   const SDLK_PLUS: SDLKey = 'SDLK_PLUS';
    75:   const SDLK_WORLD_36: SDLKey = 'SDLK_WORLD_36';
    76:   const SDLK_WORLD_37: SDLKey = 'SDLK_WORLD_37';
    77:   const SDLK_WORLD_38: SDLKey = 'SDLK_WORLD_38';
    78:   const SDLK_KP_PERIOD: SDLKey = 'SDLK_KP_PERIOD';
    79:   const SDLK_PAUSE: SDLKey = 'SDLK_PAUSE';
    80:   const SDLK_WORLD_39: SDLKey = 'SDLK_WORLD_39';
    81:   const SDLK_KP_MINUS: SDLKey = 'SDLK_KP_MINUS';
    82:   const KMOD_LALT: SDLKey = 'KMOD_LALT';
    83:   const SDLK_TAB: SDLKey = 'SDLK_TAB';
    84:   const SDLK_0: SDLKey = 'SDLK_0';
    85:   const SDLK_COMPOSE: SDLKey = 'SDLK_COMPOSE';
    86:   const SDLK_1: SDLKey = 'SDLK_1';
    87:   const SDLK_2: SDLKey = 'SDLK_2';
    88:   const SDLK_LALT: SDLKey = 'SDLK_LALT';
    89:   const SDLK_3: SDLKey = 'SDLK_3';
    90:   const SDLK_WORLD_40: SDLKey = 'SDLK_WORLD_40';
    91:   const SDLK_4: SDLKey = 'SDLK_4';
    92:   const SDLK_WORLD_41: SDLKey = 'SDLK_WORLD_41';
    93:   const SDLK_5: SDLKey = 'SDLK_5';
    94:   const SDLK_RCTRL: SDLKey = 'SDLK_RCTRL';
    95:   const SDLK_WORLD_42: SDLKey = 'SDLK_WORLD_42';
    96:   const SDLK_6: SDLKey = 'SDLK_6';
    97:   const KMOD_RALT: SDLKey = 'KMOD_RALT';
    98:   const SDLK_WORLD_43: SDLKey = 'SDLK_WORLD_43';
    99:   const SDLK_7: SDLKey = 'SDLK_7';
   100:   const SDLK_WORLD_44: SDLKey = 'SDLK_WORLD_44';
   101:   const SDLK_8: SDLKey = 'SDLK_8';
   102:   const SDLK_WORLD_45: SDLKey = 'SDLK_WORLD_45';
   103:   const SDLK_9: SDLKey = 'SDLK_9';
   104:   const SDLK_ESCAPE: SDLKey = 'SDLK_ESCAPE';
   105:   const SDLK_WORLD_46: SDLKey = 'SDLK_WORLD_46';
   106:   const SDLK_WORLD_47: SDLKey = 'SDLK_WORLD_47';
   107:   const SDLK_BACKQUOTE: SDLKey = 'SDLK_BACKQUOTE';
   108:   const SDLK_RALT: SDLKey = 'SDLK_RALT';
   109:   const SDLK_WORLD_48: SDLKey = 'SDLK_WORLD_48';
   110:   const SDLK_CARET: SDLKey = 'SDLK_CARET';
   111:   const SDLK_WORLD_49: SDLKey = 'SDLK_WORLD_49';
   112:   const SDLK_RIGHT: SDLKey = 'SDLK_RIGHT';
   113:   const SDLK_DELETE: SDLKey = 'SDLK_DELETE';
   114:   const SDLK_RSHIFT: SDLKey = 'SDLK_RSHIFT';
   115:   const SDLK_LESS: SDLKey = 'SDLK_LESS';
   116:   const SDLK_AMPERSAND: SDLKey = 'SDLK_AMPERSAND';
   117:   const SDLK_BACKSLASH: SDLKey = 'SDLK_BACKSLASH';
   118:   const SDLK_WORLD_50: SDLKey = 'SDLK_WORLD_50';
   119:   const SDLK_WORLD_51: SDLKey = 'SDLK_WORLD_51';
   120:   const KMOD_LSHIFT: SDLKey = 'KMOD_LSHIFT';
   121:   const SDLK_WORLD_52: SDLKey = 'SDLK_WORLD_52';
   122:   const SDLK_WORLD_53: SDLKey = 'SDLK_WORLD_53';
   123:   const SDLK_WORLD_54: SDLKey = 'SDLK_WORLD_54';
   124:   const SDLK_RMETA: SDLKey = 'SDLK_RMETA';
   125:   const SDLK_WORLD_55: SDLKey = 'SDLK_WORLD_55';
   126:   const SDLK_WORLD_56: SDLKey = 'SDLK_WORLD_56';
   127:   const SDLK_LCTRL: SDLKey = 'SDLK_LCTRL';
   128:   const SDLK_WORLD_57: SDLKey = 'SDLK_WORLD_57';
   129:   const SDLK_WORLD_58: SDLKey = 'SDLK_WORLD_58';
   130:   const SDLK_WORLD_59: SDLKey = 'SDLK_WORLD_59';
   131:   const SDLK_RETURN: SDLKey = 'SDLK_RETURN';
   132:   const SDLK_QUESTION: SDLKey = 'SDLK_QUESTION';
   133:   const SDLK_BREAK: SDLKey = 'SDLK_BREAK';
   134:   const SDLK_RSUPER: SDLKey = 'SDLK_RSUPER';
   135:   const SDLK_WORLD_60: SDLKey = 'SDLK_WORLD_60';
   136:   const SDLK_WORLD_61: SDLKey = 'SDLK_WORLD_61';
   137:   const KMOD_MODE: SDLKey = 'KMOD_MODE';
   138:   const SDLK_WORLD_62: SDLKey = 'SDLK_WORLD_62';
   139:   const SDLK_UNDERSCORE: SDLKey = 'SDLK_UNDERSCORE';
   140:   const SDLK_WORLD_63: SDLKey = 'SDLK_WORLD_63';
   141:   const SDLK_UNKNOWN: SDLKey = 'SDLK_UNKNOWN';
   142:   const SDLK_WORLD_64: SDLKey = 'SDLK_WORLD_64';
   143:   const SDLK_BACKSPACE: SDLKey = 'SDLK_BACKSPACE';
   144:   const SDLK_WORLD_65: SDLKey = 'SDLK_WORLD_65';
   145:   const SDLK_EQUALS: SDLKey = 'SDLK_EQUALS';
   146:   const SDLK_WORLD_66: SDLKey = 'SDLK_WORLD_66';
   147:   const SDLK_PAGEDOWN: SDLKey = 'SDLK_PAGEDOWN';
   148:   const SDLK_MODE: SDLKey = 'SDLK_MODE';
   149:   const SDLK_WORLD_67: SDLKey = 'SDLK_WORLD_67';
   150:   const SDLK_a: SDLKey = 'SDLK_a';
   151:   const SDLK_WORLD_68: SDLKey = 'SDLK_WORLD_68';
   152:   const SDLK_HOME: SDLKey = 'SDLK_HOME';
   153:   const SDLK_b: SDLKey = 'SDLK_b';
   154:   const SDLK_WORLD_69: SDLKey = 'SDLK_WORLD_69';
   155:   const SDLK_c: SDLKey = 'SDLK_c';
   156:   const SDLK_LMETA: SDLKey = 'SDLK_LMETA';
   157:   const SDLK_d: SDLKey = 'SDLK_d';
   158:   const SDLK_e: SDLKey = 'SDLK_e';
   159:   const SDLK_RIGHTBRACKET: SDLKey = 'SDLK_RIGHTBRACKET';
   160:   const SDLK_f: SDLKey = 'SDLK_f';
   161:   const SDLK_g: SDLKey = 'SDLK_g';
   162:   const SDLK_h: SDLKey = 'SDLK_h';
   163:   const SDLK_i: SDLKey = 'SDLK_i';
   164:   const SDLK_j: SDLKey = 'SDLK_j';
   165:   const SDLK_k: SDLKey = 'SDLK_k';
   166:   const SDLK_PRINT: SDLKey = 'SDLK_PRINT';
   167:   const SDLK_l: SDLKey = 'SDLK_l';
   168:   const SDLK_m: SDLKey = 'SDLK_m';
   169:   const SDLK_WORLD_70: SDLKey = 'SDLK_WORLD_70';
   170:   const SDLK_n: SDLKey = 'SDLK_n';
   171:   const SDLK_WORLD_71: SDLKey = 'SDLK_WORLD_71';
   172:   const SDLK_o: SDLKey = 'SDLK_o';
   173:   const SDLK_WORLD_72: SDLKey = 'SDLK_WORLD_72';
   174:   const SDLK_p: SDLKey = 'SDLK_p';
   175:   const SDLK_WORLD_73: SDLKey = 'SDLK_WORLD_73';
   176:   const SDLK_q: SDLKey = 'SDLK_q';
   177:   const SDLK_WORLD_74: SDLKey = 'SDLK_WORLD_74';
   178:   const SDLK_r: SDLKey = 'SDLK_r';
   179:   const SDLK_COLON: SDLKey = 'SDLK_COLON';
   180:   const SDLK_WORLD_75: SDLKey = 'SDLK_WORLD_75';
   181:   const SDLK_s: SDLKey = 'SDLK_s';
   182:   const SDLK_WORLD_76: SDLKey = 'SDLK_WORLD_76';
   183:   const SDLK_t: SDLKey = 'SDLK_t';
   184:   const SDLK_WORLD_77: SDLKey = 'SDLK_WORLD_77';
   185:   const SDLK_u: SDLKey = 'SDLK_u';
   186:   const SDLK_WORLD_78: SDLKey = 'SDLK_WORLD_78';
   187:   const SDLK_v: SDLKey = 'SDLK_v';
   188:   const SDLK_WORLD_79: SDLKey = 'SDLK_WORLD_79';
   189:   const SDLK_w: SDLKey = 'SDLK_w';
   190:   const SDLK_x: SDLKey = 'SDLK_x';
   191:   const SDLK_PERIOD: SDLKey = 'SDLK_PERIOD';
   192:   const SDLK_SEMICOLON: SDLKey = 'SDLK_SEMICOLON';
   193:   const KMOD_NONE: SDLKey = 'KMOD_NONE';
   194:   const SDLK_y: SDLKey = 'SDLK_y';
   195:   const SDLK_EURO: SDLKey = 'SDLK_EURO';
   196:   const SDLK_z: SDLKey = 'SDLK_z';
   197:   const SDLK_SYSREQ: SDLKey = 'SDLK_SYSREQ';
   198:   const SDLK_GREATER: SDLKey = 'SDLK_GREATER';
   199:   const SDLK_DOLLAR: SDLKey = 'SDLK_DOLLAR';
   200:   const SDLK_WORLD_80: SDLKey = 'SDLK_WORLD_80';
   201:   const SDLK_WORLD_81: SDLKey = 'SDLK_WORLD_81';
   202:   const SDLK_WORLD_82: SDLKey = 'SDLK_WORLD_82';
   203:   const SDLK_F10: SDLKey = 'SDLK_F10';
   204:   const SDLK_WORLD_83: SDLKey = 'SDLK_WORLD_83';
   205:   const SDLK_F11: SDLKey = 'SDLK_F11';
   206:   const SDLK_WORLD_84: SDLKey = 'SDLK_WORLD_84';
   207:   const SDLK_LSHIFT: SDLKey = 'SDLK_LSHIFT';
   208:   const SDLK_F12: SDLKey = 'SDLK_F12';
   209:   const SDLK_WORLD_85: SDLKey = 'SDLK_WORLD_85';
   210:   const SDLK_F13: SDLKey = 'SDLK_F13';
   211:   const SDLK_PAGEUP: SDLKey = 'SDLK_PAGEUP';
   212:   const SDLK_WORLD_86: SDLKey = 'SDLK_WORLD_86';
   213:   const SDLK_F14: SDLKey = 'SDLK_F14';
   214:   const SDLK_UP: SDLKey = 'SDLK_UP';
   215:   const SDLK_WORLD_87: SDLKey = 'SDLK_WORLD_87';
   216:   const KMOD_RCTRL: SDLKey = 'KMOD_RCTRL';
   217:   const SDLK_F15: SDLKey = 'SDLK_F15';
   218:   const SDLK_WORLD_88: SDLKey = 'SDLK_WORLD_88';
   219:   const SDLK_WORLD_89: SDLKey = 'SDLK_WORLD_89';
   220:   const SDLK_KP_MULTIPLY: SDLKey = 'SDLK_KP_MULTIPLY';
   221:   const SDLK_END: SDLKey = 'SDLK_END';
   222:   const SDLK_WORLD_90: SDLKey = 'SDLK_WORLD_90';
   223:   const SDLK_CLEAR: SDLKey = 'SDLK_CLEAR';
   224:   const SDLK_WORLD_91: SDLKey = 'SDLK_WORLD_91';
   225:   const SDLK_AT: SDLKey = 'SDLK_AT';
   226:   const SDLK_WORLD_92: SDLKey = 'SDLK_WORLD_92';
   227:   const SDLK_WORLD_93: SDLKey = 'SDLK_WORLD_93';
   228:   const SDLK_KP_DIVIDE: SDLKey = 'SDLK_KP_DIVIDE';
   229:   const SDLK_WORLD_94: SDLKey = 'SDLK_WORLD_94';
   230:   const SDLK_WORLD_95: SDLKey = 'SDLK_WORLD_95';
   231:   const SDLK_ASTERISK: SDLKey = 'SDLK_ASTERISK';
   232:   const SDLK_LSUPER: SDLKey = 'SDLK_LSUPER';
   233:   const KMOD_RESERVED: SDLKey = 'KMOD_RESERVED';
   234:   const KMOD_RMETA: SDLKey = 'KMOD_RMETA';
   235:   const KMOD_LCTRL: SDLKey = 'KMOD_LCTRL';
   236:   const SDLK_DOWN: SDLKey = 'SDLK_DOWN';
   237:   const SDLK_NUMLOCK: SDLKey = 'SDLK_NUMLOCK';
   238:   const SDLK_EXCLAIM: SDLKey = 'SDLK_EXCLAIM';
   239:   const KMOD_LMETA: SDLKey = 'KMOD_LMETA';
   240:   const SDLK_LAST: SDLKey = 'SDLK_LAST';
   241:   const SDLK_HELP: SDLKey = 'SDLK_HELP';
   242:   const SDLK_KP0: SDLKey = 'SDLK_KP0';
   243:   const SDLK_KP1: SDLKey = 'SDLK_KP1';
   244:   const SDLK_KP2: SDLKey = 'SDLK_KP2';
   245:   const SDLK_SCROLLOCK: SDLKey = 'SDLK_SCROLLOCK';
   246:   const SDLK_KP3: SDLKey = 'SDLK_KP3';
   247:   const SDLK_KP_PLUS: SDLKey = 'SDLK_KP_PLUS';
   248:   const SDLK_INSERT: SDLKey = 'SDLK_INSERT';
   249:   const SDLK_KP4: SDLKey = 'SDLK_KP4';
   250:   const SDLK_WORLD_10: SDLKey = 'SDLK_WORLD_10';
   251:   const SDLK_KP5: SDLKey = 'SDLK_KP5';
   252:   const SDLK_WORLD_11: SDLKey = 'SDLK_WORLD_11';
   253:   const SDLK_MINUS: SDLKey = 'SDLK_MINUS';
   254:   const SDLK_KP6: SDLKey = 'SDLK_KP6';
   255:   const SDLK_WORLD_12: SDLKey = 'SDLK_WORLD_12';
   256:   const SDLK_LEFTBRACKET: SDLKey = 'SDLK_LEFTBRACKET';
   257:   const SDLK_KP7: SDLKey = 'SDLK_KP7';
   258:   const SDLK_WORLD_13: SDLKey = 'SDLK_WORLD_13';
   259:   const SDLK_KP8: SDLKey = 'SDLK_KP8';
   260:   const SDLK_WORLD_14: SDLKey = 'SDLK_WORLD_14';
   261:   const SDLK_KP9: SDLKey = 'SDLK_KP9';
   262:   const SDLK_RIGHTPAREN: SDLKey = 'SDLK_RIGHTPAREN';
   263:   const SDLK_WORLD_15: SDLKey = 'SDLK_WORLD_15';
   264:   const SDLK_WORLD_16: SDLKey = 'SDLK_WORLD_16';
   265:   const SDLK_QUOTE: SDLKey = 'SDLK_QUOTE';
   266:   const SDLK_FIRST: SDLKey = 'SDLK_FIRST';
   267:   const SDLK_WORLD_17: SDLKey = 'SDLK_WORLD_17';
   268:   const KMOD_NUM: SDLKey = 'KMOD_NUM';
   269:   const SDLK_WORLD_18: SDLKey = 'SDLK_WORLD_18';
   270:   const SDLK_WORLD_19: SDLKey = 'SDLK_WORLD_19';
   271:   const SDLK_QUOTEDBL: SDLKey = 'SDLK_QUOTEDBL';
   272:   const KMOD_RSHIFT: SDLKey = 'KMOD_RSHIFT';
   273:   const SDLK_MENU: SDLKey = 'SDLK_MENU';
   274:   const KMOD_CAPS: SDLKey = 'KMOD_CAPS';
   275:   const SDLK_WORLD_0: SDLKey = 'SDLK_WORLD_0';
   276: 
   277:   fun eq: SDLKey * SDLKey -> bool = "$1==$2";
   278:   fun ne: SDLKey * SDLKey -> bool = "$1!=$2";
   279: }
   280: 
End felix section to lib/SDL/SDL_keysym.flx[1]
Start felix section to lib/SDL/SDL_mouse.flx[1 /1 ]
     1: #line 1275 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_mouse_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_mouse.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_BUTTON_RMASK      SDL_BUTTON(SDL_BUTTON_RIGHT)
    13: //#define SDL_BUTTON_MMASK      SDL_BUTTON(SDL_BUTTON_MIDDLE)
    14: //#define SDL_BUTTON_LMASK      SDL_BUTTON(SDL_BUTTON_LEFT)
    15: //#define SDL_BUTTON_WHEELDOWN  5
    16: //#define SDL_BUTTON_WHEELUP    4
    17: //#define SDL_BUTTON_RIGHT      3
    18: //#define SDL_BUTTON_MIDDLE     2
    19: //#define SDL_BUTTON_LEFT               1
    20: //#define SDL_BUTTON(X)         (SDL_PRESSED<<(X-1))
    21: //#define _SDL_mouse_h
    22: 
    23: //INCLUDES
    24: include"SDL/SDL_video";
    25: 
    26: module SDL_mouse_h
    27: {
    28:   requires package "sdl";
    29:   header '#include "SDL_mouse.h"';
    30:   open C_hack;
    31:   open SDL_video_h;
    32: 
    33:   //CSTRUCTS
    34:   cstruct SDL_Cursor {
    35:     area: SDL_Rect;
    36:     hot_x: int16;
    37:     hot_y: int16;
    38:     data: ptr[uint8];
    39:     mask: ptr[uint8];
    40:     save: ptr[ptr[uint8]];
    41:     wm_cursor: ptr[WMcursor];
    42:   }
    43: 
    44:   //PURE INCOMPLETE TYPES
    45:   type _struct_WMcursor = 'struct WMcursor'; //local
    46: 
    47:   //STRUCT or UNION TAG ALIASES
    48:   typedef WMcursor = _struct_WMcursor;
    49: 
    50:   /*
    51:   //TYPE ALIASES
    52:   typedef _struct_SDL_Cursor = SDL_Cursor;
    53:   */
    54: 
    55:   //PROCEDURES
    56:   proc SDL_FreeCursor: ptr[SDL_Cursor];
    57:   proc SDL_SetCursor: ptr[SDL_Cursor];
    58:   proc SDL_WarpMouse: uint16 * uint16;
    59: 
    60:   //FUNCTIONS
    61:   fun SDL_CreateCursor: ptr[uint8] * ptr[uint8] * int * int * int * int -> ptr[SDL_Cursor];
    62:   fun SDL_GetCursor: 1 -> ptr[SDL_Cursor];
    63:   fun SDL_GetMouseState: ptr[int] * ptr[int] -> uint8;
    64:   fun SDL_GetRelativeMouseState: ptr[int] * ptr[int] -> uint8;
    65:   fun SDL_ShowCursor: int -> int;
    66: }
End felix section to lib/SDL/SDL_mouse.flx[1]
Start felix section to lib/SDL/SDL_mutex.flx[1 /1 ]
     1: #line 1342 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_mutex_h
     3: //Timestamp     : 2006/1/6 2:5:23 UTC
     4: //Timestamp     : 2006/1/6 13:5:23 (local)
     5: //Raw Header    : SDL_mutex.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_MUTEX_MAXWAIT     (~(Uint32)0)
    13: //#define SDL_MUTEX_TIMEDOUT    1
    14: //#define _SDL_mutex_h
    15: 
    16: // DO NOT USE THIS MODULE
    17: // FELIX HAS ITS OWN THREAD HANDLING
    18: 
    19: module SDL_mutex_h
    20: {
    21:   requires package "sdl";
    22:   header '#include "SDL_mutex.h"';
    23:   open C_hack;
    24: 
    25:   incomplete ctypes SDL_mutex, SDL_cond, SDL_sem;
    26: 
    27:   //PROCEDURES
    28:   proc SDL_DestroyCond: ptr[SDL_cond];
    29:   proc SDL_DestroyMutex: ptr[SDL_mutex];
    30:   proc SDL_DestroySemaphore: ptr[SDL_sem];
    31: 
    32:   //FUNCTIONS
    33:   fun SDL_CondBroadcast: ptr[SDL_cond] -> int;
    34:   fun SDL_CondSignal: ptr[SDL_cond] -> int;
    35:   fun SDL_CondWait: ptr[SDL_cond] * ptr[SDL_mutex] -> int;
    36:   fun SDL_CondWaitTimeout: ptr[SDL_cond] * ptr[SDL_mutex] * uint32 -> int;
    37:   fun SDL_CreateCond: 1 -> ptr[SDL_cond];
    38:   fun SDL_CreateMutex: 1 -> ptr[SDL_mutex];
    39:   fun SDL_CreateSemaphore: uint32 -> ptr[SDL_sem];
    40:   fun SDL_SemPost: ptr[SDL_sem] -> int;
    41:   fun SDL_SemTryWait: ptr[SDL_sem] -> int;
    42:   fun SDL_SemValue: ptr[SDL_sem] -> uint32;
    43:   fun SDL_SemWait: ptr[SDL_sem] -> int;
    44:   fun SDL_SemWaitTimeout: ptr[SDL_sem] * uint32 -> int;
    45:   fun SDL_mutexP: ptr[SDL_mutex] -> int;
    46:   fun SDL_mutexV: ptr[SDL_mutex] -> int;
    47:   fun SDL_LockMutex: ptr[SDL_mutex] -> int;
    48:   fun SDL_UnlockMutex: ptr[SDL_mutex] -> int;
    49: }
End felix section to lib/SDL/SDL_mutex.flx[1]
Start felix section to lib/SDL/SDL_rwops.flx[1 /1 ]
     1: #line 1392 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_rwops_h
     3: //Timestamp     : 2006/1/6 2:5:23 UTC
     4: //Timestamp     : 2006/1/6 13:5:23 (local)
     5: //Raw Header    : SDL_rwops.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_RWclose(ctx)              (ctx)->close(ctx)
    13: //#define SDL_RWwrite(ctx, ptr, size, n)        (ctx)->write(ctx, ptr, size, n)
    14: //#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
    15: //#define SDL_RWtell(ctx)                       (ctx)->seek(ctx, 0, SEEK_CUR)
    16: //#define SDL_RWseek(ctx, offset, whence)       (ctx)->seek(ctx, offset, whence)
    17: //#define _SDL_RWops_h
    18: 
    19: //INCLUDES
    20: 
    21: module SDL_rwops_h
    22: {
    23:   open C_hack;
    24: 
    25:   //ABSTRACT TYPES
    26:   type _struct_SDL_RWops = 'struct SDL_RWops';
    27: 
    28:   //C FUNCTION POINTER TYPES
    29:   header '''typedef int (*SDL_rwops_h_cft_1)(struct SDL_RWops *,  int, int);''';
    30:   type SDL_rwops_h_cft_1 = 'SDL_rwops_h_cft_1';
    31:   header '''typedef int (*SDL_rwops_h_cft_3)(struct SDL_RWops *,  void const *,  int, int);''';
    32:   type SDL_rwops_h_cft_3 = 'SDL_rwops_h_cft_3';
    33:   header '''typedef int (*SDL_rwops_h_cft_2)(struct SDL_RWops *,  void *, int,  int);''';
    34:   type SDL_rwops_h_cft_2 = 'SDL_rwops_h_cft_2';
    35:   header '''typedef int (*SDL_rwops_h_cft_4)(struct SDL_RWops *);''';
    36:   type SDL_rwops_h_cft_4 = 'SDL_rwops_h_cft_4';
    37: 
    38:   //STRUCT or UNION TAG ALIASES
    39:   typedef SDL_RWops = _struct_SDL_RWops;
    40: 
    41:   //PROCEDURES
    42:   proc SDL_FreeRW: ptr[SDL_RWops];
    43: 
    44:   //FUNCTIONS
    45:   fun SDL_AllocRW: 1 -> ptr[SDL_RWops];
    46:   fun SDL_RWFromConstMem: caddress * int -> ptr[SDL_RWops];
    47:   fun SDL_RWFromFP: ptr[FILE] * int -> ptr[SDL_RWops];
    48:   fun SDL_RWFromFile: cptr[char] * cptr[char] -> ptr[SDL_RWops];
    49:   fun SDL_RWFromMem: address * int -> ptr[SDL_RWops];
    50: 
    51:   //STRUCT and UNION FIELDS
    52:   fun get_read: _struct_SDL_RWops -> SDL_rwops_h_cft_2 = '$1->read';
    53:   fun get_write: _struct_SDL_RWops -> SDL_rwops_h_cft_3 = '$1->write';
    54:   fun get_seek: _struct_SDL_RWops -> SDL_rwops_h_cft_1 = '$1->seek';
    55:   fun get_close: _struct_SDL_RWops -> SDL_rwops_h_cft_4 = '$1->close';
    56:   fun get_type: _struct_SDL_RWops -> uint32 = '$1->type';
    57: }
End felix section to lib/SDL/SDL_rwops.flx[1]
Start felix section to lib/SDL/SDL_timer.flx[1 /1 ]
     1: #line 1450 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_timer_h
     3: //Timestamp     : 2006/1/6 2:5:23 UTC
     4: //Timestamp     : 2006/1/6 13:5:23 (local)
     5: //Raw Header    : SDL_timer.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define TIMER_RESOLUTION      10      /* Experimentally determined */
    13: //#define SDL_TIMESLICE         10
    14: //#define _SDL_timer_h
    15: 
    16: //INCLUDES
    17: include"SDL/SDL_types";
    18: 
    19: module SDL_timer_h
    20: {
    21:   requires package "sdl";
    22:   header '#include "SDL_timer.h"';
    23:   open C_hack;
    24:   open SDL_types_h;
    25: 
    26:   //C FUNCTION POINTER TYPES
    27:   header '''typedef Uint32 (*SDL_timer_h_cft_2)(Uint32,  void *);''';
    28:   type SDL_timer_h_cft_2 = 'SDL_timer_h_cft_2';
    29:   header '''typedef Uint32 (*SDL_timer_h_cft_1)(Uint32);''';
    30:   type SDL_timer_h_cft_1 = 'SDL_timer_h_cft_1';
    31: 
    32:   //PURE INCOMPLETE TYPES
    33:   type _struct__SDL_TimerID = 'struct _SDL_TimerID'; //local
    34: 
    35:   //TYPE ALIASES
    36:   typedef SDL_NewTimerCallback = SDL_timer_h_cft_2;
    37:   typedef SDL_TimerID = ptr[_struct__SDL_TimerID];
    38:   typedef SDL_TimerCallback = SDL_timer_h_cft_1;
    39: 
    40:   //PROCEDURES
    41:   proc SDL_Delay: uint32;
    42: 
    43:   //FUNCTIONS
    44:   fun SDL_AddTimer: uint32 * SDL_timer_h_cft_2 * address -> SDL_TimerID;
    45:   fun SDL_GetTicks: 1 -> uint32;
    46:   fun SDL_RemoveTimer: SDL_TimerID -> SDL_bool;
    47:   fun SDL_SetTimer: uint32 * SDL_timer_h_cft_1 -> int;
    48: 
    49:   //CALLBACK TYPE WRAPPERS
    50:   //callback type SDL_timer_h_cft_2, client data at 1
    51:   typedef _fcbat_SDL_timer_h_cft_2 = uint32;
    52:   export type (_fcbat_SDL_timer_h_cft_2) as "_fcbat_SDL_timer_h_cft_2";
    53:   typedef _fcbt_SDL_timer_h_cft_2 = uint32 -> uint32;
    54:   export type (_fcbt_SDL_timer_h_cft_2) as "_fcbt_SDL_timer_h_cft_2";
    55:   header '''Uint32 _fcbw_SDL_timer_h_cft_2(Uint32 a1,  void *a2);''';
    56: 
    57:   const _fcbw_SDL_timer_h_cft_2: SDL_timer_h_cft_2 = "_fcbw_SDL_timer_h_cft_2";
    58:   body '''
    59:   Uint32 _fcbw_SDL_timer_h_cft_2(Uint32 a1,  void *a2){
    60:     return ((_fcbt_SDL_timer_h_cft_2)a2)->apply(a1);
    61:   }''';
    62: 
    63: 
    64:   //CALLBACK CLIENT WRAPPERS
    65:   //callback client SDL_AddTimer, client data at 1, callback at 2
    66:   fun wrapper_SDL_AddTimer(a1: uint32, a2: _fcbt_SDL_timer_h_cft_2): SDL_TimerID= {
    67:     return SDL_AddTimer(a1, _fcbw_SDL_timer_h_cft_2, C_hack::cast[address]a2);
    68:   }
    69: }
End felix section to lib/SDL/SDL_timer.flx[1]
Start felix section to lib/SDL/SDL_types.flx[1 /1 ]
     1: #line 1520 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_types_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_types.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_COMPILE_TIME_ASSERT(name, x)               \
    13: //#define SDL_HAS_64BIT_TYPE    __int64
    14: //#define SDL_HAS_64BIT_TYPE    long long
    15: //#define SDL_HAS_64BIT_TYPE    long
    16: //#define SDL_TABLESIZE(table)  (sizeof(table)/sizeof(table[0]))
    17: //#define _SDL_types_h
    18: 
    19: module SDL_types_h
    20: {
    21:   requires package "sdl";
    22:   header '#include "SDL_types.h"';
    23:   open C_hack;
    24: 
    25:   //ABSTRACT TYPES
    26:   type SDL_bool = 'SDL_bool';
    27:   type SDL_DUMMY_ENUM = 'SDL_DUMMY_ENUM';
    28: 
    29:   //TYPE ALIASES
    30:   typedef Sint64 = vlong;
    31:   typedef SDL_dummy_uint32 = ptr[int];
    32:   typedef SDL_dummy_sint64 = ptr[int];
    33:   typedef SDL_dummy_sint16 = ptr[int];
    34:   typedef SDL_dummy_sint8 = ptr[int];
    35:   typedef SDL_dummy_sint32 = ptr[int];
    36:   typedef SDL_dummy_uint8 = ptr[int];
    37:   typedef Uint64 = uvlong;
    38:   typedef SDL_dummy_uint64 = ptr[int];
    39:   typedef SDL_dummy_uint16 = ptr[int];
    40:   typedef SDL_dummy_enum = ptr[int];
    41: 
    42:   //ENUMERATION CONSTANTS
    43:   const SDL_PRESSED: int = 'SDL_PRESSED';
    44:   const DUMMY_ENUM_VALUE: int = 'DUMMY_ENUM_VALUE';
    45:   const SDL_RELEASED: int = 'SDL_RELEASED';
    46:   const SDL_TRUE: int = 'SDL_TRUE';
    47:   const SDL_FALSE: int = 'SDL_FALSE';
    48: }
End felix section to lib/SDL/SDL_types.flx[1]
Start felix section to lib/SDL/SDL_version.flx[1 /1 ]
     1: #line 1569 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_version_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_version.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_VERSION_ATLEAST(X, Y, Z) \
    13: //#define SDL_COMPILEDVERSION \
    14: //#define SDL_VERSIONNUM(X, Y, Z)                                               \
    15: //#define SDL_VERSION(X)                                                        \
    16: //#define SDL_PATCHLEVEL                8
    17: //#define SDL_MINOR_VERSION     2
    18: //#define SDL_MAJOR_VERSION     1
    19: //#define _SDL_version_h
    20: 
    21: module SDL_version_h
    22: {
    23:   requires package "sdl";
    24:   header '#include "SDL_version.h"';
    25:   open C_hack;
    26: 
    27:   //CSTRUCTS
    28:   cstruct SDL_version {
    29:     major: uint8;
    30:     minor: uint8;
    31:     patch: uint8;
    32:   }
    33: 
    34:   //STRUCT or UNION TAG ALIASES
    35: 
    36:   //TYPE ALIASES
    37:   typedef _struct_SDL_version = SDL_version;
    38: 
    39:   //FUNCTIONS
    40:   fun SDL_Linked_Version: 1 -> cptr[SDL_version];
    41: }
End felix section to lib/SDL/SDL_version.flx[1]
Start felix section to lib/SDL/SDL_video.flx[1 /1 ]
     1: #line 1611 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_video_h
     3: //Timestamp     : 2006/1/6 2:18:42 UTC
     4: //Timestamp     : 2006/1/6 13:18:42 (local)
     5: //Raw Header    : SDL_video.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_BlitSurface SDL_UpperBlit
    13: //#define SDL_SaveBMP(surface, file) \
    14: //#define SDL_AllocSurface    SDL_CreateRGBSurface
    15: //#define SDL_PHYSPAL 0x02
    16: //#define SDL_LOGPAL 0x01
    17: //#define SDL_YVYU_OVERLAY  0x55595659  /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
    18: //#define SDL_UYVY_OVERLAY  0x59565955  /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
    19: //#define SDL_YUY2_OVERLAY  0x32595559  /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
    20: //#define SDL_IYUV_OVERLAY  0x56555949  /* Planar mode: Y + U + V  (3 planes) */
    21: //#define SDL_YV12_OVERLAY  0x32315659  /* Planar mode: Y + V + U  (3 planes) */
    22: //#define SDL_PREALLOC  0x01000000      /* Surface uses preallocated memory */
    23: //#define SDL_SRCALPHA  0x00010000      /* Blit uses source alpha blending */
    24: //#define SDL_RLEACCEL  0x00004000      /* Surface is RLE encoded */
    25: //#define SDL_RLEACCELOK        0x00002000      /* Private flag */
    26: //#define SDL_SRCCOLORKEY       0x00001000      /* Blit uses a source color key */
    27: //#define SDL_HWACCEL   0x00000100      /* Blit uses hardware acceleration */
    28: //#define SDL_NOFRAME   0x00000020      /* No window caption or edge frame */
    29: //#define SDL_RESIZABLE 0x00000010      /* This video mode may be resized */
    30: //#define SDL_OPENGLBLIT        0x0000000A      /* Create an OpenGL rendering context and use it for blitting */
    31: //#define SDL_OPENGL      0x00000002      /* Create an OpenGL rendering context */
    32: //#define SDL_FULLSCREEN        0x80000000      /* Surface is a full screen display */
    33: //#define SDL_DOUBLEBUF 0x40000000      /* Set up double-buffered video mode */
    34: //#define SDL_HWPALETTE 0x20000000      /* Surface has exclusive palette */
    35: //#define SDL_ANYFORMAT 0x10000000      /* Allow any video depth/pixel-format */
    36: //#define SDL_ASYNCBLIT 0x00000004      /* Use asynchronous blits if possible */
    37: //#define SDL_HWSURFACE 0x00000001      /* Surface is in video memory */
    38: //#define SDL_SWSURFACE 0x00000000      /* Surface is in system memory */
    39: //#define SDL_Colour SDL_Color
    40: //#define SDL_ALPHA_TRANSPARENT 0
    41: //#define SDL_ALPHA_OPAQUE 255
    42: //#define _SDL_video_h
    43: 
    44: //INCLUDES
    45: include"SDL/SDL_rwops";
    46: include"SDL/SDL_types";
    47: 
    48: module SDL_video_h
    49: {
    50:   requires package "sdl";
    51:   header '#include "SDL_video.h"';
    52:   open C_hack;
    53:   open SDL_rwops_h;
    54:   open SDL_types_h;
    55: 
    56:   fun SDL_MUSTLOCK: ptr[SDL_Surface] -> bool;
    57:   const SDL_PHYSPAL : uint32;
    58:   const SDL_LOGPAL : uint32;
    59:   const SDL_YVYU_OVERLAY  : uint32;
    60:   const SDL_UYVY_OVERLAY  : uint32;
    61:   const SDL_YUY2_OVERLAY  : uint32;
    62:   const SDL_IYUV_OVERLAY  : uint32;
    63:   const SDL_YV12_OVERLAY  : uint32;
    64:   const SDL_PREALLOC  : uint32;
    65:   const SDL_SRCALPHA  : uint32;
    66:   const SDL_RLEACCEL  : uint32;
    67:   const SDL_RLEACCELOK        : uint32;
    68:   const SDL_SRCCOLORKEY       : uint32;
    69:   const SDL_HWACCEL   : uint32;
    70:   const SDL_NOFRAME   : uint32;
    71:   const SDL_RESIZABLE : uint32;
    72:   const SDL_OPENGLBLIT        : uint32;
    73:   const SDL_OPENGL      : uint32;
    74:   const SDL_FULLSCREEN        : uint32;
    75:   const SDL_DOUBLEBUF : uint32;
    76:   const SDL_HWPALETTE : uint32;
    77:   const SDL_ANYFORMAT : uint32;
    78:   const SDL_ASYNCBLIT : uint32;
    79:   const SDL_HWSURFACE : uint32;
    80:   const SDL_SWSURFACE : uint32;
    81: 
    82:   //ABSTRACT TYPES
    83:   type SDL_GrabMode = 'SDL_GrabMode';
    84:   type SDL_GLattr = 'SDL_GLattr';
    85: 
    86:   //CSTRUCTS
    87:   cstruct SDL_Color {
    88:     r: uint8;
    89:     g: uint8;
    90:     b: uint8;
    91:     unused: uint8;
    92:   }
    93:   cstruct SDL_Surface {
    94:     flags: uint32;
    95:     format: ptr[SDL_PixelFormat];
    96:     w: int;
    97:     h: int;
    98:     pitch: uint16;
    99:     pixels: address;
   100:     offset: int;
   101:     hwdata: ptr[_struct_private_hwdata];
   102:     clip_rect: SDL_Rect;
   103:     unused1: uint32;
   104:     locked: uint32;
   105:     map: ptr[_struct_SDL_BlitMap];
   106:     format_version: uint;
   107:     refcount: int;
   108:   }
   109:   cstruct SDL_Overlay {
   110:     format: uint32;
   111:     w: int;
   112:     h: int;
   113:     planes: int;
   114:     pitches: ptr[uint16];
   115:     pixels: ptr[ptr[uint8]];
   116:     hwfuncs: ptr[_struct_private_yuvhwfuncs];
   117:     hwdata: ptr[_struct_private_yuvhwdata];
   118:     hw_overlay: uint32;
   119:     UnusedBits: uint32;
   120:   }
   121:   cstruct SDL_Palette {
   122:     ncolors: int;
   123:     colors: ptr[SDL_Color];
   124:   }
   125:   cstruct SDL_Rect {
   126:     x: int16;
   127:     y: int16;
   128:     w: uint16;
   129:     h: uint16;
   130:   }
   131:   cstruct SDL_VideoInfo {
   132:     hw_available: uint32;
   133:     wm_available: uint32;
   134:     UnusedBits1: uint32;
   135:     UnusedBits2: uint32;
   136:     blit_hw: uint32;
   137:     blit_hw_CC: uint32;
   138:     blit_hw_A: uint32;
   139:     blit_sw: uint32;
   140:     blit_sw_CC: uint32;
   141:     blit_sw_A: uint32;
   142:     blit_fill: uint32;
   143:     UnusedBits3: uint32;
   144:     video_mem: uint32;
   145:     vfmt: ptr[SDL_PixelFormat];
   146:   }
   147:   cstruct SDL_PixelFormat {
   148:     palette: ptr[SDL_Palette];
   149:     BitsPerPixel: uint8;
   150:     BytesPerPixel: uint8;
   151:     Rloss: uint8;
   152:     Gloss: uint8;
   153:     Bloss: uint8;
   154:     Aloss: uint8;
   155:     Rshift: uint8;
   156:     Gshift: uint8;
   157:     Bshift: uint8;
   158:     Ashift: uint8;
   159:     Rmask: uint32;
   160:     Gmask: uint32;
   161:     Bmask: uint32;
   162:     Amask: uint32;
   163:     colorkey: uint32;
   164:     alpha: uint8;
   165:   }
   166: 
   167:   //C FUNCTION POINTER TYPES
   168:   header '''typedef int (*SDL_video_h_cft_1)(struct SDL_Surface *,  SDL_Rect *,  struct SDL_Surface *,  SDL_Rect *);''';
   169:   type SDL_video_h_cft_1 = 'SDL_video_h_cft_1';
   170: 
   171:   //EXTERNALLY COMPLETED TYPES
   172:   //type _struct_SDL_Surface defined in SDL_video_h='SDL_video.h';
   173: 
   174:   //PURE INCOMPLETE TYPES
   175:   type _struct_SDL_BlitMap = 'struct SDL_BlitMap'; //local
   176:   type _struct_private_yuvhwfuncs = 'struct private_yuvhwfuncs'; //local
   177:   type _struct_private_hwdata = 'struct private_hwdata'; //local
   178:   type _struct_private_yuvhwdata = 'struct private_yuvhwdata'; //local
   179: 
   180:   //STRUCT or UNION TAG ALIASES
   181: 
   182:   //TYPE ALIASES
   183:   typedef _struct_SDL_Surface = SDL_Surface;
   184:   typedef _struct_SDL_Overlay = SDL_Overlay;
   185:   typedef _struct_SDL_Palette = SDL_Palette;
   186:   typedef _struct_SDL_PixelFormat = SDL_PixelFormat;
   187:   typedef _struct_SDL_Rect = SDL_Rect;
   188:   typedef _struct_SDL_Color = SDL_Color;
   189:   typedef _struct_SDL_VideoInfo = SDL_VideoInfo;
   190:   typedef SDL_blit = SDL_video_h_cft_1;
   191: 
   192:   //ENUMERATION CONSTANTS
   193:   const SDL_GL_STENCIL_SIZE: int = 'SDL_GL_STENCIL_SIZE';
   194:   const SDL_GL_MULTISAMPLEBUFFERS: int = 'SDL_GL_MULTISAMPLEBUFFERS';
   195:   const SDL_GL_STEREO: int = 'SDL_GL_STEREO';
   196:   const SDL_GL_ACCUM_RED_SIZE: int = 'SDL_GL_ACCUM_RED_SIZE';
   197:   const SDL_GRAB_OFF: int = 'SDL_GRAB_OFF';
   198:   const SDL_GL_ACCUM_GREEN_SIZE: int = 'SDL_GL_ACCUM_GREEN_SIZE';
   199:   const SDL_GL_ACCUM_ALPHA_SIZE: int = 'SDL_GL_ACCUM_ALPHA_SIZE';
   200:   const SDL_GL_DEPTH_SIZE: int = 'SDL_GL_DEPTH_SIZE';
   201:   const SDL_GRAB_FULLSCREEN: int = 'SDL_GRAB_FULLSCREEN';
   202:   const SDL_GL_RED_SIZE: int = 'SDL_GL_RED_SIZE';
   203:   const SDL_GL_BLUE_SIZE: int = 'SDL_GL_BLUE_SIZE';
   204:   const SDL_GL_ACCUM_BLUE_SIZE: int = 'SDL_GL_ACCUM_BLUE_SIZE';
   205:   const SDL_GL_GREEN_SIZE: int = 'SDL_GL_GREEN_SIZE';
   206:   const SDL_GRAB_QUERY: int = 'SDL_GRAB_QUERY';
   207:   const SDL_GL_ALPHA_SIZE: int = 'SDL_GL_ALPHA_SIZE';
   208:   const SDL_GL_MULTISAMPLESAMPLES: int = 'SDL_GL_MULTISAMPLESAMPLES';
   209:   const SDL_GL_DOUBLEBUFFER: int = 'SDL_GL_DOUBLEBUFFER';
   210:   const SDL_GL_BUFFER_SIZE: int = 'SDL_GL_BUFFER_SIZE';
   211:   const SDL_GRAB_ON: int = 'SDL_GRAB_ON';
   212: 
   213:   //PROCEDURES
   214:   proc SDL_FreeSurface: ptr[SDL_Surface];
   215:   proc SDL_FreeYUVOverlay: ptr[SDL_Overlay];
   216:   proc SDL_GL_Lock: 1;
   217:   proc SDL_GL_SwapBuffers: 1;
   218:   proc SDL_GL_Unlock: 1;
   219:   proc SDL_GL_UpdateRects: int * ptr[SDL_Rect];
   220:   proc SDL_GetClipRect: ptr[SDL_Surface] * ptr[SDL_Rect];
   221:   proc SDL_GetRGB: uint32 * ptr[SDL_PixelFormat] * ptr[uint8] * ptr[uint8] * ptr[uint8];
   222:   proc SDL_GetRGBA: uint32 * ptr[SDL_PixelFormat] * ptr[uint8] * ptr[uint8] * ptr[uint8] * ptr[uint8];
   223:   proc SDL_UnlockSurface: ptr[SDL_Surface];
   224:   proc SDL_UnlockYUVOverlay: ptr[SDL_Overlay];
   225:   proc SDL_UpdateRect: ptr[SDL_Surface] * int32 * int32 * uint32 * uint32;
   226:   proc SDL_UpdateRects: ptr[SDL_Surface] * int * ptr[SDL_Rect];
   227:   proc SDL_VideoQuit: 1;
   228:   proc SDL_WM_GetCaption: ptr[ptr[char]] * ptr[ptr[char]];
   229:   proc SDL_WM_SetCaption: cptr[char] * cptr[char];
   230:   proc SDL_WM_SetIcon: ptr[SDL_Surface] * ptr[uint8];
   231: 
   232:   //FUNCTIONS
   233:   fun SDL_BlitSurface : ptr[SDL_Surface] * ptr[SDL_Rect] * ptr[SDL_Surface] * ptr[SDL_Rect] -> int;
   234:   fun SDL_ConvertSurface: ptr[SDL_Surface] * ptr[SDL_PixelFormat] * uint32 -> ptr[SDL_Surface];
   235:   fun SDL_CreateRGBSurface: uint32 * int * int * int * uint32 * uint32 * uint32 * uint32 -> ptr[SDL_Surface];
   236:   fun SDL_CreateRGBSurfaceFrom: address * int * int * int * int * uint32 * uint32 * uint32 * uint32 -> ptr[SDL_Surface];
   237:   fun SDL_CreateYUVOverlay: int * int * uint32 * ptr[SDL_Surface] -> ptr[SDL_Overlay];
   238:   fun SDL_DisplayFormat: ptr[SDL_Surface] -> ptr[SDL_Surface];
   239:   fun SDL_DisplayFormatAlpha: ptr[SDL_Surface] -> ptr[SDL_Surface];
   240:   fun SDL_DisplayYUVOverlay: ptr[SDL_Overlay] * ptr[SDL_Rect] -> int;
   241:   fun SDL_FillRect: ptr[SDL_Surface] * ptr[SDL_Rect] * uint32 -> int;
   242:   fun SDL_Flip: ptr[SDL_Surface] -> int;
   243:   fun SDL_GL_GetAttribute: SDL_GLattr * ptr[int] -> int;
   244:   fun SDL_GL_GetProcAddress: cptr[char] -> address;
   245:   fun SDL_GL_LoadLibrary: cptr[char] -> int;
   246:   fun SDL_GL_SetAttribute: SDL_GLattr * int -> int;
   247:   fun SDL_GetGammaRamp: ptr[uint16] * ptr[uint16] * ptr[uint16] -> int;
   248:   fun SDL_GetVideoInfo: 1 -> cptr[SDL_VideoInfo];
   249:   fun SDL_GetVideoSurface: 1 -> ptr[SDL_Surface];
   250:   fun SDL_ListModes: ptr[SDL_PixelFormat] * uint32 -> ptr[ptr[SDL_Rect]];
   251:   fun SDL_LoadBMP_RW: ptr[SDL_RWops] * int -> ptr[SDL_Surface];
   252:   fun SDL_LoadBMP:cptr[char]->ptr[SDL_Surface];
   253:   fun SDL_LockSurface: ptr[SDL_Surface] -> int;
   254:   fun SDL_LockYUVOverlay: ptr[SDL_Overlay] -> int;
   255:   fun SDL_LowerBlit: ptr[SDL_Surface] * ptr[SDL_Rect] * ptr[SDL_Surface] * ptr[SDL_Rect] -> int;
   256:   fun SDL_MapRGB: ptr[SDL_PixelFormat] * uint8 * uint8 * uint8 -> uint32;
   257:   fun SDL_MapRGBA: ptr[SDL_PixelFormat] * uint8 * uint8 * uint8 * uint8 -> uint32;
   258:   fun SDL_SaveBMP_RW: ptr[SDL_Surface] * ptr[SDL_RWops] * int -> int;
   259:   fun SDL_SetAlpha: ptr[SDL_Surface] * uint32 * uint8 -> int;
   260:   fun SDL_SetClipRect: ptr[SDL_Surface] * cptr[SDL_Rect] -> SDL_bool;
   261:   fun SDL_SetColorKey: ptr[SDL_Surface] * uint32 * uint32 -> int;
   262:   fun SDL_SetColors: ptr[SDL_Surface] * ptr[SDL_Color] * int * int -> int;
   263:   fun SDL_SetGamma: float * float * float -> int;
   264:   fun SDL_SetGammaRamp: cptr[uint16] * cptr[uint16] * cptr[uint16] -> int;
   265:   fun SDL_SetPalette: ptr[SDL_Surface] * int * ptr[SDL_Color] * int * int -> int;
   266:   fun SDL_SetVideoMode: int * int * int * uint32 -> ptr[SDL_Surface];
   267:   fun SDL_SoftStretch: ptr[SDL_Surface] * ptr[SDL_Rect] * ptr[SDL_Surface] * ptr[SDL_Rect] -> int;
   268:   fun SDL_UpperBlit: ptr[SDL_Surface] * ptr[SDL_Rect] * ptr[SDL_Surface] * ptr[SDL_Rect] -> int;
   269:   fun SDL_VideoDriverName: ptr[char] * int -> ptr[char];
   270:   fun SDL_VideoInit: cptr[char] * uint32 -> int;
   271:   fun SDL_VideoModeOK: int * int * int * uint32 -> int;
   272:   fun SDL_WM_GrabInput: SDL_GrabMode -> SDL_GrabMode;
   273:   fun SDL_WM_IconifyWindow: 1 -> int;
   274:   fun SDL_WM_ToggleFullScreen: ptr[SDL_Surface] -> int;
   275: }
   276: 
End felix section to lib/SDL/SDL_video.flx[1]
Start felix section to lib/SDL/SDL_endian.flx[1 /1 ]
     1: #line 1888 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_endian_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_endian.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDL_SwapBE64(X)       (X)
    13: //#define SDL_SwapBE32(X)       (X)
    14: //#define SDL_SwapBE16(X)       (X)
    15: //#define SDL_SwapLE64(X)       SDL_Swap64(X)
    16: //#define SDL_SwapLE32(X)       SDL_Swap32(X)
    17: //#define SDL_SwapLE16(X)       SDL_Swap16(X)
    18: //#define SDL_SwapBE64(X)       SDL_Swap64(X)
    19: //#define SDL_SwapBE32(X)       SDL_Swap32(X)
    20: //#define SDL_SwapBE16(X)       SDL_Swap16(X)
    21: //#define SDL_SwapLE64(X)       (X)
    22: //#define SDL_SwapLE32(X)       (X)
    23: //#define SDL_SwapLE16(X)       (X)
    24: //#define SDL_Swap64(X) (X)
    25: //#define _SDL_endian_h
    26: 
    27: //INCLUDES
    28: include "SDL/SDL_rwops";
    29: include "SDL/SDL_types";
    30: 
    31: module SDL_endian_h
    32: {
    33:   requires package "sdl";
    34:   header '#include "SDL_endian.h"';
    35:   open C_hack;
    36:   open SDL_rwops_h;
    37:   open SDL_types_h;
    38: 
    39:   //FUNCTIONS
    40:   fun SDL_ReadBE16: ptr[SDL_RWops] -> uint16;
    41:   fun SDL_ReadBE32: ptr[SDL_RWops] -> uint32;
    42:   fun SDL_ReadBE64: ptr[SDL_RWops] -> Uint64;
    43:   fun SDL_ReadLE16: ptr[SDL_RWops] -> uint16;
    44:   fun SDL_ReadLE32: ptr[SDL_RWops] -> uint32;
    45:   fun SDL_ReadLE64: ptr[SDL_RWops] -> Uint64;
    46:   fun SDL_Swap16: uint16 -> uint16;
    47:   fun SDL_Swap32: uint32 -> uint32;
    48:   fun SDL_Swap64: Uint64 -> Uint64;
    49:   fun SDL_WriteBE16: ptr[SDL_RWops] * uint16 -> int;
    50:   fun SDL_WriteBE32: ptr[SDL_RWops] * uint32 -> int;
    51:   fun SDL_WriteBE64: ptr[SDL_RWops] * Uint64 -> int;
    52:   fun SDL_WriteLE16: ptr[SDL_RWops] * uint16 -> int;
    53:   fun SDL_WriteLE32: ptr[SDL_RWops] * uint32 -> int;
    54:   fun SDL_WriteLE64: ptr[SDL_RWops] * Uint64 -> int;
    55: }
    56: 
End felix section to lib/SDL/SDL_endian.flx[1]
Start felix section to lib/SDL/SDL_framerate.flx[1 /1 ]
     1: #line 1945 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_framerate_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_framerate.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define DLLINTERFACE
    13: //#define DLLINTERFACE __declspec(dllimport)
    14: //#define DLLINTERFACE __declspec(dllexport)
    15: //#define FPS_DEFAULT           30
    16: //#define FPS_LOWER_LIMIT               1
    17: //#define FPS_UPPER_LIMIT               200
    18: //#define _SDL_framerate_h
    19: 
    20: //INCLUDES
    21: include "SDL/SDL";
    22: 
    23: module SDL_framerate_h
    24: {
    25:   requires package "sdl";
    26:   header '#include "SDL_framerate.h"';
    27:   open C_hack;
    28:   open SDL_h;
    29: 
    30:   //ABSTRACT TYPES
    31:   type FPSmanager = 'FPSmanager';
    32: 
    33:   //PROCEDURES
    34:   proc SDL_framerateDelay: ptr[FPSmanager];
    35:   proc SDL_initFramerate: ptr[FPSmanager];
    36: 
    37:   //FUNCTIONS
    38:   fun SDL_getFramerate: ptr[FPSmanager] -> int;
    39:   fun SDL_setFramerate: ptr[FPSmanager] * int -> int;
    40: }
End felix section to lib/SDL/SDL_framerate.flx[1]
Start felix section to lib/SDL/SDL_gfxPrimitives.flx[1 /1 ]
     1: #line 1986 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_gfxPrimitives_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_gfxPrimitives.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define DLLINTERFACE
    13: //#define DLLINTERFACE __declspec(dllimport)
    14: //#define DLLINTERFACE __declspec(dllexport)
    15: //#define SDL_GFXPRIMITIVES_MINOR       0
    16: //#define SDL_GFXPRIMITIVES_MAJOR       2
    17: //#define M_PI  3.141592654
    18: //#define _SDL_gfxPrimitives_h
    19: 
    20: //INCLUDES
    21: include "SDL/SDL";
    22: include "SDL/SDL_video";
    23: 
    24: module SDL_gfxPrimitives_h
    25: {
    26:   requires package "sdl";
    27:   header '#include "SDL_gfxPrimitives.h"';
    28:   open C_hack;
    29:   open SDL_h;
    30:   open SDL_video_h;
    31:   open math_h;
    32: 
    33:   //FUNCTIONS
    34:   fun aacircleColor: ptr[SDL_Surface] * int16 * int16 * int16 * uint32 -> int;
    35:   fun aacircleRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    36:   fun aaellipseColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint32 -> int;
    37:   fun aaellipseRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    38:   fun aalineColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint32 -> int;
    39:   fun aalineRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    40:   fun aapolygonColor: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * uint32 -> int;
    41:   fun aapolygonRGBA: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * uint8 * uint8 * uint8 * uint8 -> int;
    42:   fun aatrigonColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * int16 * uint32 -> int;
    43:   fun aatrigonRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    44:   fun bezierColor: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * int * uint32 -> int;
    45:   fun bezierRGBA: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * int * uint8 * uint8 * uint8 * uint8 -> int;
    46:   fun boxColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint32 -> int;
    47:   fun boxRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    48:   fun characterColor: ptr[SDL_Surface] * int16 * int16 * char * uint32 -> int;
    49:   fun characterRGBA: ptr[SDL_Surface] * int16 * int16 * char * uint8 * uint8 * uint8 * uint8 -> int;
    50:   fun circleColor: ptr[SDL_Surface] * int16 * int16 * int16 * uint32 -> int;
    51:   fun circleRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    52:   fun ellipseColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint32 -> int;
    53:   fun ellipseRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    54:   fun filledCircleColor: ptr[SDL_Surface] * int16 * int16 * int16 * uint32 -> int;
    55:   fun filledCircleRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    56:   fun filledEllipseColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint32 -> int;
    57:   fun filledEllipseRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    58:   fun filledPolygonColor: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * int -> int;
    59:   fun filledPolygonRGBA: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * uint8 * uint8 * uint8 * uint8 -> int;
    60:   fun filledTrigonColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * int16 * int -> int;
    61:   fun filledTrigonRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    62:   fun filledpieColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * uint32 -> int;
    63:   fun filledpieRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    64:   fun hlineColor: ptr[SDL_Surface] * int16 * int16 * int16 * uint32 -> int;
    65:   fun hlineRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    66:   fun lineColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint32 -> int;
    67:   fun lineRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    68:   fun pixelColor: ptr[SDL_Surface] * int16 * int16 * uint32 -> int;
    69:   fun pixelRGBA: ptr[SDL_Surface] * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    70:   fun polygonColor: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * uint32 -> int;
    71:   fun polygonRGBA: ptr[SDL_Surface] * ptr[int16] * ptr[int16] * int * uint8 * uint8 * uint8 * uint8 -> int;
    72:   fun rectangleColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint32 -> int;
    73:   fun rectangleRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    74:   fun stringColor: ptr[SDL_Surface] * int16 * int16 * ptr[char] * uint32 -> int;
    75:   fun stringRGBA: ptr[SDL_Surface] * int16 * int16 * ptr[char] * uint8 * uint8 * uint8 * uint8 -> int;
    76:   fun trigonColor: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * int16 * uint32 -> int;
    77:   fun trigonRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    78:   fun vlineColor: ptr[SDL_Surface] * int16 * int16 * int16 * uint32 -> int;
    79:   fun vlineRGBA: ptr[SDL_Surface] * int16 * int16 * int16 * uint8 * uint8 * uint8 * uint8 -> int;
    80: }
End felix section to lib/SDL/SDL_gfxPrimitives.flx[1]
Start felix section to lib/SDL/SDL_gfxPrimitives_font.flx[1 /1 ]
     1: #line 2067 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_gfxPrimitives_font_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_gfxPrimitives_font.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define GFX_FONTDATAMAX (8*256)
    13: 
    14: module SDL_gfxPrimitives_font_h
    15: {
    16:   requires package "sdl";
    17:   header '#include "SDL_gfxPrimitives_font.h"';
    18:   open C_hack;
    19: 
    20:   //VARIABLES
    21:   const gfxPrimitivesFontdata: ptr[utiny] = 'gfxPrimitivesFontdata';
    22: }
End felix section to lib/SDL/SDL_gfxPrimitives_font.flx[1]
Start felix section to lib/SDL/SDL_image.flx[1 /1 ]
     1: #line 2090 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_image_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_image.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define IMG_GetError  SDL_GetError
    13: //#define IMG_SetError  SDL_SetError
    14: //#define SDL_IMAGE_VERSION(X)                                          \
    15: //#define SDL_IMAGE_PATCHLEVEL  4
    16: //#define SDL_IMAGE_MINOR_VERSION       2
    17: //#define SDL_IMAGE_MAJOR_VERSION       1
    18: //#define _SDL_IMAGE_H
    19: 
    20: //INCLUDES
    21: include "SDL/SDL_rwops";
    22: include "SDL/SDL_version";
    23: include "SDL/SDL_video";
    24: 
    25: module SDL_image_h
    26: {
    27:   requires package "sdl";
    28:   header '#include "SDL_image.h"';
    29:   open C_hack;
    30:   open SDL_rwops_h;
    31:   open SDL_version_h;
    32:   open SDL_video_h;
    33: 
    34:   //FUNCTIONS
    35:   fun IMG_InvertAlpha: int -> int;
    36:   fun IMG_Linked_Version: 1 -> cptr[SDL_version];
    37:   fun IMG_Load: cptr[char] -> ptr[SDL_Surface];
    38:   fun IMG_LoadBMP_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    39:   fun IMG_LoadGIF_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    40:   fun IMG_LoadJPG_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    41:   fun IMG_LoadLBM_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    42:   fun IMG_LoadPCX_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    43:   fun IMG_LoadPNG_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    44:   fun IMG_LoadPNM_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    45:   fun IMG_LoadTGA_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    46:   fun IMG_LoadTIF_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    47:   fun IMG_LoadTyped_RW: ptr[SDL_RWops] * int * ptr[char] -> ptr[SDL_Surface];
    48:   fun IMG_LoadXCF_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    49:   fun IMG_LoadXPM_RW: ptr[SDL_RWops] -> ptr[SDL_Surface];
    50:   fun IMG_Load_RW: ptr[SDL_RWops] * int -> ptr[SDL_Surface];
    51:   fun IMG_ReadXPMFromArray: ptr[ptr[char]] -> ptr[SDL_Surface];
    52:   fun IMG_isBMP: ptr[SDL_RWops] -> int;
    53:   fun IMG_isGIF: ptr[SDL_RWops] -> int;
    54:   fun IMG_isJPG: ptr[SDL_RWops] -> int;
    55:   fun IMG_isLBM: ptr[SDL_RWops] -> int;
    56:   fun IMG_isPCX: ptr[SDL_RWops] -> int;
    57:   fun IMG_isPNG: ptr[SDL_RWops] -> int;
    58:   fun IMG_isPNM: ptr[SDL_RWops] -> int;
    59:   fun IMG_isTIF: ptr[SDL_RWops] -> int;
    60:   fun IMG_isXCF: ptr[SDL_RWops] -> int;
    61:   fun IMG_isXPM: ptr[SDL_RWops] -> int;
    62: }
End felix section to lib/SDL/SDL_image.flx[1]
Start felix section to lib/SDL/SDL_imageFilter.flx[1 /1 ]
     1: #line 2153 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_imageFilter_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_imageFilter.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define DLLINTERFACE
    13: //#define DLLINTERFACE __declspec(dllimport)
    14: //#define DLLINTERFACE __declspec(dllexport)
    15: //#define _SDL_imageFilter_h
    16: 
    17: module SDL_imageFilter_h
    18: {
    19:   requires package "sdl";
    20:   header '#include "SDL_imageFilter.h"';
    21:   open C_hack;
    22: 
    23:   //PROCEDURES
    24:   proc SDL_imageFilterAlignStack: 1;
    25:   proc SDL_imageFilterMMXoff: 1;
    26:   proc SDL_imageFilterMMXon: 1;
    27:   proc SDL_imageFilterRestoreStack: 1;
    28: 
    29:   //FUNCTIONS
    30:   fun SDL_imageFilterAbsDiff: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    31:   fun SDL_imageFilterAdd: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    32:   fun SDL_imageFilterAddByte: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    33:   fun SDL_imageFilterAddByteToHalf: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    34:   fun SDL_imageFilterBinarizeUsingThreshold: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    35:   fun SDL_imageFilterBitAnd: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    36:   fun SDL_imageFilterBitNegation: ptr[utiny] * ptr[utiny] * int -> int;
    37:   fun SDL_imageFilterBitOr: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    38:   fun SDL_imageFilterClipToRange: ptr[utiny] * ptr[utiny] * int * utiny * utiny -> int;
    39:   fun SDL_imageFilterConvolveKernel3x3Divide: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    40:   fun SDL_imageFilterConvolveKernel3x3ShiftRight: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    41:   fun SDL_imageFilterConvolveKernel5x5Divide: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    42:   fun SDL_imageFilterConvolveKernel5x5ShiftRight: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    43:   fun SDL_imageFilterConvolveKernel7x7Divide: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    44:   fun SDL_imageFilterConvolveKernel7x7ShiftRight: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    45:   fun SDL_imageFilterConvolveKernel9x9Divide: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    46:   fun SDL_imageFilterConvolveKernel9x9ShiftRight: ptr[utiny] * ptr[utiny] * int * int * ptr[short] * utiny -> int;
    47:   fun SDL_imageFilterDiv: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    48:   fun SDL_imageFilterMMXdetect: 1 -> int;
    49:   fun SDL_imageFilterMean: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    50:   fun SDL_imageFilterMult: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    51:   fun SDL_imageFilterMultByByte: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    52:   fun SDL_imageFilterMultDivby2: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    53:   fun SDL_imageFilterMultDivby4: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    54:   fun SDL_imageFilterMultNor: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    55:   fun SDL_imageFilterNormalizeLinear: ptr[utiny] * ptr[utiny] * int * int * int * int * int -> int;
    56:   fun SDL_imageFilterShiftLeft: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    57:   fun SDL_imageFilterShiftLeftByte: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    58:   fun SDL_imageFilterShiftRight: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    59:   fun SDL_imageFilterShiftRightAndMultByByte: ptr[utiny] * ptr[utiny] * int * utiny * utiny -> int;
    60:   fun SDL_imageFilterSobelX: ptr[utiny] * ptr[utiny] * int * int -> int;
    61:   fun SDL_imageFilterSobelXShiftRight: ptr[utiny] * ptr[utiny] * int * int * utiny -> int;
    62:   fun SDL_imageFilterSub: ptr[utiny] * ptr[utiny] * ptr[utiny] * int -> int;
    63:   fun SDL_imageFilterSubByte: ptr[utiny] * ptr[utiny] * int * utiny -> int;
    64: }
End felix section to lib/SDL/SDL_imageFilter.flx[1]
Start felix section to lib/SDL/SDL_mixer.flx[1 /1 ]
     1: #line 2218 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_mixer_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_mixer.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define Mix_GetError  SDL_GetError
    13: //#define Mix_SetError  SDL_SetError
    14: //#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
    15: //#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
    16: //#define MIX_EFFECTSMAXSPEED  "MIX_EFFECTSMAXSPEED"
    17: //#define MIX_CHANNEL_POST  -2
    18: //#define Mix_LoadWAV(file)     Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
    19: //#define MIX_MAX_VOLUME                128     /* Volume of a chunk */
    20: //#define MIX_DEFAULT_CHANNELS  2
    21: //#define MIX_DEFAULT_FORMAT    AUDIO_S16MSB
    22: //#define MIX_DEFAULT_FORMAT    AUDIO_S16LSB
    23: //#define MIX_DEFAULT_FREQUENCY 22050
    24: //#define MIX_CHANNELS  8
    25: //#define MIX_VERSION(X)                SDL_MIXER_VERSION(X)
    26: //#define MIX_PATCHLEVEL                SDL_MIXER_PATCHLEVEL
    27: //#define MIX_MINOR_VERSION     SDL_MIXER_MINOR_VERSION
    28: //#define MIX_MAJOR_VERSION     SDL_MIXER_MAJOR_VERSION
    29: //#define SDL_MIXER_VERSION(X)                                          \
    30: //#define SDL_MIXER_PATCHLEVEL  6
    31: //#define SDL_MIXER_MINOR_VERSION       2
    32: //#define SDL_MIXER_MAJOR_VERSION       1
    33: //#define _SDL_MIXER_H
    34: 
    35: //INCLUDES
    36: include "SDL/SDL_rwops";
    37: include "SDL/SDL_version";
    38: 
    39: module SDL_mixer_h
    40: {
    41:   requires package "sdl";
    42:   header '#include "SDL_mixer.h"';
    43:   open C_hack;
    44:   open SDL_rwops_h;
    45:   open SDL_version_h;
    46: 
    47:   //ABSTRACT TYPES
    48:   type Mix_MusicType = 'Mix_MusicType';
    49:   type Mix_Chunk = 'Mix_Chunk';
    50:   type Mix_Fading = 'Mix_Fading';
    51: 
    52:   //C FUNCTION POINTER TYPES
    53:   header '''typedef void (*SDL_mixer_h_cft_3)(void *, Uint8 *, int);''';
    54:   type SDL_mixer_h_cft_3 = 'SDL_mixer_h_cft_3';
    55:   header '''typedef void (*SDL_mixer_h_cft_1)(int, void *, int,  void *);''';
    56:   type SDL_mixer_h_cft_1 = 'SDL_mixer_h_cft_1';
    57:   header '''typedef void (*SDL_mixer_h_cft_2)(int, void *);''';
    58:   type SDL_mixer_h_cft_2 = 'SDL_mixer_h_cft_2';
    59:   header '''typedef void (*SDL_mixer_h_cft_5)(int);''';
    60:   type SDL_mixer_h_cft_5 = 'SDL_mixer_h_cft_5';
    61:   header '''typedef void (*SDL_mixer_h_cft_4)(void);''';
    62:   type SDL_mixer_h_cft_4 = 'SDL_mixer_h_cft_4';
    63: 
    64:   //PURE INCOMPLETE TYPES
    65:   type _struct__Mix_Music = 'struct _Mix_Music'; //local
    66: 
    67:   //STRUCT or UNION TAG ALIASES
    68:   typedef Mix_Music = _struct__Mix_Music;
    69: 
    70:   //TYPE ALIASES
    71:   typedef Mix_EffectDone_t = SDL_mixer_h_cft_2;
    72:   typedef Mix_EffectFunc_t = SDL_mixer_h_cft_1;
    73: 
    74:   //ENUMERATION CONSTANTS
    75:   const MUS_CMD: int = 'MUS_CMD';
    76:   const MIX_FADING_OUT: int = 'MIX_FADING_OUT';
    77:   const MIX_NO_FADING: int = 'MIX_NO_FADING';
    78:   const MIX_FADING_IN: int = 'MIX_FADING_IN';
    79:   const MUS_WAV: int = 'MUS_WAV';
    80:   const MUS_MID: int = 'MUS_MID';
    81:   const MUS_OGG: int = 'MUS_OGG';
    82:   const MUS_NONE: int = 'MUS_NONE';
    83:   const MUS_MOD: int = 'MUS_MOD';
    84:   const MUS_MP3: int = 'MUS_MP3';
    85: 
    86:   //PROCEDURES
    87:   proc Mix_ChannelFinished: SDL_mixer_h_cft_5;
    88:   proc Mix_CloseAudio: 1;
    89:   proc Mix_FreeChunk: ptr[Mix_Chunk];
    90:   proc Mix_FreeMusic: ptr[Mix_Music];
    91:   proc Mix_HookMusic: SDL_mixer_h_cft_3 * address;
    92:   proc Mix_HookMusicFinished: SDL_mixer_h_cft_4;
    93:   proc Mix_Pause: int;
    94:   proc Mix_PauseMusic: 1;
    95:   proc Mix_Resume: int;
    96:   proc Mix_ResumeMusic: 1;
    97:   proc Mix_RewindMusic: 1;
    98:   proc Mix_SetPostMix: SDL_mixer_h_cft_3 * address;
    99: 
   100:   //FUNCTIONS
   101:   fun Mix_AllocateChannels: int -> int;
   102:   fun Mix_ExpireChannel: int * int -> int;
   103:   fun Mix_FadeInChannelTimed: int * ptr[Mix_Chunk] * int * int * int -> int;
   104:   fun Mix_FadeInMusic: ptr[Mix_Music] * int * int -> int;
   105:   fun Mix_FadeInMusicPos: ptr[Mix_Music] * int * int * double -> int;
   106:   fun Mix_FadeOutChannel: int * int -> int;
   107:   fun Mix_FadeOutGroup: int * int -> int;
   108:   fun Mix_FadeOutMusic: int -> int;
   109:   fun Mix_FadingChannel: int -> Mix_Fading;
   110:   fun Mix_FadingMusic: 1 -> Mix_Fading;
   111:   fun Mix_GetChunk: int -> ptr[Mix_Chunk];
   112:   fun Mix_GetMusicHookData: 1 -> address;
   113:   fun Mix_GetMusicType: cptr[Mix_Music] -> Mix_MusicType;
   114:   fun Mix_GetSynchroValue: 1 -> int;
   115:   fun Mix_GroupAvailable: int -> int;
   116:   fun Mix_GroupChannel: int * int -> int;
   117:   fun Mix_GroupChannels: int * int * int -> int;
   118:   fun Mix_GroupCount: int -> int;
   119:   fun Mix_GroupNewer: int -> int;
   120:   fun Mix_GroupOldest: int -> int;
   121:   fun Mix_HaltChannel: int -> int;
   122:   fun Mix_HaltGroup: int -> int;
   123:   fun Mix_HaltMusic: 1 -> int;
   124:   fun Mix_Linked_Version: 1 -> cptr[SDL_version];
   125:   fun Mix_LoadMUS: cptr[char] -> ptr[Mix_Music];
   126:   fun Mix_LoadWAV_RW: ptr[SDL_RWops] * int -> ptr[Mix_Chunk];
   127:   fun Mix_OpenAudio: int * uint16 * int * int -> int;
   128:   fun Mix_Paused: int -> int;
   129:   fun Mix_PausedMusic: 1 -> int;
   130:   fun Mix_PlayChannelTimed: int * ptr[Mix_Chunk] * int * int -> int;
   131:   fun Mix_PlayMusic: ptr[Mix_Music] * int -> int;
   132:   fun Mix_Playing: int -> int;
   133:   fun Mix_PlayingMusic: 1 -> int;
   134:   fun Mix_QuerySpec: ptr[int] * ptr[uint16] * ptr[int] -> int;
   135:   fun Mix_QuickLoad_RAW: ptr[uint8] * uint32 -> ptr[Mix_Chunk];
   136:   fun Mix_QuickLoad_WAV: ptr[uint8] -> ptr[Mix_Chunk];
   137:   fun Mix_RegisterEffect: int * SDL_mixer_h_cft_1 * SDL_mixer_h_cft_2 * address -> int;
   138:   fun Mix_ReserveChannels: int -> int;
   139:   fun Mix_SetDistance: int * uint8 -> int;
   140:   fun Mix_SetMusicCMD: cptr[char] -> int;
   141:   fun Mix_SetMusicPosition: double -> int;
   142:   fun Mix_SetPanning: int * uint8 * uint8 -> int;
   143:   fun Mix_SetPosition: int * int16 * uint8 -> int;
   144:   fun Mix_SetReverseStereo: int * int -> int;
   145:   fun Mix_SetSynchroValue: int -> int;
   146:   fun Mix_UnregisterAllEffects: int -> int;
   147:   fun Mix_UnregisterEffect: int * SDL_mixer_h_cft_1 -> int;
   148:   fun Mix_Volume: int * int -> int;
   149:   fun Mix_VolumeChunk: ptr[Mix_Chunk] * int -> int;
   150:   fun Mix_VolumeMusic: int -> int;
   151: 
   152:   //CALLBACK TYPE WRAPPERS
   153:   //callback type SDL_mixer_h_cft_2, client data at 1
   154:   typedef _fcbat_SDL_mixer_h_cft_2 = int;
   155:   export type (_fcbat_SDL_mixer_h_cft_2) as "_fcbat_SDL_mixer_h_cft_2";
   156:   typedef _fcbt_SDL_mixer_h_cft_2 = int -> void;
   157:   export type (_fcbt_SDL_mixer_h_cft_2) as "_fcbt_SDL_mixer_h_cft_2";
   158:   header '''void _fcbw_SDL_mixer_h_cft_2(int a1, void *a2);''';
   159: 
   160:   const _fcbw_SDL_mixer_h_cft_2: SDL_mixer_h_cft_2 = "_fcbw_SDL_mixer_h_cft_2";
   161:   body '''
   162:   void _fcbw_SDL_mixer_h_cft_2(int a1, void *a2){
   163:     con_t *p  = ((_fcbt_SDL_mixer_h_cft_2)a2)->call(0, a1);
   164:     while(p) p=p->resume();
   165:   }''';
   166: 
   167:   //callback type SDL_mixer_h_cft_3, client data at 0
   168:   typedef _fcbat_SDL_mixer_h_cft_3 = ptr[uint8] * int;
   169:   export type (_fcbat_SDL_mixer_h_cft_3) as "_fcbat_SDL_mixer_h_cft_3";
   170:   typedef _fcbt_SDL_mixer_h_cft_3 = ptr[uint8] * int -> void;
   171:   export type (_fcbt_SDL_mixer_h_cft_3) as "_fcbt_SDL_mixer_h_cft_3";
   172:   header '''void _fcbw_SDL_mixer_h_cft_3(void *a1, Uint8 *a2, int a3);''';
   173: 
   174:   const _fcbw_SDL_mixer_h_cft_3: SDL_mixer_h_cft_3 = "_fcbw_SDL_mixer_h_cft_3";
   175:   body '''
   176:   void _fcbw_SDL_mixer_h_cft_3(void *a1, Uint8 *a2, int a3){
   177:     con_t *p  = ((_fcbt_SDL_mixer_h_cft_3)a1)->call(0, _fcbat_SDL_mixer_h_cft_3(a2, a3));
   178:     while(p) p=p->resume();
   179:   }''';
   180: 
   181: 
   182:   //CALLBACK CLIENT WRAPPERS
   183:   //callback client Mix_HookMusic, client data at 0, callback at 1
   184:   proc wrapper_Mix_HookMusic(a1: _fcbt_SDL_mixer_h_cft_3) {
   185:     Mix_HookMusic(_fcbw_SDL_mixer_h_cft_3, C_hack::cast[address]a1);
   186:   }
   187:   //callback client Mix_RegisterEffect, client data at 2, callback at 3
   188:   fun wrapper_Mix_RegisterEffect(a1: int, a2: SDL_mixer_h_cft_1, a3: _fcbt_SDL_mixer_h_cft_2): int= {
   189:     return Mix_RegisterEffect(a1, a2, _fcbw_SDL_mixer_h_cft_2, C_hack::cast[address]a3);
   190:   }
   191:   //callback client Mix_SetPostMix, client data at 0, callback at 1
   192:   proc wrapper_Mix_SetPostMix(a1: _fcbt_SDL_mixer_h_cft_3) {
   193:     Mix_SetPostMix(_fcbw_SDL_mixer_h_cft_3, C_hack::cast[address]a1);
   194:   }
   195: }
End felix section to lib/SDL/SDL_mixer.flx[1]
Start felix section to lib/SDL/SDL_sound.flx[1 /1 ]
     1: #line 2414 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_sound_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_sound.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SOUND_VERSION(x) \
    13: //#define SOUND_VER_PATCH 1
    14: //#define SOUND_VER_MINOR 0
    15: //#define SOUND_VER_MAJOR 1
    16: //#define SNDDECLSPEC
    17: //#define SNDDECLSPEC __declspec(dllexport)
    18: //#define SDLCALL
    19: //#define _INCLUDE_SDL_SOUND_H_
    20: 
    21: //INCLUDES
    22: include "SDL/SDL_rwops";
    23: 
    24: module SDL_sound_h
    25: {
    26:   requires package "sdl";
    27:   header '#include "SDL_sound.h"';
    28:   open C_hack;
    29:   open SDL_rwops_h;
    30: 
    31:   //ABSTRACT TYPES
    32:   type Sound_Sample = 'Sound_Sample';
    33:   type Sound_Version = 'Sound_Version';
    34:   type Sound_AudioInfo = 'Sound_AudioInfo';
    35:   type Sound_SampleFlags = 'Sound_SampleFlags';
    36:   type Sound_DecoderInfo = 'Sound_DecoderInfo';
    37: 
    38:   //ENUMERATION CONSTANTS
    39:   const SOUND_SAMPLEFLAG_ERROR: int = 'SOUND_SAMPLEFLAG_ERROR';
    40:   const SOUND_SAMPLEFLAG_NONE: int = 'SOUND_SAMPLEFLAG_NONE';
    41:   const SOUND_SAMPLEFLAG_EAGAIN: int = 'SOUND_SAMPLEFLAG_EAGAIN';
    42:   const SOUND_SAMPLEFLAG_EOF: int = 'SOUND_SAMPLEFLAG_EOF';
    43:   const SOUND_SAMPLEFLAG_CANSEEK: int = 'SOUND_SAMPLEFLAG_CANSEEK';
    44: 
    45:   //PROCEDURES
    46:   proc Sound_ClearError: 1;
    47:   proc Sound_FreeSample: ptr[Sound_Sample];
    48:   proc Sound_GetLinkedVersion: ptr[Sound_Version];
    49: 
    50:   //FUNCTIONS
    51:   fun Sound_AvailableDecoders: 1 -> ptr[cptr[Sound_DecoderInfo]];
    52:   fun Sound_Decode: ptr[Sound_Sample] -> uint32;
    53:   fun Sound_DecodeAll: ptr[Sound_Sample] -> uint32;
    54:   fun Sound_GetError: 1 -> cptr[char];
    55:   fun Sound_Init: 1 -> int;
    56:   fun Sound_NewSample: ptr[SDL_RWops] * cptr[char] * ptr[Sound_AudioInfo] * uint32 -> ptr[Sound_Sample];
    57:   fun Sound_NewSampleFromFile: cptr[char] * ptr[Sound_AudioInfo] * uint32 -> ptr[Sound_Sample];
    58:   fun Sound_Quit: 1 -> int;
    59:   fun Sound_Rewind: ptr[Sound_Sample] -> int;
    60:   fun Sound_Seek: ptr[Sound_Sample] * uint32 -> int;
    61:   fun Sound_SetBufferSize: ptr[Sound_Sample] * uint32 -> int;
    62: }
End felix section to lib/SDL/SDL_sound.flx[1]
Start felix section to lib/SDL/SDL_rotozoom.flx[1 /1 ]
     1: #line 2477 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_rotozoom_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_rotozoom.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define DLLINTERFACE
    13: //#define DLLINTERFACE __declspec(dllimport)
    14: //#define DLLINTERFACE __declspec(dllexport)
    15: //#define SMOOTHING_ON          1
    16: //#define SMOOTHING_OFF         0
    17: //#define M_PI  3.141592654
    18: //#define _SDL_rotozoom_h
    19: 
    20: //INCLUDES
    21: include "SDL/SDL";
    22: include "SDL/SDL_video";
    23: 
    24: module SDL_rotozoom_h
    25: {
    26:   requires package "sdl";
    27:   header '#include "SDL_rotozoom.h"';
    28:   open C_hack;
    29:   open SDL_h;
    30:   open SDL_video_h;
    31:   open math_h;
    32: 
    33:   //CSTRUCTS
    34:   cstruct tColorRGBA {
    35:     r: uint8;
    36:     g: uint8;
    37:     b: uint8;
    38:     a: uint8;
    39:   }
    40:   cstruct tColorY {
    41:     y: uint8;
    42:   }
    43: 
    44:   //STRUCT or UNION TAG ALIASES
    45: 
    46:   //TYPE ALIASES
    47:   typedef _struct_tColorY = tColorY;
    48:   typedef _struct_tColorRGBA = tColorRGBA;
    49: 
    50:   //PROCEDURES
    51:   proc rotozoomSurfaceSize: int * int * double * double * ptr[int] * ptr[int];
    52:   proc zoomSurfaceSize: int * int * double * double * ptr[int] * ptr[int];
    53: 
    54:   //FUNCTIONS
    55:   fun rotozoomSurface: ptr[SDL_Surface] * double * double * int -> ptr[SDL_Surface];
    56:   fun zoomSurface: ptr[SDL_Surface] * double * double * int -> ptr[SDL_Surface];
    57: }
End felix section to lib/SDL/SDL_rotozoom.flx[1]
Start felix section to lib/SDL/SDL_ttf.flx[1 /1 ]
     1: #line 2535 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_ttf_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_ttf.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define TTF_GetError  SDL_GetError
    13: //#define TTF_SetError  SDL_SetError
    14: //#define TTF_RenderUNICODE(font, text, fg, bg) \
    15: //#define TTF_RenderUTF8(font, text, fg, bg)    \
    16: //#define TTF_RenderText(font, text, fg, bg)    \
    17: //#define TTF_STYLE_UNDERLINE   0x04
    18: //#define TTF_STYLE_ITALIC      0x02
    19: //#define TTF_STYLE_BOLD                0x01
    20: //#define TTF_STYLE_NORMAL      0x00
    21: //#define UNICODE_BOM_SWAPPED   0xFFFE
    22: //#define UNICODE_BOM_NATIVE    0xFEFF
    23: //#define TTF_VERSION(X)                                                        \
    24: //#define TTF_PATCHLEVEL                6
    25: //#define TTF_MINOR_VERSION     0
    26: //#define TTF_MAJOR_VERSION     2
    27: //#define _SDLttf_h
    28: 
    29: //INCLUDES
    30: include "SDL/SDL_rwops";
    31: include "SDL/SDL_version";
    32: include "SDL/SDL_video";
    33: 
    34: module SDL_ttf_h
    35: {
    36:   requires package "sdl";
    37:   header '#include "SDL_ttf.h"';
    38:   open C_hack;
    39:   open SDL_rwops_h;
    40:   open SDL_version_h;
    41:   open SDL_video_h;
    42: 
    43:   //PURE INCOMPLETE TYPES
    44:   type _struct__TTF_Font = 'struct _TTF_Font'; //local
    45: 
    46:   //STRUCT or UNION TAG ALIASES
    47:   typedef TTF_Font = _struct__TTF_Font;
    48: 
    49:   //PROCEDURES
    50:   proc TTF_ByteSwappedUNICODE: int;
    51:   proc TTF_CloseFont: ptr[TTF_Font];
    52:   proc TTF_Quit: 1;
    53:   proc TTF_SetFontStyle: ptr[TTF_Font] * int;
    54: 
    55:   //FUNCTIONS
    56:   fun TTF_FontAscent: ptr[TTF_Font] -> int;
    57:   fun TTF_FontDescent: ptr[TTF_Font] -> int;
    58:   fun TTF_FontFaceFamilyName: ptr[TTF_Font] -> ptr[char];
    59:   fun TTF_FontFaceIsFixedWidth: ptr[TTF_Font] -> int;
    60:   fun TTF_FontFaceStyleName: ptr[TTF_Font] -> ptr[char];
    61:   fun TTF_FontFaces: ptr[TTF_Font] -> long;
    62:   fun TTF_FontHeight: ptr[TTF_Font] -> int;
    63:   fun TTF_FontLineSkip: ptr[TTF_Font] -> int;
    64:   fun TTF_GetFontStyle: ptr[TTF_Font] -> int;
    65:   fun TTF_GlyphMetrics: ptr[TTF_Font] * uint16 * ptr[int] * ptr[int] * ptr[int] * ptr[int] * ptr[int] -> int;
    66:   fun TTF_Init: 1 -> int;
    67:   fun TTF_Linked_Version: 1 -> cptr[SDL_version];
    68:   fun TTF_OpenFont: cptr[char] * int -> ptr[TTF_Font];
    69:   fun TTF_OpenFontIndex: cptr[char] * int * long -> ptr[TTF_Font];
    70:   fun TTF_OpenFontIndexRW: ptr[SDL_RWops] * int * int * long -> ptr[TTF_Font];
    71:   fun TTF_OpenFontRW: ptr[SDL_RWops] * int * int -> ptr[TTF_Font];
    72:   fun TTF_RenderGlyph_Blended: ptr[TTF_Font] * uint16 * SDL_Color -> ptr[SDL_Surface];
    73:   fun TTF_RenderGlyph_Shaded: ptr[TTF_Font] * uint16 * SDL_Color * SDL_Color -> ptr[SDL_Surface];
    74:   fun TTF_RenderGlyph_Solid: ptr[TTF_Font] * uint16 * SDL_Color -> ptr[SDL_Surface];
    75:   fun TTF_RenderText_Blended: ptr[TTF_Font] * cptr[char] * SDL_Color -> ptr[SDL_Surface];
    76:   fun TTF_RenderText_Shaded: ptr[TTF_Font] * cptr[char] * SDL_Color * SDL_Color -> ptr[SDL_Surface];
    77:   fun TTF_RenderText_Solid: ptr[TTF_Font] * cptr[char] * SDL_Color -> ptr[SDL_Surface];
    78:   fun TTF_RenderUNICODE_Blended: ptr[TTF_Font] * cptr[uint16] * SDL_Color -> ptr[SDL_Surface];
    79:   fun TTF_RenderUNICODE_Shaded: ptr[TTF_Font] * cptr[uint16] * SDL_Color * SDL_Color -> ptr[SDL_Surface];
    80:   fun TTF_RenderUNICODE_Solid: ptr[TTF_Font] * cptr[uint16] * SDL_Color -> ptr[SDL_Surface];
    81:   fun TTF_RenderUTF8_Blended: ptr[TTF_Font] * cptr[char] * SDL_Color -> ptr[SDL_Surface];
    82:   fun TTF_RenderUTF8_Shaded: ptr[TTF_Font] * cptr[char] * SDL_Color * SDL_Color -> ptr[SDL_Surface];
    83:   fun TTF_RenderUTF8_Solid: ptr[TTF_Font] * cptr[char] * SDL_Color -> ptr[SDL_Surface];
    84:   fun TTF_SizeText: ptr[TTF_Font] * cptr[char] * ptr[int] * ptr[int] -> int;
    85:   fun TTF_SizeUNICODE: ptr[TTF_Font] * cptr[uint16] * ptr[int] * ptr[int] -> int;
    86:   fun TTF_SizeUTF8: ptr[TTF_Font] * cptr[char] * ptr[int] * ptr[int] -> int;
    87:   fun TTF_WasInit: 1 -> int;
    88: }
End felix section to lib/SDL/SDL_ttf.flx[1]
Start felix section to lib/SDL/SDL_net.flx[1 /1 ]
     1: #line 2624 "./lpsrc/flx_sdl.pak"
     2: //Module        : SDL_net_h
     3: //Timestamp     : 2006/1/8 3:36:0 UTC
     4: //Timestamp     : 2006/1/8 14:36:0 (local)
     5: //Raw Header    : /usr/include/SDL/SDL_net.h
     6: //Preprocessor  : gcc -E
     7: //Input file: sdl.flxcc.i
     8: //Flxcc Control : sdl.flxcc
     9: //Felix Version : 1.1.2_rc1
    10: include 'std';
    11: 
    12: //#define SDLNet_Read32(areap)          \
    13: //#define SDLNet_Read32(areap)          \
    14: //#define SDLNet_Read32(areap)          \
    15: //#define SDLNet_Read16(areap)          \
    16: //#define SDLNet_Read16(areap)          \
    17: //#define SDLNet_Read16(areap)          \
    18: //#define SDLNet_Write32(value, areap)  \
    19: //#define SDLNet_Write32(value, areap)  \
    20: //#define SDLNet_Write32(value, areap)  \
    21: //#define SDLNet_Write16(value, areap)  \
    22: //#define SDLNet_Write16(value, areap)  \
    23: //#define SDLNet_Write16(value, areap)  \
    24: //#define SDL_DATA_ALIGNED      0
    25: //#define SDL_DATA_ALIGNED      1
    26: //#define SDLNet_GetError       SDL_GetError
    27: //#define SDLNet_SetError       SDL_SetError
    28: //#define SDLNet_SocketReady(sock) \
    29: //#define SDLNet_UDP_DelSocket(set, sock) \
    30: //#define SDLNet_TCP_DelSocket(set, sock) \
    31: //#define SDLNet_UDP_AddSocket(set, sock) \
    32: //#define SDLNet_TCP_AddSocket(set, sock) \
    33: //#define SDLNET_MAX_UDPADDRESSES       4
    34: //#define SDLNET_MAX_UDPCHANNELS        32
    35: //#define INADDR_BROADCAST      0xFFFFFFFF
    36: //#define INADDR_NONE           0xFFFFFFFF
    37: //#define INADDR_ANY            0x00000000
    38: //#define _SDLnet_h
    39: 
    40: module SDL_net_h
    41: {
    42:   requires package "sdl";
    43:   header '#include "SDL_net.h"';
    44:   open C_hack;
    45: 
    46:   //ABSTRACT TYPES
    47:   type SDLNet_GenericSocket = 'SDLNet_GenericSocket';
    48:   type IPaddress = 'IPaddress';
    49:   type UDPpacket = 'UDPpacket';
    50: 
    51:   //PURE INCOMPLETE TYPES
    52:   type _struct__UDPsocket = 'struct _UDPsocket'; //local
    53:   type _struct__SDLNet_SocketSet = 'struct _SDLNet_SocketSet'; //local
    54:   type _struct__TCPsocket = 'struct _TCPsocket'; //local
    55: 
    56:   //TYPE ALIASES
    57:   typedef UDPsocket = ptr[_struct__UDPsocket];
    58:   typedef TCPsocket = ptr[_struct__TCPsocket];
    59:   typedef SDLNet_SocketSet = ptr[_struct__SDLNet_SocketSet];
    60: 
    61:   //PROCEDURES
    62:   proc SDLNet_FreePacket: ptr[UDPpacket];
    63:   proc SDLNet_FreePacketV: ptr[ptr[UDPpacket]];
    64:   proc SDLNet_FreeSocketSet: SDLNet_SocketSet;
    65:   proc SDLNet_Quit: 1;
    66:   proc SDLNet_TCP_Close: TCPsocket;
    67:   proc SDLNet_UDP_Close: UDPsocket;
    68:   proc SDLNet_UDP_Unbind: UDPsocket * int;
    69:   proc SDLNet_Write16: uint16 * address;
    70:   proc SDLNet_Write32: uint32 * address;
    71: 
    72:   //FUNCTIONS
    73:   fun SDLNet_AddSocket: SDLNet_SocketSet * SDLNet_GenericSocket -> int;
    74:   fun SDLNet_AllocPacket: int -> ptr[UDPpacket];
    75:   fun SDLNet_AllocPacketV: int * int -> ptr[ptr[UDPpacket]];
    76:   fun SDLNet_AllocSocketSet: int -> SDLNet_SocketSet;
    77:   fun SDLNet_CheckSockets: SDLNet_SocketSet * uint32 -> int;
    78:   fun SDLNet_DelSocket: SDLNet_SocketSet * SDLNet_GenericSocket -> int;
    79:   fun SDLNet_Init: 1 -> int;
    80:   fun SDLNet_Read16: address -> uint16;
    81:   fun SDLNet_Read32: address -> uint32;
    82:   fun SDLNet_ResizePacket: ptr[UDPpacket] * int -> int;
    83:   fun SDLNet_ResolveHost: ptr[IPaddress] * cptr[char] * uint16 -> int;
    84:   fun SDLNet_ResolveIP: ptr[IPaddress] -> cptr[char];
    85:   fun SDLNet_TCP_Accept: TCPsocket -> TCPsocket;
    86:   fun SDLNet_TCP_GetPeerAddress: TCPsocket -> ptr[IPaddress];
    87:   fun SDLNet_TCP_Open: ptr[IPaddress] -> TCPsocket;
    88:   fun SDLNet_TCP_Recv: TCPsocket * address * int -> int;
    89:   fun SDLNet_TCP_Send: TCPsocket * address * int -> int;
    90:   fun SDLNet_UDP_Bind: UDPsocket * int * ptr[IPaddress] -> int;
    91:   fun SDLNet_UDP_GetPeerAddress: UDPsocket * int -> ptr[IPaddress];
    92:   fun SDLNet_UDP_Open: uint16 -> UDPsocket;
    93:   fun SDLNet_UDP_Recv: UDPsocket * ptr[UDPpacket] -> int;
    94:   fun SDLNet_UDP_RecvV: UDPsocket * ptr[ptr[UDPpacket]] -> int;
    95:   fun SDLNet_UDP_Send: UDPsocket * int * ptr[UDPpacket] -> int;
    96:   fun SDLNet_UDP_SendV: UDPsocket * ptr[ptr[UDPpacket]] * int -> int;
    97: }
    98: 
End felix section to lib/SDL/SDL_net.flx[1]
Start cpp section to rtl/flx_sdl_config.hpp[1 /1 ]
     1: #line 2723 "./lpsrc/flx_sdl.pak"
     2: #ifndef __FLX_SDL_CONFIG_GUARD__
     3: #define __FLX_SDL_CONFIG_GUARD__
     4: #include "flx_rtl_config.hpp"
     5: #ifdef BUILD_SDL
     6: #define SDL_EXTERN FLX_EXPORT
     7: #else
     8: #define SDL_EXTERN FLX_IMPORT
     9: #endif
    10: #endif
    11: 
    12: 
End cpp section to rtl/flx_sdl_config.hpp[1]
Start cpp section to faio/faio_sdl_event.hpp[1 /1 ]
     1: #line 2736 "./lpsrc/flx_sdl.pak"
     2: #ifndef __FAIO_SDL_EVENT__
     3: #define __FAIO_SDL_EVENT__
     4: #include <flx_sdl_config.hpp>
     5: #include "pthread_work_fifo.hpp"
     6: #include "faio_drv.hpp"      // thread_wakeups,
     7: #include "faio_asyncio.hpp"  // flx_driver_request_base
     8: #include "SDL_mutex.h"
     9: #include "SDL_events.h"
    10: 
    11: namespace flx { namespace faio {
    12: 
    13: // ONE PROBLEM: this is faio level. It needs to know about fthreads
    14: 
    15: // get ONE SDL event
    16: class SDL_EXTERN faio_sdl_event : public flx_driver_request_base,
    17:   public flx::pthread::worker_task {
    18:    thread_wakeup   fw;
    19:    SDL_Event *e;
    20:    SDL_mutex *m;
    21: public:
    22:   faio_sdl_event() {}     // felix linkage
    23:   faio_sdl_event(SDL_Event *_e, SDL_mutex *_m);
    24: 
    25:   // from flx_driver_request_base
    26:   bool start_async_op(demux::demuxer& demux, flx_drv* drv,  void* f);
    27: 
    28:   // from fifo_worker_task
    29:   void doit();
    30:   void finished();
    31: };
    32: 
    33: }}
    34: #endif
    35: 
End cpp section to faio/faio_sdl_event.hpp[1]
Start cpp section to faio/faio_sdl_event.cpp[1 /1 ]
     1: #line 2772 "./lpsrc/flx_sdl.pak"
     2: #include "pthread_work_fifo.hpp"
     3: #include "SDL_mutex.h"
     4: #include "SDL_events.h"
     5: #include "faio_sdl_event.hpp"
     6: 
     7: namespace flx { namespace faio {
     8: 
     9: faio_sdl_event::faio_sdl_event(SDL_Event *_e, SDL_mutex *_m) : e(_e), m(_m) {}
    10: 
    11: bool
    12: faio_sdl_event::start_async_op(demux::demuxer& demux, flx_drv* drv, void* f)
    13: {
    14:   RECORD_THREAD_INFO(fw);    // so we can wake up
    15: 
    16:   // get worker fifo, add this task
    17:   drv->get_worker_fifo()->add_worker_task(this);
    18:   return false;              // suspended
    19: }
    20: 
    21: void faio_sdl_event::doit() {
    22:   if(m)SDL_LockMutex(m);
    23:   SDL_WaitEvent(e); // blocks in pthread
    24:   if(m)SDL_UnlockMutex(m);
    25: }
    26: 
    27: void faio_sdl_event::finished(){ fw.wake(); }
    28: 
    29: }}
    30: 
End cpp section to faio/faio_sdl_event.cpp[1]
Start felix section to lib/flx_faio_sdl.flx[1 /1 ]
     1: #line 2803 "./lpsrc/flx_sdl.pak"
     2: #import <flx.flxh>
     3: 
     4: include "SDL/SDL";
     5: include "SDL/SDL_events";
     6: include "flx_faio";
     7: 
     8: module SDL_events
     9: {
    10:   requires package "sdl";
    11:   requires package "faio";
    12:   open SDL_events_h;
    13:   open SDL_mutex_h;
    14: 
    15:   header faio_sdl_event_hpp = '#include "faio_sdl_event.hpp"';
    16: 
    17:   private type sdl_event_request =
    18:     "flx::faio::faio_sdl_event"
    19:     requires faio_sdl_event_hpp
    20:   ;
    21: 
    22:   private fun mk_sdl_event_request: ptr[SDL_Event] * ptr[SDL_mutex] -> sdl_event_request =
    23:     "flx::faio::faio_sdl_event($1,$2)";
    24: 
    25:   fun event_type: SDL_Event -> uint8 = "$1.type";
    26: 
    27:   proc get_sdl_event(pe:&SDL_Event, m:ptr[SDL_mutex])
    28:   {
    29:     var cpe = unref pe;
    30:     var req = mk_sdl_event_request (cpe,m);
    31:     Faio::faio_req$ &req;
    32:   }
    33: 
    34:   proc block_sdl_events(m:ptr[SDL_mutex])
    35:   {
    36:     var dummy = SDL_UserEvent(SDL_USEREVENT,0,NULL,NULL);
    37:     ignore(SDL_PushEvent(cast [ptr[SDL_Event]] (addr dummy)));
    38:     ignore(SDL_LockMutex(m));
    39:   }
    40: 
    41:   proc unblock_sdl_events(m:ptr[SDL_mutex])
    42:   {
    43:     ignore(SDL_UnlockMutex(m));
    44:   }
    45: }
    46: 
End felix section to lib/flx_faio_sdl.flx[1]
Start felix section to tut/examples/sdl100.flx[1 /1 ]
     1: #line 2850 "./lpsrc/flx_sdl.pak"
     2: #import <flx.flxh>
     3: include "SDL/SDL";
     4: include "SDL/SDL_video";
     5: include "SDL/SDL_rwops";
     6: //include "SDL/SDL_image";
     7: include "SDL/SDL_keyboard";
     8: include "SDL/SDL_keysym";
     9: include "SDL/SDL_events";
    10: include "SDL/SDL_mutex";
    11: include "SDL/SDL_audio";
    12: include "flx_faio";
    13: include "flx_faio_sdl";
    14: 
    15: // Raw SDL interfaces
    16: open SDL_h;
    17: open SDL_video_h;
    18: open SDL_rwops_h;
    19: //open SDL_image_h;
    20: open SDL_events_h;
    21: open SDL_audio_h;
    22: open SDL_mutex_h;
    23: open SDL_keyboard_h;
    24: open SDL_keysym_h;
    25: 
    26: open C_hack;
    27: open Carray;
    28: open MixedInt;
    29: open Uint32;
    30: open Uint8;
    31: 
    32: // This is the Felix asynchronous event source
    33: open SDL_events;
    34: 
    35: proc DrawPixel(screen:ptr[SDL_Surface], x:int32, y:int32, R:uint8, G:uint8, B:uint8)
    36: {
    37:     color := SDL_MapRGB(screen.->format, R, G, B);
    38: 
    39:     if SDL_MUSTLOCK(screen) do
    40:         if SDL_LockSurface(screen) < 0 return;
    41:     done;
    42: 
    43:     match screen.->format.->BytesPerPixel with
    44:     | 1 =>
    45:       { /* Assuming 8-bpp */
    46:         bufp := cast[ptr[uint8]] screen.->pixels + y*screen.->pitch + x;
    47:         *bufp = color;
    48:       }
    49: 
    50:     | 2 =>
    51:       { /* Probably 15-bpp or 16-bpp */
    52:         bufp := cast[ptr[uint16]] screen.->pixels + y*screen.->pitch/2 + x;
    53:         *bufp = color;
    54:       }
    55: 
    56:     | 3 =>
    57:       { /* Slow 24-bpp mode, usually not used */
    58:         bufp := cast[ptr[uint8]] screen.->pixels + y*screen.->pitch + x;
    59:         *(bufp+screen.->format.->Rshift/8) = R;
    60:         *(bufp+screen.->format.->Gshift/8) = G;
    61:         *(bufp+screen.->format.->Bshift/8) = B;
    62:       }
    63: 
    64:     | 4 =>
    65:       { /* Probably 32-bpp */
    66:         bufp := cast[ptr[uint32]] screen.->pixels + y*screen.->pitch/4 + x;
    67:         *bufp = color;
    68:       }
    69:     endmatch;
    70: 
    71:     if SDL_MUSTLOCK(screen) do
    72:         SDL_UnlockSurface(screen);
    73:     done;
    74:     SDL_UpdateRect(screen, x, y, 1u, 1u);
    75: }
    76: 
    77: if SDL_Init(SDL_INIT_AUDIO \| SDL_INIT_VIDEO) < 0 do
    78:   print "Unable to init SDL"; endl;
    79:   System::exit(1);
    80: done;
    81: 
    82: var screen: ptr[SDL_Surface];
    83: screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
    84: if isNULL screen do
    85:   print "Unable to set 1024x768 video"; endl;
    86:   System::exit(1);
    87: done;
    88: 
    89: print "yo, we're off: ";
    90: print screen.->format.->BytesPerPixel;
    91: print " bytes per pixel\n";
    92: 
    93: var i = 10i32; until i == 50i32 do
    94:       DrawPixel(screen, i,i,250u8,220u8,220u8);
    95:       ++i;
    96: done;
    97: 
    98: struct sample_t {
    99:     data : ptr[uint8];
   100:     dpos: uint32;
   101:     dlen: uint32;
   102: };
   103: 
   104: macro val NUM_SOUNDS = 2;
   105: var sounds : sample_t ^ NUM_SOUNDS;
   106: 
   107: {
   108:   var j:int;
   109:   forall j in 0 upto NUM_SOUNDS-1 do
   110:     sounds.[j] = sample_t(null_ptr[uint8],0u32,0u32);
   111:   done;
   112: };
   113: 
   114: proc flx_mixaudio(stream : ptr[uint8], len : int)
   115: {
   116:   var i : int;
   117:   var amount : uint32;
   118:   forall i in 0 upto NUM_SOUNDS-1 do
   119:     amount = sounds.[i].dlen - sounds.[i].dpos;
   120:     if amount > len do amount = len; done;
   121:     var loc : ptr[uint8] = sounds.[i].data+ cast[int] sounds.[i].dpos;
   122:     SDL_MixAudio(stream, cast[cptr[uint8]] loc, amount, SDL_MIX_MAXVOLUME);
   123:     sounds.[i].dpos += amount;
   124:   done;
   125: }
   126: 
   127: var fmt : SDL_AudioSpec;
   128: fmt.freq=22050;
   129: fmt.format=AUDIO_S16;
   130: fmt.channels=2u8;
   131: fmt.silence=0u8;
   132: fmt.samples=2048u16;
   133: fmt.padding=0u16;
   134: fmt.size=0u16;
   135: 
   136: //const SDL_audio_callback : SDL_audio_h_cft_1;
   137: get_callback fmt = code [SDL_audio_h_cft_1] 'SDL_audio_callback';
   138: var mixer = the flx_mixaudio;
   139: fmt.userdata= cast[address] mixer;
   140: 
   141: 
   142: if SDL_OpenAudio(addr fmt, null_ptr[SDL_AudioSpec]) < 0 do
   143:   print "Can't open Audio"; endl;
   144:   System::exit 0;
   145: done;
   146: 
   147: proc PlaySound(filename:string)
   148: {
   149:   var idx:int;
   150:   var wave: SDL_AudioSpec;
   151:   var data : ptr[uint8];
   152:   var dlen : uint32;
   153:   var cvt : SDL_AudioCVT;
   154:   /* Look for an empty (or finished) sound slot */
   155:   forall idx in 0 upto 2 do
   156:     if sounds.[idx].dpos == sounds.[idx].dlen goto found;
   157:   done;
   158:   found:>
   159:   if idx == NUM_SOUNDS do
   160:     print "No free slot for music"; endl;
   161:     return;
   162:   done;
   163: 
   164:   if
   165:     SDL_LoadWAV(
   166:       enconst (cstr filename),
   167:       addr wave,
   168:       addr data,
   169:       addr dlen
   170:     ) == null_ptr[SDL_AudioSpec]
   171:   do
   172:     print$ "Couldn't load Wav file " + filename; endl;
   173:     return;
   174:   done;
   175:   print$ "Loaded Wav file " + filename; endl;
   176:   print "Using slot "; print idx; endl;
   177: 
   178:   var result = SDL_BuildAudioCVT(
   179:     addr cvt,
   180:     wave.format,
   181:     wave.channels,
   182:     wave.freq,
   183:     AUDIO_S16,
   184:     2u8,
   185:     22050
   186:   );
   187:   cvt.buf = array_alloc[uint8](dlen*cvt.len_mult);
   188:   memcpy(as_address cvt.buf, as_address data, cast[size] dlen);
   189:   cvt.len = dlen;
   190:   result = SDL_ConvertAudio(addr cvt);
   191:   SDL_FreeWAV(data);
   192: 
   193:   /* Put the sound data in the slot (it starts playing immediately) */
   194:   if not (isNULL sounds.[idx].data) call free sounds.[idx].data;
   195:   SDL_LockAudio();
   196:   sounds.[idx].data = cvt.buf;
   197:   sounds.[idx].dlen = cvt.len_cvt;
   198:   sounds.[idx].dpos = 0u32;
   199:   SDL_UnlockAudio();
   200: }
   201: 
   202: SDL_PauseAudio 0;
   203: {
   204:   forall i in 1 upto 16 do
   205:     filename := "media/sounds/fs" + str i + ".wav";
   206:     print$ "Playing file " + filename; endl;
   207:     PlaySound(filename);
   208:   done;
   209: };
   210: 
   211: var s: ptr[SDL_Surface] ^ 16;
   212: {
   213:   forall i in 1 upto 16 do
   214:        //filename := "media/images/fc" + str i+ ".jpg";
   215:        filename := "media/images/fc" + str i+ ".bmp";
   216:        print$ "Loading file " + filename; endl;
   217:        rwop := SDL_RWFromFile (enconst (cstr filename),enconst (c"rb"));
   218:        //s.[i-1] = IMG_LoadJPG_RW(rwop);
   219:        s.[i-1] = SDL_LoadBMP_RW(rwop,1);
   220:   done;
   221: };
   222: 
   223: var rcDest : SDL_Rect;
   224: SDL_GetClipRect(screen,addr rcDest);
   225: 
   226: black := SDL_MapRGB(screen.->format, 0u8, 0u8, 0u8);
   227: 
   228: proc waitt(t:double) (f:schannel[uint8]) {
   229:   Faio::sleep t;
   230:   write (f,SDL_USEREVENT); // hack for timer event
   231: }
   232: 
   233: /* function to handle key press events */
   234: proc handle_key( keysym : SDL_keysym)
   235: {
   236:   match keysym.sym with
   237:   | ?k when k == SDLK_ESCAPE => { Quit 0; }
   238:   | ?k when k ==  SDLK_F1 =>
   239:             { ignore$ SDL_WM_ToggleFullScreen(screen); }
   240:   | _ => {}
   241:   endmatch;
   242: }
   243: 
   244: 
   245: var event_lock = SDL_CreateMutex ();
   246: 
   247: proc poll_event(e: &SDL_Event)
   248: {
   249: tryagain:>
   250:   //print "Polling event"; endl;
   251:   var result = SDL_PollEvent(unref e);
   252:   if result > 0 do
   253:     //print "Got event"; endl;
   254:     return;
   255:   done;
   256:   Faio::sleep 0.1;
   257:   goto tryagain;
   258: }
   259: 
   260: proc waitk(f:schannel[uint8]) {
   261:   // ASYNC event reading doesn't work with SDL on Windows
   262:   // So we have busy wait ;(
   263:   //var &e : SDL_Event <- get_sdl_event event_lock;
   264:   var e : SDL_Event;
   265:   poll_event(&e);
   266: 
   267:   var et = event_type e;
   268:   whilst
   269:     et != SDL_KEYDOWN and
   270:     et != SDL_MOUSEBUTTONDOWN and
   271:     et != SDL_QUIT
   272:   do
   273:     //&e <- get_sdl_event event_lock;
   274:     poll_event(&e);
   275:     et = event_type e;
   276:   done;
   277:   if et == SDL_KEYDOWN call handle_key e.key.keysym;
   278:   write (f,et);
   279: }
   280: 
   281: proc waittk() {
   282:   var w = mk_schannel[uint8] ();
   283:   spawn_fthread { waitt 15.0 w; };
   284:   spawn_fthread { waitk w; };
   285:   var &i: uint8 <- read w;
   286: }
   287: 
   288: 
   289: forall i in 0 upto 15 do
   290:   if not (isNULL s.[i]) do
   291:     print "Show "; print i; endl;
   292:     var r = SDL_BlitSurface ( s.[i], null_ptr[SDL_Rect], screen, addr rcDest );
   293:     SDL_UpdateRect(screen, 0i32,0i32,0u,0u);
   294:     waittk;
   295:     r = SDL_FillRect(screen, addr rcDest, black);
   296:   else
   297:     print "Skip "; print i; endl;
   298:   done;
   299: done;
   300: 
   301: print "Press any key"; endl;
   302: 
   303: {
   304:   var x = mk_schannel[uint8] ();
   305:   spawn_fthread { waitk x; };
   306:   var &i : uint8 <- read x;
   307: };
   308: 
   309: Quit 0;
   310: 
   311: proc Quit(x:int)
   312: {
   313:   //print "QUIT "; print x; endl;
   314:   SDL_CloseAudio;
   315:   SDL_Quit;
   316:   System::exit x;
   317: }
   318: 
End felix section to tut/examples/sdl100.flx[1]
Start felix section to tut/examples/sdl202.flx[1 /1 ]
     1: #line 3169 "./lpsrc/flx_sdl.pak"
     2: // REQUIRES OpenGL and GLU
     3: /*
     4:  * This code was created by Jeff Molofee '99
     5:  * (ported to Linux/SDL by Ti Leggett '01)
     6:  *
     7:  * If you've found this code useful, please let me know.
     8:  *
     9:  * Visit Jeff at http://nehe.gamedev.net/
    10:  *
    11:  * or for port-specific comments, questions, bugreports etc.
    12:  * email to leggett@eecs.tulane.edu
    13:  */
    14: 
    15: #import <flx.flxh>
    16: include "SDL/SDL";
    17: include "SDL/SDL_keyboard";
    18: include "SDL/SDL_keysym";
    19: include "SDL/SDL_video";
    20: include "SDL/SDL_events";
    21: include "SDL/SDL_timer";
    22: include "SDL/SDL_mutex";
    23: include "SDL/SDL_opengl";
    24: 
    25: include "flx_faio";
    26: include "flx_faio_sdl";
    27: 
    28: 
    29: open C_hack;
    30: open Carray;
    31: open MixedInt;
    32: open Uint32;
    33: open Uint8;
    34: open Float;
    35: 
    36: open SDL_h;
    37: open SDL_video_h;
    38: open SDL_keyboard_h;
    39: open SDL_events_h;
    40: open SDL_keysym_h;
    41: open SDL_timer_h;
    42: open SDL_mutex_h;
    43: 
    44: // This is the Felix asynchronous event source
    45: open SDL_events;
    46: 
    47: open SDL_opengl_h;
    48: 
    49: /* screen width, height, and bit depth */
    50: val SCREEN_WIDTH  = 640;
    51: val SCREEN_HEIGHT = 480;
    52: val SCREEN_BPP = 16;
    53: 
    54: /* function to reset our viewport after a window resize */
    55: proc resizeWindow( wwidth : int, hheight :int)
    56: {
    57:   var height = hheight;
    58:   var width = wwidth;
    59: 
    60:   /* Protect against a divide by zero */
    61:   if height == 0 do height = 1; done;
    62:   var ratio = double_of width / double_of height;
    63: 
    64:   block_sdl_events event_lock;
    65:   /* Setup our viewport. */
    66:   glViewport( 0, 0, width, height );
    67: 
    68:   /* change to the projection matrix and set our viewing volume. */
    69:   glMatrixMode( GL_PROJECTION );
    70:   glLoadIdentity( );
    71: 
    72:   /* Set our perspective */
    73:   gluPerspective( 45.0, ratio, 0.1, 100.0 );
    74: 
    75:   /* Make sure we're chaning the model view and not the projection */
    76:   glMatrixMode( GL_MODELVIEW );
    77: 
    78:   /* Reset The View */
    79:   glLoadIdentity( );
    80:   unblock_sdl_events event_lock;
    81: }
    82: 
    83: /* general OpenGL initialization function */
    84: proc initGL()
    85: {
    86:   /* Enable smooth shading */
    87:   glShadeModel( GL_SMOOTH );
    88: 
    89:   /* Set the background black */
    90:   glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
    91: 
    92:   /* Depth buffer setup */
    93:   glClearDepth( 1.0 );
    94: 
    95:   /* Enables Depth Testing */
    96:   glEnable( GL_DEPTH_TEST );
    97: 
    98:   /* The Type Of Depth Test To Do */
    99:   glDepthFunc( GL_LEQUAL );
   100: 
   101:   /* Really Nice Perspective Calculations */
   102:   glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
   103: }
   104: 
   105: /* These are to calculate our fps */
   106: var T0     = 0;
   107: var Frames = 0;
   108: 
   109: 
   110: /* Here goes our drawing code */
   111: proc drawGLScene(drawing:1->0)
   112: {
   113:   block_sdl_events event_lock;
   114:   drawing();
   115:   unblock_sdl_events event_lock;
   116: 
   117:   /* Gather our frames per second */
   118:   Frames++;
   119:   {
   120:     var t = SDL_GetTicks();
   121:     if t - T0 >= 5000 do
   122:       val seconds = double_of (t - T0) / 1000.0;
   123:       val fps = double_of Frames / seconds;
   124:       print Frames; print " frames in "; print seconds;
   125:       print " seconds = "; print fps; print " FPS"; endl;
   126:       T0 = t;
   127:       Frames = 0;
   128:     done;
   129:   };
   130: }
   131: 
   132: /* whether or not the window is active */
   133: var isActive = true;
   134: 
   135: if SDL_Init(SDL_INIT_AUDIO \| SDL_INIT_VIDEO) < 0 do
   136:   print "Unable to init SDL"; endl;
   137:   System::exit(1);
   138: done;
   139: 
   140: var event_lock = SDL_CreateMutex();
   141: 
   142: 
   143: proc Quit(n:int)
   144: {
   145:   SDL_Quit;
   146:   System::exit 0;
   147: }
   148: 
   149: /* Fetch the video info */
   150: var videoInfo = SDL_GetVideoInfo();
   151: 
   152: if isNULL videoInfo do
   153:   print "Video query failed"; endl;
   154:   Quit 1;
   155: done;
   156: 
   157: /* the flags to pass to SDL_SetVideoMode */
   158: var
   159:   videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
   160:   videoFlags |= cast[uint] SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
   161:   videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
   162:   videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
   163: 
   164: /* This checks to see if surfaces can be stored in memory */
   165: if  videoInfo.->hw_available != 0 do
   166:         videoFlags |= SDL_HWSURFACE;
   167: else
   168:         videoFlags |= SDL_SWSURFACE;
   169: done;
   170: 
   171: /* This checks if hardware blits can be done */
   172: if videoInfo.->blit_hw != 0 do
   173:         videoFlags |= SDL_HWACCEL;
   174: done;
   175: 
   176: /* Sets up OpenGL double buffering */
   177: ignore$ SDL_GL_SetAttribute( cast[SDL_GLattr] SDL_GL_DOUBLEBUFFER, 1 );
   178: 
   179: /* get a SDL surface */
   180: var surface = SDL_SetVideoMode
   181:   (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags )
   182: ;
   183: 
   184: /* Verify there is a surface */
   185: if isNULL surface do
   186:   print "Video mode set failed"; endl;
   187:   Quit 1;
   188: done;
   189: 
   190: /* initialize OpenGL */
   191: initGL();
   192: var gl_vendor = str$ glGetString(GL_VENDOR);
   193: var gl_renderer = str$ glGetString(GL_RENDERER);
   194: var gl_version = str$ glGetString(GL_VERSION);
   195: var gl_extensions = str$ glGetString(GL_EXTENSIONS);
   196: 
   197: print$ "GL vendor = " + gl_vendor; endl;
   198: print$ "GL renderer = " + gl_renderer; endl;
   199: print$ "GL version = " + gl_version; endl;
   200: print$ "GL extensions = " + gl_extensions; endl;
   201: 
   202: /* resize the initial window */
   203: resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );
   204: 
   205: // SDL Event dispatcher
   206: proc handle_active (e:SDL_ActiveEvent)
   207: {
   208:    isActive = e.gain != 0;
   209: }
   210: 
   211: proc handle_resize(e:SDL_ResizeEvent)
   212: {
   213:   block_sdl_events event_lock;
   214:   surface = SDL_SetVideoMode(
   215:     e.w,
   216:     e.h,
   217:     16, videoFlags
   218:   );
   219:   if isNULL surface do
   220:     print "Could not get a surface after resize"; endl;
   221:   done;
   222:   resizeWindow( e.w, e.h );
   223:   unblock_sdl_events event_lock;
   224: }
   225: 
   226: /* function to handle key press events */
   227: proc handle_key( keysym : SDL_keysym)
   228: {
   229:   match keysym.sym with
   230:   | ?k when k == SDLK_ESCAPE => { Quit 0; }
   231:   | ?k when k ==  SDLK_F1 =>
   232:             {
   233:         block_sdl_events event_lock;
   234:         ignore$ SDL_WM_ToggleFullScreen( surface );
   235:         unblock_sdl_events event_lock;
   236:       }
   237:   | _ => {}
   238:   endmatch;
   239: }
   240: 
   241: /* draw the scene */
   242: proc draw(drawing: 1->0) {
   243:   if isActive call drawGLScene( drawing );
   244: }
   245: 
   246: proc keychan(x:schannel[SDL_keysym])
   247: {
   248:   whilst true do
   249:     var &k : SDL_keysym <- read x;
   250:     handle_key k;
   251:   done;
   252: }
   253: 
   254: proc activechan(x:schannel[SDL_ActiveEvent])
   255: {
   256:   whilst true do
   257:     var &k : SDL_ActiveEvent <- read x;
   258:     handle_active k;
   259:   done;
   260: }
   261: 
   262: proc resizechan(x:schannel[SDL_ResizeEvent])
   263: {
   264:   whilst true do
   265:     var &k : SDL_ResizeEvent <- read x;
   266:     handle_resize k;
   267:   done;
   268: }
   269: 
   270: proc drawchan(x:schannel[int], drawing:1->0)
   271: {
   272:   whilst true do
   273:     var &k : int <- read x;
   274:     draw drawing;
   275:   done;
   276: }
   277: 
   278: proc poll_event(e: &SDL_Event)
   279: {
   280: tryagain:>
   281:   //print "Polling event"; endl;
   282:   var result = SDL_PollEvent(unref e);
   283:   if result > 0 do
   284:     //print "Got event"; endl;
   285:     return;
   286:   done;
   287:   Faio::sleep 0.1;
   288:   goto tryagain;
   289: }
   290: 
   291: proc dispatch_event(
   292:   keyboard:schannel[SDL_keysym],
   293:   active:schannel[SDL_ActiveEvent],
   294:   resize:schannel[SDL_ResizeEvent]
   295: )
   296: {
   297:   whilst true do
   298:     // var &e : SDL_Event <- get_sdl_event event_lock;
   299:     var e : SDL_Event;
   300:     poll_event(&e);
   301: 
   302:     match e.type_ with
   303:     | ?et when et == SDL_ACTIVEEVENT =>
   304:       { write (active, e.active); }
   305: 
   306:     | ?et when et == SDL_VIDEORESIZE =>
   307:       { write (resize, e.resize); }
   308: 
   309:     | ?et when et == SDL_KEYDOWN =>
   310:       { write (keyboard, e.key.keysym); }
   311: 
   312:     | ?et when et == SDL_QUIT =>
   313:       { Quit 0; }
   314: 
   315:     | _ => {}
   316:     endmatch;
   317:   done;
   318: }
   319: 
   320: /* write ticks at the desired framerate */
   321: proc framerate (x:schannel[int], framerate:double)
   322: {
   323:   whilst true do
   324:     Faio::sleep framerate;
   325:     write (x,1);
   326:   done;
   327: }
   328: 
   329: /* LINEAR CONTROL MODEL: CANNOT DEADLOCK
   330:   ~~> async/sync connection
   331:   --> sync/sync connection
   332: 
   333:   SDL_event ~~> dispatcher
   334:                 --> resize handler
   335:                 --> active handler
   336:                 --> key handler
   337:   timer ~~> framerate --> draw
   338: */
   339: 
   340: /* make our communication channels */
   341: var keyboard = mk_schannel[SDL_keysym] ();
   342: var active = mk_schannel[SDL_ActiveEvent] ();
   343: var resize = mk_schannel[SDL_ResizeEvent] ();
   344: var clicks = mk_schannel[int] ();
   345: 
   346: /* start up the fthreads and plug them together */
   347: spawn_fthread { dispatch_event (keyboard, active, resize); };
   348: spawn_fthread { resizechan resize; };
   349: spawn_fthread { activechan active; };
   350: spawn_fthread { keychan keyboard; };
   351: 
   352: spawn_fthread { drawchan (clicks, the Drawing); };
   353: spawn_fthread { framerate (clicks, 0.1); };
   354: 
   355: // main thread hangs
   356: 
   357: // THE DRAWING
   358: proc Drawing()
   359: {
   360:   /* Clear The Screen And The Depth Buffer */
   361:   glClear( GL_COLOR_BUFFER_BIT \| GL_DEPTH_BUFFER_BIT );
   362: 
   363:   /* Move Left 1.5 Units And Into The Screen 6.0 */
   364:   glLoadIdentity();
   365:   glTranslatef( -1.5f, 0.0f, -6.0f );
   366: 
   367:   glBegin( GL_TRIANGLES );            /* Drawing Using Triangles */
   368:     glVertex3f(  0.0f,  1.0f, 0.0f ); /* Top */
   369:     glVertex3f( -1.0f, -1.0f, 0.0f ); /* Bottom Left */
   370:     glVertex3f(  1.0f, -1.0f, 0.0f ); /* Bottom Right */
   371:   glEnd( );                           /* Finished Drawing The Triangle */
   372: 
   373:   /* Move Right 3 Units */
   374:   glTranslatef( 3.0f, 0.0f, 0.0f );
   375: 
   376:   glBegin( GL_QUADS );                /* Draw A Quad */
   377:     glVertex3f( -1.0f,  1.0f, 0.0f ); /* Top Left */
   378:     glVertex3f(  1.0f,  1.0f, 0.0f ); /* Top Right */
   379:     glVertex3f(  1.0f, -1.0f, 0.0f ); /* Bottom Right */
   380:     glVertex3f( -1.0f, -1.0f, 0.0f ); /* Bottom Left */
   381:   glEnd( );                           /* Done Drawing The Quad */
   382: 
   383:   /* Draw it to the screen */
   384:   SDL_GL_SwapBuffers( );
   385: }
   386: 
End felix section to tut/examples/sdl202.flx[1]
Start felix section to tut/examples/sdl205.flx[1 /1 ]
     1: #line 3556 "./lpsrc/flx_sdl.pak"
     2: // REQUIRES OpenGL and GLU
     3: /*
     4:  * This code was created by Jeff Molofee '99
     5:  * (ported to Linux/SDL by Ti Leggett '01)
     6:  *
     7:  * If you've found this code useful, please let me know.
     8:  *
     9:  * Visit Jeff at http://nehe.gamedev.net/
    10:  *
    11:  * or for port-specific comments, questions, bugreports etc.
    12:  * email to leggett@eecs.tulane.edu
    13:  */
    14: 
    15: #import <flx.flxh>
    16: include "SDL/SDL";
    17: include "SDL/SDL_keyboard";
    18: include "SDL/SDL_keysym";
    19: include "SDL/SDL_video";
    20: include "SDL/SDL_events";
    21: include "SDL/SDL_timer";
    22: include "SDL/SDL_mutex";
    23: include "SDL/SDL_opengl";
    24: 
    25: include "flx_faio";
    26: include "flx_faio_sdl";
    27: 
    28: open C_hack;
    29: open Carray;
    30: open MixedInt;
    31: open Uint32;
    32: open Uint8;
    33: open Float;
    34: 
    35: open SDL_h;
    36: open SDL_video_h;
    37: open SDL_keyboard_h;
    38: open SDL_events_h;
    39: open SDL_keysym_h;
    40: open SDL_timer_h;
    41: open SDL_mutex_h;
    42: 
    43: // This is the Felix asynchronous event source
    44: open SDL_events;
    45: 
    46: open SDL_opengl_h;
    47: 
    48: /* screen width, height, and bit depth */
    49: val SCREEN_WIDTH  = 640;
    50: val SCREEN_HEIGHT = 480;
    51: val SCREEN_BPP = 16;
    52: 
    53: /* function to reset our viewport after a window resize */
    54: proc resizeWindow( wwidth : int, hheight :int)
    55: {
    56:   var height = hheight;
    57:   var width = wwidth;
    58: 
    59:   block_sdl_events event_lock;
    60:   /* Protect against a divide by zero */
    61:   if height == 0 do height = 1; done;
    62:   var ratio = double_of width / double_of height;
    63: 
    64:   /* Setup our viewport. */
    65:   glViewport( 0, 0, width, height );
    66: 
    67:   /* change to the projection matrix and set our viewing volume. */
    68:   glMatrixMode( GL_PROJECTION );
    69:   glLoadIdentity( );
    70: 
    71:   /* Set our perspective */
    72:   gluPerspective( 45.0, ratio, 0.1, 100.0 );
    73: 
    74:   /* Make sure we're chaning the model view and not the projection */
    75:   glMatrixMode( GL_MODELVIEW );
    76: 
    77:   /* Reset The View */
    78:   glLoadIdentity( );
    79:   unblock_sdl_events event_lock;
    80: }
    81: 
    82: /* general OpenGL initialization function */
    83: proc initGL()
    84: {
    85:   /* Enable smooth shading */
    86:   glShadeModel( GL_SMOOTH );
    87: 
    88:   /* Set the background black */
    89:   glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
    90: 
    91:   /* Depth buffer setup */
    92:   glClearDepth( 1.0 );
    93: 
    94:   /* Enables Depth Testing */
    95:   glEnable( GL_DEPTH_TEST );
    96: 
    97:   /* The Type Of Depth Test To Do */
    98:   glDepthFunc( GL_LEQUAL );
    99: 
   100:   /* Really Nice Perspective Calculations */
   101:   glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
   102: }
   103: 
   104: /* These are to calculate our fps */
   105: var T0     = 0;
   106: var Frames = 0;
   107: 
   108: var rtri = 0.0f; /* Triangle Rotation ( NEW ) */
   109: var rquad = 0.0f; /* Quad Rotation ( NEW ) */
   110: 
   111: proc rotate()
   112: {
   113:   /* Increase The Rotation Variable For The Triangle ( NEW ) */
   114:   rtri  += 0.2f;
   115:   /* Decrease The Rotation Variable For The Quad     ( NEW ) */
   116:   rquad -=0.15f;
   117: }
   118: 
   119: /* Here goes our drawing code */
   120: proc drawGLScene(drawing:1->0)
   121: {
   122:   block_sdl_events event_lock;
   123:   drawing();
   124:   unblock_sdl_events event_lock;
   125: 
   126:   /* Gather our frames per second */
   127:   Frames++;
   128:   {
   129:     var t = SDL_GetTicks();
   130:     if t - T0 >= 5000 do
   131:       val seconds = double_of (t - T0) / 1000.0;
   132:       val fps = double_of Frames / seconds;
   133:       print Frames; print " frames in "; print seconds;
   134:       print " seconds = "; print fps; print " FPS"; endl;
   135:       T0 = t;
   136:       Frames = 0;
   137:     done;
   138:   };
   139:   rotate();
   140: }
   141: 
   142: /* whether or not the window is active */
   143: var isActive = true;
   144: 
   145: if SDL_Init(SDL_INIT_AUDIO \| SDL_INIT_VIDEO) < 0 do
   146:   print "Unable to init SDL"; endl;
   147:   System::exit(1);
   148: done;
   149: 
   150: var event_lock = SDL_CreateMutex();
   151: 
   152: 
   153: proc Quit(n:int)
   154: {
   155:   SDL_Quit;
   156:   System::exit 0;
   157: }
   158: 
   159: /* Fetch the video info */
   160: var videoInfo = SDL_GetVideoInfo();
   161: 
   162: if isNULL videoInfo do
   163:   print "Video query failed"; endl;
   164:   Quit 1;
   165: done;
   166: 
   167: /* the flags to pass to SDL_SetVideoMode */
   168: var
   169:   videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
   170:   videoFlags |= cast[uint] SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
   171:   videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
   172:   videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
   173: 
   174: /* This checks to see if surfaces can be stored in memory */
   175: if  videoInfo.->hw_available != 0 do
   176:         videoFlags |= SDL_HWSURFACE;
   177: else
   178:         videoFlags |= SDL_SWSURFACE;
   179: done;
   180: 
   181: /* This checks if hardware blits can be done */
   182: if videoInfo.->blit_hw != 0 do
   183:         videoFlags |= SDL_HWACCEL;
   184: done;
   185: 
   186: /* Sets up OpenGL double buffering */
   187: ignore$ SDL_GL_SetAttribute( cast[SDL_GLattr] SDL_GL_DOUBLEBUFFER, 1 );
   188: 
   189: /* get a SDL surface */
   190: var surface = SDL_SetVideoMode
   191:   (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags )
   192: ;
   193: 
   194: /* Verify there is a surface */
   195: if isNULL surface do
   196:   print "Video mode set failed"; endl;
   197:   Quit 1;
   198: done;
   199: 
   200: /* initialize OpenGL */
   201: initGL();
   202: 
   203: /* resize the initial window */
   204: resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );
   205: 
   206: // SDL Event dispatcher
   207: proc handle_active (e:SDL_ActiveEvent)
   208: {
   209:    isActive = e.gain != 0;
   210: }
   211: 
   212: proc handle_resize(e:SDL_ResizeEvent)
   213: {
   214:   block_sdl_events event_lock;
   215:   surface = SDL_SetVideoMode(
   216:     e.w,
   217:     e.h,
   218:     16, videoFlags
   219:   );
   220:   if isNULL surface do
   221:     print "Could not get a surface after resize"; endl;
   222:   done;
   223:   resizeWindow( e.w, e.h );
   224:   unblock_sdl_events event_lock;
   225: }
   226: 
   227: /* function to handle key press events */
   228: proc handle_key( keysym : SDL_keysym)
   229: {
   230:   match keysym.sym with
   231:   | ?k when k == SDLK_ESCAPE => { Quit 0; }
   232:   | ?k when k ==  SDLK_F1 =>
   233:             {
   234:         block_sdl_events event_lock;
   235:         ignore$ SDL_WM_ToggleFullScreen( surface );
   236:         unblock_sdl_events event_lock;
   237:       }
   238:   | _ => {}
   239:   endmatch;
   240: }
   241: 
   242: /* draw the scene */
   243: proc draw(drawing: 1->0) {
   244:   if isActive call drawGLScene( drawing );
   245: }
   246: 
   247: proc keychan(x:schannel[SDL_keysym])
   248: {
   249:   whilst true do
   250:     var &k : SDL_keysym <- read x;
   251:     handle_key k;
   252:   done;
   253: }
   254: 
   255: proc activechan(x:schannel[SDL_ActiveEvent])
   256: {
   257:   whilst true do
   258:     var &k : SDL_ActiveEvent <- read x;
   259:     handle_active k;
   260:   done;
   261: }
   262: 
   263: proc resizechan(x:schannel[SDL_ResizeEvent])
   264: {
   265:   whilst true do
   266:     var &k : SDL_ResizeEvent <- read x;
   267:     handle_resize k;
   268:   done;
   269: }
   270: 
   271: proc drawchan(x:schannel[int], drawing:1->0)
   272: {
   273:   whilst true do
   274:     var &k : int <- read x;
   275:     draw drawing;
   276:   done;
   277: }
   278: 
   279: proc execute(x:schannel[int], something:1->0)
   280: {
   281:   whilst true do
   282:     var &k : int <- read x;
   283:     something();
   284:   done;
   285: }
   286: 
   287: proc poll_event(e: &SDL_Event)
   288: {
   289: tryagain:>
   290:   //print "Polling event"; endl;
   291:   var result = SDL_PollEvent(unref e);
   292:   if result > 0 do
   293:     //print "Got event"; endl;
   294:     return;
   295:   done;
   296:   Faio::sleep 0.1;
   297:   goto tryagain;
   298: }
   299: 
   300: proc dispatch_event(
   301:   keyboard:schannel[SDL_keysym],
   302:   active:schannel[SDL_ActiveEvent],
   303:   resize:schannel[SDL_ResizeEvent]
   304: )
   305: {
   306:   whilst true do
   307:     //var &e : SDL_Event <- get_sdl_event event_lock;
   308:     var e : SDL_Event;
   309:     poll_event(&e);
   310:     match e.type_ with
   311:     | ?et when et == SDL_ACTIVEEVENT =>
   312:       { write (active, e.active); }
   313: 
   314:     | ?et when et == SDL_VIDEORESIZE =>
   315:       { write (resize, e.resize); }
   316: 
   317:     | ?et when et == SDL_KEYDOWN =>
   318:       { write (keyboard, e.key.keysym); }
   319: 
   320:     | ?et when et == SDL_QUIT =>
   321:       { Quit 0; }
   322: 
   323:     | _ => {}
   324:     endmatch;
   325:   done;
   326: }
   327: 
   328: /* write ticks at the desired framerate */
   329: proc framerate (x:schannel[int], framerate:double)
   330: {
   331:   whilst true do
   332:     Faio::sleep framerate;
   333:     write (x,1);
   334:   done;
   335: }
   336: 
   337: /* LINEAR CONTROL MODEL: CANNOT DEADLOCK
   338:   ~~> async/sync connection
   339:   --> sync/sync connection
   340: 
   341:   SDL_event ~~> dispatcher
   342:                 --> resize handler
   343:                 --> active handler
   344:                 --> key handler
   345:   timer ~~> framerate --> draw
   346: */
   347: 
   348: /* make our communication channels */
   349: var keyboard = mk_schannel[SDL_keysym] ();
   350: var active = mk_schannel[SDL_ActiveEvent] ();
   351: var resize = mk_schannel[SDL_ResizeEvent] ();
   352: var clicks = mk_schannel[int] ();
   353: var rotation = mk_schannel[int] ();
   354: 
   355: /* start up the fthreads and plug them together */
   356: spawn_fthread { dispatch_event (keyboard, active, resize); };
   357: spawn_fthread { resizechan resize; };
   358: spawn_fthread { activechan active; };
   359: spawn_fthread { keychan keyboard; };
   360: 
   361: spawn_fthread { drawchan (clicks, the Drawing); };
   362: spawn_fthread { framerate (clicks, 0.05); };
   363: spawn_fthread { execute (rotation, the rotate); };
   364: spawn_fthread { framerate (rotation, 0.1); };
   365: 
   366: // main thread hangs
   367: 
   368: /* Here goes our drawing code */
   369: proc Drawing()
   370: {
   371:     /* Clear The Screen And The Depth Buffer */
   372:     glClear( GL_COLOR_BUFFER_BIT \| GL_DEPTH_BUFFER_BIT );
   373: 
   374:     /* Move Left 1.5 Units And Into The Screen 6.0 */
   375:     glLoadIdentity();
   376:     glTranslatef( -1.5f, 0.0f, -6.0f );
   377: 
   378:     /* Rotate The Triangle On The Y axis ( NEW ) */
   379:     glRotatef( rtri, 0.0f, 1.0f, 0.0f );
   380: 
   381:     glBegin( GL_TRIANGLES );             /* Drawing Using Triangles       */
   382:       glColor3f(   1.0f,  0.0f,  0.0f ); /* Red                           */
   383:       glVertex3f(  0.0f,  1.0f,  0.0f ); /* Top Of Triangle (Front)       */
   384:       glColor3f(   0.0f,  1.0f,  0.0f ); /* Green                         */
   385:       glVertex3f( -1.0f, -1.0f,  1.0f ); /* Left Of Triangle (Front)      */
   386:       glColor3f(   0.0f,  0.0f,  1.0f ); /* Blue                          */
   387:       glVertex3f(  1.0f, -1.0f,  1.0f ); /* Right Of Triangle (Front)     */
   388: 
   389:       glColor3f(   1.0f,  0.0f,  0.0f ); /* Red                           */
   390:       glVertex3f(  0.0f,  1.0f,  0.0f ); /* Top Of Triangle (Right)       */
   391:       glColor3f(   0.0f,  0.0f,  1.0f ); /* Blue                          */
   392:       glVertex3f(  1.0f, -1.0f,  1.0f ); /* Left Of Triangle (Right)      */
   393:       glColor3f(   0.0f,  1.0f,  0.0f ); /* Green                         */
   394:       glVertex3f(  1.0f, -1.0f, -1.0f ); /* Right Of Triangle (Right)     */
   395: 
   396:       glColor3f(   1.0f,  0.0f,  0.0f ); /* Red                           */
   397:       glVertex3f(  0.0f,  1.0f,  0.0f ); /* Top Of Triangle (Back)        */
   398:       glColor3f(   0.0f,  1.0f,  0.0f ); /* Green                         */
   399:       glVertex3f(  1.0f, -1.0f, -1.0f ); /* Left Of Triangle (Back)       */
   400:       glColor3f(   0.0f,  0.0f,  1.0f ); /* Blue                          */
   401:       glVertex3f( -1.0f, -1.0f, -1.0f ); /* Right Of Triangle (Back)      */
   402: 
   403:       glColor3f(   1.0f,  0.0f,  0.0f ); /* Red                           */
   404:       glVertex3f(  0.0f,  1.0f,  0.0f ); /* Top Of Triangle (Left)        */
   405:       glColor3f(   0.0f,  0.0f,  1.0f ); /* Blue                          */
   406:       glVertex3f( -1.0f, -1.0f, -1.0f ); /* Left Of Triangle (Left)       */
   407:       glColor3f(   0.0f,  1.0f,  0.0f ); /* Green                         */
   408:       glVertex3f( -1.0f, -1.0f,  1.0f ); /* Right Of Triangle (Left)      */
   409:     glEnd( );                            /* Finished Drawing The Triangle */
   410: 
   411:     /* Move Right 3 Units */
   412:     glLoadIdentity( );
   413:     glTranslatef( 1.5f, 0.0f, -6.0f );
   414: 
   415:     /* Rotate The Quad On The X axis ( NEW ) */
   416:     glRotatef( rquad, 1.0f, 0.0f, 0.0f );
   417: 
   418:     /* Set The Color To Blue One Time Only */
   419:     glColor3f( 0.5f, 0.5f, 1.0f);
   420: 
   421:     glBegin( GL_QUADS );                 /* Draw A Quad                      */
   422:       glColor3f(   0.0f,  1.0f,  0.0f ); /* Set The Color To Green           */
   423:       glVertex3f(  1.0f,  1.0f, -1.0f ); /* Top Right Of The Quad (Top)      */
   424:       glVertex3f( -1.0f,  1.0f, -1.0f ); /* Top Left Of The Quad (Top)       */
   425:       glVertex3f( -1.0f,  1.0f,  1.0f ); /* Bottom Left Of The Quad (Top)    */
   426:       glVertex3f(  1.0f,  1.0f,  1.0f ); /* Bottom Right Of The Quad (Top)   */
   427: 
   428:       glColor3f(   1.0f,  0.5f,  0.0f ); /* Set The Color To Orange          */
   429:       glVertex3f(  1.0f, -1.0f,  1.0f ); /* Top Right Of The Quad (Botm)     */
   430:       glVertex3f( -1.0f, -1.0f,  1.0f ); /* Top Left Of The Quad (Botm)      */
   431:       glVertex3f( -1.0f, -1.0f, -1.0f ); /* Bottom Left Of The Quad (Botm)   */
   432:       glVertex3f(  1.0f, -1.0f, -1.0f ); /* Bottom Right Of The Quad (Botm)  */
   433: 
   434:       glColor3f(   1.0f,  0.0f,  0.0f ); /* Set The Color To Red             */
   435:       glVertex3f(  1.0f,  1.0f,  1.0f ); /* Top Right Of The Quad (Front)    */
   436:       glVertex3f( -1.0f,  1.0f,  1.0f ); /* Top Left Of The Quad (Front)     */
   437:       glVertex3f( -1.0f, -1.0f,  1.0f ); /* Bottom Left Of The Quad (Front)  */
   438:       glVertex3f(  1.0f, -1.0f,  1.0f ); /* Bottom Right Of The Quad (Front) */
   439: 
   440:       glColor3f(   1.0f,  1.0f,  0.0f ); /* Set The Color To Yellow          */
   441:       glVertex3f(  1.0f, -1.0f, -1.0f ); /* Bottom Left Of The Quad (Back)   */
   442:       glVertex3f( -1.0f, -1.0f, -1.0f ); /* Bottom Right Of The Quad (Back)  */
   443:       glVertex3f( -1.0f,  1.0f, -1.0f ); /* Top Right Of The Quad (Back)     */
   444:       glVertex3f(  1.0f,  1.0f, -1.0f ); /* Top Left Of The Quad (Back)      */
   445: 
   446:       glColor3f(   0.0f,  0.0f,  1.0f ); /* Set The Color To Blue            */
   447:       glVertex3f( -1.0f,  1.0f,  1.0f ); /* Top Right Of The Quad (Left)     */
   448:       glVertex3f( -1.0f,  1.0f, -1.0f ); /* Top Left Of The Quad (Left)      */
   449:       glVertex3f( -1.0f, -1.0f, -1.0f ); /* Bottom Left Of The Quad (Left)   */
   450:       glVertex3f( -1.0f, -1.0f,  1.0f ); /* Bottom Right Of The Quad (Left)  */
   451: 
   452:       glColor3f(   1.0f,  0.0f,  1.0f ); /* Set The Color To Violet          */
   453:       glVertex3f(  1.0f,  1.0f, -1.0f ); /* Top Right Of The Quad (Right)    */
   454:       glVertex3f(  1.0f,  1.0f,  1.0f ); /* Top Left Of The Quad (Right)     */
   455:       glVertex3f(  1.0f, -1.0f,  1.0f ); /* Bottom Left Of The Quad (Right)  */
   456:       glVertex3f(  1.0f, -1.0f, -1.0f ); /* Bottom Right Of The Quad (Right) */
   457:     glEnd( );                            /* Done Drawing The Quad            */
   458: 
   459:     /* Draw it to the screen */
   460:     SDL_GL_SwapBuffers( );
   461: }
   462: 
End felix section to tut/examples/sdl205.flx[1]
Start felix section to tut/examples/sdl206.flx[1 /1 ]
     1: #line 4019 "./lpsrc/flx_sdl.pak"
     2: // REQUIRES OpenGL and GLU
     3: /*
     4:  * This code was created by Jeff Molofee '99
     5:  * (ported to Linux/SDL by Ti Leggett '01)
     6:  *
     7:  * If you've found this code useful, please let me know.
     8:  *
     9:  * Visit Jeff at http://nehe.gamedev.net/
    10:  *
    11:  * or for port-specific comments, questions, bugreports etc.
    12:  * email to leggett@eecs.tulane.edu
    13:  */
    14: 
    15: #import <flx.flxh>
    16: include "SDL/SDL";
    17: include "SDL/SDL_keyboard";
    18: include "SDL/SDL_keysym";
    19: include "SDL/SDL_video";
    20: include "SDL/SDL_events";
    21: include "SDL/SDL_timer";
    22: include "SDL/SDL_mutex";
    23: include "SDL/SDL_opengl";
    24: 
    25: include "flx_faio";
    26: include "flx_faio_sdl";
    27: 
    28: 
    29: open C_hack;
    30: open Carray;
    31: open MixedInt;
    32: open Uint32;
    33: open Uint8;
    34: open Float;
    35: 
    36: open SDL_h;
    37: open SDL_video_h;
    38: open SDL_keyboard_h;
    39: open SDL_events_h;
    40: open SDL_keysym_h;
    41: open SDL_timer_h;
    42: open SDL_mutex_h;
    43: 
    44: // This is the Felix asynchronous event source
    45: open SDL_events;
    46: 
    47: open SDL_opengl_h;
    48: 
    49: /* screen width, height, and bit depth */
    50: val SCREEN_WIDTH  = 640;
    51: val SCREEN_HEIGHT = 480;
    52: val SCREEN_BPP = 16;
    53: 
    54: /* function to reset our viewport after a window resize */
    55: proc resizeWindow( wwidth : int, hheight :int)
    56: {
    57:   var height = hheight;
    58:   var width = wwidth;
    59: 
    60:   /* Protect against a divide by zero */
    61:   if height == 0 do height = 1; done;
    62:   var ratio = double_of width / double_of height;
    63: 
    64:   block_sdl_events event_lock;
    65:   /* Setup our viewport. */
    66:   glViewport( 0, 0, width, height );
    67: 
    68:   /* change to the projection matrix and set our viewing volume. */
    69:   glMatrixMode( GL_PROJECTION );
    70:   glLoadIdentity( );
    71: 
    72:   /* Set our perspective */
    73:   gluPerspective( 45.0, ratio, 0.1, 100.0 );
    74: 
    75:   /* Make sure we're chaning the model view and not the projection */
    76:   glMatrixMode( GL_MODELVIEW );
    77: 
    78:   /* Reset The View */
    79:   glLoadIdentity( );
    80:   unblock_sdl_events event_lock;
    81: }
    82: 
    83: /* function to load in bitmap as a GL texture */
    84: proc LoadGLTextures( )
    85: {
    86:   /* Create storage space for the texture */
    87:   var TextureImage = SDL_LoadBMP(enconst c"media/textures/sdl206.bmp");
    88:   if isNULL TextureImage do
    89:     print "Can't load texture file media/textures/sdl206.bmp";
    90:     Quit 1;
    91:   done;
    92: 
    93:   /* Create The Texture */
    94:         glGenTextures( 1, texture );
    95: 
    96:   /* Typical Texture Generation Using Data From The Bitmap */
    97:   glBindTexture( GL_TEXTURE_2D, texture.[0] );
    98: 
    99:         /* Generate The Texture */
   100:   glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage.->w,
   101:     TextureImage.->h, 0, GL_RGB,
   102:     GL_UNSIGNED_BYTE, TextureImage.->pixels
   103:   );
   104: 
   105:   /* Linear Filtering */
   106:   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
   107:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
   108: 
   109:   /* Free up any memory we may have used */
   110:         SDL_FreeSurface( TextureImage );
   111: }
   112: 
   113: /* general OpenGL initialization function */
   114: proc initGL()
   115: {
   116:   /* Enable Texture Mapping ( NEW ) */
   117:   glEnable( GL_TEXTURE_2D );
   118: 
   119:   /* Enable smooth shading */
   120:   glShadeModel( GL_SMOOTH );
   121: 
   122:   /* Set the background black */
   123:   glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
   124: 
   125:   /* Depth buffer setup */
   126:   glClearDepth( 1.0 );
   127: 
   128:   /* Enables Depth Testing */
   129:   glEnable( GL_DEPTH_TEST );
   130: 
   131:   /* The Type Of Depth Test To Do */
   132:   glDepthFunc( GL_LEQUAL );
   133: 
   134:   /* Really Nice Perspective Calculations */
   135:   glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
   136: }
   137: 
   138: /* These are to calculate our fps */
   139: var T0     = 0;
   140: var Frames = 0;
   141: 
   142: var xrot = 0.0f; /* X Rotation ( NEW ) */
   143: var yrot = 0.0f; /* Y Rotation ( NEW ) */
   144: var zrot = 0.0f; /* Z Rotation ( NEW ) */
   145: 
   146: proc rotate()
   147: {
   148:   xrot += 0.3f; /* X Axis Rotation */
   149:   yrot += 0.2f; /* Y Axis Rotation */
   150:   zrot += 0.4f; /* Z Axis Rotation */
   151: }
   152: 
   153: var f_texture : uint ^ 1; /* Storage For One Texture ( NEW ) */
   154: var texture : ptr[uint] = carray_of f_texture;
   155: 
   156: 
   157: /* Here goes our drawing code */
   158: proc drawGLScene(drawing:1->0)
   159: {
   160:   block_sdl_events event_lock;
   161:   drawing();
   162:   unblock_sdl_events event_lock;
   163: 
   164:   /* Gather our frames per second */
   165:   Frames++;
   166:   {
   167:     var t = SDL_GetTicks();
   168:     if t - T0 >= 5000 do
   169:       val seconds = double_of (t - T0) / 1000.0;
   170:       val fps = double_of Frames / seconds;
   171:       print Frames; print " frames in "; print seconds;
   172:       print " seconds = "; print fps; print " FPS"; endl;
   173:       T0 = t;
   174:       Frames = 0;
   175:     done;
   176:   };
   177:   rotate();
   178: }
   179: 
   180: /* whether or not the window is active */
   181: var isActive = true;
   182: 
   183: if SDL_Init(SDL_INIT_AUDIO \| SDL_INIT_VIDEO) < 0 do
   184:   print "Unable to init SDL"; endl;
   185:   System::exit(1);
   186: done;
   187: 
   188: var event_lock = SDL_CreateMutex();
   189: 
   190: 
   191: proc Quit(n:int)
   192: {
   193:   SDL_Quit;
   194:   System::exit 0;
   195: }
   196: 
   197: /* Fetch the video info */
   198: var videoInfo = SDL_GetVideoInfo();
   199: 
   200: if isNULL videoInfo do
   201:   print "Video query failed"; endl;
   202:   Quit 1;
   203: done;
   204: 
   205: /* the flags to pass to SDL_SetVideoMode */
   206: var
   207:   videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
   208:   videoFlags |= cast[uint] SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
   209:   videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
   210:   videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
   211: 
   212: /* This checks to see if surfaces can be stored in memory */
   213: if  videoInfo.->hw_available != 0 do
   214:         videoFlags |= SDL_HWSURFACE;
   215: else
   216:         videoFlags |= SDL_SWSURFACE;
   217: done;
   218: 
   219: /* This checks if hardware blits can be done */
   220: if videoInfo.->blit_hw != 0 do
   221:         videoFlags |= SDL_HWACCEL;
   222: done;
   223: 
   224: /* Sets up OpenGL double buffering */
   225: ignore$ SDL_GL_SetAttribute( cast[SDL_GLattr] SDL_GL_DOUBLEBUFFER, 1 );
   226: 
   227: /* get a SDL surface */
   228: var surface = SDL_SetVideoMode
   229:   (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags )
   230: ;
   231: 
   232: /* Verify there is a surface */
   233: if isNULL surface do
   234:   print "Video mode set failed"; endl;
   235:   Quit 1;
   236: done;
   237: 
   238: /* initialize OpenGL */
   239: initGL();
   240: LoadGLTextures();
   241: 
   242: /* resize the initial window */
   243: resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );
   244: 
   245: // SDL Event dispatcher
   246: proc handle_active (e:SDL_ActiveEvent)
   247: {
   248:    isActive = e.gain != 0;
   249: }
   250: 
   251: proc handle_resize(e:SDL_ResizeEvent)
   252: {
   253:   block_sdl_events event_lock;
   254:   surface = SDL_SetVideoMode(
   255:     e.w,
   256:     e.h,
   257:     16, videoFlags
   258:   );
   259:   if isNULL surface do
   260:     print "Could not get a surface after resize"; endl;
   261:   done;
   262:   resizeWindow( e.w, e.h );
   263:   unblock_sdl_events event_lock;
   264: }
   265: 
   266: /* function to handle key press events */
   267: proc handle_key( keysym : SDL_keysym)
   268: {
   269:   match keysym.sym with
   270:   | ?k when k == SDLK_ESCAPE => { Quit 0; }
   271:   | ?k when k ==  SDLK_F1 =>
   272:             {
   273:         block_sdl_events event_lock;
   274:         ignore$ SDL_WM_ToggleFullScreen( surface );
   275:         unblock_sdl_events event_lock;
   276:       }
   277:   | _ => {}
   278:   endmatch;
   279: }
   280: 
   281: /* draw the scene */
   282: proc draw(drawing: 1->0) {
   283:   if isActive call drawGLScene( drawing );
   284: }
   285: 
   286: proc keychan(x:schannel[SDL_keysym])
   287: {
   288:   whilst true do
   289:     var &k : SDL_keysym <- read x;
   290:     handle_key k;
   291:   done;
   292: }
   293: 
   294: proc activechan(x:schannel[SDL_ActiveEvent])
   295: {
   296:   whilst true do
   297:     var &k : SDL_ActiveEvent <- read x;
   298:     handle_active k;
   299:   done;
   300: }
   301: 
   302: proc resizechan(x:schannel[SDL_ResizeEvent])
   303: {
   304:   whilst true do
   305:     var &k : SDL_ResizeEvent <- read x;
   306:     handle_resize k;
   307:   done;
   308: }
   309: 
   310: proc drawchan(x:schannel[int], drawing:1->0)
   311: {
   312:   whilst true do
   313:     var &k : int <- read x;
   314:     draw drawing;
   315:   done;
   316: }
   317: 
   318: proc execute(x:schannel[int], something:1->0)
   319: {
   320:   whilst true do
   321:     var &k : int <- read x;
   322:     something();
   323:   done;
   324: }
   325: 
   326: proc poll_event(e: &SDL_Event)
   327: {
   328: tryagain:>
   329:   //print "Polling event"; endl;
   330:   var result = SDL_PollEvent(unref e);
   331:   if result > 0 do
   332:     //print "Got event"; endl;
   333:     return;
   334:   done;
   335:   Faio::sleep 0.1;
   336:   goto tryagain;
   337: }
   338: 
   339: 
   340: proc dispatch_event(
   341:   keyboard:schannel[SDL_keysym],
   342:   active:schannel[SDL_ActiveEvent],
   343:   resize:schannel[SDL_ResizeEvent]
   344: )
   345: {
   346:   whilst true do
   347:     //var &e : SDL_Event <- get_sdl_event event_lock;
   348:     var e : SDL_Event;
   349:     poll_event(&e);
   350:     match e.type_ with
   351:     | ?et when et == SDL_ACTIVEEVENT =>
   352:       { write (active, e.active); }
   353: 
   354:     | ?et when et == SDL_VIDEORESIZE =>
   355:       { write (resize, e.resize); }
   356: 
   357:     | ?et when et == SDL_KEYDOWN =>
   358:       { write (keyboard, e.key.keysym); }
   359: 
   360:     | ?et when et == SDL_QUIT =>
   361:       { Quit 0; }
   362: 
   363:     | _ => {}
   364:     endmatch;
   365:   done;
   366: }
   367: 
   368: /* write ticks at the desired framerate */
   369: proc framerate (x:schannel[int], framerate:double)
   370: {
   371:   whilst true do
   372:     Faio::sleep framerate;
   373:     write (x,1);
   374:   done;
   375: }
   376: 
   377: /* LINEAR CONTROL MODEL: CANNOT DEADLOCK
   378:   ~~> async/sync connection
   379:   --> sync/sync connection
   380: 
   381:   SDL_event ~~> dispatcher
   382:                 --> resize handler
   383:                 --> active handler
   384:                 --> key handler
   385:   timer ~~> framerate --> draw
   386: */
   387: 
   388: /* make our communication channels */
   389: var keyboard = mk_schannel[SDL_keysym] ();
   390: var active = mk_schannel[SDL_ActiveEvent] ();
   391: var resize = mk_schannel[SDL_ResizeEvent] ();
   392: var clicks = mk_schannel[int] ();
   393: var rotation = mk_schannel[int] ();
   394: 
   395: /* start up the fthreads and plug them together */
   396: spawn_fthread { dispatch_event (keyboard, active, resize); };
   397: spawn_fthread { resizechan resize; };
   398: spawn_fthread { activechan active; };
   399: spawn_fthread { keychan keyboard; };
   400: 
   401: spawn_fthread { drawchan (clicks, the Drawing); };
   402: spawn_fthread { framerate (clicks, 0.1); };
   403: spawn_fthread { execute (rotation, the rotate); };
   404: spawn_fthread { framerate (rotation, 0.1); };
   405: 
   406: 
   407: // main thread hangs
   408: 
   409: /* Here goes our drawing code */
   410: proc Drawing()
   411: {
   412:     /* Clear The Screen And The Depth Buffer */
   413:     glClear( GL_COLOR_BUFFER_BIT \| GL_DEPTH_BUFFER_BIT );
   414: 
   415:     /* Move Into The Screen 5 Units */
   416:     glLoadIdentity( );
   417:     glTranslatef( 0.0f, 0.0f, -5.0f );
   418: 
   419:     glRotatef( xrot, 1.0f, 0.0f, 0.0f); /* Rotate On The X Axis */
   420:     glRotatef( yrot, 0.0f, 1.0f, 0.0f); /* Rotate On The Y Axis */
   421:     glRotatef( zrot, 0.0f, 0.0f, 1.0f); /* Rotate On The Z Axis */
   422: 
   423:     /* Select Our Texture */
   424:     glBindTexture( GL_TEXTURE_2D, texture.[0] );
   425: 
   426:     /* NOTE:
   427:      *   The x coordinates of the glTexCoord2f function need to inverted
   428:      * for SDL because of the way SDL_LoadBmp loads the data. So where
   429:      * in the tutorial it has glTexCoord2f( 1.0f, 0.0f ); it should
   430:      * now read glTexCoord2f( 0.0f, 0.0f );
   431:      */
   432:     glBegin(GL_QUADS);
   433:       /* Front Face */
   434:       /* Bottom Left Of The Texture and Quad */
   435:       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 1.0f );
   436:       /* Bottom Right Of The Texture and Quad */
   437:       glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 1.0f );
   438:       /* Top Right Of The Texture and Quad */
   439:       glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 1.0f );
   440:       /* Top Left Of The Texture and Quad */
   441:       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 1.0f );
   442: 
   443:       /* Back Face */
   444:       /* Bottom Right Of The Texture and Quad */
   445:       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
   446:       /* Top Right Of The Texture and Quad */
   447:       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
   448:       /* Top Left Of The Texture and Quad */
   449:       glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f,  1.0f, -1.0f );
   450:       /* Bottom Left Of The Texture and Quad */
   451:       glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f, -1.0f, -1.0f );
   452: 
   453:       /* Top Face */
   454:       /* Top Left Of The Texture and Quad */
   455:       glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
   456:       /* Bottom Left Of The Texture and Quad */
   457:       glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f,  1.0f );
   458:       /* Bottom Right Of The Texture and Quad */
   459:       glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f,  1.0f );
   460:       /* Top Right Of The Texture and Quad */
   461:       glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f,  1.0f, -1.0f );
   462: 
   463:       /* Bottom Face */
   464:       /* Top Right Of The Texture and Quad */
   465:       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
   466:       /* Top Left Of The Texture and Quad */
   467:       glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, -1.0f );
   468:       /* Bottom Left Of The Texture and Quad */
   469:       glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f, -1.0f,  1.0f );
   470:       /* Bottom Right Of The Texture and Quad */
   471:       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f,  1.0f );
   472: 
   473:       /* Right face */
   474:       /* Bottom Right Of The Texture and Quad */
   475:       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 1.0f, -1.0f, -1.0f );
   476:       /* Top Right Of The Texture and Quad */
   477:       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 1.0f,  1.0f, -1.0f );
   478:       /* Top Left Of The Texture and Quad */
   479:       glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 1.0f,  1.0f,  1.0f );
   480:       /* Bottom Left Of The Texture and Quad */
   481:       glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 1.0f, -1.0f,  1.0f );
   482: 
   483:       /* Left Face */
   484:       /* Bottom Left Of The Texture and Quad */
   485:       glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
   486:       /* Bottom Right Of The Texture and Quad */
   487:       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f,  1.0f );
   488:       /* Top Right Of The Texture and Quad */
   489:       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f,  1.0f,  1.0f );
   490:       /* Top Left Of The Texture and Quad */
   491:       glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
   492:     glEnd( );
   493: 
   494:     /* Draw it to the screen */
   495:     SDL_GL_SwapBuffers( );
   496: }
   497: 
End felix section to tut/examples/sdl206.flx[1]
Start felix section to tut/examples/sdl208.flx[1 /1 ]
     1: #line 4517 "./lpsrc/flx_sdl.pak"
     2: // REQUIRES OpenGL and GLU
     3: /*
     4:  * This code was created by Jeff Molofee '99
     5:  * (ported to Linux/SDL by Ti Leggett '01)
     6:  *
     7:  * If you've found this code useful, please let me know.
     8:  *
     9:  * Visit Jeff at http://nehe.gamedev.net/
    10:  *
    11:  * or for port-specific comments, questions, bugreports etc.
    12:  * email to leggett@eecs.tulane.edu
    13:  */
    14: 
    15: #import <flx.flxh>
    16: include "SDL/SDL";
    17: include "SDL/SDL_keyboard";
    18: include "SDL/SDL_keysym";
    19: include "SDL/SDL_video";
    20: include "SDL/SDL_events";
    21: include "SDL/SDL_timer";
    22: include "SDL/SDL_mutex";
    23: include "SDL/SDL_opengl";
    24: 
    25: include "flx_faio";
    26: include "flx_faio_sdl";
    27: 
    28: open C_hack;
    29: open Carray;
    30: open MixedInt;
    31: open Uint32;
    32: open Uint8;
    33: open Float;
    34: 
    35: open SDL_h;
    36: open SDL_video_h;
    37: open SDL_keyboard_h;
    38: open SDL_events_h;
    39: open SDL_keysym_h;
    40: open SDL_timer_h;
    41: open SDL_mutex_h;
    42: 
    43: // This is the Felix asynchronous event source
    44: open SDL_events;
    45: 
    46: open SDL_opengl_h;
    47: 
    48: /* screen width, height, and bit depth */
    49: val SCREEN_WIDTH  = 640;
    50: val SCREEN_HEIGHT = 480;
    51: val SCREEN_BPP = 16;
    52: 
    53: /* function to reset our viewport after a window resize */
    54: proc resizeWindow( wwidth : int, hheight :int)
    55: {
    56:   var height = hheight;
    57:   var width = wwidth;
    58: 
    59:   /* Protect against a divide by zero */
    60:   if height == 0 do height = 1; done;
    61:   var ratio = double_of width / double_of height;
    62: 
    63:   block_sdl_events event_lock;
    64:   /* Setup our viewport. */
    65:   glViewport( 0, 0, width, height );
    66: 
    67:   /* change to the projection matrix and set our viewing volume. */
    68:   glMatrixMode( GL_PROJECTION );
    69:   glLoadIdentity( );
    70: 
    71:   /* Set our perspective */
    72:   gluPerspective( 45.0, ratio, 0.1, 100.0 );
    73: 
    74:   /* Make sure we're chaning the model view and not the projection */
    75:   glMatrixMode( GL_MODELVIEW );
    76: 
    77:   /* Reset The View */
    78:   glLoadIdentity( );
    79:   unblock_sdl_events event_lock;
    80: }
    81: 
    82: /* function to load in bitmap as a GL texture */
    83: proc LoadGLTextures( )
    84: {
    85:   /* Create storage space for the texture */
    86:   var TextureImage = SDL_LoadBMP(enconst c"media/textures/sdl208.bmp");
    87:   if isNULL TextureImage do
    88:     print "Can't load texture file media/textures/sdl206.bmp";
    89:     Quit 1;
    90:   done;
    91: 
    92:   /* Create The Texture */
    93:         glGenTextures( 3, texture );
    94: 
    95:   /* Typical Texture Generation Using Data From The Bitmap */
    96:   glBindTexture( GL_TEXTURE_2D, texture.[0] );
    97: 
    98:         /* Generate The Texture */
    99:   glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage.->w,
   100:     TextureImage.->h, 0, GL_RGB,
   101:     GL_UNSIGNED_BYTE, TextureImage.->pixels
   102:   );
   103: 
   104:   /* Linear Filtering */
   105:   glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   106:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
   107: 
   108:   glBindTexture( GL_TEXTURE_2D, texture.[1] );
   109: 
   110:   /* Linear Filtering */
   111:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
   112:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
   113: 
   114:         /* Generate The Texture */
   115:   glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage.->w,
   116:     TextureImage.->h, 0, cast[uint] GL_RGB,
   117:     GL_UNSIGNED_BYTE, TextureImage.->pixels
   118:   );
   119: 
   120:   glBindTexture( GL_TEXTURE_2D, texture.[2] );
   121: 
   122:   /* Linear Filtering */
   123:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
   124:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST );
   125: 
   126:   /* Generate The MipMapped Texture ( NEW ) */
   127:   ignore(gluBuild2DMipmaps(
   128:     GL_TEXTURE_2D, 3,
   129:     TextureImage.->w, TextureImage.->h,
   130:     GL_RGB, GL_UNSIGNED_BYTE,
   131:     cast[caddress] TextureImage.->pixels
   132:   ));
   133: 
   134:   /* Free up any memory we may have used */
   135:         SDL_FreeSurface( TextureImage );
   136: }
   137: 
   138: /* general OpenGL initialization function */
   139: proc initGL()
   140: {
   141:   /* Enable Texture Mapping ( NEW ) */
   142:   glEnable( GL_TEXTURE_2D );
   143: 
   144:   /* Enable smooth shading */
   145:   glShadeModel( GL_SMOOTH );
   146: 
   147:   /* Set the background black */
   148:   glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
   149: 
   150:   /* Depth buffer setup */
   151:   glClearDepth( 1.0 );
   152: 
   153:   /* Enables Depth Testing */
   154:   glEnable( GL_DEPTH_TEST );
   155: 
   156:   /* The Type Of Depth Test To Do */
   157:   glDepthFunc( GL_LEQUAL );
   158: 
   159:   /* Really Nice Perspective Calculations */
   160:   glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
   161: 
   162:   /* Setup The Ambient Light */
   163:   glLightfv( GL_LIGHT1, GL_AMBIENT, enconst (carray_of LightAmbient) );
   164: 
   165:   /* Setup The Diffuse Light */
   166:   glLightfv( GL_LIGHT1, GL_DIFFUSE, enconst (carray_of LightDiffuse) );
   167: 
   168:   /* Position The Light */
   169:   glLightfv( GL_LIGHT1, GL_POSITION, enconst (carray_of LightPosition) );
   170: 
   171:   /* Enable Light One */
   172:   glEnable( GL_LIGHT1 );
   173: 
   174:   /* Full Brightness, 50% Alpha ( NEW ) */
   175:   glColor4f( 1.0f, 1.0f, 1.0f, 0.5f);
   176: 
   177:   /* Blending Function For Translucency Based On Source Alpha Value  */
   178:   glBlendFunc( GL_SRC_ALPHA, GL_ONE );
   179: }
   180: 
   181: /* These are to calculate our fps */
   182: var T0     = 0;
   183: var Frames = 0;
   184: 
   185: var xrot = 0.0f; /* X Rotation ( NEW ) */
   186: var yrot = 0.0f; /* Y Rotation ( NEW ) */
   187: var z = -5.0f;   /* Depth Into The Screen */
   188: 
   189: var xspeed = 0.0f;
   190: var yspeed = 0.0f;
   191: 
   192: proc rotate()
   193: {
   194:   xrot += xspeed; /* Add xspeed To xrot */
   195:   yrot += yspeed; /* Add yspeed To yrot */
   196: }
   197: 
   198: 
   199: var light = false; /* Whether or not lighting is on */
   200: var blend = false; /* Whether or not blending is on */
   201: 
   202: 
   203: /* Ambient Light Values ( NEW ) */
   204: var LightAmbient =  0.5f, 0.5f, 0.5f, 1.0f;
   205: 
   206: /* Diffuse Light Values ( NEW ) */
   207: var LightDiffuse  = 1.0f, 1.0f, 1.0f, 1.0f;
   208: 
   209: /* Light Position ( NEW ) */
   210: var LightPosition = 0.0f, 0.0f, 2.0f, 1.0f;
   211: 
   212: var filter = 0;
   213: 
   214: var f_texture : uint ^ 3; /* Storage For 3 Textures ( NEW ) */
   215: var texture : ptr[uint] = carray_of f_texture;
   216: 
   217: 
   218: /* Here goes our drawing code */
   219: proc drawGLScene(drawing:1->0)
   220: {
   221:   block_sdl_events event_lock;
   222:   drawing();
   223:   unblock_sdl_events event_lock;
   224: 
   225:   /* Gather our frames per second */
   226:   Frames++;
   227:   {
   228:     var t = SDL_GetTicks();
   229:     if t - T0 >= 5000 do
   230:       val seconds = double_of (t - T0) / 1000.0;
   231:       val fps = double_of Frames / seconds;
   232:       print Frames; print " frames in "; print seconds;
   233:       print " seconds = "; print fps; print " FPS"; endl;
   234:       T0 = t;
   235:       Frames = 0;
   236:     done;
   237:   };
   238:   rotate();
   239: }
   240: 
   241: /* whether or not the window is active */
   242: var isActive = true;
   243: 
   244: if SDL_Init(SDL_INIT_AUDIO \| SDL_INIT_VIDEO) < 0 do
   245:   print "Unable to init SDL"; endl;
   246:   System::exit(1);
   247: done;
   248: 
   249: var event_lock = SDL_CreateMutex();
   250: 
   251: 
   252: proc Quit(n:int)
   253: {
   254:   SDL_Quit;
   255:   System::exit 0;
   256: }
   257: 
   258: /* Fetch the video info */
   259: var videoInfo = SDL_GetVideoInfo();
   260: 
   261: if isNULL videoInfo do
   262:   print "Video query failed"; endl;
   263:   Quit 1;
   264: done;
   265: 
   266: /* the flags to pass to SDL_SetVideoMode */
   267: var
   268:   videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
   269:   videoFlags |= cast[uint] SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
   270:   videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
   271:   videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
   272: 
   273: /* This checks to see if surfaces can be stored in memory */
   274: if  videoInfo.->hw_available != 0 do
   275:         videoFlags |= SDL_HWSURFACE;
   276: else
   277:         videoFlags |= SDL_SWSURFACE;
   278: done;
   279: 
   280: /* This checks if hardware blits can be done */
   281: if videoInfo.->blit_hw != 0 do
   282:         videoFlags |= SDL_HWACCEL;
   283: done;
   284: 
   285: /* Sets up OpenGL double buffering */
   286: ignore$ SDL_GL_SetAttribute( cast[SDL_GLattr] SDL_GL_DOUBLEBUFFER, 1 );
   287: 
   288: /* get a SDL surface */
   289: var surface = SDL_SetVideoMode
   290:   (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags )
   291: ;
   292: 
   293: /* Verify there is a surface */
   294: if isNULL surface do
   295:   print "Video mode set failed"; endl;
   296:   Quit 1;
   297: done;
   298: 
   299: /* initialize OpenGL */
   300: initGL();
   301: LoadGLTextures();
   302: 
   303: /* resize the initial window */
   304: resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );
   305: 
   306: // SDL Event dispatcher
   307: proc handle_active (e:SDL_ActiveEvent)
   308: {
   309:    isActive = e.gain != 0;
   310: }
   311: 
   312: proc handle_resize(e:SDL_ResizeEvent)
   313: {
   314:   block_sdl_events event_lock;
   315:   surface = SDL_SetVideoMode(
   316:     e.w,
   317:     e.h,
   318:     16, videoFlags
   319:   );
   320:   if isNULL surface do
   321:     print "Could not get a surface after resize"; endl;
   322:   done;
   323:   resizeWindow( e.w, e.h );
   324:   unblock_sdl_events event_lock;
   325: }
   326: 
   327: /* function to handle key press events */
   328: proc handle_key( keysym : SDL_keysym)
   329: {
   330:   match keysym.sym with
   331:   | ?k when k == SDLK_ESCAPE => { Quit 0; }
   332:   | ?k when k ==  SDLK_F1 =>
   333:             { ignore$ SDL_WM_ToggleFullScreen( surface ); }
   334:   | ?k when k == SDLK_b =>
   335:     {
   336:       blend = not blend;
   337:       if blend do
   338:                     glEnable( GL_BLEND );
   339:                     glDisable( GL_DEPTH_TEST );
   340:       else
   341:                     glDisable( GL_BLEND );
   342:                     glEnable( GL_DEPTH_TEST );
   343:       done;
   344:     }
   345:   | ?k when k == SDLK_f =>
   346:     {
   347:             filter = ( filter + 1) % 3;
   348:       print "Filter "; print filter; endl;
   349:     }
   350:   | ?k when k == SDLK_l =>
   351:     {
   352:             light = not light;
   353:             if not light do
   354:         glDisable( GL_LIGHTING );
   355:             else
   356:         glEnable( GL_LIGHTING );
   357:             done;
   358:     }
   359:   | ?k when k == SDLK_PAGEUP =>
   360:     {
   361:             z = z - 0.02f;
   362:     }
   363: 
   364:   | ?k when k == SDLK_PAGEDOWN =>
   365:     {
   366:             z = z + 0.02f;
   367:     }
   368: 
   369:   | ?k when k == SDLK_UP =>
   370:     {
   371:       xspeed = xspeed - 0.01f;
   372:     }
   373: 
   374:   | ?k when k == SDLK_DOWN =>
   375:     {
   376:       xspeed = xspeed + 0.01f;
   377:     }
   378: 
   379:   | ?k when k == SDLK_RIGHT =>
   380:     {
   381:       yspeed = yspeed + 0.01f;
   382:     }
   383: 
   384:   | ?k when k == SDLK_LEFT =>
   385:     {
   386:       yspeed = yspeed - 0.01f;
   387:     }
   388: 
   389:   | _ => {}
   390:   endmatch;
   391: }
   392: 
   393: /* draw the scene */
   394: proc draw(drawing: 1->0) {
   395:   if isActive call drawGLScene( drawing );
   396: }
   397: 
   398: proc keychan(x:schannel[SDL_keysym])
   399: {
   400:   whilst true do
   401:     var &k : SDL_keysym <- read x;
   402:     handle_key k;
   403:   done;
   404: }
   405: 
   406: proc activechan(x:schannel[SDL_ActiveEvent])
   407: {
   408:   whilst true do
   409:     var &k : SDL_ActiveEvent <- read x;
   410:     handle_active k;
   411:   done;
   412: }
   413: 
   414: proc resizechan(x:schannel[SDL_ResizeEvent])
   415: {
   416:   whilst true do
   417:     var &k : SDL_ResizeEvent <- read x;
   418:     handle_resize k;
   419:   done;
   420: }
   421: 
   422: proc drawchan(x:schannel[int], drawing:1->0)
   423: {
   424:   whilst true do
   425:     var &k : int <- read x;
   426:     draw drawing;
   427:   done;
   428: }
   429: 
   430: proc execute(x:schannel[int], something:1->0)
   431: {
   432:   whilst true do
   433:     var &k : int <- read x;
   434:     something();
   435:   done;
   436: }
   437: 
   438: proc poll_event(e: &SDL_Event)
   439: {
   440: tryagain:>
   441:   //print "Polling event"; endl;
   442:   var result = SDL_PollEvent(unref e);
   443:   if result > 0 do
   444:     //print "Got event"; endl;
   445:     return;
   446:   done;
   447:   Faio::sleep 0.1;
   448:   goto tryagain;
   449: }
   450: 
   451: proc dispatch_event(
   452:   keyboard:schannel[SDL_keysym],
   453:   active:schannel[SDL_ActiveEvent],
   454:   resize:schannel[SDL_ResizeEvent]
   455: )
   456: {
   457:   whilst true do
   458:     //var &e : SDL_Event <- get_sdl_event event_lock;
   459:     var e : SDL_Event;
   460:     poll_event(&e);
   461:     match e.type_ with
   462:     | ?et when et == SDL_ACTIVEEVENT =>
   463:       { write (active, e.active); }
   464: 
   465:     | ?et when et == SDL_VIDEORESIZE =>
   466:       { write (resize, e.resize); }
   467: 
   468:     | ?et when et == SDL_KEYDOWN =>
   469:       { write (keyboard, e.key.keysym); }
   470: 
   471:     | ?et when et == SDL_QUIT =>
   472:       { Quit 0; }
   473: 
   474:     | _ => {}
   475:     endmatch;
   476:   done;
   477: }
   478: 
   479: /* write ticks at the desired framerate */
   480: proc framerate (x:schannel[int], framerate:double)
   481: {
   482:   whilst true do
   483:     Faio::sleep framerate;
   484:     write (x,1);
   485:   done;
   486: }
   487: 
   488: /* LINEAR CONTROL MODEL: CANNOT DEADLOCK
   489:   ~~> async/sync connection
   490:   --> sync/sync connection
   491: 
   492:   SDL_event ~~> dispatcher
   493:                 --> resize handler
   494:                 --> active handler
   495:                 --> key handler
   496:   timer ~~> framerate --> draw
   497: */
   498: 
   499: /* make our communication channels */
   500: var keyboard = mk_schannel[SDL_keysym] ();
   501: var active = mk_schannel[SDL_ActiveEvent] ();
   502: var resize = mk_schannel[SDL_ResizeEvent] ();
   503: var clicks = mk_schannel[int] ();
   504: var rotation = mk_schannel[int] ();
   505: 
   506: /* start up the fthreads and plug them together */
   507: spawn_fthread { dispatch_event (keyboard, active, resize); };
   508: spawn_fthread { resizechan resize; };
   509: spawn_fthread { activechan active; };
   510: spawn_fthread { keychan keyboard; };
   511: 
   512: spawn_fthread { drawchan (clicks, the Drawing); };
   513: spawn_fthread { framerate (clicks, 0.05); };
   514: spawn_fthread { execute (rotation, the rotate); };
   515: spawn_fthread { framerate (rotation, 0.01); };
   516: 
   517: 
   518: // main thread hangs
   519: 
   520: /* Here goes our drawing code */
   521: proc Drawing()
   522: {
   523:   /* Clear The Screen And The Depth Buffer */
   524:   glClear( GL_COLOR_BUFFER_BIT \| GL_DEPTH_BUFFER_BIT );
   525: 
   526:   /* Reset the view */
   527:   glLoadIdentity( );
   528: 
   529:   /* Translate Into/Out Of The Screen By z */
   530:   glTranslatef( 0.0f, 0.0f, z );
   531: 
   532:   glRotatef( xrot, 1.0f, 0.0f, 0.0f); /* Rotate On The X Axis By xrot */
   533:   glRotatef( yrot, 0.0f, 1.0f, 0.0f); /* Rotate On The Y Axis By yrot */
   534: 
   535:   /* Select A Texture Based On filter */
   536:   glBindTexture( GL_TEXTURE_2D, texture.[filter] );
   537: 
   538:   /* Start Drawing Quads */
   539:   glBegin( GL_QUADS );
   540:     /* Front Face */
   541:     /* Normal Pointing Towards Viewer */
   542:     glNormal3f( 0.0f, 0.0f, 1.0f );
   543:     /* Point 1 (Front) */
   544:     glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f, -1.0f,  1.0f );
   545:     /* Point 2 (Front) */
   546:     glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f, -1.0f,  1.0f );
   547:     /* Point 3 (Front) */
   548:     glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f,  1.0f,  1.0f );
   549:     /* Point 4 (Front) */
   550:     glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f,  1.0f,  1.0f );
   551: 
   552:     /* Back Face */
   553:     /* Normal Pointing Away From Viewer */
   554:     glNormal3f( 0.0f, 0.0f, -1.0f);
   555:     /* Point 1 (Back) */
   556:     glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
   557:     /* Point 2 (Back) */
   558:     glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
   559:     /* Point 3 (Back) */
   560:     glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f,  1.0f, -1.0f );
   561:     /* Point 4 (Back) */
   562:     glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f, -1.0f, -1.0f );
   563: 
   564:     /* Top Face */
   565:     /* Normal Pointing Up */
   566:     glNormal3f( 0.0f, 1.0f, 0.0f );
   567:     /* Point 1 (Top) */
   568:     glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
   569:     /* Point 2 (Top) */
   570:     glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f,  1.0f );
   571:     /* Point 3 (Top) */
   572:     glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f,  1.0f );
   573:     /* Point 4 (Top) */
   574:     glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f,  1.0f, -1.0f );
   575: 
   576:     /* Bottom Face */
   577:     /* Normal Pointing Down */
   578:     glNormal3f( 0.0f, -1.0f, 0.0f );
   579:     /* Point 1 (Bottom) */
   580:     glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
   581:     /* Point 2 (Bottom) */
   582:     glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, -1.0f );
   583:     /* Point 3 (Bottom) */
   584:     glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f, -1.0f,  1.0f );
   585:     /* Point 4 (Bottom) */
   586:     glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f,  1.0f );
   587: 
   588:     /* Right face */
   589:     /* Normal Pointing Right */
   590:     glNormal3f( 1.0f, 0.0f, 0.0f);
   591:     /* Point 1 (Right) */
   592:     glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 1.0f, -1.0f, -1.0f );
   593:     /* Point 2 (Right) */
   594:     glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 1.0f,  1.0f, -1.0f );
   595:     /* Point 3 (Right) */
   596:     glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 1.0f,  1.0f,  1.0f );
   597:     /* Point 4 (Right) */
   598:     glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 1.0f, -1.0f,  1.0f );
   599: 
   600:     /* Left Face*/
   601:     /* Normal Pointing Left */
   602:     glNormal3f( -1.0f, 0.0f, 0.0f );
   603:     /* Point 1 (Left) */
   604:     glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
   605:     /* Point 2 (Left) */
   606:     glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f,  1.0f );
   607:     /* Point 3 (Left) */
   608:     glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f,  1.0f,  1.0f );
   609:     /* Point 4 (Left) */
   610:     glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
   611:   glEnd();
   612: 
   613:   /* Draw it to the screen */
   614:   SDL_GL_SwapBuffers( );
   615: 
   616: }
   617: 
End felix section to tut/examples/sdl208.flx[1]
Start felix section to tut/examples/sdl209.flx[1 /1 ]
     1: #line 5135 "./lpsrc/flx_sdl.pak"
     2: // REQUIRES OpenGL and GLU
     3: /*
     4:  * This code was created by Jeff Molofee '99
     5:  * (ported to Linux/SDL by Ti Leggett '01)
     6:  *
     7:  * If you've found this code useful, please let me know.
     8:  *
     9:  * Visit Jeff at http://nehe.gamedev.net/
    10:  *
    11:  * or for port-specific comments, questions, bugreports etc.
    12:  * email to leggett@eecs.tulane.edu
    13:  */
    14: 
    15: #import <flx.flxh>
    16: include "SDL/SDL";
    17: include "SDL/SDL_keyboard";
    18: include "SDL/SDL_keysym";
    19: include "SDL/SDL_video";
    20: include "SDL/SDL_events";
    21: include "SDL/SDL_timer";
    22: include "SDL/SDL_mutex";
    23: include "SDL/SDL_opengl";
    24: 
    25: include "flx_faio";
    26: include "flx_faio_sdl";
    27: 
    28: open C_hack;
    29: open Carray;
    30: open MixedInt;
    31: open Uint32;
    32: open Uint8;
    33: open Float;
    34: 
    35: open SDL_h;
    36: open SDL_video_h;
    37: open SDL_keyboard_h;
    38: open SDL_events_h;
    39: open SDL_keysym_h;
    40: open SDL_timer_h;
    41: open SDL_mutex_h;
    42: 
    43: // This is the Felix asynchronous event source
    44: open SDL_events;
    45: 
    46: open SDL_opengl_h;
    47: 
    48: /* screen width, height, and bit depth */
    49: val SCREEN_WIDTH  = 640;
    50: val SCREEN_HEIGHT = 480;
    51: val SCREEN_BPP = 16;
    52: macro val NUM = 50;
    53: 
    54: /* function to reset our viewport after a window resize */
    55: proc resizeWindow( wwidth : int, hheight :int)
    56: {
    57:   var height = hheight;
    58:   var width = wwidth;
    59: 
    60:   /* Protect against a divide by zero */
    61:   if height == 0 do height = 1; done;
    62:   var ratio = double_of width / double_of height;
    63: 
    64:   block_sdl_events event_lock;
    65:   /* Setup our viewport. */
    66:   glViewport( 0, 0, width, height );
    67: 
    68:   /* change to the projection matrix and set our viewing volume. */
    69:   glMatrixMode( GL_PROJECTION );
    70:   glLoadIdentity( );
    71: 
    72:   /* Set our perspective */
    73:   gluPerspective( 45.0, ratio, 0.1, 100.0 );
    74: 
    75:   /* Make sure we're chaning the model view and not the projection */
    76:   glMatrixMode( GL_MODELVIEW );
    77: 
    78:   /* Reset The View */
    79:   glLoadIdentity( );
    80:   unblock_sdl_events event_lock;
    81: }
    82: 
    83: /* function to load in bitmap as a GL texture */
    84: proc LoadGLTextures( )
    85: {
    86:   /* Create storage space for the texture */
    87:   var TextureImage = SDL_LoadBMP(enconst c"media/textures/sdl209.bmp");
    88:   if isNULL TextureImage do
    89:     print "Can't load texture file media/textures/sdl209.bmp";
    90:     Quit 1;
    91:   done;
    92: 
    93:   /* Create The Texture */
    94:         glGenTextures( 1, texture );
    95: 
    96:   /* Typical Texture Generation Using Data From The Bitmap */
    97:   glBindTexture( GL_TEXTURE_2D, texture.[0] );
    98: 
    99:         /* Generate The Texture */
   100:   glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage.->w,
   101:     TextureImage.->h, 0, GL_RGB,
   102:     GL_UNSIGNED_BYTE, TextureImage.->pixels
   103:   );
   104: 
   105:   /* Linear Filtering */
   106:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
   107:         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
   108: 
   109:   /* Free up any memory we may have used */
   110:         SDL_FreeSurface( TextureImage );
   111: }
   112: 
   113: var twinkle = false;
   114: 
   115: /* Define the star structure */
   116: struct star
   117: {
   118:   /* Stars Color */
   119:   r : int;
   120:   g : int;
   121:   b : int;
   122:   dist : float;  /* Stars Distance From Center */
   123:   angle : float; /* Stars Current Angle */
   124: };
   125: 
   126: var stars : star ^ NUM; /* Make an array of size 'NUM' of stars */
   127: 
   128: var zoom = -15.0f; /* Viewing Distance Away From Stars */
   129: var tilt = 90.0f;  /* Tilt The View */
   130: 
   131: /* general OpenGL initialization function */
   132: proc initGL()
   133: {
   134:   /* Enable Texture Mapping ( NEW ) */
   135:   glEnable( GL_TEXTURE_2D );
   136: 
   137:   /* Enable smooth shading */
   138:   glShadeModel( GL_SMOOTH );
   139: 
   140:   /* Set the background black */
   141:   glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
   142: 
   143:   /* Depth buffer setup */
   144:   glClearDepth( 1.0 );
   145: 
   146:   /* Really Nice Perspective Calculations */
   147:   glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
   148: 
   149:   /* Blending Function For Translucency Based On Source Alpha Value  */
   150:   glBlendFunc( GL_SRC_ALPHA, GL_ONE );
   151: 
   152:   /* Enable Blending */
   153:   glEnable( GL_BLEND );
   154: 
   155:   /* Create A Loop That Goes Through All The Stars */
   156:   var i = 0; whilst i< NUM do
   157:           /* Start All The Stars At Angle Zero */
   158:           stars.[i].angle = 0.0f;
   159: 
   160:           /* Calculate Distance From The Center */
   161:           stars.[i].dist = ( float_of i / float_of NUM ) * 5.0f;
   162:           /* Give star.[i] A Random Red Intensity */
   163:           stars.[i].r = Cstdlib::rand( ) % 256;
   164:           /* Give star.[i] A Random Green Intensity */
   165:           stars.[i].g = Cstdlib::rand( ) % 256;
   166:           /* Give star.[i] A Random Blue Intensity */
   167:           stars.[i].b = Cstdlib::rand( ) % 256;
   168:     ++i;
   169:   done;
   170: }
   171: 
   172: /* These are to calculate our fps */
   173: var T0     = 0;
   174: var Frames = 0;
   175: var spin = 0.0f;
   176: 
   177: proc rotate()
   178: {
   179:   var i : int;
   180:   forall i in 0 upto NUM - 1 do
   181:     /* Used To Spin The Stars */
   182:     spin += 0.01f;
   183:     /* Changes The Angle Of A Star */
   184:     stars.[i].angle += float_of i / float_of NUM;
   185:     /* Changes The Distance Of A Star */
   186:     stars.[i].dist -= 0.01f;
   187: 
   188:     /* Is The Star In The Middle Yet */
   189:     if stars.[i].dist < 0.0f do
   190:       /* Move The Star 5 Units From The Center */
   191:       stars.[i].dist += 5.0f;
   192:       /* Give It A New Red Value */
   193:       stars.[i].r = Cstdlib::rand( ) % 256;
   194:       /* Give It A New Green Value */
   195:       stars.[i].g = Cstdlib::rand( ) % 256;
   196:       /* Give It A New Blue Value */
   197:       stars.[i].b = Cstdlib::rand( ) % 256;
   198:     done;
   199:   done;
   200: }
   201: 
   202: var filter = 0;
   203: 
   204: var f_texture : uint ^ 3; /* Storage For 3 Textures ( NEW ) */
   205: var texture : ptr[uint] = carray_of f_texture;
   206: 
   207: 
   208: /* Here goes our drawing code */
   209: proc drawGLScene(drawing:1->0)
   210: {
   211:   block_sdl_events event_lock;
   212:   drawing();
   213:   unblock_sdl_events event_lock;
   214: 
   215:   /* Gather our frames per second */
   216:   Frames++;
   217:   {
   218:     var t = SDL_GetTicks();
   219:     if t - T0 >= 5000 do
   220:       val seconds = double_of (t - T0) / 1000.0;
   221:       val fps = double_of Frames / seconds;
   222:       print Frames; print " frames in "; print seconds;
   223:       print " seconds = "; print fps; print " FPS"; endl;
   224:       T0 = t;
   225:       Frames = 0;
   226:     done;
   227:   };
   228:   rotate();
   229: }
   230: 
   231: /* whether or not the window is active */
   232: var isActive = true;
   233: 
   234: if SDL_Init(SDL_INIT_AUDIO \| SDL_INIT_VIDEO) < 0 do
   235:   print "Unable to init SDL"; endl;
   236:   System::exit(1);
   237: done;
   238: 
   239: var event_lock = SDL_CreateMutex();
   240: 
   241: 
   242: proc Quit(n:int)
   243: {
   244:   SDL_Quit;
   245:   System::exit 0;
   246: }
   247: 
   248: /* Fetch the video info */
   249: var videoInfo = SDL_GetVideoInfo();
   250: 
   251: if isNULL videoInfo do
   252:   print "Video query failed"; endl;
   253:   Quit 1;
   254: done;
   255: 
   256: /* the flags to pass to SDL_SetVideoMode */
   257: var
   258:   videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
   259:   videoFlags |= cast[uint] SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
   260:   videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
   261:   videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
   262: 
   263: /* This checks to see if surfaces can be stored in memory */
   264: if  videoInfo.->hw_available != 0 do
   265:         videoFlags |= SDL_HWSURFACE;
   266: else
   267:         videoFlags |= SDL_SWSURFACE;
   268: done;
   269: 
   270: /* This checks if hardware blits can be done */
   271: if videoInfo.->blit_hw != 0 do
   272:         videoFlags |= SDL_HWACCEL;
   273: done;
   274: 
   275: /* Sets up OpenGL double buffering */
   276: ignore$ SDL_GL_SetAttribute( cast[SDL_GLattr] SDL_GL_DOUBLEBUFFER, 1 );
   277: 
   278: /* get a SDL surface */
   279: var surface = SDL_SetVideoMode
   280:   (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags )
   281: ;
   282: 
   283: /* Verify there is a surface */
   284: if isNULL surface do
   285:   print "Video mode set failed"; endl;
   286:   Quit 1;
   287: done;
   288: 
   289: /* initialize OpenGL */
   290: initGL();
   291: LoadGLTextures();
   292: 
   293: /* resize the initial window */
   294: resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );
   295: 
   296: // SDL Event dispatcher
   297: proc handle_active (e:SDL_ActiveEvent)
   298: {
   299:    isActive = e.gain != 0;
   300: }
   301: 
   302: proc handle_resize(e:SDL_ResizeEvent)
   303: {
   304:   block_sdl_events event_lock;
   305:   surface = SDL_SetVideoMode(
   306:     e.w,
   307:     e.h,
   308:     16, videoFlags
   309:   );
   310:   if isNULL surface do
   311:     print "Could not get a surface after resize"; endl;
   312:   done;
   313:   resizeWindow( e.w, e.h );
   314:   unblock_sdl_events event_lock;
   315: }
   316: 
   317: /* function to handle key press events */
   318: proc handle_key( keysym : SDL_keysym)
   319: {
   320:   match keysym.sym with
   321:   | ?k when k == SDLK_ESCAPE => { Quit 0; }
   322:   | ?k when k ==  SDLK_F1 =>
   323:             {
   324:         block_sdl_events event_lock;
   325:         ignore$ SDL_WM_ToggleFullScreen( surface );
   326:         unblock_sdl_events event_lock;
   327:       }
   328:   | ?k when k == SDLK_t =>
   329:     {
   330:       twinkle = not twinkle;
   331:     }
   332:   | ?k when k == SDLK_PAGEUP =>
   333:     {
   334:             zoom = zoom - 0.2f;
   335:     }
   336: 
   337:   | ?k when k == SDLK_PAGEDOWN =>
   338:     {
   339:             zoom = zoom + 0.2f;
   340:     }
   341: 
   342:   | ?k when k == SDLK_UP =>
   343:     {
   344:       tilt = tilt - 0.5f;
   345:     }
   346: 
   347:   | ?k when k == SDLK_DOWN =>
   348:     {
   349:       tilt = tilt + 0.5f;
   350:     }
   351: 
   352:   | _ => {}
   353:   endmatch;
   354: }
   355: 
   356: /* draw the scene */
   357: proc draw(drawing: 1->0) {
   358:   if isActive call drawGLScene( drawing );
   359: }
   360: 
   361: proc keychan(x:schannel[SDL_keysym])
   362: {
   363:   whilst true do
   364:     var &k : SDL_keysym <- read x;
   365:     handle_key k;
   366:   done;
   367: }
   368: 
   369: proc activechan(x:schannel[SDL_ActiveEvent])
   370: {
   371:   whilst true do
   372:     var &k : SDL_ActiveEvent <- read x;
   373:     handle_active k;
   374:   done;
   375: }
   376: 
   377: proc resizechan(x:schannel[SDL_ResizeEvent])
   378: {
   379:   whilst true do
   380:     var &k : SDL_ResizeEvent <- read x;
   381:     handle_resize k;
   382:   done;
   383: }
   384: 
   385: proc drawchan(x:schannel[int], drawing:1->0)
   386: {
   387:   whilst true do
   388:     var &k : int <- read x;
   389:     draw drawing;
   390:   done;
   391: }
   392: 
   393: proc execute(x:schannel[int], something:1->0)
   394: {
   395:   whilst true do
   396:     var &k : int <- read x;
   397:     something();
   398:   done;
   399: }
   400: 
   401: proc poll_event(e: &SDL_Event)
   402: {
   403: tryagain:>
   404:   //print "Polling event"; endl;
   405:   var result = SDL_PollEvent(unref e);
   406:   if result > 0 do
   407:     //print "Got event"; endl;
   408:     return;
   409:   done;
   410:   Faio::sleep 0.1;
   411:   goto tryagain;
   412: }
   413: 
   414: proc dispatch_event(
   415:   keyboard:schannel[SDL_keysym],
   416:   active:schannel[SDL_ActiveEvent],
   417:   resize:schannel[SDL_ResizeEvent]
   418: )
   419: {
   420:   whilst true do
   421:     //var &e : SDL_Event <- get_sdl_event event_lock;
   422:     var e : SDL_Event;
   423:     poll_event(&e);
   424:     match e.type_ with
   425:     | ?et when et == SDL_ACTIVEEVENT =>
   426:       { write (active, e.active); }
   427: 
   428:     | ?et when et == SDL_VIDEORESIZE =>
   429:       { write (resize, e.resize); }
   430: 
   431:     | ?et when et == SDL_KEYDOWN =>
   432:       { write (keyboard, e.key.keysym); }
   433: 
   434:     | ?et when et == SDL_QUIT =>
   435:       { Quit 0; }
   436: 
   437:     | _ => {}
   438:     endmatch;
   439:   done;
   440: }
   441: 
   442: /* write ticks at the desired framerate */
   443: proc framerate (x:schannel[int], framerate:double)
   444: {
   445:   whilst true do
   446:     Faio::sleep framerate;
   447:     write (x,1);
   448:   done;
   449: }
   450: 
   451: /* LINEAR CONTROL MODEL: CANNOT DEADLOCK
   452:   ~~> async/sync connection
   453:   --> sync/sync connection
   454: 
   455:   SDL_event ~~> dispatcher
   456:                 --> resize handler
   457:                 --> active handler
   458:                 --> key handler
   459:   timer ~~> framerate --> draw
   460: */
   461: 
   462: /* make our communication channels */
   463: var keyboard = mk_schannel[SDL_keysym] ();
   464: var active = mk_schannel[SDL_ActiveEvent] ();
   465: var resize = mk_schannel[SDL_ResizeEvent] ();
   466: var clicks = mk_schannel[int] ();
   467: var rotation = mk_schannel[int] ();
   468: 
   469: /* start up the fthreads and plug them together */
   470: spawn_fthread { dispatch_event (keyboard, active, resize); };
   471: spawn_fthread { resizechan resize; };
   472: spawn_fthread { activechan active; };
   473: spawn_fthread { keychan keyboard; };
   474: 
   475: spawn_fthread { drawchan (clicks, the Drawing); };
   476: spawn_fthread { framerate (clicks, 0.05); };
   477: spawn_fthread { execute (rotation, the rotate); };
   478: spawn_fthread { framerate (rotation, 0.01); };
   479: 
   480: 
   481: // main thread hangs
   482: 
   483: /* Here goes our drawing code */
   484: proc Drawing()
   485: {
   486:   /* Clear The Screen And The Depth Buffer */
   487:   glClear( GL_COLOR_BUFFER_BIT \| GL_DEPTH_BUFFER_BIT );
   488: 
   489:     /* Select Our Texture */
   490:   glBindTexture( GL_TEXTURE_2D, texture.[0] );
   491:   glLoadIdentity( );
   492: 
   493:     /* Loop Through All The Stars */
   494:   var i = 0;
   495:   forall i in 0 upto NUM - 1 do
   496:     /* Reset The View Before We Draw Each Star */
   497:     glLoadIdentity( );
   498:     /* Zoom Into The Screen (Using The Value In 'zoom') */
   499:     glTranslatef( 0.0f, 0.0f, zoom );
   500: 
   501:     /* Tilt The View (Using The Value In 'tilt') */
   502:     glRotatef( tilt, 1.0f, 0.0f, 0.0f );
   503:     /* Rotate To The Current Stars Angle */
   504:     glRotatef( stars.[i].angle, 0.0f, 1.0f, 0.0f );
   505: 
   506:     /* Move Forward On The X Plane */
   507:     glTranslatef( stars.[i].dist, 0.0f, 0.0f );
   508: 
   509:     /* Cancel The Current Stars Angle */
   510:     glRotatef( -stars.[i].angle, 0.0f, 1.0f, 0.0f );
   511:     /* Cancel The Screen Tilt */
   512:     glRotatef( -tilt, 1.0f, 0.0f, 0.0f );
   513: 
   514:     /* Twinkling Stars Enabled */
   515:     if twinkle do
   516:       /* Assign A Color Using Bytes */
   517:       glColor4ub( utiny_of stars.[NUM - i  - 1].r,
   518:       utiny_of stars.[NUM - i  - 1].g,
   519:       utiny_of stars.[NUM - i  - 1].b, 255ut );
   520:       /* Begin Drawing The Textured Quad */
   521:       glBegin( GL_QUADS );
   522:         glTexCoord2f( 0.0f, 0.0f );
   523:         glVertex3f( -1.0f, -1.0f, 0.0f );
   524:         glTexCoord2f( 1.0f, 0.0f);
   525:         glVertex3f( 1.0f, -1.0f, 0.0f );
   526:         glTexCoord2f( 1.0f, 1.0f );
   527:         glVertex3f( 1.0f, 1.0f, 0.0f );
   528:         glTexCoord2f( 0.0f, 1.0f );
   529:         glVertex3f( -1.0f, 1.0f, 0.0f );
   530:       glEnd( );
   531:      done;
   532: 
   533:     /* Rotate The Star On The Z Axis */
   534:     glRotatef( spin, 0.0f, 0.0f, 1.0f );
   535: 
   536:     /* Assign A Color Using Bytes */
   537:     glColor4ub( utiny_of stars.[i].r, utiny_of stars.[i].g, utiny_of stars.[i].b, 255ut );
   538: 
   539:     /* Begin Drawing The Textured Quad */
   540:     glBegin( GL_QUADS );
   541:       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
   542:       glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
   543:       glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
   544:       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
   545:     glEnd( );
   546: 
   547:   done;
   548: 
   549:   /* Draw it to the screen */
   550:   SDL_GL_SwapBuffers( );
   551: }
   552: 
End felix section to tut/examples/sdl209.flx[1]
Start cpp section to tmp/sdl_opengl.cxx[1 /1 ]
     1: #line 5688 "./lpsrc/flx_sdl.pak"
     2: // for testing whether we have SDL_opengl
     3: #include <SDL.h>            // overrides main
     4: #include <SDL_opengl.h>
     5: 
     6: int
     7: main(int argc, char** argv)
     8: {
     9:     if(SDL_Init(SDL_INIT_VIDEO) == -1
    10:         || SDL_SetVideoMode(640, 480, 32, SDL_ANYFORMAT | SDL_OPENGL) == NULL)
    11:     {
    12:         return 1;       // fail
    13:     }
    14: 
    15:     // random gl stuff to make sure we link
    16:     glMatrixMode(GL_PROJECTION);
    17:     glLoadIdentity();
    18: 
    19:     return 0;           // pass
    20: }
End cpp section to tmp/sdl_opengl.cxx[1]