summaryrefslogtreecommitdiff
authorTomi Belan <tomi.belan@gmail.com>2009-10-06 19:04:25 (GMT)
committer Tomi Belan <tomi.belan@gmail.com>2009-10-06 19:04:28 (GMT)
commit5186dcc3ca5679340b8dfcf1d35f62fd364b32d0 (patch)
tree074d3cc03ab4bcdd961c0223cb28ffbd343ed6ce
parent0285a81a27e65750cddf3ed16b90919bf492cb94 (diff)
downloadkarel-master.zip
karel-master.tar.gz
karel-master.tar.bz2
nove hierarchicke usporiadanie so submodulmi.master
v prvej faze sa zatial len vsetko presuva, ale program sa nemeni, takze caka veci na starych miestach a nefunguje. to bude druha faza.
Diffstat
-rw-r--r--.gitmodules3
-rw-r--r--INSTALL200
-rw-r--r--INSTALL.mingw145
-rw-r--r--Makefile65
-rwxr-xr-xconfigure319
-rw-r--r--content/fonts/BROOKLNN.ttf (renamed from data/fonts/BROOKLNN.ttf)bin76896 -> 76896 bytes
-rw-r--r--content/fonts/DejaVuSansMono.ttf (renamed from data/fonts/DejaVuSansMono.ttf)bin317336 -> 317336 bytes
-rw-r--r--content/gui/button/focus/down.png (renamed from data/karel/gui/button/focus/down.png)bin543 -> 543 bytes
-rw-r--r--content/gui/button/focus/downleft.png (renamed from data/karel/gui/button/focus/downleft.png)bin744 -> 744 bytes
-rw-r--r--content/gui/button/focus/downright.png (renamed from data/karel/gui/button/focus/downright.png)bin729 -> 729 bytes
-rw-r--r--content/gui/button/focus/left.png (renamed from data/karel/gui/button/focus/left.png)bin519 -> 519 bytes
-rw-r--r--content/gui/button/focus/mid.png (renamed from data/karel/gui/button/focus/mid.png)bin423 -> 423 bytes
-rw-r--r--content/gui/button/focus/right.png (renamed from data/karel/gui/button/focus/right.png)bin526 -> 526 bytes
-rw-r--r--content/gui/button/focus/up.png (renamed from data/karel/gui/button/focus/up.png)bin545 -> 545 bytes
-rw-r--r--content/gui/button/focus/upleft.png (renamed from data/karel/gui/button/focus/upleft.png)bin697 -> 697 bytes
-rw-r--r--content/gui/button/focus/upright.png (renamed from data/karel/gui/button/focus/upright.png)bin746 -> 746 bytes
-rw-r--r--content/gui/button/normal/down.png (renamed from data/karel/gui/button/normal/down.png)bin519 -> 519 bytes
-rw-r--r--content/gui/button/normal/downleft.png (renamed from data/karel/gui/button/normal/downleft.png)bin666 -> 666 bytes
-rw-r--r--content/gui/button/normal/downright.png (renamed from data/karel/gui/button/normal/downright.png)bin655 -> 655 bytes
-rw-r--r--content/gui/button/normal/left.png (renamed from data/karel/gui/button/normal/left.png)bin491 -> 491 bytes
-rw-r--r--content/gui/button/normal/mid.png (renamed from data/karel/gui/button/normal/mid.png)bin453 -> 453 bytes
-rw-r--r--content/gui/button/normal/right.png (renamed from data/karel/gui/button/normal/right.png)bin501 -> 501 bytes
-rw-r--r--content/gui/button/normal/up.png (renamed from data/karel/gui/button/normal/up.png)bin518 -> 518 bytes
-rw-r--r--content/gui/button/normal/upleft.png (renamed from data/karel/gui/button/normal/upleft.png)bin635 -> 635 bytes
-rw-r--r--content/gui/button/normal/upright.png (renamed from data/karel/gui/button/normal/upright.png)bin689 -> 689 bytes
-rw-r--r--content/gui/button/pressed/down.png (renamed from data/karel/gui/button/pressed/down.png)bin477 -> 477 bytes
-rw-r--r--content/gui/button/pressed/downleft.png (renamed from data/karel/gui/button/pressed/downleft.png)bin573 -> 573 bytes
-rw-r--r--content/gui/button/pressed/downright.png (renamed from data/karel/gui/button/pressed/downright.png)bin557 -> 557 bytes
-rw-r--r--content/gui/button/pressed/left.png (renamed from data/karel/gui/button/pressed/left.png)bin490 -> 490 bytes
-rw-r--r--content/gui/button/pressed/mid.png (renamed from data/karel/gui/button/pressed/mid.png)bin418 -> 418 bytes
-rw-r--r--content/gui/button/pressed/right.png (renamed from data/karel/gui/button/pressed/right.png)bin488 -> 488 bytes
-rw-r--r--content/gui/button/pressed/up.png (renamed from data/karel/gui/button/pressed/up.png)bin417 -> 417 bytes
-rw-r--r--content/gui/button/pressed/upleft.png (renamed from data/karel/gui/button/pressed/upleft.png)bin593 -> 593 bytes
-rw-r--r--content/gui/button/pressed/upright.png (renamed from data/karel/gui/button/pressed/upright.png)bin642 -> 642 bytes
-rw-r--r--content/gui/checkbox/v1_off.png (renamed from data/karel/gui/checkbox/v1_off.png)bin2281 -> 2281 bytes
-rw-r--r--content/gui/checkbox/v1_on.png (renamed from data/karel/gui/checkbox/v1_on.png)bin2588 -> 2588 bytes
-rw-r--r--content/gui/checkbox/v2_off.png (renamed from data/karel/gui/checkbox/v2_off.png)bin2609 -> 2609 bytes
-rw-r--r--content/gui/checkbox/v2_on.png (renamed from data/karel/gui/checkbox/v2_on.png)bin2610 -> 2610 bytes
-rw-r--r--content/gui/checkbox/v3_off.png (renamed from data/karel/gui/checkbox/v3_off.png)bin2618 -> 2618 bytes
-rw-r--r--content/gui/checkbox/v3_on.png (renamed from data/karel/gui/checkbox/v3_on.png)bin2594 -> 2594 bytes
-rw-r--r--content/gui/editbox/down.png (renamed from data/karel/gui/editbox/down.png)bin363 -> 363 bytes
-rw-r--r--content/gui/editbox/downleft.png (renamed from data/karel/gui/editbox/downleft.png)bin841 -> 841 bytes
-rw-r--r--content/gui/editbox/downright.png (renamed from data/karel/gui/editbox/downright.png)bin770 -> 770 bytes
-rw-r--r--content/gui/editbox/left.png (renamed from data/karel/gui/editbox/left.png)bin388 -> 388 bytes
-rw-r--r--content/gui/editbox/right.png (renamed from data/karel/gui/editbox/right.png)bin373 -> 373 bytes
-rw-r--r--content/gui/editbox/spinbox.png (renamed from data/karel/gui/editbox/spinbox.png)bin1438 -> 1438 bytes
-rw-r--r--content/gui/editbox/spinbox_p.png (renamed from data/karel/gui/editbox/spinbox_p.png)bin1233 -> 1233 bytes
-rw-r--r--content/gui/editbox/up.png (renamed from data/karel/gui/editbox/up.png)bin368 -> 368 bytes
-rw-r--r--content/gui/editbox/upleft.png (renamed from data/karel/gui/editbox/upleft.png)bin782 -> 782 bytes
-rw-r--r--content/gui/editbox/upright.png (renamed from data/karel/gui/editbox/upright.png)bin855 -> 855 bytes
-rw-r--r--content/gui/icons/copy.png (renamed from data/karel/gui/icons/copy.png)bin2113 -> 2113 bytes
-rw-r--r--content/gui/icons/cut.png (renamed from data/karel/gui/icons/cut.png)bin2387 -> 2387 bytes
-rw-r--r--content/gui/icons/load.png (renamed from data/karel/gui/icons/load.png)bin2110 -> 2110 bytes
-rw-r--r--content/gui/icons/new.png (renamed from data/karel/gui/icons/new.png)bin1899 -> 1899 bytes
-rw-r--r--content/gui/icons/node_stepover.png (renamed from data/karel/gui/icons/node_stepover.png)bin2063 -> 2063 bytes
-rw-r--r--content/gui/icons/paste.png (renamed from data/karel/gui/icons/paste.png)bin2023 -> 2023 bytes
-rw-r--r--content/gui/icons/prefs.png (renamed from data/karel/gui/icons/prefs.png)bin3343 -> 3343 bytes
-rw-r--r--content/gui/icons/prefs_alt.png (renamed from data/karel/gui/icons/prefs_alt.png)bin3833 -> 3833 bytes
-rw-r--r--content/gui/icons/resume.png (renamed from data/karel/gui/icons/resume.png)bin1701 -> 1701 bytes
-rw-r--r--content/gui/icons/run.png (renamed from data/karel/gui/icons/run.png)bin1925 -> 1925 bytes
-rw-r--r--content/gui/icons/save.png (renamed from data/karel/gui/icons/save.png)bin2289 -> 2289 bytes
-rw-r--r--content/gui/icons/save_alt.png (renamed from data/karel/gui/icons/save_alt.png)bin2286 -> 2286 bytes
-rw-r--r--content/gui/icons/stepinsrc.png (renamed from data/karel/gui/icons/stepinsrc.png)bin2214 -> 2214 bytes
-rw-r--r--content/gui/icons/subflow_stepinto.png (renamed from data/karel/gui/icons/subflow_stepinto.png)bin1697 -> 1697 bytes
-rw-r--r--content/gui/icons/subflow_stepout.png (renamed from data/karel/gui/icons/subflow_stepout.png)bin1730 -> 1730 bytes
-rw-r--r--content/gui/node/down.png (renamed from data/karel/gui/node/down.png)bin363 -> 363 bytes
-rw-r--r--content/gui/node/downleft.png (renamed from data/karel/gui/node/downleft.png)bin641 -> 641 bytes
-rw-r--r--content/gui/node/downright.png (renamed from data/karel/gui/node/downright.png)bin624 -> 624 bytes
-rw-r--r--content/gui/node/left.png (renamed from data/karel/gui/node/left.png)bin388 -> 388 bytes
-rw-r--r--content/gui/node/right.png (renamed from data/karel/gui/node/right.png)bin373 -> 373 bytes
-rw-r--r--content/gui/node/up.png (renamed from data/karel/gui/node/up.png)bin368 -> 368 bytes
-rw-r--r--content/gui/node/upleft.png (renamed from data/karel/gui/node/upleft.png)bin622 -> 622 bytes
-rw-r--r--content/gui/node/upright.png (renamed from data/karel/gui/node/upright.png)bin653 -> 653 bytes
-rw-r--r--content/gui/scrollbar/rope.png (renamed from data/karel/gui/scrollbar/rope.png)bin883 -> 883 bytes
-rw-r--r--content/gui/scrollbar/shadow.png (renamed from data/karel/gui/scrollbar/shadow.png)bin10024 -> 10024 bytes
-rw-r--r--content/gui/scrollbar/weights.png (renamed from data/karel/gui/scrollbar/weights.png)bin6965 -> 6965 bytes
-rw-r--r--content/gui/scrollbar/wheel.png (renamed from data/karel/gui/scrollbar/wheel.png)bin21305 -> 21305 bytes
-rw-r--r--content/gui/scrollbar/wheel000.png (renamed from data/karel/gui/scrollbar/wheel000.png)bin6399 -> 6399 bytes
-rw-r--r--content/gui/scrollbar/wheel022.png (renamed from data/karel/gui/scrollbar/wheel022.png)bin6513 -> 6513 bytes
-rw-r--r--content/gui/scrollbar/wheel045.png (renamed from data/karel/gui/scrollbar/wheel045.png)bin6428 -> 6428 bytes
-rw-r--r--content/gui/scrollbar/wheel067.png (renamed from data/karel/gui/scrollbar/wheel067.png)bin6507 -> 6507 bytes
-rw-r--r--content/gui/scrollbar/wheel090.png (renamed from data/karel/gui/scrollbar/wheel090.png)bin6349 -> 6349 bytes
-rw-r--r--content/gui/scrollbar/wheel112.png (renamed from data/karel/gui/scrollbar/wheel112.png)bin6462 -> 6462 bytes
-rw-r--r--content/gui/scrollbar/wheel135.png (renamed from data/karel/gui/scrollbar/wheel135.png)bin6404 -> 6404 bytes
-rw-r--r--content/gui/scrollbar/wheel157.png (renamed from data/karel/gui/scrollbar/wheel157.png)bin6503 -> 6503 bytes
-rw-r--r--content/gui/scrollbar/wheel180.png (renamed from data/karel/gui/scrollbar/wheel180.png)bin6402 -> 6402 bytes
-rw-r--r--content/gui/scrollbar/wheel202.png (renamed from data/karel/gui/scrollbar/wheel202.png)bin6468 -> 6468 bytes
-rw-r--r--content/gui/scrollbar/wheel225.png (renamed from data/karel/gui/scrollbar/wheel225.png)bin6443 -> 6443 bytes
-rw-r--r--content/gui/scrollbar/wheel247.png (renamed from data/karel/gui/scrollbar/wheel247.png)bin6516 -> 6516 bytes
-rw-r--r--content/gui/scrollbar/wheel270.png (renamed from data/karel/gui/scrollbar/wheel270.png)bin6374 -> 6374 bytes
-rw-r--r--content/gui/scrollbar/wheel292.png (renamed from data/karel/gui/scrollbar/wheel292.png)bin6460 -> 6460 bytes
-rw-r--r--content/gui/scrollbar/wheel315.png (renamed from data/karel/gui/scrollbar/wheel315.png)bin6394 -> 6394 bytes
-rw-r--r--content/gui/scrollbar/wheel337.png (renamed from data/karel/gui/scrollbar/wheel337.png)bin6499 -> 6499 bytes
-rw-r--r--content/gui/window/corner.png (renamed from data/karel/gui/window/corner.png)bin10251 -> 10251 bytes
-rw-r--r--content/gui/window/down.png (renamed from data/karel/gui/window/down.png)bin3290 -> 3290 bytes
-rw-r--r--content/gui/window/downleft.png (renamed from data/karel/gui/window/downleft.png)bin11581 -> 11581 bytes
-rw-r--r--content/gui/window/downright.png (renamed from data/karel/gui/window/downright.png)bin11954 -> 11954 bytes
-rw-r--r--content/gui/window/header.png (renamed from data/karel/gui/window/header.png)bin22069 -> 22069 bytes
-rw-r--r--content/gui/window/header_i.png (renamed from data/karel/gui/window/header_i.png)bin1647 -> 1647 bytes
-rw-r--r--content/gui/window/header_x.png (renamed from data/karel/gui/window/header_x.png)bin1662 -> 1662 bytes
-rw-r--r--content/gui/window/headerleft.png (renamed from data/karel/gui/window/headerleft.png)bin8514 -> 8514 bytes
-rw-r--r--content/gui/window/headerright.png (renamed from data/karel/gui/window/headerright.png)bin8662 -> 8662 bytes
-rw-r--r--content/gui/window/left.png (renamed from data/karel/gui/window/left.png)bin2482 -> 2482 bytes
-rw-r--r--content/gui/window/mid.png (renamed from data/karel/gui/window/mid.png)bin342128 -> 342128 bytes
-rw-r--r--content/gui/window/right.png (renamed from data/karel/gui/window/right.png)bin2749 -> 2749 bytes
-rw-r--r--content/gui/window/up.png (renamed from data/karel/gui/window/up.png)bin3462 -> 3462 bytes
-rw-r--r--content/gui/window/upleft.png (renamed from data/karel/gui/window/upleft.png)bin11658 -> 11658 bytes
-rw-r--r--content/gui/window/upright.png (renamed from data/karel/gui/window/upright.png)bin12120 -> 12120 bytes
-rw-r--r--content/karel/GUI.lua (renamed from data/karel/GUI.lua)0
-rw-r--r--content/karel/Machine.lua (renamed from data/karel/Machine.lua)0
-rw-r--r--content/karel/Main.lua (renamed from data/karel/Main.lua)0
-rw-r--r--content/karel/ProgramNode.lua (renamed from data/karel/ProgramNode.lua)0
-rw-r--r--content/karel/Project.lua (renamed from data/karel/Project.lua)0
-rw-r--r--content/karel/RoomModel.lua (renamed from data/karel/RoomModel.lua)0
-rw-r--r--content/karel/RoomView.lua (renamed from data/karel/RoomView.lua)0
-rw-r--r--content/robot.obj (renamed from data/karel/robot.obj)0
-rw-r--r--content/robot.png (renamed from data/karel/robot.png)bin527919 -> 527919 bytes
-rw-r--r--content/roomgfx/brick.png (renamed from data/karel/roomgfx/brick.png)bin155423 -> 155423 bytes
-rw-r--r--content/roomgfx/bubble.png (renamed from data/karel/roomgfx/bubble.png)bin87529 -> 87529 bytes
-rw-r--r--content/roomgfx/fence.png (renamed from data/karel/roomgfx/fence.png)bin290950 -> 290950 bytes
-rw-r--r--content/roomgfx/floor.png (renamed from data/karel/roomgfx/floor.png)bin5359 -> 5359 bytes
-rw-r--r--content/start.lua (renamed from data/start.lua)0
-rw-r--r--data/core/Console.lua122
-rw-r--r--data/core/Cursor.lua137
-rw-r--r--data/core/Event.lua36
-rw-r--r--data/core/FS.lua265
-rw-r--r--data/core/Fonts.lua49
-rw-r--r--data/core/MainLoop.lua210
-rw-r--r--data/core/Mask.lua77
-rw-r--r--data/core/Music.lua49
-rw-r--r--data/core/Node.lua182
-rw-r--r--data/core/Selection.lua186
-rw-r--r--data/core/TextInput.lua89
-rw-r--r--data/core/Textures.lua87
-rw-r--r--data/core/Vector.lua64
-rw-r--r--data/core/Widget.lua152
-rw-r--r--data/core/Window.lua173
-rw-r--r--data/core/ZUtil.lua24
-rw-r--r--data/core/extlib.lua331
-rw-r--r--data/core/globalgl.lua14
-rw-r--r--data/core/justify.lua71
-rw-r--r--data/core/strict.lua41
-rw-r--r--data/karel.info2
-rw-r--r--data/test/console.lua11
-rw-r--r--data/test/debug.lua1
-rw-r--r--data/test/ftgl.lua38
-rw-r--r--data/test/jump.lua105
-rw-r--r--data/test/nehe/crate.bmpbin196662 -> 0 bytes
-rw-r--r--data/test/nehe/glass.bmpbin49220 -> 0 bytes
-rw-r--r--data/test/nehe/mud.bmpbin196662 -> 0 bytes
-rw-r--r--data/test/nehe/nehe.bmpbin196664 -> 0 bytes
-rw-r--r--data/test/nehe/nehe02.lua35
-rw-r--r--data/test/nehe/nehe03.lua36
-rw-r--r--data/test/nehe/nehe04.lua46
-rw-r--r--data/test/nehe/nehe05.lua97
-rw-r--r--data/test/nehe/nehe06.lua73
-rw-r--r--data/test/nehe/nehe07.lua105
-rw-r--r--data/test/nehe/nehe08.lua111
-rw-r--r--data/test/nehe/nehe09.lua104
-rw-r--r--data/test/nehe/nehe10.lua88
-rw-r--r--data/test/nehe/nehelib.lua50
-rw-r--r--data/test/nehe/star.bmpbin49206 -> 0 bytes
-rw-r--r--data/test/nehe/world.txt160
-rw-r--r--data/test/ortho.lua81
-rw-r--r--data/test/pack.lua263
-rw-r--r--data/userrc.lua0
-rw-r--r--src/ftgl.c301
-rw-r--r--src/ftgl.h107
-rw-r--r--src/gengl.lua1298
-rw-r--r--src/glproto.c17
-rw-r--r--src/glproto.h22
-rw-r--r--src/launcher.lua195
-rw-r--r--src/lbitlib.c69
-rw-r--r--src/lbuflib.c409
-rw-r--r--src/leiolib.c100
-rw-r--r--src/lftgllib.c191
-rw-r--r--src/lxlib.c88
-rw-r--r--src/lzlib.c99
-rw-r--r--src/main.c213
-rw-r--r--src/makepak.sh45
m---------ult0
181 files changed, 3 insertions, 7648 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..924b0cc
--- a/dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "ult"]
+ path = ult
+ url = ../ult.git
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 1e2117b..0000000
--- a/INSTALL
+++ b/dev/null
@@ -1,200 +0,0 @@
-
-Summary
-=======
-
-You need Lua 5.1, SDL, SDL_image, SDL_mixer, Freetype, Zlib, Zip, OpenGL.
-./configure --prefix=/usr
-make
-make install
-
-
-Requirements
-============
-
-C Compiler (for example, GCC)
-GNU Make (unless you're building manually)
-Lua 5.1 - www.lua.org
-SDL - www.libsdl.org
-SDL_image - www.libsdl.org/projects/SDL_image
-SDL_mixer - www.libsdl.org/projects/SDL_mixer
-Freetype - www.freetype.org or gnuwin32.sf.net
-Zlib - www.zlib.net
-Zip - www.info-zip.org
-OpenGL + GLU
-
-
-Automated build
-===============
-
-The build system doesn't use autoconf and automake, but care was taken
-to ensure that its interface is compatible with them.
-
-./configure [OPTIONS]
-
-See './configure --help' for a list of options. If you don't need to specify
-any options, you can skip this step entirely - 'make' will run ./configure
-for you. To install in /usr instead of /usr/local, use
-'./configure --prefix=/usr'.
-
-make
-
-It is recommended to run 'make' without options - if you need to set Makefile
-variables, pass them as arguments to ./configure (e.g. './configure CC=c99').
-'make install DESTDIR=/path/' (see below) is an exception from this.
-
-make install (as root)
-
-Installing the program is optional. If you want to install in another root
-(e.g., when creating a package for a distribution), use
-'make install DESTDIR=/where/to/install/'. (Note that the binary expects
-to find the data files in PREFIX. Also, you must use the same DESTDIR when
-using 'make uninstall'.)
-
-
-Building under MinGW
-====================
-
-INSTALL.mingw is a script that automatically installs all the required
-libraries under /mingw. (The libraries are downloaded into a temporary
-directory, 'mingwlibs'. It's safe to remove this directory after the script
-finishes successfully.) Once the libraries are installed, use './configure'
-and 'make' as usual. './configure' also copies all required DLL files into
-its directory.
-
-
-Manual build
-============
-
-If you want to build using another method (e.g. without GNU make), you can
-build the software manually.
-
-1. In the src/ directory, run 'lua launcher.lua launcher.h'. This generates
- launcher.h, which is #include'd in main.c.
-
-2. In the src/ directory, run 'cat /path/to/gl.h /path/to/glu.h
- /path/to/glext.h/or/SDL_opengl.h | lua gengl.lua > lgllib.c'. This generates
- lgllib.c, which should be built together with the other .c files.
- (If your shell doesn't have cat or pipelines, concatenate gl.h, glu.h and
- SDL_opengl.h by hand in a standard text editor.)
-
-2. If you plan to install in a non-standard location, add
- '-DDATAPATH="/the/dir/containing/the/.pak/files/"' to CFLAGS.
-
-3. Compile all *.c files in src/ into a single binary. Link all required
- libraries (see above) to it.
-
-4. Generate the .pak files by using 'sh src/makepak.sh input.info' for each
- '*.info' file. If you don't have a shell, you can skip this step and later
- install data/* (not just data/*.pak), but that's not recommended. (The data/
- has a higher virtual filesystem stacking priority than other .pak files,
- so add-ons and patches may not work correctly.)
-
-4. To install, copy the binary to '/usr/bin/karel', and 'data/*.pak' to
- '/usr/share/karel/'.
-
-
-GENERIC INSTALLATION INSTRUCTIONS
-=================================
-
-The following document has been modified to exclude features that aren't
-implemented in the build system (e.g. compiling for multiple architectures).
-
-Basic Installation
-==================
-
- These are generic installation instructions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
-
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. Run `./configure --help'
-for details on some of the pertinent environment variables.
-
- You can give `configure' initial values for variables by setting
-them in the environment. You can do that on the command line like this:
-
- ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
-
- *Note Environment Variables::, for more details.
-
-Installation Names
-==================
-
- By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Environment Variables
-=====================
-
- Variables not defined in a site shell script can be set in the
-environment passed to configure. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-will cause the specified gcc to be used as the C compiler (unless it is
-overridden in the site shell script).
diff --git a/INSTALL.mingw b/INSTALL.mingw
deleted file mode 100644
index 33ed721..0000000
--- a/INSTALL.mingw
+++ b/dev/null
@@ -1,145 +0,0 @@
-#!/bin/sh
-if [ "$1" != "--with-jit" ] && [ "$1" != "--without-jit" ]; then echo -n "
-BUILDING UNDER MinGW
-
-This package requires several libraries that aren't installed under MinGW by
-default. INSTALL.mingw is a script that can help install them with minimal
-user interaction.
-
-Make sure you have a recent MSYS snapshot. In particular, bash 2 and lower
-isn't supported. msysCORE-1.0.11-20080826.tar.gz was tested to work.
-
-The script uses wget to download the libraries. Use Google 'wget win32' to
-find and download wget.exe. Put it into /mingw/bin/, or somewhere else in
-your \$PATH.
-
-If you don't have unzip.exe in your \$PATH, the script will download a copy.
-However, it requires user interaction to unzip this copy using an external
-unzip program.
-
-If you want to use LuaJIT (recommended), run:
- INSTALL.mingw --with-jit
-If you want to use vanilla Lua, run:
- INSTALL.mingw --without-jit
-"; exit 1
-fi
-# THE SHELL PART
-
-echo ' *** PART 1. system check '
-if ! type file >/dev/null 2>/dev/null; then
- echo "ERROR: Old MSYS version."
- echo "Download an update from http://sourceforge.net/projects/mingw/"
- exit 1
-fi
-if [ "$BASH_VERSION" ] && [ "${BASH_VERSION:0:1}" -lt 3 ]; then
- echo "ERROR: Old MSYS version."
- echo "Download an update from http://sourceforge.net/projects/mingw/"
- exit 1
-fi
-echo "MSYS version up to date."
-if ! type wget >/dev/null 2>/dev/null; then
- echo "ERROR: wget not found. Please download wget.exe (google: wget windows)"
- echo "and place it in /mingw/bin."
- exit 1
-fi
-echo "wget found."
-
-set -e
-
-mkdir -p mingwlibs
-cd mingwlibs
-
-dowget () {
- local link; local -a tmp; tmp=($2); [ -f "${tmp[0]}" ] && export "$1=${tmp[0]}" && return
- if [ "$4" ]; then
- link="`wget -nv -O- "$3" | grep -i href".*$4" | sed q |
- sed 's/^.*href=\("[^"]*\|'"'[^']*"'\).*$/\1/I'`"
- else link=.$3; fi
- wget -B "$3" -i- <<<"${link:1}" || exit 1
- tmp=($2); export "$1=${tmp[0]}"
-}
-
-echo $'\n *** PART 2. unzip \n'
-if ! type unzip &>/dev/null; then
- dowget unzipm "unzip*bin*.zip" http://gnuwin32.sourceforge.net/downlinks/unzip-bin-zip.php
- unzipw=(); didprompt=
- while true; do
- unzipw=(bin/unzip.exe); [ -f "${unzipw[0]}" ] && break
- unzipw=(unzip*/bin/unzip.exe); [ -f "${unzipw[0]}" ] && break
- if [ ! "$didprompt" ]; then
- didprompt=yes
- echo "User interaction needed - please unpack the file"
- echo "$unzip in the current directory."
- explorer "$unzipm" || true
- fi
- sleep 5
- done
- echo "*** Installing unzip in /mingw/bin/"
- install "${unzipw[0]}" /mingw/bin/unzip.exe
-fi
-
-echo $'\n *** PART 3. SDL \n'
-dowget sdl "SDL-devel-*-mingw32*.t*" http://libsdl.org/download-1.2.php mingw32
-rm -rf SDL-*/; tar xf "$sdl"
-cd SDL-*/; make install-sdl prefix=/mingw; cd ..
-
-echo $'\n *** PART 4. SDL_image \n'
-dowget sdl_image "SDL_image-devel-*.zip" http://libsdl.org/projects/SDL_image/ devel.*zip
-rm -rf SDL_image-*/; unzip "$sdl_image"
-cp -r SDL_image-*/include /mingw/; cp SDL_image-*/lib/*.dll /mingw/bin/
-
-echo $'\n *** PART 5. SDL_mixer \n'
-dowget sdl_mixer "SDL_mixer-devel-*.zip" http://libsdl.org/projects/SDL_mixer/ devel.*zip
-rm -rf SDL_mixer-*/; unzip "$sdl_mixer"
-cp -r SDL_mixer-*/include /mingw/; cp SDL_mixer-*/lib/*.dll /mingw/bin/
-
-echo $'\n *** PART 6. zlib \n'
-dowget zlib "zlib*-dll.zip" http://www.zlib.net/zlib123-dll.zip
-rm -rf zlib; mkdir zlib; cd zlib
-unzip ../"$zlib"
-cp -r include lib /mingw/; cp *.dll /mingw/bin/
-cd ..
-
-echo $'\n *** PART 7. freetype \n'
-dowget freetype "freetype-*-bin.zip" http://gnuwin32.sourceforge.net/downlinks/freetype-bin-zip.php
-rm -rf freetype; mkdir freetype; cd freetype
-unzip ../"$freetype"; cp -r * /mingw/
-cd ..
-# gnuwin32 freetype-config isn't usable under MinGW...
-echo "*** Fixing /mingw/bin/freetype-config"
-tmp=(/mingw/bin/*freetype*.dll); m=${tmp[0]}; m=${m##*/}; m=${m%.dll}
-sed 's@^ *libs=.*$@libs="-L/mingw/bin -l'"$m"'"@
-s@^ *prefix=.*@prefix=/mingw@' <freetype/bin/freetype-config >/mingw/bin/freetype-config
-
-if [ "$1" == "--with-jit" ]; then
- echo $'\n *** PART 8. LuaJIT \n'
- dowget luajit "LuaJIT*.zip" http://luajit.org/download.html LuaJIT.*zip
- rm -rf LuaJIT-*/; unzip "$luajit"; cd LuaJIT-*/
- make generic
- echo "*** Installing LuaJIT in /mingw and /mingw/share/lua/jit/"
- install src/luajit.exe /mingw/bin/lua.exe
- install src/{lua.h,luaconf.h,lualib.h,lauxlib.h} /mingw/include/
- install src/liblua.a /mingw/lib/
- mkdir -p /mingw/share/lua/jit
- install jit/*.lua /mingw/share/lua/jit/
- cd ..
-else
- echo $'\n *** PART 8. Lua \n'
- dowget luasrc "lua-*.tar.gz" http://lua.org/download.html ftp/lua-
- rm -rf lua-*/; tar xf "$luasrc"; cd lua-*/
- make generic
- mkdir -p /mingw/man/man1 /mingw/share/lua /mingw/lib/lua
- install src/{lua.exe,luac.exe} /mingw/bin/
- install src/{lua.h,luaconf.h,lualib.h,lauxlib.h} /mingw/include/
- install src/liblua.a /mingw/lib/
- install doc/{lua.1,luac.1} /mingw/man/man1/
-fi
-
-echo $'\n *** PART 8. zip \n'
-dowget zipbin "zip*bin*.zip" http://gnuwin32.sourceforge.net/packages/zip.htm "zip.*bin.*zip"
-dowget zipdep "zip*dep*.zip" http://gnuwin32.sourceforge.net/packages/zip.htm "zip.*dep.*zip"
-rm -rf zipexe; mkdir zipexe; cd zipexe
-unzip ../"$zipbin" "bin/*"; unzip ../"$zipdep" "bin/*"; cp -r bin /mingw/
-cd ..
-
-echo $'\n *** FINISHED \n'
diff --git a/Makefile b/Makefile
deleted file mode 100644
index ddc38b0..0000000
--- a/Makefile
+++ b/dev/null
@@ -1,65 +0,0 @@
-
-# $(ult_target) isn't known before including config.mk
-_all: all
-
-.build/config.mk:
- ./configure
-include .build/config.mk
-
-dependencies = $(wildcard .build/*.d)
-ifneq ($(dependencies),)
--include $(dependencies)
-endif
-
-# make VERBOSE=1 shows full commands
-cmd = $(if $(VERBOSE)$(findstring s,$(MAKEFLAGS)),,@echo ' $(1) $(2)' && )$(call cmd_$(1),$(2),$(3))
-cmd_LAUNCHER = $(LUA) $(2)
-cmd_BINDING = cat $(2) | $(LUA) $< $(basename $(notdir $(1))) > $(1)
-cmd_CC = $(CC) -c $(CFLAGS) -o $(1) $< $(2)
-cmd_LD = $(LD) $(LDFLAGS) -o $(1) $^ $(2)
-cmd_RM = touch .build && $(RM) -f $(1) && ( rmdir -p $(dir $(1)) 2>/dev/null || true )
-cmd_PAK = sh src/makepak.sh $(2)
-cmd_INSTALL = $(INSTALL) -d $(dir $(1)) && $(INSTALL) $(2) $(1)
-
-ult_target = $(PROGRAM_PREFIX)karel$(PROGRAM_SUFFIX)
-
-all: data/karel.pak $(ult_target)
-
-$(ult_target): $(patsubst src/%.c,.build/%.o,$(wildcard src/*.c)) .build/lgllib.o .build/lsdllib.o
- $(call cmd,LD,$@,$(LUA_LDFLAGS) $(SDL_LDFLAGS) $(SDL_IMAGE_LDFLAGS) $(SDL_MIXER_LDFLAGS) $(ZLIB_LDFLAGS) $(FREETYPE_LDFLAGS) $(GL_LDFLAGS) $(GLU_LDFLAGS))
-
-header_path := $(if $(wildcard /mingw/*),/mingw/include/,/usr/include/)
-
-.build/lgllib.c: src/gengl.lua $(addprefix $(header_path),GL/gl.h GL/glu.h SDL/SDL_opengl.h)
- $(call cmd,BINDING,$@,$(filter %.h,$^))
-.build/lsdllib.c: src/gengl.lua $(addprefix $(header_path)SDL/SDL_,main.h stdinc.h active.h audio.h cdrom.h cpuinfo.h endian.h error.h events.h joystick.h keyboard.h keysym.h loadso.h mouse.h mutex.h rwops.h thread.h timer.h video.h version.h quit.h) $(wildcard $(header_path)SDL_image.h) $(wildcard $(header_path)SDL_mixer.h) $(wildcard $(header_path)SDL/SDL_image.h) $(wildcard $(header_path)SDL/SDL_mixer.h)
- $(call cmd,BINDING,$@,$(filter %.h,$^))
-vpath %.c .build
-
-vpath %.c src
-.build/%.o: %.c
- $(call cmd,CC,$@,$(LUA_CFLAGS) $(SDL_CFLAGS) $(SDL_IMAGE_CFLAGS) $(SDL_MIXER_CFLAGS) $(ZLIB_CFLAGS) $(FREETYPE_CFLAGS) $(GL_CFLAGS) $(GLU_CFLAGS) -Isrc -I.build "-DDATAPATH=\"$(DATADIR)\"")
-
-.build/main.o: .build/launcher.h
-
-.build/launcher.h: src/launcher.lua
- $(call cmd,LAUNCHER,$@,$< $@ $(if $(JITLIB),$(JITLIB)/opt.lua))
-
-%.pak: %.info
- $(call cmd,PAK,$@,$<)
-
-install: all
- $(call cmd,INSTALL,$(DESTDIR)$(BINDIR)/$(ult_target),$(ult_target))
- $(call cmd,INSTALL,$(DESTDIR)$(DATADIR)/karel.pak,-m644 data/karel.pak)
-
-uninstall:
- $(call cmd,RM,$(DESTDIR)$(BINDIR)/$(ult_target),)
- $(call cmd,RM,$(DESTDIR)$(DATADIR)/karel.pak,)
-
-clean:
- -$(RM) -f $(ult_target) .build/*.[chod] stdout.txt stderr.txt
-
-distclean:
- -$(RM) -rf $(ult_target) .build *.dll stdout.txt stderr.txt
-
-.PHONY: _all all install uninstall clean distclean
diff --git a/configure b/configure
deleted file mode 100755
index 48f9b33..0000000
--- a/configure
+++ b/dev/null
@@ -1,319 +0,0 @@
-#!/bin/sh
-
-# check bash
-if [ ! "$BASH_VERSION" ]; then
- echo "WARNING: it's recommended to run ./configure in bash."
- echo "Using a different shell may cause errors."
- echo "Use 'export BASH_VERSION=override' to continue."
- exit 1
-fi
-
-if [ "$BASH_VERSION" != "override" -a "${BASH_VERSION:0:1}" -lt 3 ]; then
- echo "ERROR: too old bash version"
- if [ -f /msys.bat ]; then
- echo -n "If you're using MSYS, download an update from "
- echo "<http://sf.net/projects/mingw>"
- echo "(Download -> MSYS Base System -> Technology Preview -> bash)"
- fi
- exit 1
-fi
-
-die () { echo "$@"; exit 1; }
-
-checking () { echo -n "checking $1... "; }
-
-var_default () { [ "${!1}" ] || export "$1=$2"; }
-check_program () {
- [ "${!1}" ] || export "$1=`command -v $2 2>/dev/null`"
- [ "${!1}" ] && return 0
- [ "$3" != "-o" ] && die "Couldn't find $2... try --$1=<your path>"
- return 1
-}
-
-# parse command-line arguments
-for arg; do
- if [ "$get_f" ]; then
- get_f=
- . "$arg"
- continue
- fi
- case "$arg" in
- --help|-h)
- echo '
-Usage: ./configure [-f <file.sh>] [--<var>=<value>] [--add-<var>=<value>]
-
- --help Display this help
- -f <file> Read VAR="value" list from <file.sh>
- --<var>=<value> Set <VAR> to <value>
- --with-<var>=<value> Set <VAR> to <value>
- --append-<var>=<value> Appends <value> to <VAR>, keeping previous value
-
-./configure is controlled with environment variables. --<var>=<value> and
---with-<var>=<value> are just short-hand forms. For example,
---with-program-suffix=_debug simply sets PROGRAM_SUFFIX=_debug.
-(<var> is automatically converted to uppercase.)
-
-Installation directories:
- --prefix=PREFIX Install files in PREFIX [/usr/local]
-
- --bindir=DIR user executables [PREFIX/games]
- --datadir=DIR read-only architecture-independent data
- [PREFIX/share/karel]
-
-Generic options:
- --cc=CC use compiler CC [gcc]
- --ld=LD use linker LD [CC]
- --cflags=CFLAGS C compiler flags [-O2 -Wall]
- --ldflags=LDFLAGS linker flags [-lm]
- --make=MAKE Makefile interpreter [make]
- --lua=LUA Lua 5.1 interpreter [lua5.1 or lua]
-
-`make'"'"' verbosity:
- --verbose=yes writes full commands (alias: make VERBOSE=yes)
-
-Program names:
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- (on Windows, SUFFIX defaults to .exe)
-
-Libraries:
- (<lib> can be Lua, SDL, SDL_image, SDL_mixer, zlib, freetype, GL, GLU)
-
- --with-<lib>-cflags=CFLAGS the library needs CFLAGS
- --with-<lib>-ldflags=LDFLAGS the library needs LDFLAGS
- (where <lib> can be LUA, SDL, SDL_IMAGE, SDL_MIXER, ZLIB, FREETYPE, GL, GLU)
-
- --with-jitlib=JITDIR if building with LuaJIT, the directory with
- jit/opt.lua and jit/opt_inline.lua
-
- pkg-config lua, sdl-config and freetype-config are used to autodetect
- the CFLAGS and LDFLAGS where approporiate.
-
- Default values for LDFLAGS:
- --with-lua-ldflags=-lua
- --with-sdl-ldflags=-lSDL
- --with-sdl_image-ldflags=-lSDL_image
- --with-sdl_mixer-ldflags=-lSDL_mixer
- --with-zlib-ldflags=-lz
- --with-freetype-ldflags=-lfreetype
- --with-gl-ldflags=-lGL (on Windows, -lopengl32)
- --with-glu-ldflags=-lGLU (on Windows, -lglu32)
-
-If you have headers or libraries in a non-standard path, simply use something
-like --append-cflags=-I/path (or --<lib>-cflags=I/path to disable autodetect).
-'
- exit 0
- ;;
- -f)
- get_f=yes
- ;;
- --append-*)
- # handled later
- ;;
- --*)
- arg=${arg#--}; arg=${arg#with-}
- export "`tr a-z- A-Z_ <<<"${arg%%=*}"`=${arg#*=}"
- ;;
- *)
- die "ERROR: unrecognized argument '$arg'"
- ;;
- esac
-done
-[ "$get_f" ] && die "ERROR: -f requires an argument"
-
-# temporary build directory
-rm -rf .build
-mkdir .build
-
-var_default CC gcc
-var_default LD $CC
-var_default CFLAGS "-O2 -Wall"
-var_default LDFLAGS "-lm"
-var_default MAKE make
-
-$CC --help >/dev/null 2>&1
-[ "$?" == 127 ] && die "couldn't run $CC... try --cc=<your compiler>"
-
-echo -n "Dependency rules generator: "
-echo "" >.build/conftmp.c
-if $CC $CFLAGS -MMD -MP -c -o .build/conftmp.o .build/conftmp.c 2>/dev/null; then
- set - "$@" --append-cflags="-MMD -MP"
- echo "yes"
-else
- echo "no"
-fi
-rm -f .build/conftmp.[cdo]
-
-# check Windows
-sh.exe --help >/dev/null 2>&1
-if [ "$?" != 127 ]; then
- echo "MinGW detected"
- var_default PROGRAM_SUFFIX .exe
- var_default GL_LDFLAGS -lopengl32
- var_default GLU_LDFLAGS -lglu32
- var_default ZLIB_LDFLAGS -lzdll
- var_default GET_DLL yes
- var_default BINDIR .
- var_default DATADIR .
- set - "$@" --append-ldflags=-L.
-else
- var_default GL_LDFLAGS -lGL
- var_default GLU_LDFLAGS -lGLU
-fi
-
-var_default PREFIX "/usr/local"
-var_default BINDIR "$PREFIX/games"
-var_default DATADIR "$PREFIX/share/karel"
-
-check_program INSTALL install
-check_program RM rm
-
-check_program LUA lua5.1 -o
-check_program LUA lua -o
-check_program LUA luajit -o
-check_program LUA lua
-[ ! "$LUA" ] && exit 1
-tmp=`$LUA -v 2>&1`
-[ "${tmp:0:7}" != "Lua 5.1" ] && die "Invalid Lua version: $tmp"
-echo "Lua binary: ${LUA##*/}"
-
-echo -n "Lua compile flags: "
-if ! [ "$LUA_CFLAGS" -a "$LUA_LDFLAGS" ]; then
- if check_program PKG_CONFIG pkg-config -o; then
- tmp=
- $PKG_CONFIG --exists lua && tmp=lua
- $PKG_CONFIG --exists lua51 && tmp=lua51
- $PKG_CONFIG --exists lua5.1 && tmp=lua5.1
- if [ "$tmp" ]; then
- var_default LUA_CFLAGS `"$PKG_CONFIG" --cflags $tmp`
- var_default LUA_LDFLAGS `"$PKG_CONFIG" --libs $tmp`
- echo "from pkg-config $tmp"
- else
- echo "using defaults"
- fi
- else
- echo "using defaults"
- fi
- var_default LUA_LDFLAGS -llua
-else
- echo "from command-line switches"
-fi
-
-var_default ZLIB_LDFLAGS -lz
-
-echo -n "SDL compile flags: "
-if ! [ "$SDL_CFLAGS" -a "$FREETYPE_LDFLAGS" ]; then
- if check_program SDL_CONFIG sdl-config -o; then
- echo "from sdl-config"
- var_default SDL_CFLAGS "`"$SDL_CONFIG" --cflags`"
- var_default SDL_LDFLAGS "`"$SDL_CONFIG" --libs`"
- else
- echo "using defaults"
- var_default SDL_LDFLAGS -lSDL
- fi
-else
- echo "from command-line switches"
-fi
-var_default SDL_IMAGE_LDFLAGS -lSDL_image
-var_default SDL_MIXER_LDFLAGS -lSDL_mixer
-
-echo -n "Freetype compile flags: "
-if ! [ "$FREETYPE_CFLAGS" -a "$FREETYPE_LDFLAGS" ]; then
- if check_program FT_CONFIG freetype-config -o; then
- # the gnuwin32 freetype-config can't be trusted
- if ! [ -d "`"$FT_CONFIG" --prefix`" ] && [ -f /bin/sh.exe ]; then
- echo "using gnuwin32 workaround"
- var_default FREETYPE_CFLAGS -I/mingw/include/freetype2
- var_default FREETYPE_LDFLAGS -lfreetype6
- else
- echo "from freetype-config"
- var_default FREETYPE_CFLAGS "`"$FT_CONFIG" --cflags`"
- var_default FREETYPE_LDFLAGS "`"$FT_CONFIG" --libs`"
- fi
- else
- echo "using defaults"
- var_default FREETYPE_LDFLAGS -lfreetype
- fi
-else
- echo "from command-line switches"
-fi
-
-if [ "$JITLIB" ]; then
- [ -f "$JITLIB/opt.lua" ] || JITLIB=""
-elif [ -f /usr/share/lua/jit/opt.lua ]; then
- JITLIB=/usr/share/lua/jit
-elif [ -f /mingw/share/lua/jit/opt.lua ]; then
- JITLIB=/mingw/share/lua/jit
-fi
-
-for arg; do
- [ "${arg#--append-}" == "$arg" ] && continue
- arg=${arg#--append-}
- name=`tr a-z- A-Z_ <<<"${arg%%=*}"`
- export "$name=${!name} ${arg#*=}"
-done
-
-if [ "$GET_DLL" ]; then
- echo "Copying dll files to current directory..."
- rm -f *.dll
- cp /mingw/bin/{SDL,SDL_image,SDL_mixer,freetype*,zlib*}.dll .
- cp /mingw/bin/{*jpeg*,*png*,*ogg*,*vorbis*}.dll .
-fi
-
-exp_cflags="CFLAGS LUA_CFLAGS SDL_CFLAGS SDL_IMAGE_CFLAGS SDL_MIXER_CFLAGS ZLIB_CFLAGS FREETYPE_CFLAGS GL_CFLAGS GLU_CFLAGS"
-exp_ldflags="LDFLAGS LUA_LDFLAGS SDL_LDFLAGS SDL_IMAGE_LDFLAGS SDL_MIXER_LDFLAGS ZLIB_LDFLAGS FREETYPE_LDFLAGS GL_LDFLAGS GLU_LDFLAGS"
-exp_other="CC LD MAKE LUA INSTALL RM PROGRAM_PREFIX PROGRAM_SUFFIX BINDIR DATADIR VERBOSE JITLIB"
-
-echo "Compiling test program..."
-conftmp='#include <SDL.h>
-#include <SDL_image.h>
-#include <SDL_mixer.h>
-#include <SDL_opengl.h>
-#include <lua.h>
-#include <zlib.h>
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#ifndef LUA_VERSION_NUM
-#error "Lua 5.1 required"
-#elif LUA_VERSION_NUM != 501
-#error "Lua 5.1 required"
-#endif
-int main(int argc, char **argv) {
-SDL_Linked_Version();
-IMG_Linked_Version();
-Mix_Linked_Version();
-zlibVersion();
-lua_newthread(NULL);
-FT_Init_FreeType(NULL);
-// C++ / C99 comments and variable declarations
-int var = 0;
-return var; }'
-echo "$conftmp" >.build/conftmp.c; echo "$conftmp" >.build/conftmp.log
-cmd="$CC -o .build/conftmp .build/conftmp.c"
-for i in $exp_cflags $exp_ldflags; do cmd="$cmd ${!i}"; done
-echo $'\n'"$cmd"$'\n' >.build/conftmp.log
-if $cmd >>.build/conftmp.log 2>&1; then
- rm -f .build/conftmp .build/conftmp.exe .build/conftmp.c .build/conftmp.d
-else
- echo "Failed to compile a test program (.build/conftmp.c)"
- echo "See .build/conftmp.log for details."
- echo "Make sure you have all the required libraries."
- if [ "`grep -E c:2[12] .build/conftmp.log`" ]; then
- echo "Make sure your compiler supports base C99 features."
- fi
- exit 1
-fi
-
-echo "# generated by configure" > .build/config.mk
-for i in $exp_other $exp_cflags $exp_ldflags; do
- echo "$i = ${!i}"
-done >> .build/config.mk
-
-echo ""
-echo "LuaJIT optimizer: ${JITLIB:-not used}"
-echo "Binary install path: $BINDIR"
-echo "Data install path: $DATADIR"
-echo ""
-echo "Everything works -- run '$MAKE' now"
-echo ""
-exit 0
diff --git a/data/fonts/BROOKLNN.ttf b/content/fonts/BROOKLNN.ttf
index 3df4b78..3df4b78 100644
--- a/data/fonts/BROOKLNN.ttf
+++ b/content/fonts/BROOKLNN.ttf
Binary files differ
diff --git a/data/fonts/DejaVuSansMono.ttf b/content/fonts/DejaVuSansMono.ttf
index a96ac6f..a96ac6f 100644
--- a/data/fonts/DejaVuSansMono.ttf
+++ b/content/fonts/DejaVuSansMono.ttf
Binary files differ
diff --git a/data/karel/gui/button/focus/down.png b/content/gui/button/focus/down.png
index 113b994..113b994 100644
--- a/data/karel/gui/button/focus/down.png
+++ b/content/gui/button/focus/down.png
Binary files differ
diff --git a/data/karel/gui/button/focus/downleft.png b/content/gui/button/focus/downleft.png
index 6ccd1ac..6ccd1ac 100644
--- a/data/karel/gui/button/focus/downleft.png
+++ b/content/gui/button/focus/downleft.png
Binary files differ
diff --git a/data/karel/gui/button/focus/downright.png b/content/gui/button/focus/downright.png
index 4f6ca6a..4f6ca6a 100644
--- a/data/karel/gui/button/focus/downright.png
+++ b/content/gui/button/focus/downright.png
Binary files differ
diff --git a/data/karel/gui/button/focus/left.png b/content/gui/button/focus/left.png
index 474cf8f..474cf8f 100644
--- a/data/karel/gui/button/focus/left.png
+++ b/content/gui/button/focus/left.png
Binary files differ
diff --git a/data/karel/gui/button/focus/mid.png b/content/gui/button/focus/mid.png
index a722181..a722181 100644
--- a/data/karel/gui/button/focus/mid.png
+++ b/content/gui/button/focus/mid.png
Binary files differ
diff --git a/data/karel/gui/button/focus/right.png b/content/gui/button/focus/right.png
index d01bff3..d01bff3 100644
--- a/data/karel/gui/button/focus/right.png
+++ b/content/gui/button/focus/right.png
Binary files differ
diff --git a/data/karel/gui/button/focus/up.png b/content/gui/button/focus/up.png
index cc87e1c..cc87e1c 100644
--- a/data/karel/gui/button/focus/up.png
+++ b/content/gui/button/focus/up.png
Binary files differ
diff --git a/data/karel/gui/button/focus/upleft.png b/content/gui/button/focus/upleft.png
index 6a638b3..6a638b3 100644
--- a/data/karel/gui/button/focus/upleft.png
+++ b/content/gui/button/focus/upleft.png
Binary files differ
diff --git a/data/karel/gui/button/focus/upright.png b/content/gui/button/focus/upright.png
index 7ebbfa7..7ebbfa7 100644
--- a/data/karel/gui/button/focus/upright.png
+++ b/content/gui/button/focus/upright.png
Binary files differ
diff --git a/data/karel/gui/button/normal/down.png b/content/gui/button/normal/down.png
index b7c3868..b7c3868 100644
--- a/data/karel/gui/button/normal/down.png
+++ b/content/gui/button/normal/down.png
Binary files differ
diff --git a/data/karel/gui/button/normal/downleft.png b/content/gui/button/normal/downleft.png
index 157ad46..157ad46 100644
--- a/data/karel/gui/button/normal/downleft.png
+++ b/content/gui/button/normal/downleft.png
Binary files differ
diff --git a/data/karel/gui/button/normal/downright.png b/content/gui/button/normal/downright.png
index 2dc7f7d..2dc7f7d 100644
--- a/data/karel/gui/button/normal/downright.png
+++ b/content/gui/button/normal/downright.png
Binary files differ
diff --git a/data/karel/gui/button/normal/left.png b/content/gui/button/normal/left.png
index 29ce331..29ce331 100644
--- a/data/karel/gui/button/normal/left.png
+++ b/content/gui/button/normal/left.png
Binary files differ
diff --git a/data/karel/gui/button/normal/mid.png b/content/gui/button/normal/mid.png
index 2ece551..2ece551 100644
--- a/data/karel/gui/button/normal/mid.png
+++ b/content/gui/button/normal/mid.png
Binary files differ
diff --git a/data/karel/gui/button/normal/right.png b/content/gui/button/normal/right.png
index abcbd2f..abcbd2f 100644
--- a/data/karel/gui/button/normal/right.png
+++ b/content/gui/button/normal/right.png
Binary files differ
diff --git a/data/karel/gui/button/normal/up.png b/content/gui/button/normal/up.png
index c0b9bbc..c0b9bbc 100644
--- a/data/karel/gui/button/normal/up.png
+++ b/content/gui/button/normal/up.png
Binary files differ
diff --git a/data/karel/gui/button/normal/upleft.png b/content/gui/button/normal/upleft.png
index 57d438e..57d438e 100644
--- a/data/karel/gui/button/normal/upleft.png
+++ b/content/gui/button/normal/upleft.png
Binary files differ
diff --git a/data/karel/gui/button/normal/upright.png b/content/gui/button/normal/upright.png
index e43c088..e43c088 100644
--- a/data/karel/gui/button/normal/upright.png
+++ b/content/gui/button/normal/upright.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/down.png b/content/gui/button/pressed/down.png
index e9159fb..e9159fb 100644
--- a/data/karel/gui/button/pressed/down.png
+++ b/content/gui/button/pressed/down.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/downleft.png b/content/gui/button/pressed/downleft.png
index bb17565..bb17565 100644
--- a/data/karel/gui/button/pressed/downleft.png
+++ b/content/gui/button/pressed/downleft.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/downright.png b/content/gui/button/pressed/downright.png
index 7234bf2..7234bf2 100644
--- a/data/karel/gui/button/pressed/downright.png
+++ b/content/gui/button/pressed/downright.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/left.png b/content/gui/button/pressed/left.png
index 85098b6..85098b6 100644
--- a/data/karel/gui/button/pressed/left.png
+++ b/content/gui/button/pressed/left.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/mid.png b/content/gui/button/pressed/mid.png
index ff8ef24..ff8ef24 100644
--- a/data/karel/gui/button/pressed/mid.png
+++ b/content/gui/button/pressed/mid.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/right.png b/content/gui/button/pressed/right.png
index cdf3fee..cdf3fee 100644
--- a/data/karel/gui/button/pressed/right.png
+++ b/content/gui/button/pressed/right.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/up.png b/content/gui/button/pressed/up.png
index ef6cfad..ef6cfad 100644
--- a/data/karel/gui/button/pressed/up.png
+++ b/content/gui/button/pressed/up.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/upleft.png b/content/gui/button/pressed/upleft.png
index c03e4a6..c03e4a6 100644
--- a/data/karel/gui/button/pressed/upleft.png
+++ b/content/gui/button/pressed/upleft.png
Binary files differ
diff --git a/data/karel/gui/button/pressed/upright.png b/content/gui/button/pressed/upright.png
index 48698d1..48698d1 100644
--- a/data/karel/gui/button/pressed/upright.png
+++ b/content/gui/button/pressed/upright.png
Binary files differ
diff --git a/data/karel/gui/checkbox/v1_off.png b/content/gui/checkbox/v1_off.png
index e77c7ed..e77c7ed 100644
--- a/data/karel/gui/checkbox/v1_off.png
+++ b/content/gui/checkbox/v1_off.png
Binary files differ
diff --git a/data/karel/gui/checkbox/v1_on.png b/content/gui/checkbox/v1_on.png
index 7b2d8b7..7b2d8b7 100644
--- a/data/karel/gui/checkbox/v1_on.png
+++ b/content/gui/checkbox/v1_on.png
Binary files differ
diff --git a/data/karel/gui/checkbox/v2_off.png b/content/gui/checkbox/v2_off.png
index 947cf1a..947cf1a 100644
--- a/data/karel/gui/checkbox/v2_off.png
+++ b/content/gui/checkbox/v2_off.png
Binary files differ
diff --git a/data/karel/gui/checkbox/v2_on.png b/content/gui/checkbox/v2_on.png
index 0933bcb..0933bcb 100644
--- a/data/karel/gui/checkbox/v2_on.png
+++ b/content/gui/checkbox/v2_on.png
Binary files differ
diff --git a/data/karel/gui/checkbox/v3_off.png b/content/gui/checkbox/v3_off.png
index 4c0b03d..4c0b03d 100644
--- a/data/karel/gui/checkbox/v3_off.png
+++ b/content/gui/checkbox/v3_off.png
Binary files differ
diff --git a/data/karel/gui/checkbox/v3_on.png b/content/gui/checkbox/v3_on.png
index 3c50717..3c50717 100644
--- a/data/karel/gui/checkbox/v3_on.png
+++ b/content/gui/checkbox/v3_on.png
Binary files differ
diff --git a/data/karel/gui/editbox/down.png b/content/gui/editbox/down.png
index dd563fa..dd563fa 100644
--- a/data/karel/gui/editbox/down.png
+++ b/content/gui/editbox/down.png
Binary files differ
diff --git a/data/karel/gui/editbox/downleft.png b/content/gui/editbox/downleft.png
index 12d398e..12d398e 100644
--- a/data/karel/gui/editbox/downleft.png
+++ b/content/gui/editbox/downleft.png
Binary files differ
diff --git a/data/karel/gui/editbox/downright.png b/content/gui/editbox/downright.png
index dcd45f8..dcd45f8 100644
--- a/data/karel/gui/editbox/downright.png
+++ b/content/gui/editbox/downright.png
Binary files differ
diff --git a/data/karel/gui/editbox/left.png b/content/gui/editbox/left.png
index 57ede9b..57ede9b 100644
--- a/data/karel/gui/editbox/left.png
+++ b/content/gui/editbox/left.png
Binary files differ
diff --git a/data/karel/gui/editbox/right.png b/content/gui/editbox/right.png
index 9801bee..9801bee 100644
--- a/data/karel/gui/editbox/right.png
+++ b/content/gui/editbox/right.png
Binary files differ
diff --git a/data/karel/gui/editbox/spinbox.png b/content/gui/editbox/spinbox.png
index e3e135e..e3e135e 100644
--- a/data/karel/gui/editbox/spinbox.png
+++ b/content/gui/editbox/spinbox.png
Binary files differ
diff --git a/data/karel/gui/editbox/spinbox_p.png b/content/gui/editbox/spinbox_p.png
index 22e968f..22e968f 100644
--- a/data/karel/gui/editbox/spinbox_p.png
+++ b/content/gui/editbox/spinbox_p.png
Binary files differ
diff --git a/data/karel/gui/editbox/up.png b/content/gui/editbox/up.png
index cdba8d0..cdba8d0 100644
--- a/data/karel/gui/editbox/up.png
+++ b/content/gui/editbox/up.png
Binary files differ
diff --git a/data/karel/gui/editbox/upleft.png b/content/gui/editbox/upleft.png
index b26fb08..b26fb08 100644
--- a/data/karel/gui/editbox/upleft.png
+++ b/content/gui/editbox/upleft.png
Binary files differ
diff --git a/data/karel/gui/editbox/upright.png b/content/gui/editbox/upright.png
index ab481a0..ab481a0 100644
--- a/data/karel/gui/editbox/upright.png
+++ b/content/gui/editbox/upright.png
Binary files differ
diff --git a/data/karel/gui/icons/copy.png b/content/gui/icons/copy.png
index 444c0dd..444c0dd 100644
--- a/data/karel/gui/icons/copy.png
+++ b/content/gui/icons/copy.png
Binary files differ
diff --git a/data/karel/gui/icons/cut.png b/content/gui/icons/cut.png
index f8f43b8..f8f43b8 100644
--- a/data/karel/gui/icons/cut.png
+++ b/content/gui/icons/cut.png
Binary files differ
diff --git a/data/karel/gui/icons/load.png b/content/gui/icons/load.png
index 754bb32..754bb32 100644
--- a/data/karel/gui/icons/load.png
+++ b/content/gui/icons/load.png
Binary files differ
diff --git a/data/karel/gui/icons/new.png b/content/gui/icons/new.png
index 36c2e1b..36c2e1b 100644
--- a/data/karel/gui/icons/new.png
+++ b/content/gui/icons/new.png
Binary files differ
diff --git a/data/karel/gui/icons/node_stepover.png b/content/gui/icons/node_stepover.png
index 2e442a5..2e442a5 100644
--- a/data/karel/gui/icons/node_stepover.png
+++ b/content/gui/icons/node_stepover.png
Binary files differ
diff --git a/data/karel/gui/icons/paste.png b/content/gui/icons/paste.png
index e0f16ef..e0f16ef 100644
--- a/data/karel/gui/icons/paste.png
+++ b/content/gui/icons/paste.png
Binary files differ
diff --git a/data/karel/gui/icons/prefs.png b/content/gui/icons/prefs.png
index ed5d2d2..ed5d2d2 100644
--- a/data/karel/gui/icons/prefs.png
+++ b/content/gui/icons/prefs.png
Binary files differ
diff --git a/data/karel/gui/icons/prefs_alt.png b/content/gui/icons/prefs_alt.png
index 012cf57..012cf57 100644
--- a/data/karel/gui/icons/prefs_alt.png
+++ b/content/gui/icons/prefs_alt.png
Binary files differ
diff --git a/data/karel/gui/icons/resume.png b/content/gui/icons/resume.png
index 3e03658..3e03658 100644
--- a/data/karel/gui/icons/resume.png
+++ b/content/gui/icons/resume.png
Binary files differ
diff --git a/data/karel/gui/icons/run.png b/content/gui/icons/run.png
index dbd8d3d..dbd8d3d 100644
--- a/data/karel/gui/icons/run.png
+++ b/content/gui/icons/run.png
Binary files differ
diff --git a/data/karel/gui/icons/save.png b/content/gui/icons/save.png
index 3cd74b7..3cd74b7 100644
--- a/data/karel/gui/icons/save.png
+++ b/content/gui/icons/save.png
Binary files differ
diff --git a/data/karel/gui/icons/save_alt.png b/content/gui/icons/save_alt.png
index bdbfcb3..bdbfcb3 100644
--- a/data/karel/gui/icons/save_alt.png
+++ b/content/gui/icons/save_alt.png
Binary files differ
diff --git a/data/karel/gui/icons/stepinsrc.png b/content/gui/icons/stepinsrc.png
index bf19bf5..bf19bf5 100644
--- a/data/karel/gui/icons/stepinsrc.png
+++ b/content/gui/icons/stepinsrc.png
Binary files differ
diff --git a/data/karel/gui/icons/subflow_stepinto.png b/content/gui/icons/subflow_stepinto.png
index b7acbd2..b7acbd2 100644
--- a/data/karel/gui/icons/subflow_stepinto.png
+++ b/content/gui/icons/subflow_stepinto.png
Binary files differ
diff --git a/data/karel/gui/icons/subflow_stepout.png b/content/gui/icons/subflow_stepout.png
index afdcb20..afdcb20 100644
--- a/data/karel/gui/icons/subflow_stepout.png
+++ b/content/gui/icons/subflow_stepout.png
Binary files differ
diff --git a/data/karel/gui/node/down.png b/content/gui/node/down.png
index dd563fa..dd563fa 100644
--- a/data/karel/gui/node/down.png
+++ b/content/gui/node/down.png
Binary files differ
diff --git a/data/karel/gui/node/downleft.png b/content/gui/node/downleft.png
index 973867f..973867f 100644
--- a/data/karel/gui/node/downleft.png
+++ b/content/gui/node/downleft.png
Binary files differ
diff --git a/data/karel/gui/node/downright.png b/content/gui/node/downright.png
index 7f81531..7f81531 100644
--- a/data/karel/gui/node/downright.png
+++ b/content/gui/node/downright.png
Binary files differ
diff --git a/data/karel/gui/node/left.png b/content/gui/node/left.png
index 57ede9b..57ede9b 100644
--- a/data/karel/gui/node/left.png
+++ b/content/gui/node/left.png
Binary files differ
diff --git a/data/karel/gui/node/right.png b/content/gui/node/right.png
index 9801bee..9801bee 100644
--- a/data/karel/gui/node/right.png
+++ b/content/gui/node/right.png
Binary files differ
diff --git a/data/karel/gui/node/up.png b/content/gui/node/up.png
index cdba8d0..cdba8d0 100644
--- a/data/karel/gui/node/up.png
+++ b/content/gui/node/up.png
Binary files differ
diff --git a/data/karel/gui/node/upleft.png b/content/gui/node/upleft.png
index a8d6716..a8d6716 100644
--- a/data/karel/gui/node/upleft.png
+++ b/content/gui/node/upleft.png
Binary files differ
diff --git a/data/karel/gui/node/upright.png b/content/gui/node/upright.png
index 03e5513..03e5513 100644
--- a/data/karel/gui/node/upright.png
+++ b/content/gui/node/upright.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/rope.png b/content/gui/scrollbar/rope.png
index 7421fee..7421fee 100644
--- a/data/karel/gui/scrollbar/rope.png
+++ b/content/gui/scrollbar/rope.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/shadow.png b/content/gui/scrollbar/shadow.png
index 0ed4216..0ed4216 100644
--- a/data/karel/gui/scrollbar/shadow.png
+++ b/content/gui/scrollbar/shadow.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/weights.png b/content/gui/scrollbar/weights.png
index 458004c..458004c 100644
--- a/data/karel/gui/scrollbar/weights.png
+++ b/content/gui/scrollbar/weights.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel.png b/content/gui/scrollbar/wheel.png
index ec418d8..ec418d8 100644
--- a/data/karel/gui/scrollbar/wheel.png
+++ b/content/gui/scrollbar/wheel.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel000.png b/content/gui/scrollbar/wheel000.png
index 397bb5a..397bb5a 100644
--- a/data/karel/gui/scrollbar/wheel000.png
+++ b/content/gui/scrollbar/wheel000.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel022.png b/content/gui/scrollbar/wheel022.png
index 17c7a61..17c7a61 100644
--- a/data/karel/gui/scrollbar/wheel022.png
+++ b/content/gui/scrollbar/wheel022.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel045.png b/content/gui/scrollbar/wheel045.png
index 13f2992..13f2992 100644
--- a/data/karel/gui/scrollbar/wheel045.png
+++ b/content/gui/scrollbar/wheel045.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel067.png b/content/gui/scrollbar/wheel067.png
index 2684ecd..2684ecd 100644
--- a/data/karel/gui/scrollbar/wheel067.png
+++ b/content/gui/scrollbar/wheel067.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel090.png b/content/gui/scrollbar/wheel090.png
index ed13df3..ed13df3 100644
--- a/data/karel/gui/scrollbar/wheel090.png
+++ b/content/gui/scrollbar/wheel090.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel112.png b/content/gui/scrollbar/wheel112.png
index 47fa1d4..47fa1d4 100644
--- a/data/karel/gui/scrollbar/wheel112.png
+++ b/content/gui/scrollbar/wheel112.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel135.png b/content/gui/scrollbar/wheel135.png
index 5f42c91..5f42c91 100644
--- a/data/karel/gui/scrollbar/wheel135.png
+++ b/content/gui/scrollbar/wheel135.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel157.png b/content/gui/scrollbar/wheel157.png
index c89e196..c89e196 100644
--- a/data/karel/gui/scrollbar/wheel157.png
+++ b/content/gui/scrollbar/wheel157.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel180.png b/content/gui/scrollbar/wheel180.png
index c5fdfb5..c5fdfb5 100644
--- a/data/karel/gui/scrollbar/wheel180.png
+++ b/content/gui/scrollbar/wheel180.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel202.png b/content/gui/scrollbar/wheel202.png
index e137590..e137590 100644
--- a/data/karel/gui/scrollbar/wheel202.png
+++ b/content/gui/scrollbar/wheel202.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel225.png b/content/gui/scrollbar/wheel225.png
index 337124f..337124f 100644
--- a/data/karel/gui/scrollbar/wheel225.png
+++ b/content/gui/scrollbar/wheel225.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel247.png b/content/gui/scrollbar/wheel247.png
index dd7342f..dd7342f 100644
--- a/data/karel/gui/scrollbar/wheel247.png
+++ b/content/gui/scrollbar/wheel247.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel270.png b/content/gui/scrollbar/wheel270.png
index 393e8a4..393e8a4 100644
--- a/data/karel/gui/scrollbar/wheel270.png
+++ b/content/gui/scrollbar/wheel270.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel292.png b/content/gui/scrollbar/wheel292.png
index 0ef88c6..0ef88c6 100644
--- a/data/karel/gui/scrollbar/wheel292.png
+++ b/content/gui/scrollbar/wheel292.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel315.png b/content/gui/scrollbar/wheel315.png
index e4f4540..e4f4540 100644
--- a/data/karel/gui/scrollbar/wheel315.png
+++ b/content/gui/scrollbar/wheel315.png
Binary files differ
diff --git a/data/karel/gui/scrollbar/wheel337.png b/content/gui/scrollbar/wheel337.png
index d7b1b3a..d7b1b3a 100644
--- a/data/karel/gui/scrollbar/wheel337.png
+++ b/content/gui/scrollbar/wheel337.png
Binary files differ
diff --git a/data/karel/gui/window/corner.png b/content/gui/window/corner.png
index ca26d67..ca26d67 100644
--- a/data/karel/gui/window/corner.png
+++ b/content/gui/window/corner.png
Binary files differ
diff --git a/data/karel/gui/window/down.png b/content/gui/window/down.png
index 7615404..7615404 100644
--- a/data/karel/gui/window/down.png
+++ b/content/gui/window/down.png
Binary files differ
diff --git a/data/karel/gui/window/downleft.png b/content/gui/window/downleft.png
index 6eaf02c..6eaf02c 100644
--- a/data/karel/gui/window/downleft.png
+++ b/content/gui/window/downleft.png
Binary files differ
diff --git a/data/karel/gui/window/downright.png b/content/gui/window/downright.png
index db336a5..db336a5 100644
--- a/data/karel/gui/window/downright.png
+++ b/content/gui/window/downright.png
Binary files differ
diff --git a/data/karel/gui/window/header.png b/content/gui/window/header.png
index 3184f62..3184f62 100644
--- a/data/karel/gui/window/header.png
+++ b/content/gui/window/header.png
Binary files differ
diff --git a/data/karel/gui/window/header_i.png b/content/gui/window/header_i.png
index 7259b37..7259b37 100644
--- a/data/karel/gui/window/header_i.png
+++ b/content/gui/window/header_i.png
Binary files differ
diff --git a/data/karel/gui/window/header_x.png b/content/gui/window/header_x.png
index 6c999d2..6c999d2 100644
--- a/data/karel/gui/window/header_x.png
+++ b/content/gui/window/header_x.png
Binary files differ
diff --git a/data/karel/gui/window/headerleft.png b/content/gui/window/headerleft.png
index 693173f..693173f 100644
--- a/data/karel/gui/window/headerleft.png
+++ b/content/gui/window/headerleft.png
Binary files differ
diff --git a/data/karel/gui/window/headerright.png b/content/gui/window/headerright.png
index 6aaeabf..6aaeabf 100644
--- a/data/karel/gui/window/headerright.png
+++ b/content/gui/window/headerright.png
Binary files differ
diff --git a/data/karel/gui/window/left.png b/content/gui/window/left.png
index 7b2ae44..7b2ae44 100644
--- a/data/karel/gui/window/left.png
+++ b/content/gui/window/left.png
Binary files differ
diff --git a/data/karel/gui/window/mid.png b/content/gui/window/mid.png
index 70ee02f..70ee02f 100644
--- a/data/karel/gui/window/mid.png
+++ b/content/gui/window/mid.png
Binary files differ
diff --git a/data/karel/gui/window/right.png b/content/gui/window/right.png
index 9ed9f0d..9ed9f0d 100644
--- a/data/karel/gui/window/right.png
+++ b/content/gui/window/right.png
Binary files differ
diff --git a/data/karel/gui/window/up.png b/content/gui/window/up.png
index 1158438..1158438 100644
--- a/data/karel/gui/window/up.png
+++ b/content/gui/window/up.png
Binary files differ
diff --git a/data/karel/gui/window/upleft.png b/content/gui/window/upleft.png
index cbbf2d1..cbbf2d1 100644
--- a/data/karel/gui/window/upleft.png
+++ b/content/gui/window/upleft.png
Binary files differ
diff --git a/data/karel/gui/window/upright.png b/content/gui/window/upright.png
index e02cd2e..e02cd2e 100644
--- a/data/karel/gui/window/upright.png
+++ b/content/gui/window/upright.png
Binary files differ
diff --git a/data/karel/GUI.lua b/content/karel/GUI.lua
index 29ce681..29ce681 100644
--- a/data/karel/GUI.lua
+++ b/content/karel/GUI.lua
diff --git a/data/karel/Machine.lua b/content/karel/Machine.lua
index aa0bd02..aa0bd02 100644
--- a/data/karel/Machine.lua
+++ b/content/karel/Machine.lua
diff --git a/data/karel/Main.lua b/content/karel/Main.lua
index 66841c6..66841c6 100644
--- a/data/karel/Main.lua
+++ b/content/karel/Main.lua
diff --git a/data/karel/ProgramNode.lua b/content/karel/ProgramNode.lua
index 435c18a..435c18a 100644
--- a/data/karel/ProgramNode.lua
+++ b/content/karel/ProgramNode.lua
diff --git a/data/karel/Project.lua b/content/karel/Project.lua
index ba74965..ba74965 100644
--- a/data/karel/Project.lua
+++ b/content/karel/Project.lua
diff --git a/data/karel/RoomModel.lua b/content/karel/RoomModel.lua
index 6e64da0..6e64da0 100644
--- a/data/karel/RoomModel.lua
+++ b/content/karel/RoomModel.lua
diff --git a/data/karel/RoomView.lua b/content/karel/RoomView.lua
index 1c7f4d2..1c7f4d2 100644
--- a/data/karel/RoomView.lua
+++ b/content/karel/RoomView.lua
diff --git a/data/karel/robot.obj b/content/robot.obj
index 5866091..5866091 100644
--- a/data/karel/robot.obj
+++ b/content/robot.obj
diff --git a/data/karel/robot.png b/content/robot.png
index c1c21c0..c1c21c0 100644
--- a/data/karel/robot.png
+++ b/content/robot.png
Binary files differ
diff --git a/data/karel/roomgfx/brick.png b/content/roomgfx/brick.png
index c70a2a3..c70a2a3 100644
--- a/data/karel/roomgfx/brick.png
+++ b/content/roomgfx/brick.png
Binary files differ
diff --git a/data/karel/roomgfx/bubble.png b/content/roomgfx/bubble.png
index 1df35a0..1df35a0 100644
--- a/data/karel/roomgfx/bubble.png
+++ b/content/roomgfx/bubble.png
Binary files differ
diff --git a/data/karel/roomgfx/fence.png b/content/roomgfx/fence.png
index db4eb76..db4eb76 100644
--- a/data/karel/roomgfx/fence.png
+++ b/content/roomgfx/fence.png
Binary files differ
diff --git a/data/karel/roomgfx/floor.png b/content/roomgfx/floor.png
index d42f679..d42f679 100644
--- a/data/karel/roomgfx/floor.png
+++ b/content/roomgfx/floor.png
Binary files differ
diff --git a/data/start.lua b/content/start.lua
index 7483fc0..7483fc0 100644
--- a/data/start.lua
+++ b/content/start.lua
diff --git a/data/core/Console.lua b/data/core/Console.lua
deleted file mode 100644
index 556ba1f..0000000
--- a/data/core/Console.lua
+++ b/dev/null
@@ -1,122 +0,0 @@
-
-require 'MainLoop'
-require 'Textures'
-require 'Fonts'
-require 'TextInput'
-
-local _G = _G
-local gl, glu, SDL = gl, glu, SDL
-local Fonts, TextInput, MainLoop = Fonts, TextInput, MainLoop
-local Class = Class
-
-module(...)
-
-local Console = _M
-MainLoop:instantiate(Console)
-
-Console.font = 'fonts/DejaVuSansMono.ttf:10'
-Console.texture = nil
-
-Console.command = nil
-Console.input = nil
-Console.scroll = 0
-Console.histpos = 0
-
-function Console:initialize()
- MainLoop.initialize(self)
- self.history = self.history or {}
- self.output = self.output or {}
- self.input = self.input or TextInput:new{ font = Fonts[self.font] }
-end
-
-function Console:write(...)
- for l in _G.table.concat({...}):gmatch('[^\n]+') do
- self.output[#self.output+1] = l
- end
-end
-
-function Console:display()
- gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT)
- if self.parentloop then self.parentloop:display() end
- gl.PushAttrib(gl.ALL_ATTRIB_BITS)
- gl.MatrixMode(gl.PROJECTION)
- gl.PushMatrix()
- gl.LoadIdentity()
- gl.Ortho(0, _G.WIDTH, 0, _G.HEIGHT, -1, 1)
- gl.MatrixMode(gl.MODELVIEW)
- gl.PushMatrix()
- -- TODO maybe disable some more things (stencil etc.) -- if needed
- gl.Disable(gl.DEPTH_TEST)
- gl.Disable(gl.LIGHTING)
- gl.Enable(gl.TEXTURE_2D)
- gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); gl.Enable(gl.BLEND)
- gl.LoadIdentity()
- gl.Translate(30, 30, 0)
- gl.Color(0, 0, 0, 0.5); gl.BindTexture(gl.TEXTURE_2D, 0)
- Fonts.DrawBoundingBox(Fonts[self.font],
- Fonts[self.font]:prepare(self.input.text) + 3)
- gl.Color(1, 1, 1, 1)
- gl.PushMatrix(); self.input:display(); gl.PopMatrix()
- for i = 0, 30 do
- local id = #self.output - i - self.scroll
- if self.output[id] then
- gl.Translate(0, Fonts[self.font].height, 0)
- gl.Color(0, 0, 0, 0.5); gl.BindTexture(gl.TEXTURE_2D, 0)
- Fonts.DrawBoundingBox(Fonts[self.font], self.output[id])
- gl.Color(1, 1, 1, 1)
- gl.PushMatrix(); Fonts[self.font]:print(self.output[id]); gl.PopMatrix()
- end
- end
- gl.PopMatrix()
- gl.MatrixMode(gl.PROJECTION)
- gl.PopMatrix()
- gl.MatrixMode(gl.MODELVIEW)
- gl.PopAttrib()
-end
-
-function Console:update()
- self.input:update()
- if self.command then
- local c = self.command; self.command = nil
- local f, err = _G.loadstring('return '..c, '=debug')
- if not f then f, err = _G.loadstring(c, '=debug') end
- if not f then self:write(err); return end
- local e = { loop = self.parentloop,
- self = self, cwrite = function (...) return self:write(...) end }
- _G.setmetatable(e, { __index = _G, __newindex = _G }); _G.setfenv(f, e)
- local _, result = _G.pcall(f) -- TODO multret
- if result ~= nil and _G.type(result) ~= 'string' then
- result = _G.inspect.object(result, _G.inspect.indented) end
- self:write(result)
- end
-end
-
-function Console:key(ev)
- if not ev.down then return end
- if ev.sym == SDL.K_ESCAPE or ev.sym == SDL.K_BACKQUOTE then self.running = false
- elseif ev.sym == SDL.K_PAGEUP then
- if self.output[#self.output - self.scroll - 10] then
- self.scroll = self.scroll + 10 end
- elseif ev.sym == SDL.K_PAGEDOWN then
- if self.output[#self.output - self.scroll + 10] then
- self.scroll = self.scroll - 10 end
- elseif ev.sym == SDL.K_UP or ev.sym == SDL.K_DOWN then
- if #self.history > 0 then
- self.histpos = self.histpos + (ev.sym == SDL.K_UP and -1 or 1)
- while self.histpos < 1 do
- self.histpos = self.histpos + #self.history end
- while self.histpos > #self.history do
- self.histpos = self.histpos - #self.history end
- self.input.text = self.history[self.histpos] or ''
- self.input.cursor = self.input.text:ulen()
- end
- elseif ev.sym == SDL.K_RETURN or ev.sym == SDL.K_KP_ENTER then
- self.command = self.input.text
- self.history[#self.history+1] = self.input.text
- self:write(self.input.text)
- self.histpos, self.scroll = 1, 0
- self.input.text, self.input.cursor = '', 0
- else
- self.input:key(ev)
- end
-end
diff --git a/data/core/Cursor.lua b/data/core/Cursor.lua
deleted file mode 100644
index 2d43e0e..0000000
--- a/data/core/Cursor.lua
+++ b/dev/null
@@ -1,137 +0,0 @@
-
-require 'Node'
-
-local _G = _G
-local pairs = pairs
-local SDL, gl = SDL, gl
-local Node = Node
-
-module(...)
-
--- TODO move AnimationState to a separate file
-AnimationState = _G.Class()
-
-AnimationState.t = nil
-AnimationState.length = nil
-AnimationState.old = nil
-AnimationState.dest = nil
-
-function AnimationState:animFn(time_percent)
- --return ((1 - _G.math.cos(time_percent * _G.math.pi)) / 2)
- return _G.math.cos((1 - time_percent) * _G.math.pi/2)
-end
-
--- TODO definitely replace this with a better OOP system which has dynamic attributes
-function AnimationState:getDest()
- return self.dest
-end
-function AnimationState:setDest(d)
- self.dest = d
-end
-
-function AnimationState:getCurrent()
- -- IMPORTANT TODO use frameFraction
- if self.t and self.t >= self.length then self.t, self.old = nil, nil end
- local result, dest = {}, self:getDest()
- if not self.t or not self.old then return dest end
- local progress = self:animFn(self.t/self.length) -- (0..1) clampf
- for k,v in pairs(self.old) do result[k] = v + progress*(dest[k] - v) end
- return result
-end
-
-function AnimationState:go(dest, length)
- if not length then -- go to dest immediately
- self.old, self.t = nil, nil
- else
- self.old = self:getCurrent()
- self.t = 1
- self.length = length
- end
- self:setDest(dest)
-end
-
-function AnimationState:update()
- if self.t then self.t = self.t + 1 end
-end
-
-local Cursor = _M
-Node:instantiate(Cursor)
-
-Cursor.isCursor = true
-Cursor.layer = 20
-Cursor.doesDisplay = false
-Cursor.moveTime = 10
-Cursor.pos = nil
-Cursor.aux = nil
-
-function Cursor:initialize()
- Node.initialize(Cursor)
- self.pos = AnimationState:new{}
- self.aux = AnimationState:new{}
- -- self.pos should always have SDL.GetMouseState() as dest
- function self.pos:setDest(d)
- self.dest = d
- SDL.WarpMouse(d[1], _G.HEIGHT - d[2])
- end
- function self.pos:getDest()
- -- maybe (TODO really?) SDL.WarpMouse() won't work immediately, so don't
- -- use SDL.GetMouseState() (through cur_x,y) until self.t > 1
- if self.t == 1 then return self.dest end
- return { _G.Event.mouse.cur_x, _G.HEIGHT - _G.Event.mouse.cur_y }
- end
-end
-
-function Cursor:inserted()
- self:getLoop().cursor = self
- return Node.inserted(self)
-end
-
-function Cursor:removed()
- if self:getLoop().cursor == self then self:getLoop().cursor = nil end
- return Node.removed(self)
-end
-
-function Cursor:hide()
- self.doesDisplay = false
-end
-
-function Cursor:moveAux(...)
- self.aux:go({...}, self.doesDisplay and self.moveTime)
- self.doesDisplay = true
-end
-
-function Cursor:move(x, y, ...)
- self.pos:go({x, y}, self.doesDisplay and self.moveTime)
- self.aux:go({...}, self.doesDisplay and self.moveTime)
- self.doesDisplay = true
-end
-
-function Cursor:update()
- self.pos:update()
- self.aux:update()
-end
-
-function Cursor:displayPrepare()
- Node.displayPrepare(self)
- gl.PushMatrix()
-end
-
-function Cursor:displayCleanup()
- gl.PopMatrix()
- Node.displayCleanup(self)
-end
-
-function Cursor:displayContent()
- if _G.Selection.active then return end
- local cur_x, cur_y = _G.unpack(self.pos:getCurrent())
- gl.LoadIdentity()
- gl.Translate(cur_x, cur_y, 0)
- gl.BindTexture(gl.TEXTURE_2D, 0)
- gl.Color(1, 1, 1)
- gl.LineWidth(2)
- gl.Begin(gl.LINES)
- gl.Vertex(-10, 0); gl.Vertex(10, 0)
- gl.Vertex(0, -10); gl.Vertex(0, 10)
- gl.End()
-end
-
diff --git a/data/core/Event.lua b/data/core/Event.lua
deleted file mode 100644
index 17e2048..0000000
--- a/data/core/Event.lua
+++ b/dev/null
@@ -1,36 +0,0 @@
-
-local _G = _G
-local SDL = SDL
-
-module(...)
-
-function send(ev, target)
- if target then ev.target = target end
- if not ev.target then
- _G.notice("warning - event target is nil; discarding event"); return false end
- local n, o, parents = 0, ev.target, {}
- while o do n=n+1; parents[n] = o; o = o.parent end
- for i = n, 1, -1 do if parents[i]:eventFilter(ev) then return true end end
- for i = 1, n do if parents[i]:event(ev) then return true end end
- return false
-end
-
--- the value are constructed so that Event.key[sym] is true when an
--- :update() function should handle a key
-JUST_PRESSED = 1 -- just pressed (needed for JUST_RELEASED to work)
-JUST_RELEASED = 2 -- already released, but it wasn't handled by :update() yet
-PRESSED = 3 -- can be released
-OVERRIDDEN = false -- already handled by Event.send, ignore it in :update()
-RELEASED = nil
-key = {}
-function key_update()
- for k, v in _G.pairs(key) do
- if v == JUST_PRESSED then key[k] = PRESSED end
- if v == JUST_RELEASED then key[k] = RELEASED end end
-end
-
--- cur_x,y are the most up-to-date information for the current display frame
--- TODO: can't they be merged into x,y?
-mouse = { x = 0, y = 0, cur_x = 0, cur_y = 0 }
-
-active = { [SDL.APPINPUTFOCUS] = true, [SDL.APPMOUSEFOCUS] = true, [SDL.APPACTIVE] = true }
diff --git a/data/core/FS.lua b/data/core/FS.lua
deleted file mode 100644
index a75db51..0000000
--- a/data/core/FS.lua
+++ b/dev/null
@@ -1,265 +0,0 @@
-
-require 'Unzip' -- embedded in launcher.h
-
-local _G = _G
-local Unzip = Unzip
-local io, table, string = io, table, string
-local assert, error, ipairs, loadstring, pairs, print, rawset, pcall =
- assert, error, ipairs, loadstring, pairs, print, rawset, pcall
-local getenv = os.getenv
-
-local _rwfromfile, _mkdir, _remove = nil
-
-module(...)
-
-
-local function _fixpath(s) return _G._WIN32 and s:gsub('^./',''):gsub('/$',''):gsub('/','\\') or s end
-
-local function _dirname(s) return s:gsub('/*[^/]+/*$', '') end
-
-local function Join(a,b) return a:gsub('/+$', '') .. '/' .. b:gsub('^/+', '') end
-
-
-local archiveHandles = {}
-local archives = {}
-fstab, mtab, roots = {}, {}, {}
-
-_M.mpath = 'core/?.lua;?.lua'
-
-
---[[ runs a config file in a protected environment.
- the config file is expected to set some global variables in its environment.
- (it can't access any global variables from outside.) this environment is
- returned as a result. if an error occurs, nil and a message are returned,
- and the message is written on stderr. if the function call takes too many
- instructions, an error message is output to help identify infinite loops.
- ]]
-function runConfig(fname, body)
- local chunk, err = loadstring(body or assert(load(fname):read()), '@'..fname)
- if not chunk then io.out(fname..": "..err.."\n"); return false, err end
- local env = {}
- _G.setfenv(chunk, env)
- local hook_activated = false
- _G.debug.sethook(function ()
- if hook_activated then return end; hook_activated = true
- io.out("warning: file '"..fname.."' is loading slowly\n")
- io.out(" (maybe it contains an infinite loop?)\n")
- end, "", 1000)
- local ret, err = _G.pcall(chunk)
- _G.debug.sethook()
- if hook_activated then io.out(" finished loading '"..fname.."'\n") end
- if ret == false then io.out(fname..": "..err.."\n"); return false, err end
- return env
-end
-
-
-local function iterateFiles_fn(fsroot, fname)
- local tmp, isreg, isdir = assert(io.stat(_fixpath(fsroot..fname)))
- if isreg then _G.coroutine.yield(fname); return end
- if isdir then
- for i, entry in ipairs(assert(io.dirent(_fixpath(fsroot..fname)))) do
- if entry:sub(1, 1) ~= '.' then
- iterateFiles_fn(fsroot, Join(fname, entry):gsub('^/+', ''))
- end end end
- -- NOTE: if not isdir and not isreg, the file simply gets skipped
-end
-
--- this function iterates recursively over a directory
-function iterateFiles(dir)
- return _G.coroutine.wrap(iterateFiles_fn), Join(dir, ''), ''
-end
-
-
-local function nameToRealpath(name)
- local root_id = name:match('^[^/]*')
- assert(roots[root_id], "unknown FS root name '"..root_id.."'")
- return Join(roots[root_id], name:sub(#root_id+1, -1))
-end
-
-
-_G.setmetatable(archiveHandles, { __index = function (t, k)
- t[k] = _G.SDL.RWFromFile(_fixpath(nameToRealpath(k)), 'rb'); return t[k] end })
-
--- archiveHandles stay open until this function is called.
-function closeLoadingSession()
- for pak,handle in pairs(archiveHandles) do
- archiveHandles[pak]:close(); archiveHandles[pak] = nil end
- _G.collectgarbage'collect'
-end
-
-
-local function openPak(name, mountpoint)
- local infofile = name:match('[^/]*$'):match('^[^.]*')..'.info'
- local entry_table = {}
- local vfs = { name = name, files = {}, type = 'unknown' }
- function vfs:open(ename)
- return Unzip.entry(entry_table[ename], archiveHandles[name]) end
-
- local status, result = pcall(Unzip.archive, name, archiveHandles[name])
- if not status then io.out(result..'\n'); return end
-
- for i,ename in ipairs(result) do
- local entry = result[ename]
- if ename == infofile then
- local status, body = pcall(Unzip.entry, entry, archiveHandles[name])
- if not status then io.out(name..': '..body..'\n'); return end
- local info, err = runConfig(Join(name, ename), body:read())
- if not info then return end
- for k,v in pairs(info) do
- if k == 'type' or not vfs[k] then vfs[k] = v end end
- else
- vfs.files[Join(mountpoint, ename)] = vfs
- entry_table[Join(mountpoint, ename)] = entry
- end
- end
-
- fstab[name] = vfs
-end
-
-
-local function openDir(name, mountpoint)
- -- this expects roots[name] to be the directory's fspath
- local vfs = { name = name, files = {}, type = 'directory' }
- local fsroot = nameToRealpath(name)
- function vfs:open(fname)
- return _G.SDL.RWFromFile(_fixpath(Join(fsroot, fname:sub(#Join(mountpoint, '')+1, -1))), 'rb')
- end
- if io.stat(_fixpath(fsroot)) then
- for file in iterateFiles(fsroot) do
- if file:sub(-4):lower() == ".pak" then
- openPak(Join(name, file), Join(mountpoint, _dirname(file)))
- else
- vfs.files[Join(mountpoint, file)] = vfs
- end
- end
- end
- fstab[name] = vfs
-end
-
-
-function init(datapath, userpath, myrwfromfile, mymkdir, myremove)
- if roots.USER then return end -- already initialized
- _rwfromfile, _mkdir, _remove = myrwfromfile, mymkdir, myremove
- roots.DATA = datapath; openDir('DATA', '/')
- roots.USER = userpath; openDir('USER', '/')
- for name,vfs in pairs(fstab) do
- if vfs.type == 'core' then table.insert(mtab, name) end
- end
- table.sort(mtab, function (a, b) return (fstab[a].priority or 0) < (fstab[b].priority or 0) end)
- table.insert(mtab, 'DATA')
- table.insert(mtab, 'USER')
- table.insert(_G.package.loaders, function (modname)
- local e = ''
- for i in mpath:gmatch('[^;]+') do
- local f = i:gsub('%?', (modname:gsub('%.', '/')))
- if lookupFile(f) then return loadCode(f) end
- e = e .. "\n\tno file '"..f.."' in the FS database"
- end
- return e
- end)
-end
-
-
-function loadMtab(newmtab)
- -- this sets mtab to newmtab, making some changes:
- -- entries that aren't present in fstab are ignored.
- -- all core paks are always at the beginning, sorted by priority.
- -- vfs USER is always at the end.
- for k,v in pairs(mtab) do mtab[k] = nil end
- for name,vfs in pairs(fstab) do
- if vfs.type == 'core' then table.insert(mtab, name) end
- end
- table.sort(mtab, function (a, b) return (fstab[a].priority or 0) < (fstab[b].priority or 0) end)
- for i,v in ipairs(newmtab) do
- if not fstab[v] then io.out("vfs '"..v.."' not found; ignoring\n") end
- if v ~= 'USER' and fstab[v] and fstab[v].type ~= 'core' then
- table.insert(mtab, v)
- end end
- table.insert(mtab, 'USER')
-end
-
-
-function lookupFile(filename)
- filename = Join('', filename)
- local found = nil
- for i,vfsname in ipairs(mtab) do
- local vfs = fstab[vfsname]
- if vfs.files[filename] then found = vfs end
- end
- return found
-end
-
-
-function matchFiles(wildcard)
- local found, result, n = {}, {}, 1
- for i,vfsname in ipairs(mtab) do
- local files = fstab[vfsname].files
- for fn, vfs in pairs(fstab[vfsname].files) do
- if not found[fn] and (not wildcard or fn:match(wildcard)) then
- found[fn] = true; result[n] = fn; n = n + 1
- end
- end
- end
- table.sort(result)
- return result
-end
-
-
-function load(filename)
- filename = Join('', filename)
- return assert(lookupFile(filename), filename..": file not found"):open(filename)
-end
-
-function loadCode(filename)
- return assert(loadstring(assert(load(filename):read()), "@"..filename))
-end
-
-
-
--- this checks if the path is well-formed and doesn't contain suspicious characters
--- only paths that pass this check can be used in write functions
-local function checkPath(path)
- -- contains \ (incorrect directory separator)?
- if path:match('\\') then return false end
- -- contains a non-ASCII character?
- if path:match('[^ -~]') then return false end
- -- contains '..' (up one level)?
- if ('/'..path..'/'):match('/%.%./') then return false end
- -- it seems to be OK
- return true
-end
-
--- functions for manipulating the user directory
--- note that this is the only I/O output facility in the whole program, as
--- the standard write functions are only passed to FS.init() and can't be
--- accessed from outside FS.
-
-local function user_mkdir_fn(path)
- if not io.stat(_fixpath(roots.USER)) then
- _G.notice("creating user data directory in '"..roots.USER.."'")
- assert(_mkdir(_fixpath(roots.USER)))
- end
- if Join(path, '') == '/' then return end
- if not io.stat(_fixpath(Join(roots.USER, path))) then
- user_mkdir_fn(_dirname(path))
- assert(_mkdir(_fixpath(Join(roots.USER, path))))
- end
-end
-
-function write(path, body)
- assert(checkPath(path), "malformed path")
- path = Join('', path)
- user_mkdir_fn(_dirname(path))
- local fh = assert(_rwfromfile(Join(roots.USER, path), 'wb'))
- assert(fh:write(body)); fh:close()
- if fstab.USER and not fstab.USER.files[path] then
- fstab.USER.files[path] = fstab.USER
- end
-end
-
-function remove(path)
- assert(checkPath(path), "malformed path")
- path = Join('', path)
- if io.stat(_fixpath(Join(roots.USER, path))) then assert(_remove(_fixpath(Join(roots.USER, path)))) end
- if fstab.USER then fstab.USER.files[path] = nil end
-end
diff --git a/data/core/Fonts.lua b/data/core/Fonts.lua
deleted file mode 100644
index 185ccae..0000000
--- a/data/core/Fonts.lua
+++ b/dev/null
@@ -1,49 +0,0 @@
-
-require 'Textures'
-
-local _G = _G
-local gl = gl
-local type, assert, tonumber, setmetatable = type, assert, tonumber, setmetatable
-local getAndBindTexid, FSload = Textures.getAndBindTexid, FS.load
-
-module(...)
-
-Cache = {}
-
-setmetatable(_M, { __index = function (_, name)
- local kerning = not name:match('&$')
- name = name:gsub('&$', '')
- local texsize = tonumber(name:match('~(%d+)$') or 256)
- name = name:gsub('~%d+$', '')
- local fontsize = tonumber(assert(name:match(':(%d+)$')))
- name = name:gsub(':%d+$', '')
- Cache[kerning] = Cache[kerning] or {}
- Cache[kerning][fontsize] = Cache[kerning][fontsize] or {}
- Cache[kerning][fontsize][name] = Cache[kerning][fontsize][name] or
- FSload(name):font(fontsize, texsize, getAndBindTexid(), kerning)
- return Cache[kerning][fontsize][name]
-end })
-
-function GetDimensions(font)
- -- TODO: FTGL has imprecise bbox information
- return font.ascent, font.ascent - font.height
-end
-
-function DrawBoundingBox(font, right)
- local top, bottom = GetDimensions(font)
- if type(right) ~= 'number' then right = font:prepare(right) end
- gl.Begin(gl.QUADS)
- gl.Vertex(0, top); gl.Vertex(0, bottom)
- gl.Vertex(right, bottom); gl.Vertex(right, top)
- gl.End()
-end
-
-function GetCursorPosition(font, text, cursor_x)
- -- TODO with binary search, this could be O(log N)
- local len, old_pos, current_pos = text:ulen(), nil, 0
- for i = 1, len do
- old_pos, current_pos = current_pos, font:prepare(text:usub(1, i))
- if cursor_x < (old_pos + current_pos)/2 then return i-1 end
- end
- return len
-end
diff --git a/data/core/MainLoop.lua b/data/core/MainLoop.lua
deleted file mode 100644
index 21070cd..0000000
--- a/data/core/MainLoop.lua
+++ b/dev/null
@@ -1,210 +0,0 @@
-
-require 'extlib'
-require 'Node'
-require 'Event'
-require 'Textures'
-require 'Selection'
-
-local _G = _G
-local bit, gl, glu, SDL = bit, gl, glu, SDL
-local Event, Textures, Class, Transient, Selection =
- Event, Textures, Class, Transient, Selection
-
-module(...)
-
-local MainLoop = _M
-
-Class(MainLoop)
-
-MainLoop.frameFraction = 0
-
-MainLoop.ticksPerSecond = 25
-MainLoop.maxFrameskip = 5
-
-function MainLoop:initialize()
- Transient[self].updateFps = _G.makeFpsSensor()
- self.root = self.root or _G.Node.Root:new{}
- self.focus = self.root
- self.root.mainloop = self
- self.root:inserted()
-end
-
-function MainLoop:forceKeyRelease()
- Event.key_update()
- for sym, state in _G.pairs(Event.key) do if state ~= Event.RELEASED then
- ev = { sym = sym, mod = 0, unicode = 0, type = SDL.KEYUP, down = false }
- Event.key[sym] = Event.RELEASED; if self then self:key(ev) end
- end end
- Event.key_update()
-end
-
-function MainLoop:forceMouseRelease()
- if not self then return end
- for butid = 1, 5 do if Event.mouse[butid] then
- self:mouseButton({ type = SDL.MOUSEBUTTONUP, down = false, button = butid,
- x = Event.mouse.x, y = Event.mouse.y })
- end end
-end
-
-function MainLoop:quit()
- _G.error(false) -- "already reported error", just end the program
-end
-
-function MainLoop:active(state, gain)
- Event.active[state] = gain
- --_G.notice("[active ".._G.tostring(state).." ".._G.tostring(gain).."]")
-
- if gain ~= false then return end -- gains don't need to be handled here
-
- if bit.band(state, SDL.APPACTIVE) ~= 0 then
- -- the app also effectively loses mouse and keyboard focus
- self:active(SDL.APPINPUTFOCUS, false)
- self:active(SDL.APPMOUSEFOCUS, false)
- if self.pauseWhileMinimized then
- while true do -- event loop while app is minimized
- local evn = SDL.PollEvent()
- if evn and evn.type == SDL.ACTIVEEVENT and evn.gain and
- bit.band(evn.state, SDL.APPACTIVE) ~= 0 then return end
- if evn and evn.type == SDL.QUIT then self:quit(); return end
- SDL.Delay(10)
- end
- end
- end
-
- if state == SDL.APPINPUTFOCUS then self:forceKeyRelease() end
-
- -- when the window loses mouse, drag'n'drop can still continue, so
- -- self:forceMouseRelease() isn't needed here. (tested under Win32 and X11)
-end
-
-function MainLoop:key(ev)
- ev.type = 'Key'; local received = Event.send(ev, self.focus)
- if ev.down and received then Event.key[ev.sym] = Event.OVERRIDDEN end
-end
-
-function MainLoop:mouseMotion(ev)
- if not self.forceHover then self.hover, self.hoverinfo =
- Selection.get(Event.mouse.x, _G.HEIGHT-Event.mouse.y, self) end
- if self.hover then self:setFocus(self.hover) end
- ev.type = 'MouseMotion'; Event.send(ev, self.focus)
-end
-
-function MainLoop:mouseButton(ev)
- if not self.forceHover then self.hover, self.hoverinfo =
- Selection.get(Event.mouse.x, _G.HEIGHT-Event.mouse.y, self) end
- if self.hover then self:setFocus(self.hover) end
- -- TODO remove MouseButtonAway, add 'background' nodes where applicable
- -- (and convert :eventMouseButton to check :getLoop().hover elsewhere)
- ev.type = self.hover and 'MouseButton' or 'MouseButtonAway'; Event.send(ev, self.focus)
-end
-
-function MainLoop:update()
- self.root:update()
-end
-
-function MainLoop:display()
- gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT)
- gl.LoadIdentity()
- self.root:display()
-end
-
-function MainLoop:setFocus(obj)
- if self.focus == obj then return end
- local oldfocus = self.focus; self.focus = obj
- -- when node:lostFocus() returns true, it overrides the focus change
- if oldfocus and oldfocus:lostFocus() then self.focus = oldfocus
- elseif self.focus then self.focus:gotFocus() end
-end
-
-function MainLoop:subLoop(klass, proto)
- proto = proto or {}
- proto.parentloop = self
- klass:new(proto):run()
- Transient[self].nextUpdate = SDL.GetTicks()
-end
-
-function MainLoop:replaceLoop(klass, proto)
- proto = proto or {}
- proto.parentloop = self.parentloop
- self.tail_fn = function () return klass:new(proto):run() end
- self.running = false
-end
-
-function MainLoop:run()
- local motion_ev = nil
-
- if self.parentloop then
- self.parentloop:forceKeyRelease(); self.parentloop:forceMouseRelease()
- else MainLoop.forceKeyRelease() end
-
- -- this game loop structure is modeled after the article at
- -- <http://dewitters.koonsolo.com/gameloop.html>
-
- Transient[self].nextUpdate = SDL.GetTicks()
- self.running = true
- while self.running do
- local loops = 0
- while SDL.GetTicks() > Transient[self].nextUpdate and loops < self.maxFrameskip do
- -- compress runs of SDL.MOUSEMOTION events - Selection.get() can be
- -- expensive and most of the time, only the last SDL.MOUSEMOTION matters
- local last_motion
- while true do -- handle all SDL events in queue
- local ev = SDL.PollEvent()
- if ev and ev.type == SDL.MOUSEMOTION then -- rewrite last_motion
- ev.buttons = nil -- all button state changes should be
- -- reported with SDL.MOUSEBUTTONUP/DOWN
- Event.mouse.x, Event.mouse.y = ev.x, ev.y
- last_motion = ev
- elseif last_motion then -- this runs even when ev == nil
- self:mouseMotion(last_motion); last_motion = nil
- end
- if not ev then break end
- if ev.type == SDL.ACTIVEEVENT then
- for i,v in _G.ipairs({SDL.APPACTIVE, SDL.APPMOUSEFOCUS, SDL.APPINPUTFOCUS}) do
- if bit.band(ev.state, v) ~= 0 then self:active(v, ev.gain) end end
- elseif ev.type == SDL.QUIT then self:quit()
- elseif ev.type == SDL.KEYDOWN then
- ev.down = true; Event.key[ev.sym] = Event.JUST_PRESSED; self:key(ev)
- elseif ev.type == SDL.KEYUP then
- if Event.key[ev.sym] ~= Event.RELEASED then
- Event.key[ev.sym] = (Event.key[ev.sym] == Event.JUST_PRESSED
- and Event.JUST_RELEASED or Event.RELEASED)
- ev.down = false; self:key(ev) end
- elseif ev.type == SDL.MOUSEBUTTONDOWN then
- ev.x, ev.y = nil; ev.down = true
- Event.mouse[ev.button] = true; self:mouseButton(ev)
- elseif ev.type == SDL.MOUSEBUTTONUP then
- ev.x, ev.y = nil; ev.down = false
- if Event.mouse[ev.button] then
- Event.mouse[ev.button] = nil; self:mouseButton(ev) end
- end
- end
-
- self:update()
- Event.key_update()
- if not self.running then break end
-
- Transient[self].nextUpdate = Transient[self].nextUpdate + (1000 / self.ticksPerSecond)
- loops = loops + 1
- end
- if not self.running then break end
-
- -- frameFraction is a clampf representing what fraction of the current
- -- tick has passed. (update 'ticks' aren't the same as display 'frames'.)
- local skipTicks = 1000 / self.ticksPerSecond
- self.frameFraction = _G.math.min(1,
- (SDL.GetTicks() - Transient[self].nextUpdate + skipTicks) / skipTicks)
-
- SDL.PumpEvents()
- local _; _, Event.mouse.cur_x, Event.mouse.cur_y = SDL.GetMouseState()
- self:display(); SDL.GL_SwapBuffers()
- if self.forceDelay then SDL.Delay(self.forceDelay) end
- Transient[self].updateFps()
- end
-
- self:forceKeyRelease()
- self:forceMouseRelease()
-
- if self.tail_fn then return self:tail_fn() end
-end
-
diff --git a/data/core/Mask.lua b/data/core/Mask.lua
deleted file mode 100644
index 5d334fb..0000000
--- a/data/core/Mask.lua
+++ b/dev/null
@@ -1,77 +0,0 @@
-
-local _G = _G
-local assert, unpack = assert, unpack
-local gl, GL = gl, GL
-
-module(...)
-
-Stencil = {}
-
-function Stencil.overlay(dontPush)
- -- draw a quad on the whole viewport
- -- (used e.g. for globally decreasing stencil buffer values)
- if not dontPush then
- gl.PushAttrib(GL.ALL_ATTRIB_BITS)
- gl.MatrixMode(GL.MODELVIEW); gl.PushMatrix()
- end
- gl.Disable(GL.DEPTH_TEST)
- gl.DepthMask(0)
- gl.LoadIdentity()
- gl.MatrixMode(GL.PROJECTION)
- gl.PushMatrix(); gl.LoadIdentity()
- gl.Begin(GL.QUADS)
- gl.Vertex(-1, -1, -1); gl.Vertex(1, -1, -1)
- gl.Vertex(1, 1, -1); gl.Vertex(-1, 1, -1)
- gl.End()
- gl.PopMatrix()
- if not dontPush then
- gl.MatrixMode(GL.MODELVIEW); gl.PopMatrix()
- gl.PopAttrib()
- end
-end
-
-function Stencil.prepareTopLevel()
- gl.Enable(GL.STENCIL_TEST)
- gl.StencilFunc(GL.EQUAL, 0, -1)
-end
-
-function Stencil.cleanupTopLevel()
- gl.Disable(GL.STENCIL_TEST)
-end
-
-function Stencil.push(shape)
- local depth = gl.GetBoolean(GL.DEPTH_TEST, 1); gl.Disable(GL.DEPTH_TEST)
- gl.StencilOp(GL.KEEP, GL.KEEP, GL.INCR)
- gl.ColorMask(0, 0, 0, 0); shape:displayStencil(); gl.ColorMask(1, 1, 1, 1)
- if depth then gl.Enable(GL.DEPTH_TEST) end
- gl.StencilFunc(GL.EQUAL, gl.GetInteger(GL.STENCIL_REF, 1) + 1, -1)
- gl.StencilOp(GL.KEEP, GL.KEEP, GL.KEEP)
-end
-
-function Stencil.pop()
- -- restore old stencil buffer values
- gl.StencilOp(GL.KEEP, GL.KEEP, GL.DECR)
- gl.ColorMask(0, 0, 0, 0); Stencil.overlay(); gl.ColorMask(1, 1, 1, 1)
- gl.StencilFunc(GL.EQUAL, gl.GetInteger(GL.STENCIL_REF, 1) - 1, -1)
-end
-
-
-Scissor = {} -- TODO test it (and btw, is it needed at all?)
-
-local scissorStack = { n = 0 }
-
-function Scissor.push(x, y, w, h)
- local now = gl.GetInteger(GL.SCISSOR_BOX, 4)
- local x2, y2 = x+w-1, y+h-1
- local nowx2, nowy2 = now[1]+now[3]-1, now[2]+now[4]-1
- if x < now[1] then x = now[1] end; if y < now[2] then y = now[2] end
- if x2 < nowx2 then x2 = nowx2 end; if y2 < nowy2 then y2 = nowy2 end
- scissorStack.n = scissorStack.n + 1; scissorStack[scissorStack.n] = now
- gl.Scissor(x, y, x2-x+1, y2-y+1)
-end
-
-function Scissor.pop()
- assert(scissorStack.n > 0, "scissor stack is empty")
- gl.Scissor(unpack(scissorStack[scissorStack.n]))
- scissorStack.n = scissorStack.n - 1
-end
diff --git a/data/core/Music.lua b/data/core/Music.lua
deleted file mode 100644
index ff86ad4..0000000
--- a/data/core/Music.lua
+++ b/dev/null
@@ -1,49 +0,0 @@
-
-local _G = _G
-local SDL = SDL
-
-module(...)
-
-local musicChannel = nil
-
-local cache = {}
-
-function load(fname)
- if not cache[fname] then
- local rw = _G.FS.load(fname)
- cache[fname] = SDL.LoadWAV_RW(rw, true); rw:disown()
- end
- return cache[fname]
-end
-
-function play(fname, ...)
- -- _G._SOUND is whether the sound engine could be initialized.
- -- _G.SOUND is a user config variable telling if sound is enabled.
- if not (_G._SOUND and _G.SOUND) then return end
- musicChannel = SDL.PlayChannel(nil, load(fname), ...)
-end
-
-function stop()
- if musicChannel then SDL.HaltChannel(musicChannel) end
- musicChannel = nil
-end
-
-local current = nil
-local currentN = nil
-
-function update(list)
- if not (_G._SOUND and _G.SOUND) then return end
- if list ~= current then
- current = list
- currentN = nil
- stop()
- end
- if current and #current > 0 and not (musicChannel and
- (SDL.Playing(musicChannel) or SDL.Paused(musicChannel))) then
- local newN = _G.math.random(#current)
- while newN == currentN and #current > 1 do
- newN = _G.math.random(#current) end
- currentN = newN
- play(current[currentN])
- end
-end
diff --git a/data/core/Node.lua b/data/core/Node.lua
deleted file mode 100644
index ef9dbd3..0000000
--- a/data/core/Node.lua
+++ b/dev/null
@@ -1,182 +0,0 @@
-
-require 'Textures'
-
-local _G = _G
-local math = math
-local ipairs = ipairs
-local gl = gl
-local Textures = Textures
-
-module(...)
-
-local Node = _M
-_G.Class(Node)
-
-Node.parent = nil
-Node.layer = 0
-Node.doesDisplay = true
-Node.doesDisplayChildren = true
-
-function Node:initialize()
- self.F = {}
- _G.setmetatable(self.F, { __index = function (t, k)
- k = self:find(k, true); return k[#k] end })
-end
-
--- TODO: should :inserted() and :removed() be called recursively?
--- i.e., should they be called for all children of an inserted/removed object?
-
-function Node:inserted()
-end
-
-function Node:removed()
-end
-
-function Node:gotFocus()
-end
-
-function Node:lostFocus()
- -- when this returns true, it overrides focus change and retains focus
-end
-
-function Node:displayChildren()
- if not self.doesDisplayChildren then return end
- for i,v in ipairs(self) do v:display() end
-end
-
-function Node:updateChildren()
- for i,v in ipairs(self) do v:update() end
-end
-
-function Node:display()
- if not self.doesDisplay then return end
- self:displayPrepare()
- self:displayContent()
- self:displayCleanup()
-end
-
-function Node:displayPrepare()
-end
-
-function Node:displayContent()
- self:displayChildren()
-end
-
-function Node:displayCleanup()
-end
-
-function Node:update()
- self:updateChildren()
-end
-
-function Node:addChild(ch, pos)
- _G.assert(not ch.parent)
- if not pos then
- pos = 1
- for i,v in ipairs(self) do -- TODO more optimal algorithm?
- if v.layer <= ch.layer then pos = i+1 end end
- end
- _G.table.insert(self, pos, ch)
- ch.parent = self
- ch:inserted()
- return ch
-end
-
-function Node:replaceBy(newch)
- -- note: aNode:replaceBy(nil) means to remove the node
- _G.assert(self.parent)
- local myid = nil
- for i,v in ipairs(self.parent) do
- if v == self then myid = i end end
- _G.assert(myid, "inconsistent parent-child object graph")
- _G.table.remove(self.parent, myid)
- self:removed()
- if newch then
- if newch.parent then newch:replaceBy(nil) end
- newch.layer = self.layer
- self.parent:addChild(newch, myid)
- end
- self.parent = nil
- return newch
-end
-
-function Node:refreshLayer() -- to be called after changing self.layer etc.
- -- disable self.inserted and self.removed, we aren't actually doing that
- local old_inserted, old_removed = self.inserted, self.removed
- self.inserted, self.removed = function () end, function () end
- local old_parent = self.parent
- self:replaceBy(nil); old_parent:addChild(self)
- self.inserted, self.removed = old_inserted, old_removed
-end
-
-function Node:find(...)
- local result, ar, n = {}, {...}, _G.select('#', ...)
- for i,v in ipairs(self) do
- local ok = true
- for m = 1, n, 2 do
- _G.assert(ar[m+1] ~= nil, "arg "..(m+1).." is nil")
- if ar[m+1] == false then ok = ok and not v[ar[m]]
- elseif ar[m+1] == true then ok = ok and v[ar[m]] and true
- elseif v[ar[m]] ~= ar[m+1] then ok = false end
- end
- if ok then result[#result+1] = v end
- end
- return result
-end
-
-function Node:getLoop()
- return self.mainloop or (self.parent and self.parent:getLoop())
-end
-
-function Node:event(ev)
- local handler = 'event' .. ev.type
- if not self[handler] then return false end
- return self[handler](self, ev)
-end
-
-function Node:eventFilter(ev)
- return false
-end
-
-
--- a helper class that uses eventFilter() to allow access to the console.
-Root = Node:instantiate()
-
-function Root:eventFilter(ev)
- if not self.parent and ev.type == 'Key' and
- ev.down and ev.sym == _G.SDL.K_BACKQUOTE then
- self.mainloop:subLoop(_G.require'Console'); return true end -- TODO ugly
-end
-
-
-Moving = Node:instantiate()
-
-Moving.floorPosition = false
-Moving.isOffset = true -- if false, gl.LoadIdentity() is used
-Moving.x, Moving.y, Moving.z = 0, 0, 0
-Moving.dx, Moving.dy, Moving.dz = 0, 0, 0
-
-function Moving:displayPrepare()
- Node.displayPrepare(self)
- gl.PushMatrix()
- if not self.isOffset then gl.LoadIdentity() end
- local ff = self:getLoop().frameFraction
- local x, y, z = self.x+self.dx*ff, self.y+self.dy*ff, self.z+self.dz*ff
- if self.floorPosition then
- x, y, z = math.floor(x), math.floor(y), math.floor(z) end
- gl.Translate(x, y, z)
-end
-
-function Moving:displayCleanup()
- gl.PopMatrix()
- Node.displayCleanup(self)
-end
-
-function Moving:update()
- Node.update(self)
- if self.x and self.y and self.z then
- self.x = self.x + self.dx
- self.y = self.y + self.dy
- self.z = self.z + self.dz
- end
-end
diff --git a/data/core/Selection.lua b/data/core/Selection.lua
deleted file mode 100644
index e260d7f..0000000
--- a/data/core/Selection.lua
+++ b/dev/null
@@ -1,186 +0,0 @@
-
-local _G = _G
-local math, table, string = math, table, string
-local ipairs, assert, setmetatable = ipairs, assert, setmetatable
-local bit, SDL, gl, GL, glu = bit, SDL, gl, gl, glu
-
-module(...)
-
-local Selection = _M
-
-Selection.active = false
-
----[==[ selection through color coding
-
--- To ease usage, this also hides or modifies GL functions that can interfere
--- with color coding (e.g. glShadeModel or glColor). However, this is a 'leaky
--- abstraction'. For example, glInterleavedArrays and glClearColor aren't
--- hidden. Take care when using this.
-
-local Names, Stack, ColorMask
-
-Selection.gl = nil
-
-local rBits, gBits, bBits, rMask, gMask, bMask, rShift, gShift, bShift
-local function setcolor(onlyMask)
- if not Stack[#Stack] then -- when the stack's empty, don't draw anything
- Selection.gl.ColorMask(false, false, false, false); return
- else Selection.gl.ColorMask(_G.unpack(ColorMask, 1, 4)) end
- if onlyMask then return end
- -- from OpenGL FAQ 11.050
- if not rBits then
- rBits = gl.GetInteger(GL.RED_BITS, 1)
- gBits = gl.GetInteger(GL.GREEN_BITS, 1)
- bBits = gl.GetInteger(GL.BLUE_BITS, 1)
- -- glColor4ub won't work with more than 8 bits
- -- TODO: I'm not sure if the code will work correctly with *Bits>8
- -- (the following is supposed to make sure it does, but does it?)
- if rBits > 8 then rBits = 8 end
- if gBits > 8 then gBits = 8 end
- if bBits > 8 then bBits = 8 end
- rMask = bit.lshift(bit.lshift(1, rBits) - 1, gBits + bBits)
- gMask = bit.lshift(bit.lshift(1, gBits) - 1, bBits)
- bMask = bit.lshift(1, bBits) - 1
- rShift = rBits + gBits + bBits - 8
- gShift = gBits + bBits - 8
- bShift = bBits - 8
- end
- _G.assert(Stack[#Stack] < bit.lshift(1, rBits + gBits + bBits) - 1,
- "too many selectable objects")
- Selection.gl.Color4ub(
- bit.rshift(bit.band(Stack[#Stack], rMask), rShift),
- bit.rshift(bit.band(Stack[#Stack], gMask), gShift),
- bit.rshift(bit.band(Stack[#Stack], bMask), bShift), 255)
-end
-local function color2id(r, g, b, a)
- if not rBits then return nil end
- if r == 255 and g == 255 and b == 255 then return nil end
- return bit.bor(
- bit.band(bit.lshift(r, rShift), rMask),
- bit.band(bit.lshift(g, gShift), gMask),
- bit.band(bit.lshift(b, bShift), bMask))
-end
-
-function Selection.push(object, ...)
- if not Selection.active then return end
- local name = #Names + 1
- Names[name] = { object = object, ... }
- Stack[#Stack+1] = name; setcolor()
-end
-
-function Selection.pop()
- if not Selection.active then return end
- Stack[#Stack] = nil; setcolor()
-end
-
-local mybuf = SDL.RWFromNewMem(4)
-function Selection.get(x, y, selected)
- gl.PushAttrib(GL.ALL_ATTRIB_BITS)
- -- from OpenGL FAQ 11.040
- local bad_modes = { [GL.BLEND] = true, [GL.DITHER] = true, [GL.FOG] = true,
- [GL.LIGHTING] = true, [GL.TEXTURE_1D] = true, [GL.TEXTURE_2D] = true }
- if GL.TEXTURE_3D then bad_modes[GL.TEXTURE_3D] = true end -- TODO is 'if' needed?
- for k, v in _G.pairs(bad_modes) do gl.Disable(k) end
- gl.ShadeModel(GL.FLAT)
- gl.ClearColor(1, 1, 1, 1); gl.Color(1, 1, 1, 1)
- if not Selection.gl then -- create copies of functions we'll hide
- local block = { Color = true, ColorPointer = true, ColorMask = true,
- ShadeModel = true, Enable = true }
- Selection.gl = {}
- for k, v in _G.pairs(gl) do
- if block[k] or k:match('^Color%d') then Selection.gl[k] = v end end
- end
- for k, v in _G.pairs(Selection.gl) do gl[k] = function () end end
- gl.Enable = function (v)
- return not bad_modes[v] and Selection.gl.Enable(v) or nil end
- gl.ColorMask = function (...) ColorMask = {...}; setcolor(true) end
- ColorMask = gl.GetBoolean(GL.COLOR_WRITEMASK, 4); Names = {}
- Stack, active = {}, true
- setcolor(); selected:display()
- Stack, active = nil, false
- for k, v in _G.pairs(Selection.gl) do gl[k] = v end -- restore gl funcs
- gl.PopAttrib()
-
- gl.ReadPixels(x, y, 1, 1, GL.RGBA, GL.UNSIGNED_BYTE, mybuf:baseptr())
- local id = color2id(string.unpack(mybuf:baseptr(), mybuf:stopptr(), '4A'))
- local nameInfo = Names[id]; Names = nil
- return nameInfo and nameInfo.object, nameInfo
-end
-
---[===[ ]==]
-
--- classic OpenGL selection with glSelectBuffer
--- This model can detect all objects that were selected, not just the one on
--- top, but it was abandoned because it can't handle tests (e.g. stencil test
--- or scissor test), and false positives were reported for invisible objects.
-
-Selection.bufferSize = 64 -- TODO not enough?
-
-local pickbuf
-local Names
-
-function push(object, ...)
- if not Selection.active then return end
- local name = #Names + 1
- Names[name] = { object = object, ... }
- gl.PushName(name)
-end
-
-function pop()
- gl.PopName()
-end
-
-function getHits(x, y, selected)
- local zero = string.pack('I', 0)
- if not pickbuf then
- pickbuf = SDL.RWFromNewMem(bufferSize*#zero) end
- assert(pickbuf:seek('set')) -- clear the buffer
- assert(pickbuf:write(zero:rep(bufferSize)))
-
- gl.MatrixMode(GL.PROJECTION)
- local projection = gl.GetDouble(GL.PROJECTION_MATRIX)
- gl.LoadIdentity()
- glu.PickMatrix(x, y, 1, 1, gl.GetInteger(GL.VIEWPORT))
- gl.MultMatrix(projection)
- gl.MatrixMode(GL.MODELVIEW)
-
- gl.SelectBuffer(bufferSize, pickbuf:baseptr()); gl.RenderMode(GL.SELECT)
- Names = Names or {}; active = true; selected:display(); active = false
- local len = gl.RenderMode(gl.RENDER)
- local content = string.unpack(pickbuf:baseptr(), pickbuf:stopptr(),
- bufferSize..'I', true)
-
- local hits = {}
- local pos = 1
- if len < 0 then len = math.huge end
- for i = 1, len do
- if not content[pos+2] then break end -- incomplete hit
- if not content[pos+2+content[pos]] then break end -- incomplete hit
- local hit = { minz = content[pos+1], maxz = content[pos+2] }
- for j = 1, content[pos] do hit[j] = content[pos+2+j] end
- table.insert(hits, hit)
- pos = pos + 3 + content[pos]
- end
-
- gl.MatrixMode(GL.PROJECTION); gl.LoadMatrix(projection)
- gl.MatrixMode(GL.MODELVIEW)
-
- return hits
-end
-
-function get(x, y, selected)
- Names = {}
- local hits = getHits(x, y, selected)
- table.sort(hits, function (a,b) return a.minz < b.minz end)
- -- (TODO: the above should sort hits so that hits[1] is nearest. check it.)
- local nameInfo
- for i, hit in ipairs(hits) do
- -- ignore empty (unnamed) hits
- if hit[1] then nameInfo = Names[hit[#hit]]; break end
- end
- Names = nil
- return nameInfo and nameInfo.object, nameInfo
-end
-
-
---]===]
diff --git a/data/core/TextInput.lua b/data/core/TextInput.lua
deleted file mode 100644
index 67ad1d0..0000000
--- a/data/core/TextInput.lua
+++ b/dev/null
@@ -1,89 +0,0 @@
-
-local _G = _G
-local SDL, gl = SDL, gl
-
-module(...)
-
-local TextInput = _M
-_G.Class(TextInput)
-
-TextInput.text = ''
-TextInput.cursor = nil
-TextInput.blink = 0
-TextInput.font = nil
-TextInput.selected = false
-
--- BIG TODO: it would be neat if TextInput could be controlled by mouse
-
-function TextInput:initialize()
- _G.assert(self.font)
- self.font:prepare(self.text)
- if not self.cursor then self.cursor = self.text:ulen() end
- SDL.EnableUNICODE(true)
- SDL.EnableKeyRepeat(SDL.DEFAULT_REPEAT_DELAY, SDL.DEFAULT_REPEAT_INTERVAL)
-end
-
-function TextInput:key(ev)
- if not ev.down then return false end
- local unicode = ev.unicode ~= 127 and ev.unicode ~= 0 and ev.unicode
- if self.blink then self.blink = 0 end
- if ev.sym == SDL.K_HOME then
- self.selected = false
- self.cursor = 0
- elseif ev.sym == SDL.K_END then
- self.selected = false
- self.cursor = self.text:ulen()
- elseif ev.sym == SDL.K_LEFT then
- self.selected = false
- if self.cursor <= 0 then return false end
- self.cursor = self.cursor - 1
- elseif ev.sym == SDL.K_RIGHT then
- self.selected = false
- if self.cursor >= self.text:ulen() then return false end
- self.cursor = self.cursor + 1
- elseif (ev.sym == SDL.K_DELETE or ev.sym == SDL.K_BACKSPACE) and self.selected then
- self.text, self.cursor, self.selected = '', 0, false
- elseif ev.sym == SDL.K_BACKSPACE then
- return self:key{ down = true, sym = SDL.K_LEFT } and
- self:key{ down = true, sym = SDL.K_DELETE }
- elseif ev.sym == SDL.K_DELETE then
- if self.cursor >= self.text:ulen() then return false end
- self.text = self.text:usub(1, self.cursor) ..
- self.text:usub(self.cursor + 2, -1)
- elseif unicode and unicode >= 32 then
- if self.selected then self.text, self.cursor = '', 0 end
- self.selected = false
- self.text = self.text:usub(1, self.cursor) ..
- _G.string.uchar(ev.unicode) .. self.text:usub(self.cursor + 1, -1)
- self.cursor = self.cursor + 1
- self.font:prepare(self.text) -- load new glyphs
- else
- return false
- end
- return true
-end
-
-function TextInput:displayCursor()
- if not self.blink or self.blink < 1 then
- gl.PushMatrix()
- gl.Translate(self.font:prepare(self.text:usub(1, self.cursor)), 0, 0)
- gl.LineWidth(1)
- gl.BindTexture(gl.TEXTURE_2D, 0)
- gl.Begin(gl.LINES)
- gl.Vertex(1, self.font.ascent - self.font.height)
- gl.Vertex(1, self.font.ascent)
- gl.End()
- gl.PopMatrix()
- end
-end
-
-function TextInput:display()
- self:displayCursor()
- self.font:print(self.text)
-end
-
-TextInput.displayContent = TextInput.display
-
-function TextInput:update()
- if self.blink then self.blink = (self.blink + (1/15)) % 2 end
-end
diff --git a/data/core/Textures.lua b/data/core/Textures.lua
deleted file mode 100644
index b6effb9..0000000
--- a/data/core/Textures.lua
+++ b/dev/null
@@ -1,87 +0,0 @@
-
-local _G = _G
-local gl = gl
-
-module(...)
-
--- returns src resized to have dimensions of values 2^n.
-local function nearestPowerOf2(n)
- local p = 2; while p < n do p = p*2 end; return p
-end
-function resizeAsTexture(src)
- local w, h = src:w(), src:h()
- local newsize = nearestPowerOf2(_G.math.max(w, h))
- local dest = _G.SDL.CreateRGBSurface(newsize, newsize)
- dest:FillRect(0, 0, 0); src:BlitSurface(nil, dest, { 0, newsize - h })
- return dest
-end
-
-function getAndBindTexid()
- local tid = gl.GenTextures(1)
- gl.BindTexture(gl.TEXTURE_2D, tid)
- gl.TexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
- gl.TexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
- return tid
-end
-
-local imageCache, textureCache = {}, {}
-
-function bind(texname, mipmap)
- if not texname then
- -- In early versions of Scion, it was common for missing textures to crash
- -- the whole program. This is a failsafe that binds texture 0. It won't
- -- display correctly, but at least it won't fail ungracefully.
- _G.notice("WARNING: got nil texname! binding 0.")
- gl.BindTexture(gl.TEXTURE_2D, 0)
- return 0, { name = 0,
- w = 1, h = 1, origw = 1, origh = 1, wratio = 1, hratio = 1 }
- end
- if _G.type(texname) == 'table' and texname.name then
- gl.BindTexture(gl.TEXTURE_2D, texname.name)
- return texname.name, texname
- end
- if _G.type(texname) == 'number' then
- gl.BindTexture(gl.TEXTURE_2D, texname)
- return texname, textureCache[texname]
- end
- if textureCache[texname] then
- gl.BindTexture(gl.TEXTURE_2D, textureCache[texname].name)
- return textureCache[texname].name, textureCache[texname]
- end
- local info = { name = getAndBindTexid() }
- local flags = texname:match('{[^}]*}$') or ''
- local fname = texname:sub(1, -1-#flags)
- flags = flags:match('^{(.*)}$') or ''
- if not imageCache[fname] then
- local rw = _G.FS.load(fname)
- imageCache[fname] = _G.SDL.IMG_Load_RW(rw, true); rw:disown()
- imageCache[fname]:SetAlpha(0, 255)
- end
- local image = imageCache[fname]
- info.origw, info.origh = image:w(), image:h()
- local resize = nil
- if flags == '^2' then
- image = resizeAsTexture(image)
- elseif flags:match('^%d+,%d+,%d+,%d+$') then
- local oldimage = image
- local x, y, w, h = flags:match('^(%d+),(%d+),(%d+),(%d+)$')
- image = _G.SDL.CreateRGBSurface(w, h)
- oldimage:BlitSurface({ x, y, w, h }, image, { 0, 0 })
- elseif flags:match('^%*[0-9.]+$') then
- -- *(number) makes Textures.bind pretend that the texture has other
- -- dimensions that it really has. this only changes info.{[wh],orig[wh]},
- -- but that's enough for computing glTexCoords.
- resize = _G.assert(_G.tonumber(flags:sub(2)))
- info.origw = _G.math.floor(image:w() * resize)
- info.origh = _G.math.floor(image:h() * resize)
- else
- _G.assert(flags == '', "unknown texture flags")
- end
- info.w, info.h = image:w(), image:h()
- if resize then info.w, info.h = info.origw, info.origh end
- info.wratio, info.hratio = info.origw / info.w, info.origh / info.h
- image:glTexImage2D(mipmap)
- textureCache[texname] = info; textureCache[info.name] = info
- return info.name, info
-end
-
diff --git a/data/core/Vector.lua b/data/core/Vector.lua
deleted file mode 100644
index 0f30a98..0000000
--- a/data/core/Vector.lua
+++ b/dev/null
@@ -1,64 +0,0 @@
-
-local _G = _G
-local setmetatable, type = setmetatable, type
-local sqrt, max = math.sqrt, math.max
-
-module(...)
-
-local Vector = _M
-setmetatable(_M, {
- __call = function (f, o) return setmetatable(o or {}, _M) end })
-
-local names = { x = 1, y = 2, z = 3, w = 4 }
-function _M.__index(t, k)
- if names[k] then return t[names[k]] end
- if type(k) == 'number' then return 0 end
- return _M[k] end
-
-function _M.__add(a, b)
- local r = Vector{}; for i = 1, #a do r[i] = a[i] + b[i] end
- return r
-end
-
-function _M.__sub(a, b)
- return __add(a, __unm(b))
-end
-
-function _M.__mul(a, b)
- if type(b) ~= 'number' then return nil end
- local r = Vector{}; for i = 1, #a do r[i] = a[i] * b end
- return r
-end
-
-function _M.__div(a, b)
- if type(b) ~= 'number' then return nil end
- local r = Vector{}; for i = 1, #a do r[i] = a[i] / b end
- return r
-end
-
-function _M.__unm(a, b)
- local r = Vector{}; for i = 1, #a do r[i] = -a[i] end
- return r
-end
-
-function _M.__len(a)
- return sqrt(dot(a, a))
-end
-
-function _M.__eq(a, b)
- for i = 1, math.max(#a, #b) do if a[i] ~= b[i] then return false end end
- return true
-end
-
-function cross(a, b)
- return Vector{ a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x }
-end
-
-function dot(a, b)
- local r = 0; for i = 1, #a do r = r + a[i]*b[i] end
- return r
-end
-
-function normalize(a)
- return a / #a
-end
diff --git a/data/core/Widget.lua b/data/core/Widget.lua
deleted file mode 100644
index 95a1a78..0000000
--- a/data/core/Widget.lua
+++ b/dev/null
@@ -1,152 +0,0 @@
-
-require 'Node'
-
-local _G = _G
-local ipairs = ipairs
-local Class, Mixin = Class, Mixin
-
-module(...)
-
-
-local Widget = _M
-_G.Node:instantiate(Widget)
-
-function Widget:set_mixin(...)
- local parents = { ... }
- parents[#parents+1] = _M
- Mixin(self, unpack(parents))
-end
-
-function Widget:initialize()
- _G.Node.initialize(self)
- self.geometry = { 0, 0, 0, 0 }
- self.layout = nil
-end
-
-function Widget:updateGeometry()
- if self.layout then return self.layout:updateGeometry() end
-end
-
-
-Layout = Class()
-
-function Layout:initialize()
- _G.assert(self.widget, "Widget.Layout:initialize() requires self.widget")
- self.rules = { }
-end
-
-
-HBoxLayout = Layout:instantiate()
-
-local function _computeGeometry(self, min_sizes, rules, total_avail)
- local wi = self.widget
- local avail, factors_sum, one_part, everything_ok
- local sizes = {}
- while not everything_ok do
- local avail = total_avail
- factors_sum = 0
- for i,v in ipairs(wi.children) do
- if rules[i] == nil then sizes[i] = min_sizes[i] end
- avail = avail - (rules[i] ~= nil and 0 or min_sizes[i])
- factors_sum = factor_sum + (rules[i] or 0)
- end
- if avail < 0 then
- -- this happens when total_avail is not enough and it's below
- -- the minimum size of wi. content overflow will probably result
- -- (meaning, the widget's contents will be outside its bounding box)
- return min_sizes -- "set" all sizes to min_sizes
- end
- one_part = (factors_sum == 0 and 0 or avail / factors_sum)
- everything_ok = true
- for i,v in ipairs(wi.children) do if rules[i] ~= nil then
- sizes[i] = one_part * rules[i]
- if sizes[i] < min_sizes[i] then
- everything_ok = false
- rules[i] = nil -- rule==nil means use min_size
- end
- end end
- -- TODO: can this become an endless cycle?
- end
- return sizes
-end
-
-function HBoxLayout:minimumWidth()
- local wi = self.widget
- local inw = 0
- for i,v in ipairs(wi.children) do
- inw = inw + wi.spacing + v:minimumWidth()
- end
- return wi.padding[1] + (inw - wi.spacing) + wi.padding[3]
-end
-
-function HBoxLayout:minimumHeight(w)
- local wi = self.widget
- local inh = 0
- -- minimumHeight() requires the widget height as an argument, so
- -- this has to compute widths of all child widgets
- local min_sizes, min_rules = {}, {}
- for i,v in ipairs(wi.children) do min_sizes[i] = v:minimumWidth() end
- local total_avail = w - wi.padding[1] - wi.padding[3]
- local sizes = _computeGeometry(self, min_sizes, min_rules, total_avail)
- for i,v in ipairs(wi.children) do
- local size = v:minimumHeight(sizes[i])
- if inh < size then inh = size end
- end
- return wi.padding[2] + inh + wi.padding[4]
-end
-
-function HBoxLayout:updateGeometry()
- local wi = self.widget
- local inw = wi.geometry[3] - wi.padding[1] - wi.padding[3]
- local inh = wi.geometry[4] - wi.padding[2] - wi.padding[4]
- local total_avail = inw - wi.spacing * (#wi.children > 1 and #wi.children-1 or 0)
- local min_sizes = {}
- for i,v in ipairs(wi.children) do min_sizes[i] = v:minimumWidth() end
- local sizes = _computeGeometry(self, min_sizes, _G.table.icopy(self.rules), total_avail)
- local pos = wi.padding[1]
- for i,v in ipairs(wi.children) do
- v:setGeometry(_G.math.floor(pos), wi.padding[2], _G.math.floor(sizes[i]), inh)
- pos = pos + sizes[i] + wi.spacing
- end
-end
-
-
-VBoxLayout = Layout:instantiate()
-
-function VBoxLayout:minimumWidth()
- local wi = self.widget
- local inw = 0
- for i,v in ipairs(wi.children) do
- local size = v:minimumWidth()
- if inw < size then inw = size end
- end
- return wi.padding[1] + inw + wi.padding[3]
-end
-
-function VBoxLayout:minimumHeight(w)
- local wi = self.widget
- local inw = w - wi.padding[1] - wi.padding[3]
- local inh = 0
- for i,v in ipairs(wi.children) do
- inh = inh + wi.spacing + v:minimumHeight(inw)
- end
- return wi.padding[2] + (inh - wi.spacing) + wi.padding[4]
-end
-
-function VBoxLayout:updateGeometry()
- local wi = self.widget
- local inw = wi.geometry[3] - wi.padding[1] - wi.padding[3]
- local inh = wi.geometry[4] - wi.padding[2] - wi.padding[4]
- local total_avail = inh - wi.spacing * (#wi.children > 1 and #wi.children-1 or 0)
- local min_sizes = {}
- for i,v in ipairs(wi.children) do min_sizes[i] = v:minimumHeight(inw) end
- local sizes = _computeGeometry(self, min_sizes, _G.table.icopy(self.rules), total_avail)
- local pos = wi.padding[2]
- for i,v in ipairs(wi.children) do
- v:setGeometry(wi.padding[1], _G.math.floor(pos), inw, _G.math.floor(sizes[i]))
- pos = pos + sizes[i] + wi.spacing
- end
-end
-
-
-
diff --git a/data/core/Window.lua b/data/core/Window.lua
deleted file mode 100644
index 14891c4..0000000
--- a/data/core/Window.lua
+++ b/dev/null
@@ -1,173 +0,0 @@
-
-require 'Mask'
-require 'Node'
-require 'Event'
-require 'Textures'
-require 'Selection'
-
-local _G = _G
-local select = select
-local SDL, gl, GL, glu = SDL, gl, GL, glu
-local Mask, Node, Event, Textures, Selection =
- Mask, Node, Event, Textures, Selection
-
-module(...)
-
--- TODO: all Windows should be inside a top-level object which:
--- * translates the coordinate system to the upper-left corner
--- * sets glStencilFunc(GL_EQUAL, 0, (default value))
-
-local Window = _M
-Node:instantiate(Window)
-
-Window.x = 0
-Window.y = 0
-Window.w = 0
-Window.h = 0 -- negative number
-
-Window.dragThreshold = 7
-
-function Window:lostFocus()
- if self.pressed then return true end -- keep focus
-end
-
-function Window:isDragged()
- return self.pressed and ((Event.mouse.x - self.pressed.x)^2 +
- (Event.mouse.y - self.pressed.y)^2) > self.dragThreshold^2
-end
-
-function Window:resize(w, h)
- self.w = w
- self.h = h
-end
-
-function Window:moveToFront()
- --[[
- if self.parent[#self.parent] ~= self then
- local parent, parentlen = self.parent, #self.parent
- self:replaceBy(nil); parent:addChild(self, parentlen) end
- ]]
- if self.parent[#self.parent] ~= self then self:refreshLayer() end
-end
-
-function Window:eventMouseMotion(ev)
- if self:isDragged() and self.pressed.resize then
- self:resize(self.pressed.origw - self.pressed.x + Event.mouse.x,
- self.pressed.origh + self.pressed.y - Event.mouse.y)
- return true
- end
-end
-
-function Window:eventMouseButtonAway(ev)
- if self.pressed then return self:eventMouseButton(ev) end
-end
-
-function Window:eventMouseButton(ev)
- if ev.down and ev.button == 1 then
- self:moveToFront()
- if self:getLoop().hover ~= self then return end
- self.pressed = { x = Event.mouse.x, y = Event.mouse.y,
- resize = ev.resize, -- can be set in eventMouseButton by subclasses
- origw = self.w, origh = self.h }
- return true
- elseif not ev.down and ev.button == 1 then
- if self:isDragged() and not self.pressed.resize then
- self.x = self.x - self.pressed.x + Event.mouse.x
- self.y = self.y + self.pressed.y - Event.mouse.y
- end
- self.pressed = nil
- return true
- end
-end
-
-function Window:displayPrepare()
- Node.displayPrepare(self)
- gl.PushMatrix()
- if self:isDragged() and not self.pressed.resize then
- gl.Translate(self.x - self.pressed.x + Event.mouse.cur_x,
- self.y + self.pressed.y - Event.mouse.cur_y, 0)
- else
- gl.Translate(self.x, self.y, 0)
- end
- Selection.push(self)
-end
-
-function Window:displayContent()
- gl.BindTexture(GL.TEXTURE_2D, 0)
- gl.Color(0, 1, 0)
- gl.Begin(GL.QUADS)
- gl.Vertex(0, 0)
- gl.Vertex(self.w, 0)
- gl.Vertex(self.w, self.h)
- gl.Vertex(0, self.h)
- gl.End()
- self:displayChildren()
-end
-
-function Window:displayCleanup()
- Selection.pop(self)
- gl.PopMatrix()
- Node.displayCleanup(self)
-end
-
-
-Content = Node:instantiate()
-
--- values relative to self.parent.x,y,w,h
-Content.mx = 0 -- positive
-Content.my = 0 -- negative
-Content.mw = 0 -- negative (content is smaller than the whole window)
-Content.mh = 0 -- positive
-
-function Content:displayStencil()
- gl.Begin(GL.QUADS)
- gl.Vertex(0, 0)
- gl.Vertex(self.parent.w + self.mw, 0)
- gl.Vertex(self.parent.w + self.mw, self.parent.h + self.mh)
- gl.Vertex(0, self.parent.h + self.mh)
- gl.End()
-end
-
-function Content:displayContent()
- gl.BindTexture(GL.TEXTURE_2D, 0)
- gl.Color(0, 0, 1)
- if self:getLoop().focus == self then gl.Color(0, 0.5, 1) end
- gl.Begin(GL.TRIANGLES)
- gl.Vertex(-20, -20)
- gl.Vertex(self.parent.w / 2, self.parent.h)
- gl.Vertex(self.parent.w, self.parent.h / 2)
- gl.End()
- self:displayChildren()
-end
-
-function Content:displayPrepare()
- Node.displayPrepare(self)
- gl.PushMatrix(); gl.Translate(self.mx, self.my, 0)
- Mask.Stencil.push(self)
- Selection.push(self)
-end
-
-function Content:displayCleanup()
- Selection.pop()
- Mask.Stencil.pop()
- gl.PopMatrix()
- Node.displayCleanup(self)
-end
-
-function Content:eventMouseButton(ev)
- return true
-end
-
-
-TestRoot = Node.Root:instantiate()
-
-function TestRoot:displayPrepare()
- Node.Root.displayPrepare(self)
- Mask.Stencil.prepareTopLevel()
-end
-
-function TestRoot:displayCleanup()
- Mask.Stencil.cleanupTopLevel()
- Node.Root.displayCleanup(self)
-end
-
diff --git a/data/core/ZUtil.lua b/data/core/ZUtil.lua
deleted file mode 100644
index 15726d6..0000000
--- a/data/core/ZUtil.lua
+++ b/dev/null
@@ -1,24 +0,0 @@
-
-local _G = _G
-local SDL, zlib, string = SDL, zlib, string
-local assert = assert
-
-module(...)
-
-function compress(source)
- local sourceLen = #source
- local destLen = zlib.compressBound(sourceLen)
- local destBuf = SDL.RWFromNewMem(destLen)
- destLen = zlib.compress(destBuf:baseptr(), destLen, source, sourceLen)
- -- last six bytes contain an ULT footer with uncompressed length
- return assert(destBuf:read(destLen)) ..
- string.pack('<2sC', 'Z\014', sourceLen)
-end
-
-function uncompress(dest)
- local header, sourceLen = string.unpack(dest:sub(-6, -1), '<2sC')
- assert(header == 'Z\014', "malformed data")
- local sourceBuf = SDL.RWFromNewMem(sourceLen)
- sourceLen = zlib.uncompress(sourceBuf:baseptr(), sourceLen, dest, #dest)
- return assert(sourceBuf:read(sourceLen))
-end
diff --git a/data/core/extlib.lua b/data/core/extlib.lua
deleted file mode 100644
index e1d80a2..0000000
--- a/data/core/extlib.lua
+++ b/dev/null
@@ -1,331 +0,0 @@
-
--- EXTENDED LIBRARY
-
--- function notice()
-
-function notice_ex(stacklevel, ...) -- TODO a better name
- local ar = debug.getinfo((stacklevel or 1) + 1, 'Sl')
- local ln = ar.currentline and ar.currentline > 0 and
- " "..ar.short_src..":"..ar.currentline..":" or ""
- local out = io.out or io.write; out("notice:"..ln)
- -- TODO use xselect when available
- for i = 1, select('#', ...) do out(" "..tostring(select(i, ...))) end
- out"\n"
-end
-
-function notice(...) return notice_ex(2, ...) end
-
--- deep table copy
-
-function table.dcopy(src)
- local dest = {}
- for k,v in pairs(src) do dest[k] = (type(v) == 'table' and table.dcopy(v) or v) end
- return dest
-end
-
--- FPS counter
-
-function makeFpsSensor(auto_display)
- local last_update, frames = 0, 0
- return function ()
- -- this should be called every frame
- frames = frames + 1
- local now = SDL.GetTicks()
- local sec_passed = (now - last_update) / 1000
- if math.floor(now / 1000) <= math.floor(last_update / 1000) then
- return end -- the next second hasn't begun yet
- local msg = ("%2ds %.3ffps"):format(now/1000 % 100, frames/sec_passed)
- last_update = now; frames = 0
- if auto_display == false then return msg end
- if _WIN32 then notice(msg); return msg end
- -- when not in Win32, it's assumed that the output goes to a terminal.
- -- the following escape sequences were tested on an xterm.
- local amsg = " "..msg; (io.out or io.write)("\0277\027[A\027[512G"..
- amsg:gsub('.', '\b')..amsg.."\0278")
- return msg
- end
-end
-
--- OOP class mechanics
-
-local _toplevel_class = {}
-
-function _toplevel_class:instantiate(o)
- self.__index = self
- return setmetatable(o or {}, self)
-end
-
-function _toplevel_class:new(o)
- o = self:instantiate(o)
- return o:initialize() or o
-end
-
-function _toplevel_class:initialize()
-end
-
-function Class(o)
- -- this makes o an instance of _toplevel_class
- return _toplevel_class:instantiate(o)
-end
-
---[=[
--- Mixins are disabled for now -- they are too hard to debug. For example:
--- a saved game set CURRENTFIELD.hover = {}. Then, when aMainLoop:mouseEvent
--- wants to set self.hover to nil, it always changes to {}. But things like
--- getmetatable(self).hover return nil too. Should mixins be reenabled later,
--- the documentation and usability really need improvement.
-
-local function _mixin_index(t, key)
- for i,v in ipairs(getmetatable(t)) do
- local tmp = v[key]; if tmp then return tmp end
- end
-end
-
-function Mixin(o, ...)
- local mt = { __index = _mixin_index, ... }
- setmetatable(o, mt)
- return o
-end
-
---]=]
-
--- a table for transient object information
-Transient = {}; setmetatable(Transient, { __mode = 'k',
- __index = function (t,k) t[k] = {}; return t[k] end })
-
---------------------------------
-
--- additional string functions
-
-function string.chomp(s, sep)
- return s:gsub((sep or '\r?\n\r?')..'$', '')
-end
-
-do
- local function make_quote_subst(t, ch)
- t[ch] = string.format('\\%03d', ch:byte()); return t[ch]
- end
- local quote_subst = { ['\b'] = '\\b', ['\n'] = '\\n', ['\r'] = '\\r',
- ['\t'] = '\\t', [']'] = ']', [ [[\]] ] = [[\\]], ['"'] = [[\"]] }
- setmetatable(quote_subst, { __index = make_quote_subst })
-
- function string.quote(s)
- return '"' .. s:gsub("[^ !#-[^-~]", quote_subst) .. '"'
- end
-end
-
-if getmetatable("") then getmetatable("").__inspect = string.quote end
-
-function string.ufix(s)
- return (' '..s..' '):gsub('[\127\254\255]', '?')
- :gsub('[\192-\253]+([^\128-\191])', '?%1')
- :gsub('([^\128-\253])[\128-\191]+', '%1?')
- :gsub('[\192-\253][\128-\191]+', function (q) local b = string.byte(q)
- return (#q ~= (b >= 252 and 6 or b >= 248 and 5 or b >= 240 and 4 or
- b >= 224 and 3 or 2) and '?') end):sub(2, -2)
-end
-
-function string.ulen(s)
- return #s:ufix():gsub('[\128-\191]', '')
-end
-
-function string.usub(s, i, j)
- s = s:ufix(); local l = s:ulen()
- j = j or -1; if i < 0 then i = l+1+i end; if j < 0 then j = l+1+j end
- local n, vv, st = 0, 0, nil
- if i > l or j < 0 or i > j then return '' end
- for p in s:gmatch('[%0\1-\127\192-\255][\128-\191]*') do
- n = n + 1
- if n == i then st = vv + 1 end
- vv = vv + #p
- if n == j then return s:sub(st, vv) end
- end
- return s:sub(st, vv)
-end
-
-function string.uchar(...)
- local st, len, pr = {}, nil, nil
- for _,n in ipairs({...}) do
- len, pr = nil, nil
- if n > 0x04000000 then len, pr = 6, 0xFC
- elseif n > 0x00200000 then len, pr = 5, 0xF8
- elseif n > 0x00010000 then len, pr = 4, 0xF0
- elseif n > 0x00000800 then len, pr = 3, 0xE0
- elseif n > 0x00000080 then len, pr = 2, 0xC0
- else len, pr = 1, 0 end
- for i = len-1, 0, -1 do
- local m = bit.rshift(n, 6*i)
- st[#st+1] = i == len-1 and (pr + m) or (0x80 + bit.band(0x3F, m))
- end
- end
- return string.char(unpack(st))
-end
-
---------------------------------
-
--- base64 decoder
-
-do
- local decode_t = {}
- for i = 1, 26 do decode_t[i + 64] = i - 1 end
- for i = 1, 26 do decode_t[i + 96] = i - 1 + 26 end
- for i = 0, 9 do decode_t[i + 48] = i + 26 + 26 end
- decode_t[43] = 26 + 26 + 10
- decode_t[47] = 26 + 26 + 10 + 1
- decode_t[61] = 0
-
- function base64_decode(s)
- _G.assert(#s%4 == 0, "unsupported base64 length")
- local out = {}
- for i = 0, #s-1, 4 do
- local m = bit.bor(
- bit.lshift(decode_t[string.byte(s, i+1, i+1)], 18),
- bit.lshift(decode_t[string.byte(s, i+2, i+2)], 12),
- bit.lshift(decode_t[string.byte(s, i+3, i+3)], 6),
- bit.lshift(decode_t[string.byte(s, i+4, i+4)], 0))
- table.insert(out, string.char(
- bit.band(bit.rshift(m, 16), 0xFF),
- bit.band(bit.rshift(m, 8), 0xFF),
- bit.band(m, 0xFF)))
- end
- return table.concat(out)
- end
-end
-
---------------------------------
-
--- the 'inspect' functions
-
--- NOTE: Don't call inspect.object(self) from inside __inspect! It will cause
--- a stack overflow.
-
-inspect = {}
-
-function inspect.userdata(o, state)
- assert(not state.export, "userdata can't be exported")
- local typename = nil
- if debug and debug.getregistry then
- local metatable = getmetatable(o)
- for n, v in pairs(debug.getregistry()) do
- if v == metatable then typename = n end
- end
- end
- if not typename then return "<"..tostring(o)..">" end
- return "<"..typename.." - "..tostring(o)..">"
-end
-
-inspect['function'] = function (o, state)
- assert(not state.export, "functions can't be exported")
- if not debug or not debug.getinfo then return "<"..tostring(o)..">" end
- local typename = nil
- local ar = debug.getinfo(o, "Sn")
- local str = "<"..ar.what.." "..tostring(o)
- if ar.namewhat and ar.namewhat ~= "" then
- return str .. " ('"..ar.namewhat.."')>"
- elseif ar.short_src and ar.short_src ~= "" and ar.what ~= "C" then
- return str .. " ("..ar.short_src..":"..ar.linedefined..")>"
- else
- return str .. ">"
- end
-end
-
-function inspect.thread(o, state)
- assert(not state.export, "threads can't be exported")
- return "<"..tostring(o)..">"
-end
-
-function inspect.string(o)
- -- string.__inspect is normally string.quote, but this is a fallback
- return string.format("%q", o)
-end
-
-function inspect.iterate(t)
- local ipairs_phase = true
- return function (t, k)
- if ipairs_phase then
- local i = k and k+1 or 0
- if rawget(t, i) then return i end
- ipairs_phase = false
- end
- return next(t, k)
- end, t
-end
-
-function inspect.blacklist(blacklist)
- return function (t)
- local orig_iter = inspect.iterate(t)
- return function (t, k)
- repeat k = orig_iter(t, k) until not blacklist[k]
- return k
- end, t
- end
-end
-
-function inspect.whitelist(whitelist)
- return function (t)
- return function (t, k)
- repeat k = next(whitelist, k) until not k or
- (whitelist[k] and rawget(t, k) ~= nil)
- return k
- end, t
- end
-end
-
---[[ About indentation:
- state.indent is what gets written before every table key-value pair.
- When indentation is off, it's one space. When indentation is on, it's
- a newline and some spaces (depending on current indentation level).
- state.indent_inc is what gets appended to indent in every recursion level
- of _inspect.table. When indentation is off, it's nothing. When
- indentation is on, it's the indentation character (e.g. "\t").
- ]]
-
-function inspect.table(o, state, iterator)
- iterator = iterator or state.iterator or inspect.iterate
- local result = '{'
-
- state.inspecting = state.inspecting or {}
- if state.inspecting[o] then
- assert(not state.export, "recursive tables can't be exported") -- TODO
- return '<...>' end -- prevent infinite loop
- state.inspecting[o] = true
- if getmetatable(o) and not state.export then
- result = '{ --[[ has a metatable ]]' end
-
- local keys_done, empty, last_int = {}, true, nil
- local function try_key(k)
- if keys_done[k] then return end; keys_done[k] = true
- local show_key; empty = false -- from Lua manual:
- if (k == 1 and not last_int) or (last_int and last_int + 1 == k) then
- last_int = k; show_key = '' -- field ::= exp
- elseif type(k) == 'string' and k:match('^[%a_][%w_]*$') then
- show_key = k..' = ' -- field ::= Name '=' exp
- else -- field ::= '[' exp ']' '=' exp
- show_key = '['..inspect.object(k, state)..'] = '
- end
- result = result .. state.indent .. show_key ..
- inspect.object(rawget(o, k), state) .. ','
- end
-
- state.indent = state.indent or " "; local old_indent = state.indent
- state.indent = state.indent .. (state.indent_inc or '') -- add indentation
- for k in iterator(o) do try_key(k) end
- state.indent = old_indent -- remove indentation
-
- if not state.concise then state.inspecting[o] = false end
- if empty then return result .. '}' end
- -- remove the last comma and add a closing bracket
- return result:gsub(',$', '') .. state.indent .. '}'
-end
-
-function inspect.object(o, state)
- return (rawget(getmetatable(o) or {}, "__inspect") or
- inspect[type(o)] or tostring)(o, state or {})
-end
-
--- inspection modes/states
-inspect.indented = { indent = "\n", indent_inc = " " }
-inspect.export = { indent = "\n", indent_inc = " ", export = true }
-
-function print_r(o) notice_ex(2, inspect.object(o, inspect.indented)) end
-
diff --git a/data/core/globalgl.lua b/data/core/globalgl.lua
deleted file mode 100644
index eb37330..0000000
--- a/data/core/globalgl.lua
+++ b/dev/null
@@ -1,14 +0,0 @@
-
--- this simple file makes gl and glu available in global namespace
-
-for i,tableid in ipairs({ 'gl', 'glu' }) do
- for k,v in pairs(_G[tableid]) do
- local t = type(v)
- if t == 'function' then
- rawset(_G, tableid..k, v)
- elseif t == 'number' or t == 'boolean' or t == 'string' then
- rawset(_G, 'GL_'..k, v)
- end
- end
-end
-
diff --git a/data/core/justify.lua b/data/core/justify.lua
deleted file mode 100644
index 95712f5..0000000
--- a/data/core/justify.lua
+++ b/dev/null
@@ -1,71 +0,0 @@
-
-Justify = {}
-
-function Justify.splitWords(font, str)
- local words = {}
- for word in str:gmatch("%S+") do
- table.insert(words, { word = word, length = font:prepare(word) })
- end
- return words
-end
-
-function Justify.getLineEnd(font, words, line_width, line_begin)
- local space = font:prepare(" ")
- local total_length = 0
- if words[line_begin].length + space > line_width then return line_begin end
- for i = line_begin, #words do
- if total_length + words[i].length + space > line_width then return i-1 end
- total_length = total_length + words[i].length + space
- end
- return #words
-end
-
-function Justify.getSpaceSize(words, line_width, line_begin, line_end)
- for i = line_begin, line_end do
- line_width = line_width - words[i].length
- end
- -- num_spaces is num_words_on_line-1; num_words_on_line is line_end-line_begin+1
- return line_width / (line_end - line_begin)
-end
-
-function Justify.prepare(font, str, line_width, line_begin)
- line_begin = line_begin or 1
- local words = Justify.splitWords(font, str)
- local line_end = Justify.getLineEnd(font, words, line_width, line_begin)
- local prepare = {
- words = words, font = font, line_width = line_width,
- line_begin = line_begin, line_end = line_end,
- space = Justify.getSpaceSize(words, line_width, line_begin, line_end)
- }
- setmetatable(prepare, Justify)
- return prepare
-end
-
-function Justify.nextLine(prepare)
- if prepare.line_end == #prepare.words then return nil end
- local line_begin = prepare.line_end + 1
- local line_end = Justify.getLineEnd(prepare.font, prepare.words, prepare.line_width, line_begin)
- local nextLine = {
- words = prepare.words, font = prepare.font, line_width = prepare.line_width,
- line_begin = line_begin, line_end = line_end,
- space = Justify.getSpaceSize(prepare.words, prepare.line_width, line_begin, line_end)
- }
- setmetatable(nextLine, Justify)
- return nextLine
-end
-
-function Justify.prepareLines(font, str, line_width, line_begin)
- local line = Justify.prepare(font, str, line_width, line_begin)
- local lines = { line }
- while line do
- line = Justify.nextLine(line); table.insert(lines, line)
- end
- return lines
-end
-
-function Justify.print(prepare)
- for i = prepare.line_begin, prepare.line_end do
- prepare.font:print(prepare.words[i].word)
- if i ~= prepare.line_end then glTranslate(prepare.space, 0, 0) end
- end
-end
diff --git a/data/core/strict.lua b/data/core/strict.lua
deleted file mode 100644
index 604619d..0000000
--- a/data/core/strict.lua
+++ b/dev/null
@@ -1,41 +0,0 @@
---
--- strict.lua
--- checks uses of undeclared global variables
--- All global variables must be 'declared' through a regular assignment
--- (even assigning nil will do) in a main chunk before being used
--- anywhere or assigned to inside a function.
---
-
-local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
-
-local mt = getmetatable(_G)
-if mt == nil then
- mt = {}
- setmetatable(_G, mt)
-end
-
-mt.__declared = {}
-
-local function what ()
- local d = getinfo(3, "S")
- return d and d.what or "C"
-end
-
-mt.__newindex = function (t, n, v)
- if not mt.__declared[n] then
- local w = what()
- if w ~= "main" and w ~= "C" then
- error("assign to undeclared variable '"..n.."'", 2)
- end
- mt.__declared[n] = true
- end
- rawset(t, n, v)
-end
-
-mt.__index = function (t, n)
- if not mt.__declared[n] and what() ~= "C" then
- error("variable '"..n.."' is not declared", 2)
- end
- return rawget(t, n)
-end
-
diff --git a/data/karel.info b/data/karel.info
deleted file mode 100644
index 5468ce9..0000000
--- a/data/karel.info
+++ b/dev/null
@@ -1,2 +0,0 @@
--- FILES core fonts karel start.lua userrc.lua
-type = 'core'
diff --git a/data/test/console.lua b/data/test/console.lua
deleted file mode 100644
index 49c6b70..0000000
--- a/data/test/console.lua
+++ b/dev/null
@@ -1,11 +0,0 @@
-
-require 'Console'
-require 'test.nehe.nehelib'
-
-WIDTH = 800; HEIGHT = 600; FULLSCREEN = false
-
-math.randomseed(os.time())
-
-initScreen()
-
-Console:new{}:run()
diff --git a/data/test/debug.lua b/data/test/debug.lua
deleted file mode 100644
index ffaf25d..0000000
--- a/data/test/debug.lua
+++ b/dev/null
@@ -1 +0,0 @@
-debug.debug()
diff --git a/data/test/ftgl.lua b/data/test/ftgl.lua
deleted file mode 100644
index 75dcbd3..0000000
--- a/data/test/ftgl.lua
+++ b/dev/null
@@ -1,38 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-require 'justify'
-
---my_string = "KERNING IS A TECHNIQUE THAT CHANGES SPACES BETWEEN GLYPHS."
-my_string = assert(FS.load('core/FS.lua'):read())
-
-function drawGLScene()
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glColor(0, 0, 0)
- glTranslate(10, HEIGHT-my_font.ascent, 0)
- for i,v in ipairs(my_string_justify) do
- glPushMatrix()
- glTranslate(0, -(i-1)*my_font.height, 0)
- Justify.print(v)
- glPopMatrix()
- end
-end
-
-initScreen()
-
-glMatrixMode(GL_PROJECTION); glLoadIdentity()
-glOrtho(0, WIDTH, 0, HEIGHT, -100, 100)
-glMatrixMode(GL_MODELVIEW); glLoadIdentity()
-
-glClearColor(1, 1, 0, 0)
-
-glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-my_texture = glGenTextures(1)
-my_font = FS.load('fonts/DejaVuSansMono.ttf'):font(12, 256, my_texture, true)
-glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
-glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
-my_string_justify = Justify.prepareLines(my_font, my_string, 620)
-
-NeheLoop:new():run()
diff --git a/data/test/jump.lua b/data/test/jump.lua
deleted file mode 100644
index 9f7bb90..0000000
--- a/data/test/jump.lua
+++ b/dev/null
@@ -1,105 +0,0 @@
-
-require 'extlib'
-require 'globalgl'
-require 'Event'
-require 'MainLoop'
-
-function toggle(enabling)
- return enabling and glEnable or glDisable
-end
-
-WIDTH = 1024
-HEIGHT = 768
-FULLSCREEN = false
-
-GameLoop = MainLoop:instantiate()
-
-function GameLoop:initialize()
- MainLoop.initialize(self)
- self.scroll_x, self.scroll_y = 0, 0, 0, 0
- self.my_x, self.my_y = 100, 100
- self.speed_x, self.speed_y = 0, 0
-end
-
-function GameLoop:key(ev)
- if not ev.down then return end
- if ev.sym == SDL.K_ESCAPE then self:quit() end
- if ev.sym == SDL.K_F1 then pcall(SDL.WM_ToggleFullScreen); return end
- -- handleKeypress(ev.sym)
-end
-
-local function changeval(val, change, min, max)
- if change > 0 then
- return val < max and val+change or val
- else
- return val > min and val+change or val
- end
-end
-function GameLoop:update()
- self.my_x = self.my_x + self.speed_x
- self.my_y = self.my_y + self.speed_y
-
- if self.speed_y == 0 then
- self.speed_x = changeval(self.speed_x, Event.key[SDL.K_RIGHT] and 1 or -1, 0, 5)
- self.speed_x = changeval(self.speed_x, Event.key[SDL.K_LEFT] and -1 or 1, -5, 0)
- if Event.key[SDL.K_UP] then self.speed_y = 8 end
- end
-
- self.speed_y = self.speed_y - 0.4 -- gravity
-
- if not self:canBePresent(self.my_x + self.speed_x, self.my_y) then self.speed_x = 0 end
- if not self:canBePresent(self.my_x, self.my_y + self.speed_y) then self.speed_y = 0 end
- if not self:canBePresent(self.my_x + self.speed_x, self.my_y + self.speed_y) then self.speed_x, self.speed_y = 0, 0 end
-end
-
-function GameLoop:canBePresent(x, y)
- if x < 50 or x > 200 then return false end
- if y < 50 or y > 200 then return false end
- return true
-end
-
-function GameLoop:display()
- glClear(GL_COLOR_BUFFER_BIT)
- glBindTexture(GL_TEXTURE_2D, 0)
-
- glLoadIdentity()
- glColor(1, 1, 0)
- glBegin(GL_QUADS)
- glVertex(50-16, 50-16)
- glVertex(200+16, 50-16)
- glVertex(200+16, 200+16)
- glVertex(50-16, 200+16)
- glEnd()
-
- glLoadIdentity()
- glTranslate(self.my_x + self.frameFraction*self.speed_x, self.my_y + self.frameFraction*self.speed_y, 0)
- glColor(1, 0, 0)
- glBegin(GL_QUADS)
- glVertex(-16, -16)
- glVertex(16, -16)
- glVertex(16, 16)
- glVertex(-16, 16)
- glEnd()
-end
-
-SDL.GL_SetAttribute(SDL.GL_DOUBLEBUFFER, 1)
-SDL.GL_SetAttribute(SDL.GL_ALPHA_SIZE, 1)
-SDL.SetVideoMode(WIDTH, HEIGHT, FULLSCREEN)
-glViewport(0, 0, WIDTH, HEIGHT)
-
-glClearColor(1, 1, 1, 1)
-
-glMatrixMode(GL_PROJECTION)
-glLoadIdentity()
---gluPerspective(45.0, WIDTH/HEIGHT, 0.1, 100.0)
-glOrtho(0, WIDTH, 0, HEIGHT, -100, 100)
-
-glMatrixMode(GL_MODELVIEW)
-glLoadIdentity()
-
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-glEnable(GL_TEXTURE_2D)
-glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-glEnable(GL_BLEND)
-
-GameLoop:new():run()
diff --git a/data/test/nehe/crate.bmp b/data/test/nehe/crate.bmp
deleted file mode 100644
index 652ff7e..0000000
--- a/data/test/nehe/crate.bmp
+++ b/dev/null
Binary files differ
diff --git a/data/test/nehe/glass.bmp b/data/test/nehe/glass.bmp
deleted file mode 100644
index 1acf064..0000000
--- a/data/test/nehe/glass.bmp
+++ b/dev/null
Binary files differ
diff --git a/data/test/nehe/mud.bmp b/data/test/nehe/mud.bmp
deleted file mode 100644
index 9b10897..0000000
--- a/data/test/nehe/mud.bmp
+++ b/dev/null
Binary files differ
diff --git a/data/test/nehe/nehe.bmp b/data/test/nehe/nehe.bmp
deleted file mode 100644
index d36bd34..0000000
--- a/data/test/nehe/nehe.bmp
+++ b/dev/null
Binary files differ
diff --git a/data/test/nehe/nehe02.lua b/data/test/nehe/nehe02.lua
deleted file mode 100644
index ffb8195..0000000
--- a/data/test/nehe/nehe02.lua
+++ b/dev/null
@@ -1,35 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glTranslate(-1.5, 0, -6)
-
- glBegin(GL_TRIANGLES)
- glVertex( 0, 1, 0)
- glVertex(-1, -1, 0)
- glVertex( 1, -1, 0)
- glEnd()
-
- glTranslate(3.0, 0, 0)
-
- glBegin(GL_QUADS)
- glVertex(-1, 1, 0)
- glVertex( 1, 1, 0)
- glVertex( 1, -1, 0)
- glVertex(-1, -1, 0)
- glEnd()
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe03.lua b/data/test/nehe/nehe03.lua
deleted file mode 100644
index 0232fa2..0000000
--- a/data/test/nehe/nehe03.lua
+++ b/dev/null
@@ -1,36 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glTranslate(-1.5, 0, -6)
-
- glBegin(GL_TRIANGLES)
- glColor(1, 0, 0) glVertex( 0, 1, 0)
- glColor(0, 1, 0) glVertex(-1, -1, 0)
- glColor(0, 0, 1) glVertex( 1, -1, 0)
- glEnd()
-
- glTranslate(3.0, 0, 0)
-
- glColor(0.5, 0.5, 1)
- glBegin(GL_QUADS)
- glVertex(-1, 1, 0)
- glVertex( 1, 1, 0)
- glVertex( 1, -1, 0)
- glVertex(-1, -1, 0)
- glEnd()
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe04.lua b/data/test/nehe/nehe04.lua
deleted file mode 100644
index 986fb1f..0000000
--- a/data/test/nehe/nehe04.lua
+++ b/dev/null
@@ -1,46 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-rtri = 0; rquad = 0
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glTranslate(-1.5, 0, -6)
- glRotate(rtri + (interpolation * 0.8), 0, 1, 0)
-
- glBegin(GL_TRIANGLES)
- glColor(1, 0, 0); glVertex( 0, 1, 0)
- glColor(0, 1, 0); glVertex(-1, -1, 0)
- glColor(0, 0, 1); glVertex( 1, -1, 0)
- glEnd()
-
- glLoadIdentity()
- glTranslate(1.5, 0, -6)
- glRotate(rquad + (interpolation * -0.6), 1, 0, 0)
-
- glBegin(GL_QUADS)
- glColor(0.5, 0.5, 1)
- glVertex(-1, 1, 0)
- glVertex( 1, 1, 0)
- glVertex( 1, -1, 0)
- glVertex(-1, -1, 0)
- glEnd()
-end
-
-function computeFrame()
- rtri = rtri + 0.8
- rquad = rquad - 0.6
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe05.lua b/data/test/nehe/nehe05.lua
deleted file mode 100644
index 699db3b..0000000
--- a/data/test/nehe/nehe05.lua
+++ b/dev/null
@@ -1,97 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-rtri = 0; rquad = 0
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glTranslate(-1.5, 0, -6)
- glRotate(rtri + (interpolation * 0.8), 0, 1, 0)
-
- glBegin(GL_TRIANGLES)
- glColor(1, 0, 0); glVertex( 0, 1, 0)
- glColor(0, 1, 0); glVertex(-1, -1, 1)
- glColor(0, 0, 1); glVertex( 1, -1, 1)
-
- glColor(1, 0, 0); glVertex( 0, 1, 0)
- glColor(0, 0, 1); glVertex( 1, -1, 1)
- glColor(0, 1, 0); glVertex( 1, -1, -1)
-
- glColor(1, 0, 0); glVertex( 0, 1, 0)
- glColor(0, 1, 0); glVertex( 1, -1, -1)
- glColor(0, 0, 1); glVertex(-1, -1, -1)
-
- glColor(1, 0, 0); glVertex( 0, 1, 0)
- glColor(0, 0, 1); glVertex(-1, -1, -1)
- glColor(0, 1, 0); glVertex(-1, -1, 1)
- glEnd()
-
- --[[ toto je spodok, ale aj tak ho nevidno
- glBegin(GL_QUADS)
- glColor(0, 1, 0); glVertex(-1, -1, 1)
- glColor(0, 0, 1); glVertex( 1, -1, 1)
- glColor(0, 1, 0); glVertex( 1, -1, -1)
- glColor(0, 0, 1); glVertex(-1, -1, -1)
- glEnd()
- --]]
-
- glLoadIdentity()
- glTranslate(1.5, 0, -7)
- glRotate(rquad + (interpolation * -0.6), 1, 1, 1)
-
- glBegin(GL_QUADS)
- glColor(0, 1, 0)
- glVertex( 1, 1, -1)
- glVertex(-1, 1, -1)
- glVertex(-1, 1, 1)
- glVertex( 1, 1, 1)
-
- glColor(1, 0.5, 0)
- glVertex( 1, -1, 1)
- glVertex(-1, -1, 1)
- glVertex(-1, -1, -1)
- glVertex( 1, -1, -1)
-
- glColor(1, 0, 0)
- glVertex( 1, 1, 1)
- glVertex(-1, 1, 1)
- glVertex(-1, -1, 1)
- glVertex( 1, -1, 1)
-
- glColor(1, 1, 0)
- glVertex(-1, 1, -1)
- glVertex( 1, 1, -1)
- glVertex( 1, -1, -1)
- glVertex(-1, -1, -1)
-
- glColor(0, 0, 1)
- glVertex(-1, 1, 1)
- glVertex(-1, 1, -1)
- glVertex(-1, -1, -1)
- glVertex(-1, -1, 1)
-
- glColor(1, 0, 1)
- glVertex( 1, 1, -1)
- glVertex( 1, 1, 1)
- glVertex( 1, -1, 1)
- glVertex( 1, -1, -1)
- glEnd()
-end
-
-function computeFrame()
- rtri = rtri + 0.8
- rquad = rquad - 0.6
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe06.lua b/data/test/nehe/nehe06.lua
deleted file mode 100644
index aa3b0bc..0000000
--- a/data/test/nehe/nehe06.lua
+++ b/dev/null
@@ -1,73 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-xrot, yrot, zrot = 0, 0, 0
-my_texture = nil
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glTranslate(0, 0, -5)
- glRotate(xrot + (interpolation * 0.3), 1, 0, 0)
- glRotate(yrot + (interpolation * 0.2), 0, 1, 0)
- glRotate(zrot + (interpolation * 0.4), 0, 0, 1)
-
- glBindTexture(GL_TEXTURE_2D, my_texture)
-
- glBegin(GL_QUADS)
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, 1, 1)
- glTexCoord(1, 0); glVertex( 1, 1, 1)
-
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 1); glVertex(-1, -1, -1)
- glTexCoord(0, 1); glVertex( 1, -1, -1)
-
- glTexCoord(1, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, 1)
-
- glTexCoord(1, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 0); glVertex( 1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, -1)
-
- glTexCoord(1, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
-
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, -1)
- glEnd()
-end
-
-function computeFrame()
- xrot = xrot + 0.3
- yrot = yrot + 0.2
- zrot = zrot + 0.4
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-glEnable(GL_TEXTURE_2D)
-
-my_texture = glGenTextures(1)
-glBindTexture(GL_TEXTURE_2D, my_texture)
-loadImage('test/nehe/nehe.bmp'):glTexImage2D()
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe07.lua b/data/test/nehe/nehe07.lua
deleted file mode 100644
index cfc3047..0000000
--- a/data/test/nehe/nehe07.lua
+++ b/dev/null
@@ -1,105 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-light = false
-xrot, yrot, xspeed, yspeed = 0, 0, 0, 0
-zpos = -5
-filter = 1
-my_textures = { }
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glTranslate(0, 0, zpos)
- glRotate(xrot + (interpolation * xspeed), 1, 0, 0)
- glRotate(yrot + (interpolation * yspeed), 0, 1, 0)
-
- glBindTexture(GL_TEXTURE_2D, my_textures[filter])
-
- glBegin(GL_QUADS)
- glNormal(0, 1, 0)
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, 1, 1)
- glTexCoord(1, 0); glVertex( 1, 1, 1)
-
- glNormal(0, -1, 0)
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 1); glVertex(-1, -1, -1)
- glTexCoord(0, 1); glVertex( 1, -1, -1)
-
- glNormal(0, 0, 1)
- glTexCoord(1, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, 1)
-
- glNormal(0, 0, -1)
- glTexCoord(1, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 0); glVertex( 1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, -1)
-
- glNormal(-1, 0, 0)
- glTexCoord(1, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
-
- glNormal(1, 0, 0)
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, -1)
- glEnd()
-end
-
-function computeFrame()
- xrot = xrot + xspeed
- yrot = yrot + yspeed
-
- if Event.key[SDL.K_PAGEUP] then zpos = zpos - 0.02 end
- if Event.key[SDL.K_PAGEDOWN] then zpos = zpos + 0.02 end
- if Event.key[SDL.K_UP] then xspeed = xspeed - 0.3 end
- if Event.key[SDL.K_DOWN] then xspeed = xspeed + 0.3 end
- if Event.key[SDL.K_LEFT] then yspeed = yspeed - 0.3 end
- if Event.key[SDL.K_RIGHT] then yspeed = yspeed + 0.3 end
-end
-
-function handleKeypress(sym)
- if sym == SDL.K_f then filter = (filter == 3 and 2 or filter+1) end
- if sym == SDL.K_l then light = not light; toggle(light)(GL_LIGHTING) end
-end
-
-local function _f(a,b)
- glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,a)
- glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,b)
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-
-glLight(GL_LIGHT1, GL_AMBIENT, 0.5, 0.5, 0.5, 1)
-glLight(GL_LIGHT1, GL_DIFFUSE, 1, 1, 1, 1)
-glLight(GL_LIGHT1, GL_POSITION, 0, 0, 2, 1)
-glEnable(GL_LIGHT1)
-
-glEnable(GL_TEXTURE_2D)
-my_textures = { glGenTextures(3) }
-local img = loadImage('test/nehe/crate.bmp')
-glBindTexture(GL_TEXTURE_2D, my_textures[1])
-_f(GL_NEAREST, GL_NEAREST); img:glTexImage2D()
-glBindTexture(GL_TEXTURE_2D, my_textures[2])
-_f(GL_LINEAR, GL_LINEAR); img:glTexImage2D()
-glBindTexture(GL_TEXTURE_2D, my_textures[3])
-_f(GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST); img:glTexImage2D(true)
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe08.lua b/data/test/nehe/nehe08.lua
deleted file mode 100644
index fd0cdb0..0000000
--- a/data/test/nehe/nehe08.lua
+++ b/dev/null
@@ -1,111 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-light, blend = false, false
-xrot, yrot, xspeed, yspeed = 0, 0, 0, 0
-zpos = -5
-filter = 1
-my_textures = { }
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glTranslate(0, 0, zpos)
- glRotate(xrot + (interpolation * xspeed), 1, 0, 0)
- glRotate(yrot + (interpolation * yspeed), 0, 1, 0)
-
- glBindTexture(GL_TEXTURE_2D, my_textures[filter])
-
- glColor(1, 1, 1, 0.5)
-
- glBegin(GL_QUADS)
- glNormal(0, 1, 0)
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, 1, 1)
- glTexCoord(1, 0); glVertex( 1, 1, 1)
-
- glNormal(0, -1, 0)
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 1); glVertex(-1, -1, -1)
- glTexCoord(0, 1); glVertex( 1, -1, -1)
-
- glNormal(0, 0, 1)
- glTexCoord(1, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, 1)
-
- glNormal(0, 0, -1)
- glTexCoord(1, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 0); glVertex( 1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, -1)
-
- glNormal(-1, 0, 0)
- glTexCoord(1, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
-
- glNormal(1, 0, 0)
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, -1)
- glEnd()
-end
-
-function computeFrame()
- xrot = xrot + xspeed
- yrot = yrot + yspeed
-
- if Event.key[SDL.K_PAGEUP] then zpos = zpos - 0.02 end
- if Event.key[SDL.K_PAGEDOWN] then zpos = zpos + 0.02 end
- if Event.key[SDL.K_UP] then xspeed = xspeed - 0.3 end
- if Event.key[SDL.K_DOWN] then xspeed = xspeed + 0.3 end
- if Event.key[SDL.K_LEFT] then yspeed = yspeed - 0.3 end
- if Event.key[SDL.K_RIGHT] then yspeed = yspeed + 0.3 end
-end
-
-function handleKeypress(sym)
- if sym == SDL.K_f then filter = (filter == 3 and 1 or filter+1) end
- if sym == SDL.K_l then light = not light; toggle(light)(GL_LIGHTING) end
- if sym == SDL.K_b then blend = not blend; toggle(blend)(GL_BLEND); toggle(not blend)(GL_DEPTH_TEST) end
-end
-
-local function _f(a,b)
- glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,a)
- glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,b)
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-
-glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-
-glLight(GL_LIGHT1, GL_AMBIENT, 0.5, 0.5, 0.5, 1)
-glLight(GL_LIGHT1, GL_DIFFUSE, 1, 1, 1, 1)
-glLight(GL_LIGHT1, GL_POSITION, 0, 0, 2, 1)
-glEnable(GL_LIGHT1)
-
-glEnable(GL_TEXTURE_2D)
-my_textures = { glGenTextures(3) }
---local img = loadImage('test/nehe/glass.bmp')
-local img = loadImage('test/nehe/nehe.bmp')
-glBindTexture(GL_TEXTURE_2D, my_textures[1])
-_f(GL_NEAREST, GL_NEAREST); img:glTexImage2D()
-glBindTexture(GL_TEXTURE_2D, my_textures[2])
-_f(GL_LINEAR, GL_LINEAR); img:glTexImage2D()
-glBindTexture(GL_TEXTURE_2D, my_textures[3])
-_f(GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST); img:glTexImage2D(true)
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe09.lua b/data/test/nehe/nehe09.lua
deleted file mode 100644
index 0f17b5c..0000000
--- a/data/test/nehe/nehe09.lua
+++ b/dev/null
@@ -1,104 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-twinkle = false
-splotches = true
-num_stars = 50
-stars = { }
-zoom = -15
-tilt = 90
-spin = 0
-my_texture = nil
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glBindTexture(GL_TEXTURE_2D, my_texture)
-
- for i = 1, num_stars do
- glLoadIdentity()
-
- glPushName(i) -- picking test
-
- glTranslate(0, 0, zoom)
- glRotate(tilt, 1, 0, 0)
- glRotate(stars[i].angle + (interpolation * i/num_stars), 0, 1, 0)
- glTranslate(stars[i].dist, 0, 0)
- glRotate(-stars[i].angle, 0, 1, 0)
- glRotate(-tilt, 1, 0, 0)
-
- if twinkle then
- glColor(stars[num_stars-i+1].r, stars[num_stars-i+1].g, stars[num_stars-i+1].b, 1)
- glBegin(GL_QUADS)
- glTexCoord(0, 0); glVertex(-1, -1, 0)
- glTexCoord(1, 0); glVertex( 1, -1, 0)
- glTexCoord(1, 1); glVertex( 1, 1, 0)
- glTexCoord(0, 1); glVertex(-1, 1, 0)
- glEnd()
- end
-
- glRotate(spin + (interpolation * 0.01), 0, 0, 1)
- glColor(stars[i].r, stars[i].g, stars[i].b, 1)
- glBegin(GL_QUADS)
- glTexCoord(0, 0); glVertex(-1, -1, 0)
- glTexCoord(1, 0); glVertex( 1, -1, 0)
- glTexCoord(1, 1); glVertex( 1, 1, 0)
- glTexCoord(0, 1); glVertex(-1, 1, 0)
- glEnd()
-
- glPopName()
- end
-end
-
-function computeFrame()
- spin = spin + 0.01
- for i = 1, num_stars do
- stars[i].angle = stars[i].angle + i/num_stars
- -- I like it more when stars[i].dist doesn't change.
--- stars[i].dist = stars[i].dist - 0.01
- if stars[i].dist < 0 then
- stars[i].dist = stars[i].dist + 5
- stars[i].r = math.random()
- stars[i].g = math.random()
- stars[i].b = math.random()
- end
- end
-
- if Event.key[SDL.K_PAGEUP] then zoom = zoom - 0.2 end
- if Event.key[SDL.K_PAGEDOWN] then zoom = zoom + 0.2 end
- if Event.key[SDL.K_UP] then tilt = tilt - 0.5 end
- if Event.key[SDL.K_DOWN] then tilt = tilt + 0.5 end
-end
-
-function handleKeypress(sym)
- if sym == SDL.K_t then twinkle = not twinkle end
- if sym == SDL.K_s then
- -- the original NeHe implementation uses a messed up blendFunc
- -- pressing 'S' in this program toggles a better-looking version
- splotches = not splotches
- if splotches then glBlendFunc(GL_SRC_ALPHA, GL_ONE) else
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR) end
- end
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-glEnable(GL_TEXTURE_2D)
-glBlendFunc(GL_SRC_ALPHA, GL_ONE)
-glEnable(GL_BLEND)
-for i = 1, num_stars do
- stars[i] = { angle = 0, dist = i/num_stars*5,
- r = math.random(), g = math.random(), b = math.random() }
-end
-
-my_texture = glGenTextures(1)
-glBindTexture(GL_TEXTURE_2D, my_texture)
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
-loadImage('test/nehe/star.bmp'):glTexImage2D()
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehe10.lua b/data/test/nehe/nehe10.lua
deleted file mode 100644
index 5eaef83..0000000
--- a/data/test/nehe/nehe10.lua
+++ b/dev/null
@@ -1,88 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-function setupWorld(world)
- local lines = {}
- for v in world:gmatch('[^\n]+') do
- if v:match('^ *[^/]') then lines[#lines+1] = v end
- end
- local numtriangles = tonumber(lines[1]:match('NUMPOLLIES (%d+)'))
- if not numtriangles then error'incorrect world file' end
-
- local lineno = 2
- local sector = {}
- for i = 1, numtriangles do
- sector[i] = {}
- for m = 1, 3 do
- local x,y,z,u,v = lines[lineno]:match('(%S+) +(%S+) +(%S+) +(%S+) +(%S+)')
- sector[i][m] = { x = tonumber(x), y = tonumber(y), z = tonumber(z), u = tonumber(u), v = tonumber(v) }
- lineno = lineno + 1
- end
- end
- return sector
-end
-
-heading, xpos, zpos, yrot, walkbias, walkbiasangle, lookupdown, z = 0, 0, 0, 0, 0, 0, 0, 0
-blend = false
-my_textures = { }
-my_world = nil
-
-function drawGLScene(interpolate)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glLoadIdentity()
- glRotate(lookupdown, 1, 0, 0)
- glRotate(-heading, 0, 1, 0)
- glTranslate(-xpos, -walkbias-0.25, -zpos)
-
- glBindTexture(GL_TEXTURE_2D, my_textures[1])
-
- for tmp, t in ipairs(my_world) do
- glBegin(GL_TRIANGLES)
- glNormal(0, 0, 1)
- glTexCoord(t[1].u, t[1].v); glVertex(t[1].x, t[1].y, t[1].z)
- glTexCoord(t[2].u, t[2].v); glVertex(t[2].x, t[2].y, t[2].z)
- glTexCoord(t[3].u, t[3].v); glVertex(t[3].x, t[3].y, t[3].z)
- glEnd()
- end
-end
-
-function computeFrame()
- if Event.key[SDL.K_UP] then
- xpos = xpos - math.sin(math.rad(heading)) * 0.05
- zpos = zpos - math.cos(math.rad(heading)) * 0.05
- walkbiasangle = (walkbiasangle >= 359 and 0 or walkbiasangle+10)
- walkbias = math.sin(math.rad(walkbiasangle)) / 20
- end
- if Event.key[SDL.K_DOWN] then
- xpos = xpos + math.sin(math.rad(heading)) * 0.05
- zpos = zpos + math.cos(math.rad(heading)) * 0.05
- walkbiasangle = (walkbiasangle < 1 and 350 or walkbiasangle-10)
- walkbias = math.sin(math.rad(walkbiasangle)) / 20
- end
- if Event.key[SDL.K_RIGHT] then heading = heading - 1 end
- if Event.key[SDL.K_LEFT] then heading = heading + 1 end
- if Event.key[SDL.K_PAGEUP] then lookupdown = lookupdown - 1 end
- if Event.key[SDL.K_PAGEDOWN] then lookupdown = lookupdown + 1 end
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LESS) -- TODO: why GL_LESS and not GL_LEQUAL?
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-glEnable(GL_TEXTURE_2D)
-glBlendFunc(GL_SRC_ALPHA, GL_ONE)
-
-my_textures = { glGenTextures(1) }
-glBindTexture(GL_TEXTURE_2D, my_textures[1])
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
-loadImage('test/nehe/mud.bmp'):glTexImage2D()
-
-my_world = setupWorld(assert(FS.load('test/nehe/world.txt'):read()))
-
-NeheLoop:new():run()
diff --git a/data/test/nehe/nehelib.lua b/data/test/nehe/nehelib.lua
deleted file mode 100644
index 3593c89..0000000
--- a/data/test/nehe/nehelib.lua
+++ b/dev/null
@@ -1,50 +0,0 @@
-
-require 'extlib'
-require 'globalgl'
-require 'Event'
-require 'MainLoop'
-
-function toggle(enabling)
- return enabling and glEnable or glDisable
-end
-
--- the GL app itself may overwrite these functions and settings
-WIDTH = 640
-HEIGHT = 480
-FULLSCREEN = false
-function handleKeypress(sym)
-end
-function computeFrame()
-end
-function drawGLScene(interpolation)
-end
-
-NeheLoop = MainLoop:instantiate()
-
-function NeheLoop:key(ev)
- if not ev.down then return end
- if ev.sym == SDL.K_ESCAPE then self:quit() end
- if ev.sym == SDL.K_F1 then pcall(SDL.WM_ToggleFullScreen); return end
- handleKeypress(ev.sym)
-end
-function NeheLoop:update()
- computeFrame()
-end
-function NeheLoop:display()
- drawGLScene(self.frameFraction)
-end
-
-function loadImage(fn)
- local rw = FS.load(fn); local img = SDL.IMG_Load_RW(rw, true); rw:disown()
- return img
-end
-
-function initScreen(w, h, f)
- SDL.GL_SetAttribute(SDL.GL_DOUBLEBUFFER, 1)
- SDL.GL_SetAttribute(SDL.GL_ALPHA_SIZE, 1)
- SDL.SetVideoMode(WIDTH, HEIGHT, FULLSCREEN)
- glViewport(0, 0, WIDTH, HEIGHT)
- glMatrixMode(GL_PROJECTION); glLoadIdentity()
- gluPerspective(45.0, WIDTH/HEIGHT, 0.1, 100.0)
- glMatrixMode(GL_MODELVIEW); glLoadIdentity()
-end
diff --git a/data/test/nehe/star.bmp b/data/test/nehe/star.bmp
deleted file mode 100644
index d693c48..0000000
--- a/data/test/nehe/star.bmp
+++ b/dev/null
Binary files differ
diff --git a/data/test/nehe/world.txt b/data/test/nehe/world.txt
deleted file mode 100644
index a3368bb..0000000
--- a/data/test/nehe/world.txt
+++ b/dev/null
@@ -1,160 +0,0 @@
-
-NUMPOLLIES 36
-
-// Floor 1
--3.0 0.0 -3.0 0.0 6.0
--3.0 0.0 3.0 0.0 0.0
- 3.0 0.0 3.0 6.0 0.0
-
--3.0 0.0 -3.0 0.0 6.0
- 3.0 0.0 -3.0 6.0 6.0
- 3.0 0.0 3.0 6.0 0.0
-
-// Ceiling 1
--3.0 1.0 -3.0 0.0 6.0
--3.0 1.0 3.0 0.0 0.0
- 3.0 1.0 3.0 6.0 0.0
--3.0 1.0 -3.0 0.0 6.0
- 3.0 1.0 -3.0 6.0 6.0
- 3.0 1.0 3.0 6.0 0.0
-
-// A1
-
--2.0 1.0 -2.0 0.0 1.0
--2.0 0.0 -2.0 0.0 0.0
--0.5 0.0 -2.0 1.5 0.0
--2.0 1.0 -2.0 0.0 1.0
--0.5 1.0 -2.0 1.5 1.0
--0.5 0.0 -2.0 1.5 0.0
-
-// A2
-
- 2.0 1.0 -2.0 2.0 1.0
- 2.0 0.0 -2.0 2.0 0.0
- 0.5 0.0 -2.0 0.5 0.0
- 2.0 1.0 -2.0 2.0 1.0
- 0.5 1.0 -2.0 0.5 1.0
- 0.5 0.0 -2.0 0.5 0.0
-
-// B1
-
--2.0 1.0 2.0 2.0 1.0
--2.0 0.0 2.0 2.0 0.0
--0.5 0.0 2.0 0.5 0.0
--2.0 1.0 2.0 2.0 1.0
--0.5 1.0 2.0 0.5 1.0
--0.5 0.0 2.0 0.5 0.0
-
-// B2
-
- 2.0 1.0 2.0 2.0 1.0
- 2.0 0.0 2.0 2.0 0.0
- 0.5 0.0 2.0 0.5 0.0
- 2.0 1.0 2.0 2.0 1.0
- 0.5 1.0 2.0 0.5 1.0
- 0.5 0.0 2.0 0.5 0.0
-
-// C1
-
--2.0 1.0 -2.0 0.0 1.0
--2.0 0.0 -2.0 0.0 0.0
--2.0 0.0 -0.5 1.5 0.0
--2.0 1.0 -2.0 0.0 1.0
--2.0 1.0 -0.5 1.5 1.0
--2.0 0.0 -0.5 1.5 0.0
-
-// C2
-
--2.0 1.0 2.0 2.0 1.0
--2.0 0.0 2.0 2.0 0.0
--2.0 0.0 0.5 0.5 0.0
--2.0 1.0 2.0 2.0 1.0
--2.0 1.0 0.5 0.5 1.0
--2.0 0.0 0.5 0.5 0.0
-
-// D1
-
-2.0 1.0 -2.0 0.0 1.0
-2.0 0.0 -2.0 0.0 0.0
-2.0 0.0 -0.5 1.5 0.0
-2.0 1.0 -2.0 0.0 1.0
-2.0 1.0 -0.5 1.5 1.0
-2.0 0.0 -0.5 1.5 0.0
-
-// D2
-
-2.0 1.0 2.0 2.0 1.0
-2.0 0.0 2.0 2.0 0.0
-2.0 0.0 0.5 0.5 0.0
-2.0 1.0 2.0 2.0 1.0
-2.0 1.0 0.5 0.5 1.0
-2.0 0.0 0.5 0.5 0.0
-
-// Upper hallway - L
--0.5 1.0 -3.0 0.0 1.0
--0.5 0.0 -3.0 0.0 0.0
--0.5 0.0 -2.0 1.0 0.0
--0.5 1.0 -3.0 0.0 1.0
--0.5 1.0 -2.0 1.0 1.0
--0.5 0.0 -2.0 1.0 0.0
-
-// Upper hallway - R
-0.5 1.0 -3.0 0.0 1.0
-0.5 0.0 -3.0 0.0 0.0
-0.5 0.0 -2.0 1.0 0.0
-0.5 1.0 -3.0 0.0 1.0
-0.5 1.0 -2.0 1.0 1.0
-0.5 0.0 -2.0 1.0 0.0
-
-// Lower hallway - L
--0.5 1.0 3.0 0.0 1.0
--0.5 0.0 3.0 0.0 0.0
--0.5 0.0 2.0 1.0 0.0
--0.5 1.0 3.0 0.0 1.0
--0.5 1.0 2.0 1.0 1.0
--0.5 0.0 2.0 1.0 0.0
-
-// Lower hallway - R
-0.5 1.0 3.0 0.0 1.0
-0.5 0.0 3.0 0.0 0.0
-0.5 0.0 2.0 1.0 0.0
-0.5 1.0 3.0 0.0 1.0
-0.5 1.0 2.0 1.0 1.0
-0.5 0.0 2.0 1.0 0.0
-
-
-// Left hallway - Lw
-
--3.0 1.0 0.5 1.0 1.0
--3.0 0.0 0.5 1.0 0.0
--2.0 0.0 0.5 0.0 0.0
--3.0 1.0 0.5 1.0 1.0
--2.0 1.0 0.5 0.0 1.0
--2.0 0.0 0.5 0.0 0.0
-
-// Left hallway - Hi
-
--3.0 1.0 -0.5 1.0 1.0
--3.0 0.0 -0.5 1.0 0.0
--2.0 0.0 -0.5 0.0 0.0
--3.0 1.0 -0.5 1.0 1.0
--2.0 1.0 -0.5 0.0 1.0
--2.0 0.0 -0.5 0.0 0.0
-
-// Right hallway - Lw
-
-3.0 1.0 0.5 1.0 1.0
-3.0 0.0 0.5 1.0 0.0
-2.0 0.0 0.5 0.0 0.0
-3.0 1.0 0.5 1.0 1.0
-2.0 1.0 0.5 0.0 1.0
-2.0 0.0 0.5 0.0 0.0
-
-// Right hallway - Hi
-
-3.0 1.0 -0.5 1.0 1.0
-3.0 0.0 -0.5 1.0 0.0
-2.0 0.0 -0.5 0.0 0.0
-3.0 1.0 -0.5 1.0 1.0
-2.0 1.0 -0.5 0.0 1.0
-2.0 0.0 -0.5 0.0 0.0 \ No newline at end of file
diff --git a/data/test/ortho.lua b/data/test/ortho.lua
deleted file mode 100644
index 9342641..0000000
--- a/data/test/ortho.lua
+++ b/dev/null
@@ -1,81 +0,0 @@
-
-require 'test.nehe.nehelib'
-
-xrot, yrot, zrot = 0, 0, 0
-my_texture = nil
-
-function drawGLScene(interpolation)
- glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT)
-
- glMatrixMode(GL_PROJECTION); glLoadIdentity()
- gluPerspective(45.0, 640/480, 0.1, 100.0)
- glMatrixMode(GL_MODELVIEW); glLoadIdentity()
-
- glTranslate(0, 0, -5)
- glRotate(xrot + (interpolation * 0.3), 1, 0, 0)
- glRotate(yrot + (interpolation * 0.2), 0, 1, 0)
- glRotate(zrot + (interpolation * 0.4), 0, 0, 1)
-
- glBindTexture(GL_TEXTURE_2D, my_texture)
-
- glBegin(GL_QUADS)
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, 1, 1)
- glTexCoord(1, 0); glVertex( 1, 1, 1)
-
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 1); glVertex(-1, -1, -1)
- glTexCoord(0, 1); glVertex( 1, -1, -1)
-
- glTexCoord(1, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 0); glVertex(-1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, 1)
-
- glTexCoord(1, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 0); glVertex( 1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, -1)
-
- glTexCoord(1, 1); glVertex(-1, 1, 1)
- glTexCoord(0, 1); glVertex(-1, 1, -1)
- glTexCoord(0, 0); glVertex(-1, -1, -1)
- glTexCoord(1, 0); glVertex(-1, -1, 1)
-
- glTexCoord(1, 1); glVertex( 1, 1, -1)
- glTexCoord(0, 1); glVertex( 1, 1, 1)
- glTexCoord(0, 0); glVertex( 1, -1, 1)
- glTexCoord(1, 0); glVertex( 1, -1, -1)
- glEnd()
-
- glMatrixMode(GL_PROJECTION); glLoadIdentity()
- glOrtho(0, 4, 0, 3, -1, 1)
- glMatrixMode(GL_MODELVIEW); glLoadIdentity()
- glBegin(GL_TRIANGLES) glVertex(1, 0, 0) glVertex(2, 1, 0) glVertex(3, 0, 0) glEnd()
-end
-
-function computeFrame()
- xrot = xrot + 0.3
- yrot = yrot + 0.2
- zrot = zrot + 0.4
-end
-
-initScreen()
-
-glShadeModel(GL_SMOOTH)
-glClearColor(0, 0, 0, 0)
-glClearDepth(1)
-glEnable(GL_DEPTH_TEST)
-glDepthFunc(GL_LEQUAL)
-glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
-glEnable(GL_TEXTURE_2D)
-
-my_texture = glGenTextures(1)
-glBindTexture(GL_TEXTURE_2D, my_texture)
-loadImage('test/nehe/nehe.bmp'):glTexImage2D()
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
-glTexParameter(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
-
-NeheLoop:new():run()
diff --git a/data/test/pack.lua b/data/test/pack.lua
deleted file mode 100644
index 0b97636..0000000
--- a/data/test/pack.lua
+++ b/dev/null
@@ -1,263 +0,0 @@
-
--- based on <http://www.inf.puc-rio.br/~roberto/struct/teststruct>
-
-local a,b,c,d,e,f,x
-
-assert(#string.pack("C", 67324752) == 4)
-
-assert(string.pack('a', 10) == "\010")
-assert(string.pack('aaa', 10, 20, 30) == "\010\020\030")
-
-assert(string.pack('<b', 10) == string.char(10, 0))
-assert(string.pack('>b', 10) == string.char(0, 10))
-assert(string.pack('<b', -10) == string.char(256-10, 256-1))
-
-assert(string.pack('<c', 10) == string.char(10, 0, 0, 0))
-assert(string.pack('>c', 10) == string.char(0, 0, 0, 10))
-assert(string.pack('<c', -10) == string.char(256-10, 256-1, 256-1, 256-1))
-
-assert(string.unpack(string.char(10, 0), '<b') == 10)
-assert(string.unpack(string.char(0, 10), '>b') == 10)
-assert(string.unpack(string.char(256-10, 256-1), '<b') == -10)
-
-assert(string.unpack(string.char(10, 0, 0, 1), '<c') == 10 + 2^(3*8))
-assert(string.unpack(string.char(0, 1, 0, 10), '>c') == 10 + 2^(2*8))
-assert(string.unpack(string.char(256-10, 256-1, 256-1, 256-1), '<c') == -10)
-
--- limits
-lims = {{'A', 255}, {'a', 127}, {'a', -128},
- {'B', 2^16 - 1}, {'b', 2^15 - 1}, {'b', -2^15},
- {'C', 2^32 - 1}, {'c', 2^31 - 1}, {'c', -2^31},
- -- 2^64-1 would work, but doesn't fit accurately in a lua_Number
- -- this is a rounding error, it can't be fixed by string.pack
- {'D', 2^63}, {'d', 2^62}, {'d', -2^62},
- }
-
-if #string.pack('l', 1) == 4 then -- 32-bit tests
- for _,v in pairs{
- {'H', 255}, {'h', 127}, {'h', -128},
- {'W', 2^16 - 1}, {'w', 2^15 - 1}, {'w', -2^15},
- {'I', 2^32 - 1}, {'i', 2^31 - 1}, {'i', -2^31},
- {'L', 2^32 - 1}, {'l', 2^31 - 1}, {'l', -2^31},
- } do table.insert(lims, v) end
-end
-
-for _, a in pairs{'', '>', '<'} do
- for _, l in pairs(lims) do
- local fmt = a .. l[1]
- assert(string.unpack(string.pack(fmt, l[2]), fmt) == l[2], fmt.." failed")
- end
-end
-
-
--- tests for fixed-sized ints
-for i, c in pairs{[1]='a',[2]='b',[4]='c'} do
- x = string.pack('<'..c, -3)
- assert(string.len(x) == i, i.." failed")
- assert(x == string.char(256-3) .. string.rep(string.char(256-1), i-1), i.." failed")
- assert(string.unpack(x, '<'..c) == -3, i.." failed")
-end
-
-
--- alignment
-d = string.pack("F", 5.1)
-ali = {[1] = string.char(1)..d,
- [2] = string.char(1, 0)..d,
- [4] = string.char(1, 0, 0, 0)..d,
- [8] = string.char(1, 0, 0, 0, 0, 0, 0, 0)..d,
- }
-
-for a,r in pairs(ali) do
- assert(string.pack(a.."!aF", 1, 5.1) == r, a.." failed")
- local x,y = string.unpack(r, a.."!aF")
- assert(x == 1 and y == 5.1, a.." failed")
-end
-
-
--- strings
-assert(string.unpack("alo alo", "s") == "") -- unspecified length
-assert(string.pack("s", "alo alo") == "alo alo")
-assert(pcall(string.pack, "4s", "alo alo") == false)
-assert(string.pack("z", "alo alo") == "alo alo\0")
-assert(string.pack("4z", "alo alo") == "alo ")
-assert(string.pack("5z", "alo alo") == "alo a")
-assert(string.pack("10z", "alo alo") == "alo alo\0\0\0")
-for _,fmt in pairs{'7s', 'z', '7z', '10z'} do
- assert(string.unpack(string.pack(fmt, "alo alo"), fmt) == "alo alo", fmt.." failed")
-end
-for _,fmt in pairs{'4z', '5z'} do -- small lengths, incomplete information packed
- local x = string.pack(fmt, "alo alo")
- assert(string.unpack(x, fmt) == x, fmt.." failed")
-end
-assert(string.pack("4!a>7s", 1, "alo alo") == "\1alo alo")
-assert(string.pack("2!<z", "alo alo") == "alo alo\0")
-assert(string.pack("0s", "alo alo") == "alo alo")
-for _, f in pairs{"H", "l", "b", "A"} do
- for _, s in pairs{"", "a", "alo", string.rep("x", 200)} do
- local x = string.pack("S"..f, s)
- assert(string.unpack(x, "S"..f) == s, f.." "..s:sub(1,5).." failed")
- end
-end
-
--- tables
-x = "\0\0\0\1\0\2\0\3alo\4\0"
-a, b = string.unpack(x, "<x2bSab", true, 2)
-assert(b == #x)
-assert(table.concat(a, ',') == '1,2,alo,4' and a[3] == "alo")
-assert(string.pack("<3x2bSab", a) == x)
-
--- offsets
-x = string.pack("!>iiiii", 1, 2, 3, 4, 5)
-local i, k = 0, 1
-while i < #x do
- local v, j = string.unpack(x, "!>i", i)
- assert(j == i + 4 and v == k, k.." failed")
- i = j; k = k + 1
-end
-
--- alignments are *not* relative to 'absolute' positions
-x = string.pack("8! xd", 12)
-assert(string.unpack(x, "8! 3xd") == 12)
-assert(string.unpack(x, "8! d", 3) ~= 12)
-x = string.pack("2! xb", 2)
-assert(string.unpack(x, "2! xb") == 2)
-assert(string.unpack(x, "2! b", 1) == 2*256)
-assert(string.unpack(x, "2! b", 2) == 2)
-
-
-assert(string.pack("<cbaxxB", -2, 10, -10, 250) ==
- "\254\255\255\255\010\000\246\000\000\250\000")
-
-a,b,c,d = string.unpack("\254\255\255\255\010\000\246\000\000\250\000", "<cbaxxB")
-assert(a == -2 and b == 10 and c == -10 and d == 250)
-
-assert(string.pack(">cAxxB", -20, 10, 250) == "\255\255\255\236\10\0\0\0\250")
-
-a, b, c, d = string.unpack("\255\255\255\236\10\0\0\0\250", ">cAxxB")
-assert(a == -20 and b == 10 and c == 250 and d == 9)
-
-a,b,c,d,e = string.unpack(
- '000'..string.pack(">fFfB", 3.5, -24e-5, 200.5, 30000),
- ">fFfB", 3)
-assert(a == 3.5 and b == -24e-5 and c == 200.5 and d == 30000 and e == 21)
-
-a,b,c,d,e = string.unpack(
- '000'..string.pack("<fFxxfB", -13.5, 24e5, 200.5, 300),
- "<fFxxfB", 3)
-assert(a == -13.5 and b == 24e5 and c == 200.5 and d == 300 and e == 23)
-
-x = string.pack(">BfcB", 10, 20, -30, 40001)
-assert(string.len(x) == 2+4+4+2)
-assert(string.unpack(x, ">f", 2) == 20)
-a,b,c,d = string.unpack(x, ">bfcB") -- "B"/"b" [sic]
-assert(a == 10 and b == 20 and c == -30 and d == 40001)
-
-local s = "hello hello"
-x = string.pack("Sh", s)
-assert(string.unpack(x, "Sh") == s)
-x = string.pack("SL", s)
-assert(string.unpack(x, " S L ") == s)
-x = string.pack("1z 3z a", s, s, 0)
-assert(x == "hhel\0")
-assert(string.unpack(x, "4xa") == 0)
-assert(string.unpack(x, "z") == "hhel")
-a, b = string.unpack(x.."\042", "za")
-assert(a == "hhel" and b == 42)
-
-if #string.pack('l', 1) == 4 and #string.pack('!xl', 1) == 8 then
- assert(string.pack("<!l", 3) == "\3\0\0\0")
- assert(string.pack("<!xl", 3) == "\0\0\0\0\3\0\0\0")
- assert(string.pack("<!xxl", 3) == "\0\0\0\0\3\0\0\0")
- assert(string.pack("<!xxxl", 3) == "\0\0\0\0\3\0\0\0")
-
- assert(string.unpack("\3\0\0\0", "<!l") == 3)
- assert(string.unpack("\0\0\0\0\3\0\0\0", "<!xl") == 3)
- assert(string.unpack("\0\0\0\0\3\0\0\0", "<!xxl") == 3)
- assert(string.unpack("\0\0\0\0\3\0\0\0", "<!xxxl") == 3)
-
- assert(string.pack("<2! h l w", 2, 3, 5) == "\2\0\3\0\0\0\5\0")
- a,b,c = string.unpack("\2\0\3\0\0\0\5\0", "<2!hlw")
- assert(a == 2 and b == 3 and c == 5)
-
- assert(string.pack("<8!hlw", 2, 3, 5) == "\2\0\0\0\3\0\0\0\5\0")
- a,b,c = string.unpack("\2\0\0\0\3\0\0\0\5\0", "<8!hlw")
- assert(a == 2 and b == 3 and c == 5)
-else
- print "Skipping 32bit-only tests"
-end
-
-assert(string.pack(">zb", "aloi", 3) == "aloi\0\0\3")
-assert(string.pack(">!zb", "aloi", 3) == "aloi\0\0\0\3")
-x = "aloi\0\0\0\0\3\2\0\0"
-a, b, c = string.unpack(x, "<!zc")
-assert(a == "aloi" and b == 2*256+3 and c == string.len(x))
-
-x = string.pack("4!zzz", "hi", "hello", "bye")
-a,b,c = string.unpack(x, "zzz")
-assert(a == "hi" and b == "hello" and c == "bye")
-a, i = string.unpack(x, "z", 0)
-assert(a == "hi")
-a, i = string.unpack(x, "z", i)
-assert(a == "hello")
-a, i = string.unpack(x, "z", i)
-assert(a == "bye")
-
-
-
--- test for weird conditions
-assert(string.pack(">>>b <!!!<b", 10, 10) == "\000\010\010\000")
-assert(string.pack("<3!xc", 10) == "\000\000\000\010\000\000\000")
-assert(string.unpack("\2ab", "(comment)\nS\t(1a) A ()") == "ab")
-assert(not pcall(string.pack, "Sf", "alo"))
-assert(not pcall(string.pack, "S4L", "alo"))
-assert(not pcall(string.pack, "3", 10))
-assert(not pcall(string.pack, "aa", 6))
-assert(not pcall(string.pack, "(comment "))
-assert(not pcall(string.pack, ")"))
-assert(select('#', string.unpack("\1\2\3\4\5", "aa\0aa")) == 3)
-assert(pcall(string.pack, "", 1, 2, nil, 3, 4))
-assert(not pcall(string.pack, "e", 10))
-assert(string.pack("<=b", 8) == string.pack(">=b", 8))
-assert(string.pack("") == "")
-assert(string.pack(" ") == "")
-assert(string.pack(">>><<<!!") == "")
-assert(not pcall(string.unpack, "alo", "S"))
-assert(not pcall(string.unpack, "alo", "z"))
-assert(string.unpack("alo\0", "z") == "alo")
-assert(not pcall(string.pack, "4s", "alo"))
-assert(pcall(string.pack, "3s", "alo"))
-assert(not pcall(string.unpack, "alo", "4s"))
-assert(pcall(string.unpack, "alo", "3s"))
-assert(not pcall(string.unpack, "\4alo", "Sh"))
-assert(pcall(string.unpack, "\3alo", "Sh"))
-
-assert(not pcall(string.unpack, "alo", "a", 4))
-assert(not pcall(string.unpack, "alo", "a", 3))
-assert(string.unpack("alo\3", "a", 3) == 3)
-
--- test lightuserdata access
-if SDL then
- x = SDL.RWFromNewMem(8)
- string.pack(x:baseptr(), x:stopptr(), "<CSa", 192, "Abc")
- assert(assert(x:read(8)) == "\192\0\0\0\003Abc"); assert(x:seek('set'))
- a, b, c = string.unpack(x:baseptr(), x:stopptr(), "<CSa")
- assert(a == 192 and b == "Abc" and c == 8)
- a, b, c = string.unpack(x:baseptr(), 8, "<CSa")
- assert(a == 192 and b == "Abc" and c == 8)
- for i = 1, 7 do
- assert(x:seek('set', i))
- assert(not pcall(string.unpack, x:baseptr(), x:hereptr(), "<CSa"),
- i.." failed")
- assert(not pcall(string.unpack, x:baseptr(), i, "<CSa"),
- i.." failed")
- assert(not pcall(string.unpack, x:hereptr(), x:stopptr(), "<CSa"),
- i.." failed")
- assert(not pcall(string.unpack, x:baseptr(), x:stopptr(), "<CSa", i),
- i.." failed")
- end
-else
- print "Skipping userdata tests"
-end
-
-print'OK'
-
diff --git a/data/userrc.lua b/data/userrc.lua
deleted file mode 100644
index e69de29..0000000
--- a/data/userrc.lua
+++ b/dev/null
diff --git a/src/ftgl.c b/src/ftgl.c
deleted file mode 100644
index 7b1d4bf..0000000
--- a/src/ftgl.c
+++ b/dev/null
@@ -1,301 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <SDL_opengl.h>
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#include "ftgl.h"
-
-struct _FTGL_Glyph {
- long tex_x, tex_y; // glyph coordinates on the texture (in pixels)
- double l, r, u, d; // glyph coordinates (in texture coordinates) - left, right, up, down
- long w, h;
- long offleft, offtop, advance; // bitmap offset (left, top) and glyph advance
- long character; // UCS character code of the glyph
- FT_UInt ft_index; // Freetype internal glyph index (this isn't the same thing as gid)
-};
-
-static int increase_texture_size(FTGL_Font* font) {
- int y;
- int new_tex_size = font->texture_size * 2;
- int new_pitch, old_pitch;
- unsigned char* new_tex_data = (unsigned char *)malloc(2 * new_tex_size * new_tex_size);
- if(!new_tex_data) {
- free((void *)font->texture_data); font->texture_data = NULL;
- return 0;
- }
- memset(new_tex_data, 0, 2 * new_tex_size * new_tex_size);
- new_pitch = new_tex_size * 2; old_pitch = font->texture_size * 2;
- for(y = 0; y < font->texture_size; y++)
- memcpy(&new_tex_data[new_pitch*y], &font->texture_data[old_pitch*y], old_pitch); // copy one line from the old texture
- free((void *)font->texture_data);
- font->texture_size = new_tex_size;
- font->texture_data = new_tex_data;
- return 1;
-}
-
-static int render_glyph(FTGL_Font* font, long ch) {
- int gx, gy, w, tex_pos;
- long gid;
- FT_UInt ft_index;
- FT_GlyphSlot gslot; // glyph slot, provided by Freetype
- struct _FTGL_Glyph* glyph; // glyph data inside struct font_t
-
- ft_index = FT_Get_Char_Index(font->face, ch);
-
- if(FT_Load_Glyph(font->face, ft_index, FT_LOAD_RENDER) != 0)
- return 1; // ignore errors, only don't load the glyph
-
- if(font->num_glyphs == font->num_allocated_glyphs) { /* allocate more glyphs */
- font->num_allocated_glyphs += 8;
- font->glyph = (struct _FTGL_Glyph *)realloc(font->glyph, font->num_allocated_glyphs * sizeof(struct _FTGL_Glyph));
- if(!font->glyph) return 0;
- memset(font->glyph + font->num_glyphs, 0, (font->num_allocated_glyphs - font->num_glyphs) * sizeof(struct _FTGL_Glyph));
- }
-
- gid = font->num_glyphs;
- font->num_glyphs++;
-
- gslot = font->face->glyph;
- w = gslot->bitmap.width + 2;
- if(font->pen_x + w > font->texture_size) {
- font->pen_x = 0; font->pen_y += font->height;
- }
- if(font->pen_y + font->height > font->texture_size) {
- if(increase_texture_size(font) != 1) return 0; // need bigger texture
- }
- glyph = &font->glyph[gid];
- glyph->w = gslot->bitmap.width; glyph->h = gslot->bitmap.rows;
- glyph->tex_x = font->pen_x; glyph->tex_y = font->pen_y;
- glyph->offleft = gslot->bitmap_left; glyph->offtop = gslot->bitmap_top - glyph->h;
- glyph->advance = gslot->advance.x >> 6; glyph->character = ch;
- glyph->ft_index = ft_index;
- for(gy = 0; gy < glyph->h; gy++) {
- for(gx = 0; gx < glyph->w; gx++) {
- tex_pos = 2 * (font->pen_x+gx + font->texture_size*(font->pen_y+gy)); // bpp*(x+w*y)
- // texture is GL_LUMINANCE_ALPHA. luminance is always 1
- font->texture_data[tex_pos] = 255;
- font->texture_data[tex_pos + 1] = gslot->bitmap.buffer[gx + gy*gslot->bitmap.pitch];
- }
- }
- font->pen_x += w;
- return 1;
-}
-
-static void save_texture(FTGL_Font* font) {
- int i;
- if(font->texture)
- glBindTexture(GL_TEXTURE_2D, font->texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, font->texture_size, font->texture_size, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, font->texture_data);
- /* re-compute texture coordinates of glyphs */
- for(i = 0; i < font->num_glyphs; i++) {
- font->glyph[i].l = 1.0 / font->texture_size * (font->glyph[i].tex_x);
- font->glyph[i].r = 1.0 / font->texture_size * (font->glyph[i].tex_x + font->glyph[i].w);
- font->glyph[i].u = 1.0 / font->texture_size * (font->glyph[i].tex_y);
- font->glyph[i].d = 1.0 / font->texture_size * (font->glyph[i].tex_y + font->glyph[i].h);
- }
-}
-
-static long get_kerning(FTGL_Font *font, int prev_gid, int gid) {
- FT_Vector delta;
- if(!(font->use_kerning && prev_gid && gid))
- return 0;
- FT_Get_Kerning(font->face, font->glyph[prev_gid].ft_index,
- font->glyph[gid].ft_index, FT_KERNING_DEFAULT, &delta);
- return (delta.x >> 6);
-}
-
-static void draw_underline(FTGL_Font *font, double x1, double x2) {
- int y = FT_MulFix(font->face->underline_position, font->face->size->metrics.y_scale) >> 6;
- glPushAttrib(GL_ENABLE_BIT);
- glDisable(GL_TEXTURE_2D);
- glBegin(GL_LINES); glVertex2d(x1, y); glVertex2d(x2, y); glEnd();
- glPopAttrib();
-}
-
-static long utf8_to_ucs(const char* str) {
- unsigned char ch = *((const unsigned char *)str);
- if(ch < 0xC0)
- return ch;
- if(ch < 0xE0) {
- if(!str[1]) return ch;
- return (((long)(str[0] & 0x1F)) << 6) | ((long)(str[1] & 0x3F));
- }
- if(ch < 0xF0) {
- if(!str[1] || !str[2]) return ch;
- return (((long)(str[0] & 0x1F)) << 12) | (((long)(str[1] & 0x3F)) << 6) |
- ((long)(str[2] & 0x3F));
- }
- if(ch < 0xFA) {
- if(!str[1] || !str[2] || !str[3]) return ch;
- return (((long)(str[0] & 0x07)) << 18) | (((long)(str[1] & 0x3F)) << 12) |
- (((long)(str[2] & 0x3F)) << 6) | ((long)(str[3] & 0x3F));
- }
- if(ch < 0xFC) {
- if(!str[1] || !str[2] || !str[3] || !str[4]) return ch;
- return (((long)(str[0] & 0x07)) << 24) | (((long)(str[1] & 0x3F)) << 18) |
- (((long)(str[2] & 0x3F)) << 12) | (((long)(str[3] & 0x3F)) << 6) |
- ((long)(str[4] & 0x3F));
- }
- if(ch < 0xFE) {
- if(!str[1] || !str[2] || !str[3] || !str[4] || !str[5]) return ch;
- return (((long)(str[0] & 0x07)) << 30) | (((long)(str[1] & 0x3F)) << 24) |
- (((long)(str[2] & 0x3F)) << 18) | (((long)(str[3] & 0x3F)) << 12) |
- (((long)(str[4] & 0x3F)) << 6) | ((long)(str[5] & 0x3F));
- }
- return ch;
-}
-
-FTGL_Font* FTGL_Create(FT_Face face, int initial_texture_size, unsigned int texture_id, int use_kerning) {
- int ch;
- FTGL_Font* font = (FTGL_Font *)malloc(sizeof(FTGL_Font));
- if(!font) return NULL;
- memset(font, 0, sizeof(*font));
- font->face = face; font->texture = texture_id;
- font->texture_size = initial_texture_size;
- font->height = (face->size->metrics.height + 63) >> 6;
- font->ascent = (FT_MulFix(face->bbox.yMax, face->size->metrics.y_scale) + 63) >> 6;
- font->descent = FT_MulFix(face->bbox.yMin, face->size->metrics.y_scale) >> 6;
- font->use_kerning = use_kerning && FT_HAS_KERNING(face);
- font->num_allocated_glyphs = 96;
- font->glyph = (struct _FTGL_Glyph *)malloc(font->num_allocated_glyphs * sizeof(struct _FTGL_Glyph));
- if(!font->glyph) { FTGL_Destroy(font); return NULL; }
- memset(font->glyph, 0, font->num_allocated_glyphs * sizeof(struct _FTGL_Glyph));
- font->texture_data = (unsigned char *)malloc(2 * initial_texture_size * initial_texture_size);
- if(!font->texture_data) { FTGL_Destroy(font); return NULL; }
- memset(font->texture_data, 0, 2 * initial_texture_size * initial_texture_size);
- for(ch = 32; ch < 127; ch++) { // render ASCII glyphs
- if(render_glyph(font, ch) == 0) { FTGL_Destroy(font); return NULL; }
- }
- save_texture(font);
- return font;
-}
-
-void FTGL_Destroy(FTGL_Font* font) {
- if(!font)
- return;
- free((void *)font->glyph);
- free((void *)font->texture_data);
- memset(font, 0, sizeof(*font));
- free((void *)font);
-}
-
-long FTGL_Prepare(FTGL_Font* font, const char* str) {
- long i, j, ucs;
- long length = 0;
- int changed = 0, gid, prev_gid = 0;
- if(!font->glyph || !font->texture_data) return -1;
- for(i = 0; str[i]; i++) {
- if((((const unsigned char*)str)[i] & 0xC0) == 0x80) // incomplete part of an UTF-8 character
- continue;
- if(str[i] > 0 && str[i] < 127) // standard ASCII; rendered in FTGL_Create
- gid = str[i] - 32;
- else {
- gid = -1;
- ucs = utf8_to_ucs(&str[i]);
- for(j = 95; j < font->num_glyphs; j++)
- if(font->glyph[j].character == ucs)
- gid = j;
- if(gid == -1) {
- if(render_glyph(font, ucs) == 0) return -1;
- changed = 1;
- if(font->glyph[font->num_glyphs-1].character == ucs)
- gid = font->num_glyphs-1;
- }
- }
- if(gid != -1) {
- length += get_kerning(font, prev_gid, gid); prev_gid = gid;
- length += font->glyph[gid].advance;
- }
- }
- if(changed)
- save_texture(font); // save new glyphs
- return length;
-}
-
-void FTGL_Print(FTGL_Font* font, const char* str, int underline) {
- struct _FTGL_Glyph *glyph;
- int gid, prev_gid = 0;
- int active_underline = 0;
- long i, j, ucs, length = 0;
-
- if(!font->glyph || !font->texture_data) return;
-
- if(font->texture)
- glBindTexture(GL_TEXTURE_2D, font->texture);
-
- if(underline < 1 || underline > 126)
- underline = 0;
-
- for(i = 0; str[i]; i++) {
- if((((const unsigned char *)str)[i] & 0xC0) == 0x80) // incomplete part of an UTF-8 character
- continue;
-
- if(str[i] == underline && underline > 1) {
- active_underline = 1;
- continue;
- }
-
- if(str[i] > 0 && str[i] < 127)
- gid = str[i] - 32;
- else {
- gid = -1;
- ucs = utf8_to_ucs(&str[i]);
- for(j = 95; j < font->num_glyphs; j++)
- if(font->glyph[j].character == ucs)
- gid = j;
- if(gid == -1) // not found (this only happens if FTGL_Prepare wasn't used)
- continue;
- }
-
- if(font->use_kerning) {
- j = get_kerning(font, prev_gid, gid);
- length += j;
- glTranslated(j, 0, 0);
- }
- prev_gid = gid;
-
- glyph = &font->glyph[gid];
-#if 1
- if(glyph->w != 0) {
- glTranslated(glyph->offleft, glyph->offtop, 0);
- glBegin(GL_QUADS);
- glTexCoord2d(glyph->l, glyph->d); glVertex2d(0, 0);
- glTexCoord2d(glyph->r, glyph->d); glVertex2d(glyph->w, 0);
- glTexCoord2d(glyph->r, glyph->u); glVertex2d(glyph->w, glyph->h);
- glTexCoord2d(glyph->l, glyph->u); glVertex2d(0, glyph->h);
- glEnd();
- glTranslated(-glyph->offleft, -glyph->offtop, 0);
- }
- if(active_underline && glyph->advance != 0)
- draw_underline(font, 0, glyph->advance);
- active_underline = 0;
- glTranslated(glyph->advance, 0, 0);
- length += glyph->advance;
-#else
-#define SC (1.0/font->height)
- if(glyph->w != 0) {
- glTranslated(glyph->offleft*SC, glyph->offtop*SC, 0);
- glBegin(GL_QUADS);
- glTexCoord2d(glyph->l, glyph->d); glVertex2d(0, 0);
- glTexCoord2d(glyph->r, glyph->d); glVertex2d(glyph->w*SC, 0);
- glTexCoord2d(glyph->r, glyph->u); glVertex2d(glyph->w*SC, glyph->h*SC);
- glTexCoord2d(glyph->l, glyph->u); glVertex2d(0, glyph->h*SC);
- glEnd();
- glTranslated(-glyph->offleft*SC, -glyph->offtop*SC, 0);
- }
- if(active_underline && glyph->advance != 0)
- draw_underline(font, 0, glyph->advance*SC);
- active_underline = 0;
- glTranslated(glyph->advance*SC, 0, 0);
- length += glyph->advance*SC;
-#endif
- }
- if(underline == 1)
- draw_underline(font, -length, 0);
-}
-
diff --git a/src/ftgl.h b/src/ftgl.h
deleted file mode 100644
index 1a6a0ba..0000000
--- a/src/ftgl.h
+++ b/dev/null
@@ -1,107 +0,0 @@
-
-#ifndef _FTGL_H
-#define _FTGL_H
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-struct _FTGL_Glyph;
-
-typedef struct _FTGL_Font {
- unsigned int texture; // OpenGL texture ID
- int texture_size; // current texture size
- long height; // font height (distance between baselines)
- long ascent; // max dist. between baseline and glyph top
- long descent; // max dist. between baseline and glyph bottom
- FT_Face face; // the Freetype face object
- int use_kerning; // whether the font uses kerning
-
- // private part starts here
- struct _FTGL_Glyph *glyph; // rendered glyph data
- int num_glyphs; // n.o. rendered glyphs
- int num_allocated_glyphs; // size of the glyph array
-
- int pen_x, pen_y; // glyph renderer state (current pen position)
- unsigned char* texture_data; // glyph renderer state (font texture image)
-} FTGL_Font;
-
-/**
- * creates a new FTGL_Font object.
- *
- * FTGL_Font keeps an OpenGL texture that contains glyphs from a font face,
- * and can use this texture to render a string in OpenGL.
- *
- * 'face' is the Freetype face which will be rendered. It should already have
- * a size (use something like FT_Set_Char_Size(face, 0, size*64, 0, 96)).
- *
- * 'initial_texture_size' is the initial size of the texture. (It must be a
- * power of two.) If the texture isn't big enough for all required glyphs,
- * it'll automatically grow. (This is an expensive operation, and textures can
- * be used more effectively when already created with the correct size.)
- * You can query the current texture size with font->texture_size.
- *
- * Kerning is used if 'use_kerning' is true and the face supports it.
- *
- * The only things FTGL does with textures is glBindTexture and glTexImage2D.
- * Creating and deleting textures must be done by you.
- *
- * As a side effect, this function changes current bound texture to
- * 'texture_id'.
- *
- * This function renders all ASCII characters. If the printed strings contain
- * Unicode, you must FTGL_Prepare each string to render them.
- *
- * This function returns NULL in case of errors.
- */
-FTGL_Font* FTGL_Create(FT_Face face, int initial_texture_size, unsigned int texture_id, int use_kerning);
-
-/**
- * destroys a FTGL_Font object.
- *
- * This doesn't destroy the OpenGL texture nor the FT_Face object.
- */
-void FTGL_Destroy(FTGL_Font* font);
-
-/**
- * prints a string.
- *
- * It prints the string using OpenGL at the current position (0,0,0).
- *
- * This doesn't use any Freetype functions. All glyphs in the string must
- * already be rendered and inside the font->glyph array. Use FTGL_Prepare to
- * make sure all characters in the string are already rendered.
- *
- * 'string' should be in UTF-8. Non-ASCII characters will be converted to UCS
- * automatically.
- *
- * If 'underline' is 0, the string isn't underlined. If 'underline' is 1, the
- * whole string is underlined. If 'underline' is an ASCII code (other than 0
- * and 1), it's a special character that, when found in 'string', underlines
- * the following glyph.
- *
- * As a side effect, this function changes current bound texture to the font
- * texture, and translates the current GL position to the end of the string.
- *
- * This function might not work correctly if the following is not enabled:
- * glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,
- * GL_ONE_MINUS_SRC_ALPHA);
- */
-void FTGL_Print(FTGL_Font* font, const char* string, int underline);
-
-/**
- * prepares a string for printing.
- *
- * If the string contains Unicode glyphs that weren't rendered yet, this
- * renders them and stores them in the font texture (expanding it if it isn't
- * big enough).
- *
- * Every string should be FTGL_Prepare'd at least once before printing. It
- * isn't needed to call FTGL_Prepare every frame, however.
- *
- * On success, FTGL_Prepare returns the string's width. (Thus, it can be used
- * to measure string sizes before printing them.) If it returns -1, a memory
- * error occured and the font is invalid (it can't be used anymore).
- */
-long FTGL_Prepare(FTGL_Font* font, const char* string);
-
-#endif
diff --git a/src/gengl.lua b/src/gengl.lua
deleted file mode 100644
index 97d4fee..0000000
--- a/src/gengl.lua
+++ b/dev/null
@@ -1,1298 +0,0 @@
-
-dofile(arg[0]:gsub('[^/\\]+$', '')..'../data/core/extlib.lua')
-
--- HOW TO USE.
--- cat /usr/include/{GL/{gl,glu},SDL/SDL_opengl}.h | lua gengl.lua lgllib > lgllib.c
--- cat /usr/include/SDL/SDL_*.h | lua gengl.lua lsdllib > lsdllib.c
--- (under MinGW, use /mingw/include instead of /usr/include)
-
-function write_output_lsdllib()
- check_funcs = {
- int = 'luaL_checkinteger(L, @n)',
- Uint8 = 'luaL_checkinteger(L, @n)',
- Uint16 = 'luaL_checkinteger(L, @n)',
- Uint32 = 'luaL_checkinteger(L, @n)',
- size_t = 'luaL_checkinteger(L, @n)',
- SDL_GrabMode = 'luaL_checkinteger(L, @n)',
- SDL_GLattr = 'luaL_checkinteger(L, @n)',
- float = 'luaL_checknumber(L, @n)',
- double = 'luaL_checknumber(L, @n)',
- ['SDL_Rect*'] = '&checkrect(L, @n)',
- ['const char*'] = 'luaL_checkstring(L, @n)',
- ['SDL_Surface*'] = '*((SDL_Surface **) luaL_checkudata(L, @n, "SDL_Surface"))',
- ['Mix_Chunk*'] = '*((Mix_Chunk **) luaL_checkudata(L, @n, "Mix_Chunk"))',
- ['SDL_RWops*'] = 'checkrwops(L, @n)',
- }
-
- return_codes = {
- int = 'lua_pushinteger(L, @b);',
- Uint8 = 'lua_pushinteger(L, @b);',
- Uint16 = 'lua_pushinteger(L, @b);',
- Uint32 = 'lua_pushinteger(L, @b);',
- SDL_GrabMode = 'lua_pushinteger(L, @b);',
- SDL_GLattr = 'luaL_checkinteger(L, @n)',
- float = 'lua_pushnumber(L, @b);',
- double = 'lua_pushnumber(L, @b);',
- ['const char*'] = 'lua_pushstring(L, @b);',
- void = '@v;',
- }
-
- Assert0 = '(void)(@v && luaL_error(L, "%s", SDL_GetError()));'
- AssertTrue = '(void)(@v || luaL_error(L, "%s", SDL_GetError()));'
-
- BoolPush = 'lua_pushboolean(L, @b);'
- BoolCheck = 'checkboolean(L, @n)'
-
- io.write([[
-/* auto-generated by gengl.lua */
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <lua.h>
-#include <lauxlib.h>
-
-#include <SDL.h>
-#include <SDL_image.h>
-#include <SDL_mixer.h>
-
-#include "glproto.h"
-
-static GLboolean checkboolean(lua_State *L, int narg) {
-]].. --[=[ TODO: this may not be right. can SDL funcs handle integers other than 1?
- (this was made like this because SDL_EnableUNICODE, SDL_WM_GrabInput and others
- use 0 and 1 (false and true) for setting states and -1 for querying.) ]=] [[
- return lua_isnumber(L, narg) ? lua_tointeger(L, narg) : lua_toboolean(L, narg);
-}
-
-static int wrapped_seek(SDL_RWops *my, int offset, int whence) {
- SDL_RWops *orig = (SDL_RWops *)my->hidden.mem.here;
- if(!orig) return -1;
- return SDL_RWseek(orig, offset, whence);
-}
-
-static int wrapped_read(SDL_RWops *my, void *ptr, int size, int maxnum) {
- SDL_RWops *orig = (SDL_RWops *)my->hidden.mem.here;
- if(!orig) return -1;
- return SDL_RWread(orig, ptr, size, maxnum);
-}
-
-static int wrapped_write(SDL_RWops *my, const void *ptr, int size, int maxnum) {
- SDL_RWops *orig = (SDL_RWops *)my->hidden.mem.here;
- if(!orig) return -1;
- return SDL_RWwrite(orig, ptr, size, maxnum);
-}
-
-static int wrapped_close(SDL_RWops *my) {
- if(!my) return 0;
- SDL_RWops *orig = (SDL_RWops *)my->hidden.mem.here;
- if(!orig) return -1;
- if(SDL_RWclose(orig) != 0) return -1;
- my->hidden.mem.here = NULL; // forget wrapper->origRWops link
- if(my->hidden.mem.base) // forget userdata->wrapper link
- *(SDL_RWops **)my->hidden.mem.base = NULL;
- my->hidden.mem.base = NULL; // forget wrapper->userdata link
- SDL_FreeRW(my);
- return 0;
-}
-
-SDL_RWops *checkrwops (lua_State *L, int narg) {
- SDL_RWops **r = (SDL_RWops **) luaL_checkudata(L, narg, "SDL_RWops");
- luaL_argcheck(L, *r, narg, "RWops already closed");
- return *r;
-}
-
-void disown_rwops(SDL_RWops **handle) {
- if(!*handle) return;
- (*handle)->hidden.mem.base = NULL; // forget wrapper->userdata link
- *handle = NULL; // forget userdata->wrapper link
-}
-
-static SDL_RWops **wrap_rwops(lua_State *L, SDL_RWops *orig) {
- SDL_RWops *wrapper = SDL_AllocRW();
- if(wrapper == NULL) luaL_error(L, "out of memory");
- SDL_RWops **handle = (SDL_RWops **) lua_newuserdata(L, sizeof(SDL_RWops *));
- *handle = wrapper; // make userdata->wrapper link
- luaL_getmetatable(L, "SDL_RWops"); lua_setmetatable(L, -2);
- wrapper->seek = wrapped_seek;
- wrapper->read = wrapped_read;
- wrapper->write = wrapped_write;
- wrapper->close = wrapped_close;
- wrapper->hidden.mem.base = (void *)handle; // make wrapper->origRWops link
- wrapper->hidden.mem.here = (void *)orig; // make wrapper->userdata link
- return handle;
-}
-
-SDL_Surface **wrap_surface (lua_State *L, SDL_Surface *surface) {
- SDL_Surface **handle = (SDL_Surface **) lua_newuserdata(L, sizeof(SDL_Surface *));
- *handle = surface;
- luaL_getmetatable(L, "SDL_Surface"); lua_setmetatable(L, -2);
- return handle;
-}
-
-Mix_Chunk **wrap_chunk (lua_State *L, Mix_Chunk *chunk) {
- Mix_Chunk **handle = (Mix_Chunk **) lua_newuserdata(L, sizeof(Mix_Chunk *));
- *handle = chunk;
- luaL_getmetatable(L, "Mix_Chunk"); lua_setmetatable(L, -2);
- return handle;
-}
-
-static int _newmem_close(SDL_RWops *rw) {
- if(rw) {
- if(rw->hidden.mem.base)
- free(rw->hidden.mem.base);
- rw->hidden.mem.base = NULL;
- SDL_FreeRW(rw);
- }
- return 0;
-}
-
-SDL_RWops* wrapRWFromNewMem(size_t size) {
- SDL_RWops *rw;
- void *mem = malloc(size);
- if(mem == NULL) return NULL;
- memset(mem, 0, size);
- rw = SDL_RWFromMem(mem, size);
- if(rw == NULL) { free(mem); return NULL; }
- rw->close = _newmem_close;
- return rw;
-}
-
-SDL_Rect *checkrect(lua_State *L, int narg, SDL_Rect *r) {
- luaL_checktype(L, narg, LUA_TTABLE);
- lua_rawgeti(L, narg, 1); r->x = luaL_checkinteger(L, -1);
- lua_rawgeti(L, narg, 2); r->y = luaL_checkinteger(L, -1);
- lua_rawgeti(L, narg, 3); r->w = luaL_optinteger(L, -1, 0);
- lua_rawgeti(L, narg, 4); r->h = luaL_optinteger(L, -1, 0);
- lua_pop(L, 4);
- return r;
-}
-
-#define evfield(name, val) (lua_pushinteger(L, event->val), lua_setfield(L, -2, #name))
-void pushevent (lua_State *L, SDL_Event *event) {
- lua_newtable(L);
-
- evfield(type, type);
-
- switch(event->type) {
- case SDL_ACTIVEEVENT:
- lua_pushboolean(L, event->active.gain); lua_setfield(L, -2, "gain");
- evfield(state, active.state);
- break;
-
- case SDL_KEYDOWN:
- case SDL_KEYUP:
- evfield(sym, key.keysym.sym);
- evfield(mod, key.keysym.mod);
- evfield(unicode, key.keysym.unicode);
- break;
-
- case SDL_MOUSEMOTION:
- evfield(x, motion.x); evfield(y, motion.y);
- evfield(xrel, motion.xrel); evfield(yrel, motion.yrel);
- evfield(buttons, motion.state);
- break;
-
- case SDL_MOUSEBUTTONDOWN:
- case SDL_MOUSEBUTTONUP:
- evfield(button, button.button);
- evfield(x, button.x); evfield(y, button.y);
- break;
-
- case SDL_VIDEORESIZE:
- evfield(w, resize.w); evfield(h, resize.h);
- break;
-
- default:
- /* the other event types don't have any values */
- break;
- }
-}
-
-static Uint32 getpixel(SDL_Surface *surface, int x, int y)
-{
- /* this function is from the SDL docs available at www.libsdl.org */
-
- int bpp = surface->format->BytesPerPixel;
- /* Here p is the address to the pixel we want to retrieve */
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
-
- switch(bpp) {
- case 1: return *p;
- case 2: return *(Uint16 *)p;
- case 3: if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
- return p[0] << 16 | p[1] << 8 | p[2];
- else
- return p[0] | p[1] << 8 | p[2] << 16;
- case 4: return *(Uint32 *)p;
- default: return 0; /* shouldn't happen, but avoids warnings */
- }
-}
-
-static int wrapSetVideoMode(int w, int h, int fullscreen) {
- if(SDL_SetVideoMode(w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0)) == NULL)
- return 0;
- if(!glproto_connect()) return 0;
- return 1;
-}
-
-static SDL_Surface* wrapCreateRGBSurface(int w, int h) {
- return SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000);
-}
-
-static int wrapFillRect(SDL_Surface *s, int r, int g, int b, SDL_Rect *rect) {
- return SDL_FillRect(s, rect, SDL_MapRGB(s->format, r, g, b));
-}
-
-static int wrapglTexImage2D (SDL_Surface *s, int want_mipmap) {
- /* NOTE: since glTexImage2D expect image data to be from bottom to top, I can't just supply surface->pixels.
- * (Many people work around it by transforming the texture matrix, but I don't like that workaround.)
- * Thus, I manually convert the data to the format OpenGL wants.
- * (This also has the advantage that I can use any pixel formats I want, including BPP<3, because I use
- * SDL's own SDL_GetRGB functions and don't access surface->pixels directly.)
- */
- /* I found the basic idea for the code here:
- * http://www.nabble.com/SDL_Surface---3E-OpenGL-texture-only-works-with-RGBA--to14212148.html
- */
- int alpha = (s->format->BytesPerPixel == 4);
- int texture_type = alpha ? GL_RGBA : GL_RGB;
- int x, y;
- int pos = 0;
- int lock = SDL_MUSTLOCK(s);
- GLubyte *data = (GLubyte *)malloc(s->w * s->h * (alpha ? 4 : 3));
- if(data == NULL) { SDL_SetError("out of memory"); return -1; }
- if((s->w & (s->w - 1)) != 0) {
- SDL_SetError("surface's width isn't a power of two");
- return -1;
- }
- if((s->h & (s->h - 1)) != 0) {
- SDL_SetError("surface's height isn't a power of two");
- return -1;
- }
- if(lock) SDL_LockSurface(s);
- for(y = s->h - 1; y >= 0; y--) {
- for(x = 0; x < s->w; x++) {
- if(alpha) {
- SDL_GetRGBA(getpixel(s, x, y), s->format, &data[pos+0], &data[pos+1], &data[pos+2], &data[pos+3]);
- pos += 4;
- } else {
- SDL_GetRGB(getpixel(s, x, y), s->format, &data[pos+0], &data[pos+1], &data[pos+2]);
- pos += 3;
- }
- }
- }
- if(lock) SDL_UnlockSurface(s);
-
- glTexImage2D(GL_TEXTURE_2D, 0, texture_type, s->w, s->h, 0, texture_type, GL_UNSIGNED_BYTE, data);
- if(want_mipmap)
- gluBuild2DMipmaps(GL_TEXTURE_2D, texture_type, s->w, s->h, texture_type, GL_UNSIGNED_BYTE, data);
-
- free((void *)data);
- return 0;
-}
-
-static int is_memrwops(SDL_RWops *rw) {
- static int (*mem_seek)(struct SDL_RWops *, int, int) = NULL;
- if (mem_seek == NULL) {
- SDL_RWops *memrw = SDL_RWFromConstMem(NULL, 0);
- mem_seek = memrw->seek;
- SDL_RWclose(memrw);
- }
- return (rw->seek == mem_seek);
-}
-
-static int rwops_baseptr(lua_State *L) {
- SDL_RWops *rw = checkrwops(L, 1);
- while(rw->close == wrapped_close) rw = (SDL_RWops *)rw->hidden.mem.here;
- luaL_argcheck(L, is_memrwops(rw), 1, "expected memory buffer RWops");
- lua_pushlightuserdata(L, rw->hidden.mem.base);
- return 1;
-}
-
-static int rwops_hereptr(lua_State *L) {
- SDL_RWops *rw = checkrwops(L, 1);
- while(rw->close == wrapped_close) rw = (SDL_RWops *)rw->hidden.mem.here;
- luaL_argcheck(L, is_memrwops(rw), 1, "expected memory buffer RWops");
- lua_pushlightuserdata(L, rw->hidden.mem.here);
- return 1;
-}
-
-static int rwops_stopptr(lua_State *L) {
- SDL_RWops *rw = checkrwops(L, 1);
- while(rw->close == wrapped_close) rw = (SDL_RWops *)rw->hidden.mem.here;
- luaL_argcheck(L, is_memrwops(rw), 1, "expected memory buffer RWops");
- lua_pushlightuserdata(L, rw->hidden.mem.stop);
- return 1;
-}
-
-const void* check_const_ptr(lua_State *L, int narg) {
- if(lua_isstring(L, narg))
- return (const void *)lua_tolstring(L, narg, NULL);
- luaL_argcheck(L, lua_type(L, narg) == LUA_TLIGHTUSERDATA, narg, "expected pointer");
- return lua_touserdata(L, narg);
-}
-
-void *check_ptr(lua_State *L, int narg) {
- luaL_argcheck(L, lua_type(L, narg) == LUA_TLIGHTUSERDATA, narg, "expected pointer");
- return lua_touserdata(L, narg);
-}
-
-int rwops_disown_fn(lua_State *L) {
- disown_rwops((SDL_RWops **) luaL_checkudata(L, 1, "SDL_RWops"));
- return 0;
-}
-
-static size_t rw_maxlen(SDL_RWops *rw) {
- size_t current = SDL_RWtell(rw);
- size_t maxlen = SDL_RWseek(rw, 0, RW_SEEK_END) - current;
- SDL_RWseek(rw, current, RW_SEEK_SET);
- return maxlen;
-}
-
-static int rwops_read (lua_State *L) {
- SDL_RWops *rw = checkrwops(L, 1);
- size_t len, nread;
- void *s;
- len = luaL_optinteger(L, 2, rw_maxlen(rw));
- s = malloc(len * sizeof(char));
- if(s == NULL) luaL_error(L, "out of memory");
- memset(s, 0, len * sizeof(char));
- nread = SDL_RWread(rw, s, sizeof(char), len);
- lua_pushinteger(L, nread);
- if(nread != len) {
- lua_pushnil(L);
- lua_pushstring(L, SDL_GetError());
- lua_pushlstring(L, (const char *)s, nread);
- free(s);
- return 3;
- }
- lua_pushlstring(L, (const char *)s, nread);
- free(s);
- return 1;
-}
-
-static int rwops_write (lua_State *L) {
- SDL_RWops *rw = checkrwops(L, 1);
- size_t len, nwrote;
- const char *s;
- if(lua_type(L, 2) == LUA_TLIGHTUSERDATA) {
- s = (const char *)lua_touserdata(L, 2);
- len = luaL_checkinteger(L, 3);
- }
- else {
- s = luaL_checklstring(L, 2, &len);
- len = luaL_optinteger(L, 3, len);
- }
- nwrote = SDL_RWwrite(rw, s, 1, len);
- if(nwrote != len) {
- lua_pushnil(L);
- lua_pushstring(L, SDL_GetError());
- lua_pushinteger(L, nwrote);
- return 3;
- }
- lua_pushboolean(L, 1);
- return 1;
-}
-
-static int rwops_seek(lua_State *L) {
- static const int mode[] = {RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END};
- static const char *const modenames[] = {"set", "cur", "end", NULL};
- SDL_RWops *rw = checkrwops(L, 1);
- int op = luaL_checkoption(L, 2, "cur", modenames);
- int result = SDL_RWseek(rw, luaL_optlong(L, 3, 0), mode[op]);
- if(result < 0) {
- lua_pushnil(L);
- lua_pushstring(L, SDL_GetError());
- return 2;
- }
- lua_pushinteger(L, result);
- return 1;
-}
-
-static int rwops_gc (lua_State *L) {
- SDL_RWops **r = (SDL_RWops **) luaL_checkudata(L, 1, "SDL_RWops");
- if(r && *r) {
- SDL_RWclose(*r);
- *r = NULL;
- }
- return 0;
-}
-]])
- local b = {}; setmetatable(b, { __index = function (_, fn)
- return function (...) io.write(Bind(fn, ...), "\n\n") end
- end })
-
- b.SDL_GL_SwapBuffers{}
- b.SDL_GetTicks{}
- b.SDL_Delay{}
- b.SDL_WM_GrabInput{}
- b.SDL_WM_SetCaption{ [1] = { opt = 'NULL' }, [2] = { opt = 'NULL' } }
- b.SDL_WM_SetIcon{ [2] = { check_func = 'NULL' } --[[ TODO make variable second argument) ]] }
- b.SDL_WM_ToggleFullScreen{ return_code = AssertTrue, [1] = { check_func = 'SDL_GetVideoSurface()' } }
- b.SDL_EnableUNICODE{ return_code = BoolPush, [1] = { check_func = BoolCheck } }
- b.SDL_EnableKeyRepeat{ return_code = Assert0 }
- b.SDL_WarpMouse{}
- b.SDL_ShowCursor{ return_code = BoolPush, [1] = { check_func = BoolCheck } }
- b.SDL_GetMouseState{ Returns=1 }
- b.SDL_PollEvent{ [1] = { check_func = '&e' }, return_code = 'SDL_Event e;'..
- '\nif(@b == 0)\n lua_pushnil(L);\nelse\n pushevent(L, &e);' }
- b.SDL_WaitEvent{ [1] = { check_func = '&e' }, return_code = 'SDL_Event e;'..
- '\n(void)(@b || luaL_error(L, "%s", SDL_GetError()));\npushevent(L, &e);' }
- b.SDL_PumpEvents{}
- b.wrapCreateRGBSurface{
- prototype = { return_type = 'SDL_Surface*', argtypes = { 'int', 'int' } },
- return_code = 'SDL_Surface *s = @b;\n(void)(s || luaL_error(L, "%s", SDL_GetError()));\nwrap_surface(L, s);' }
- b.SDL_GL_SetAttribute{ return_code = Assert0 }
- b.SDL_GL_GetAttribute{ return_code = Assert0, Returns=1 }
- b.wrapSetVideoMode{ return_code = AssertTrue, prototype = { return_type = 'int', argtypes = { 'int', 'int', 'int' } },
- [3] = { check_func = BoolCheck, opt = 0 } }
- b.SDL_RWFromFile{ return_code =
- 'SDL_RWops *rw = @b;\n(void)(rw || luaL_error(L, "%s", SDL_GetError()));\nwrap_rwops(L, rw);' }
- b.SDL_RWFromMem{ [1] = { check_func = 'check_ptr(L, @n)' }, return_code =
- 'SDL_RWops *rw = @b;\n(void)(rw || luaL_error(L, "%s", SDL_GetError()));\nwrap_rwops(L, rw);' }
- b.wrapRWFromNewMem{ prototype = { return_type = 'SDL_RWops*', argtypes = { 'size_t' } }, return_code =
- 'SDL_RWops *rw = @b;\n(void)(rw || luaL_error(L, "out of memory"));\nwrap_rwops(L, rw);' }
-
- b.Mix_PlayChannelTimed{ [1] = { opt = -1 }, [3] = { opt = 0 }, [4] = { opt = -1 }, return_code =
- 'int r = @b;\n(void)(r == -1 && luaL_error(L, "%s", SDL_GetError()));\nlua_pushinteger(L, r);' }
- b.Mix_FadeInChannelTimed{ [1] = { opt = -1 }, [3] = { opt = 0 }, [5] = { opt = -1 }, return_code =
- 'int r = @b;\n(void)(r == -1 && luaL_error(L, "%s", SDL_GetError()));\nlua_pushinteger(L, r);' }
- b.Mix_AllocateChannels{ [1] = { opt = -1 } }
- b.Mix_Volume{ [1] = { opt = -1 }, [2] = { opt = -1 } }
- b.Mix_VolumeChunk{ [2] = { opt = -1 } }
- b.Mix_FadeOutChannel{ [1] = { opt = -1 } }
- b.Mix_FadingChannel{ return_code = return_codes.int } -- TODO: make sure enum Mix_Fading is available
- b.Mix_Pause{}
- b.Mix_Resume{}
- b.Mix_Paused{ return_code = BoolPush }
- b.Mix_Playing{ return_code = BoolPush }
- b.Mix_HaltChannel{ return_code = '@v;' }
- b.Mix_ExpireChannel{ [1] = { opt = -1 } }
- b.Mix_ReserveChannels{}
- b.Mix_GroupChannel{ [2] = { opt = -1 }, return_code = AssertTrue }
- b.Mix_GroupChannels{ [3] = { opt = -1 }, return_code = AssertTrue }
- b.Mix_GroupCount{ [1] = { opt = -1 } }
- b.Mix_GroupAvailable{ [1] = { opt = -1 } }
- b.Mix_GroupOldest{ [1] = { opt = -1 } }
- b.Mix_GroupNewer{ [1] = { opt = -1 } }
- b.Mix_FadeOutGroup{ [1] = { opt = -1 } }
- b.Mix_HaltGroup{ return_code = '@v;' }
-
- b.IMG_Load_RW{ [2] = { check_func = BoolCheck },
- return_code = 'SDL_Surface *s = @b;\n(void)(s || luaL_error(L, "%s", SDL_GetError()));\nwrap_surface(L, s);' }
- b.Mix_LoadWAV_RW{ [2] = { check_func = BoolCheck },
- return_code = 'Mix_Chunk *c = @b;\n(void)(c || luaL_error(L, "%s", SDL_GetError())); wrap_chunk(L, c);' }
-
- b.wrapFillRect{ [5] = { opt = 'NULL', check_func = 'checkrect(L, @n, &r)' }, return_code = 'SDL_Rect r;\n'..Assert0,
- prototype = { return_type = 'int', argtypes = { 'SDL_Surface*', 'int', 'int', 'int', 'SDL_Rect*' } } }
- b.SDL_SetAlpha{}
- b.SDL_w{ base_call = '(@a)->w', prototype = { return_type = 'int', argtypes = { 'SDL_Surface*' } } }
- b.SDL_h{ base_call = '(@a)->h', prototype = { return_type = 'int', argtypes = { 'SDL_Surface*' } } }
- b.SDL_BlitSurface{ return_code = 'SDL_Rect rect1, rect2;\n'..Assert0,
- prototype = { return_type = 'int', argtypes = { 'SDL_Surface*', 'SDL_Rect*', 'SDL_Surface*', 'SDL_Rect*' } },
- [2] = { opt = 'NULL', check_func = 'checkrect(L, @n, &rect1)' },
- [4] = { opt = 'NULL', check_func = 'checkrect(L, @n, &rect2)' } }
- b.wrapglTexImage2D{ return_code = Assert0, prototype = { return_type = 'int', argtypes = { 'SDL_Surface*', 'int' } }, [2] = { check_func = BoolCheck } --[[ TODO arg2 default=false (I think) ]] }
- b.SDL_FreeSurface{ base_call = 'SDL_Surface *s = @a; if(s && (SDL_GetVideoSurface() != s)) SDL_FreeSurface(s)' }
- b.Mix_FreeChunk{}
-
- local nobind = { Mix_FreeChunk=true, SDL_FreeSurface=true, IMG_Load_RW=true }
-
- local function regitem(n,v) io.write(' { "', n, '", ', v, ' },\n') end
- io.write[[
-int luaopen_SDL(lua_State *L) {
- int i;
- const luaL_Reg reg_SDL[] = {
-]]
- for _,f in ipairs(bindlist) do if not nobind[f] then regitem(f:sub(5), 'b_'..f) end end
- io.write[[
- { "IMG_Load_RW", b_IMG_Load_RW },
- { "PlayChannel", b_Mix_PlayChannelTimed },
- { "FadeInChannel", b_Mix_FadeInChannelTimed },
- { NULL, NULL }
- };
- const luaL_Reg reg_RWops[] = {
- { "read", rwops_read },
- { "write", rwops_write },
- { "seek", rwops_seek },
- { "close", rwops_gc },
- { "disown", rwops_disown_fn },
- { "baseptr", rwops_baseptr },
- { "hereptr", rwops_hereptr },
- { "stopptr", rwops_stopptr },
- { "__gc", rwops_gc },
- { NULL, NULL }
- };
- struct {
- const char *name;
- lua_Integer value;
- } const_sdl[] = {
-]]
- for c in Input:gsub('\n[^#][^\n]*', ''):gmatch('\n# *define *SDL_[%w_]*%s+%d+[^\n]*') do
- regitem(c:match('SDL_([%w_]*)'), c:match('SDL_[%w_]*%s*(.*)')) end
- for c in Input:gsub('\n[^#][^\n]*', ''):gmatch('\n# *define *KMOD_[%w_]*[^\n]*') do
- regitem(c:match('KMOD_[%w_]*'), c:match('KMOD_[%w_]*%s*(.*)')) end
- for e in Input:gsub('\n#[^\n]*', ''):gmatch('%Wenum%s*[%w_]*%s*(%b{})') do
- for c in e:gsub('^', ','):gmatch(',%s*([%w_]+)') do
- regitem(c:gsub('^SDL_?', ''), c) end end
- io.write[[
- { NULL, 0 }
- };
-
- lua_settop(L, 0);
-
- luaL_register(L, "SDL", reg_SDL);
- for(i = 0; const_sdl[i].name; i++) {
- lua_pushinteger(L, const_sdl[i].value);
- lua_setfield(L, 1, const_sdl[i].name);
- }
-
- luaL_newmetatable(L, "SDL_Surface");
- lua_pushvalue(L, 1); lua_setfield(L, -2, "__index"); /* metatable.__index = SDL */
- lua_pushcfunction(L, b_SDL_FreeSurface); lua_setfield(L, -2, "__gc");
-
- luaL_newmetatable(L, "Mix_Chunk");
- lua_pushvalue(L, 1); lua_setfield(L, -2, "__index");
- lua_pushcfunction(L, b_Mix_FreeChunk); lua_setfield(L, -2, "__gc");
-
- luaL_newmetatable(L, "SDL_RWops");
- lua_pushvalue(L, -1); lua_setfield(L, -2, "__index");
- luaL_register(L, NULL, reg_RWops);
-
- lua_settop(L, 1);
- return 1;
-}
-]]
-end
-
-function write_output_lgllib()
- check_funcs = {
- GLenum = 'checkenum(L, @n)',
- GLbitfield = 'luaL_checkinteger(L, @n)',
- GLboolean = 'checkboolean(L, @n)',
- GLbyte = 'luaL_checkinteger(L, @n)',
- GLubyte = 'luaL_checkinteger(L, @n)',
- GLshort = 'luaL_checkinteger(L, @n)',
- GLushort = 'luaL_checkinteger(L, @n)',
- GLint = 'luaL_checkinteger(L, @n)',
- GLuint = 'luaL_checkinteger(L, @n)',
- GLsizei = 'luaL_checkinteger(L, @n)',
- GLfloat = 'luaL_checknumber(L, @n)',
- GLclampf = 'luaL_checknumber(L, @n)',
- GLdouble = 'luaL_checknumber(L, @n)',
- GLclampd = 'luaL_checknumber(L, @n)',
- ['const GLubyte*'] = '(const GLubyte *)luaL_checkstring(L, @n)',
- ['GLUnurbs*'] = '*((GLUnurbs **) luaL_checkudata(L, @n, "GLUnurbs"))',
- ['GLUquadric*'] = '*((GLUquadric **) luaL_checkudata(L, @n, "GLUquadric"))',
- ['GLUtesselator*'] = '*((GLUtesselator **) luaL_checkudata(L, @n, "GLUtesselator"))',
- }
-
- return_codes = {
- GLenum = 'lua_pushinteger(L, @b);',
- GLbitfield = 'lua_pushinteger(L, @b);',
- GLboolean = 'lua_pushboolean(L, @b);',
- GLbyte = 'lua_pushinteger(L, @b);',
- GLubyte = 'lua_pushinteger(L, @b);',
- GLshort = 'lua_pushinteger(L, @b);',
- GLushort = 'lua_pushinteger(L, @b);',
- GLint = 'lua_pushinteger(L, @b);',
- GLuint = 'lua_pushinteger(L, @b);',
- GLsizei = 'lua_pushinteger(L, @b);',
- GLfloat = 'lua_pushnumber(L, @b);',
- GLclampf = 'lua_pushnumber(L, @b);',
- GLdouble = 'lua_pushnumber(L, @b);',
- GLclampd = 'lua_pushnumber(L, @b);',
- ['const GLubyte*'] = 'lua_pushstring(L, (const char *)@b);',
- void = '@v;',
- }
-
- io.write[[
-/* auto-generated by gengl.lua */
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <lua.h>
-#include <lauxlib.h>
-
-#include <SDL_opengl.h>
-
-#include "glproto.h"
-
-/* from lsdllib.c */
-const void* check_const_ptr(lua_State *L, int narg);
-void* check_ptr(lua_State *L, int narg);
-
-GLenum checkenum(lua_State *L, int narg) {
- if(lua_type(L, narg) == LUA_TSTRING) {
- GLenum e;
- lua_getglobal(L, "gl");
- if(!lua_istable(L, -1)) luaL_error(L, "can't find global table gl");
- lua_pushvalue(L, narg);
- lua_gettable(L, -2);
- if(!lua_isnumber(L, -1)) luaL_argerror(L, narg, "invalid GL constant");
- e = lua_tointeger(L, -1);
- lua_pop(L, 2);
- return e;
- }
- return luaL_checkinteger(L, narg);
-}
-
-GLboolean checkboolean(lua_State *L, int narg) {
- return lua_isnumber(L, narg) ? (lua_tointeger(L, narg) != GL_FALSE) :
- lua_toboolean(L, narg);
-}
-
-]]
- local b = {}; setmetatable(b, { __index = function (_, fn)
- return function (...) io.write(Bind(fn, ...), "\n\n") end
- end })
- b.glClearIndex{}
- b.glClearColor{}
- b.glClear{}
- b.glIndexMask{}
- b.glColorMask{}
- b.glAlphaFunc{}
- b.glBlendFunc{}
- b.glLogicOp{}
- b.glCullFace{}
- b.glFrontFace{}
- b.glPointSize{}
- b.glLineWidth{}
- b.glLineStipple{}
- b.glPolygonMode{}
- b.glPolygonOffset{}
--- glPolygonStipple glGetPolygonStipple TODO (maybe)
- b.glEdgeFlag{}
--- glEdgeFlagv
- b.glScissor{}
- b.glClipPlane{ Array=4 }
- b.glGetClipPlane{ Returns=4 }
- b.glDrawBuffer{}
- b.glReadBuffer{}
- b.glEnable{}
- b.glDisable{}
- b.glIsEnabled{}
- b.glEnableClientState{}
- b.glDisableClientState{}
- b.glGetBooleanv{ suffix=1, Returns=16 }
- b.glGetDoublev{ suffix=1, Returns=16 }
- b.glGetIntegerv{ suffix=1, Returns=16 }
- b.glPushAttrib{}
- b.glPopAttrib{}
- b.glPushClientAttrib{}
- b.glPopClientAttrib{}
- b.glRenderMode{}
- b.glGetError{}
- b.glGetString{}
- b.glFinish{}
- b.glFlush{}
- b.glHint{}
- b.glClearDepth{}
- b.glDepthFunc{}
- b.glDepthMask{}
- b.glDepthRange{}
- b.glClearAccum{}
- b.glAccum{}
- b.glMatrixMode{}
- b.glOrtho{}
- b.glFrustum{}
- b.glViewport{}
- b.glPushMatrix{}
- b.glPopMatrix{}
- b.glLoadIdentity{}
- b.glLoadMatrixd{ suffix=1, Array=16 }
--- glLoadMatrixf
- b.glMultMatrixd{ suffix=1, Array=16 }
--- glMultMatrixf
- b.glRotated{ suffix=1 }
--- glRotatef
- b.glScaled{ suffix=1 }
--- glScalef
- b.glTranslated{ suffix=1 }
--- glTranslatef
- b.glIsList{}
- b.glDeleteLists{}
- b.glGenLists{}
- b.glNewList{}
- b.glEndList{}
- b.glCallList{}
- b.glCallLists{ Buffer=true }
- b.glListBase{}
- b.glBegin{}
- b.glEnd{}
- -- glVertex, glNormal, glIndex, glColor, glTexCoord, glRasterPos,
- -- glRect: only one variant
- b.glVertex4dv{ suffix=3, Array=4, defaults='{ 0, 0, 0, 1 }' }
- b.glNormal3dv{ suffix=3, Array=3 }
- b.glIndexd{ suffix=1 }
- b.glColor4dv{ suffix=3, Array=4, defaults='{ 0, 0, 0, 1 }' }
- b.glColor4ubv{ suffix=1, Array=4, defaults='{ 0, 0, 0, 255 }' }
- b.glTexCoord4dv{ suffix=3, Array=4, defaults='{ 0, 0, 0, 1 }' }
- b.glRasterPos4dv{ suffix=3, Array=4, defaults='{ 0, 0, 0, 1 }' }
- b.glRectd{ suffix=1 }
- b.glVertexPointer{ Buffer=true }
- b.glNormalPointer{ Buffer=true }
- b.glColorPointer{ Buffer=true }
- b.glIndexPointer{ Buffer=true }
- b.glTexCoordPointer{ Buffer=true }
- b.glEdgeFlagPointer{ Buffer=true }
--- glGetPointerv maybe TODO?
- b.glArrayElement{}
- b.glDrawArrays{}
- b.glDrawElements{ Buffer=true }
- b.glInterleavedArrays{ Buffer=true }
- b.glShadeModel{}
--- glLightf
--- glLighti
- b.glLightfv{ suffix=2, Array=4, defaults=true }
--- glLightiv
- b.glGetLightfv{ suffix=2, Returns=4 }
--- glGetLightiv
--- glLightModelf
--- glLightModeli
- b.glLightModelfv{ suffix=2, Array=4, defaults=true }
--- glLightModeliv
--- glMaterialf
--- glMateriali
- b.glMaterialfv{ suffix=2, Array=4, defaults=true }
--- glMaterialiv
- b.glGetMaterialfv{ suffix=2, Returns=4 }
--- glGetMaterialiv
- b.glColorMaterial{}
- b.glPixelZoom{}
- b.glPixelStoref{ suffix=1 }
--- glPixelStorei
- b.glPixelTransferf{ suffix=1 }
--- glPixelTransferi
- b.glPixelMapfv{ suffix=1, Buffer=true }
- b.glPixelMapuiv{ suffix=1, Buffer=true }
- b.glPixelMapusv{ suffix=1, Buffer=true }
- b.glGetPixelMapfv{ suffix=1, Buffer=true }
- b.glGetPixelMapuiv{ suffix=1, Buffer=true }
- b.glGetPixelMapusv{ suffix=1, Buffer=true }
- b.glBitmap{ Buffer=true }
- b.glReadPixels{ Buffer=true }
- b.glDrawPixels{ Buffer=true }
- b.glCopyPixels{}
- b.glStencilFunc{}
- b.glStencilMask{}
- b.glStencilOp{}
- b.glClearStencil{}
- -- glTexGen, glGetTexGen, glTexEnv, glGetTexEnv, glTexParameter,
- -- glGetTexParameter, glGetTexLevelParameter: only one variant
- b.glTexGendv{ suffix=2, Array=4, defaults=true }
- b.glGetTexGendv{ suffix=2, Returns=4 }
- b.glTexEnvfv{ suffix=2, Array=4, defaults=true }
- b.glGetTexEnvfv{ suffix=2, Returns=4 }
- b.glTexParameterfv{ suffix=2, Array=4, defaults=true }
- b.glGetTexParameterfv{ suffix=2, Returns=4 }
- b.glGetTexLevelParameterfv{ suffix=2, Returns=4 } -- TODO: does this return 4 results?
- b.glTexImage1D{ Buffer=true }
- b.glTexImage2D{ Buffer=true }
- b.glGetTexImage{ Buffer=true }
- b.glGenTextures{ [1] = { Counter=true }, Returns='c1' }
- b.glDeleteTextures{ [1] = { Counter=true }, Array='c1' }
- b.glBindTexture{}
- b.glPrioritizeTextures{ [1] = { Counter=true }, Array='c1' }
- b.glAreTexturesResident{ [1] = { Counter=true }, [2] = { Array='c1' }, [3] = { Returns='c1' } }
- b.glIsTexture{}
- b.glTexSubImage1D{ Buffer=true }
- b.glTexSubImage2D{ Buffer=true }
- b.glCopyTexImage1D{}
- b.glCopyTexImage2D{}
- b.glCopyTexSubImage1D{}
- b.glCopyTexSubImage2D{}
--- glMap1:d maybe TODO
--- glMap1f
--- glMap2:d maybe TODO
--- glMap2f
--- glGetMap:dv maybe TODO
--- glGetMapfv
--- glGetMapiv
- b.glEvalCoord1d{ suffix=1 }
--- glEvalCoord1f
--- glEvalCoord1dv
--- glEvalCoord1fv
- b.glEvalCoord2d{ suffix=1 }
--- glEvalCoord2f
--- glEvalCoord2dv
--- glEvalCoord2fv
- b.glMapGrid1d{ suffix=1 }
--- glMapGrid1f
- b.glMapGrid2d{ suffix=1 }
--- glMapGrid2f
- b.glEvalPoint1{}
- b.glEvalPoint2{}
- b.glEvalMesh1{}
- b.glEvalMesh2{}
--- glFogf
--- glFogi
- b.glFogfv{ suffix=2, Array=4, defaults=true }
--- glFogiv
- b.glFeedbackBuffer{ Buffer=true }
- b.glPassThrough{}
- b.glSelectBuffer{ Buffer=true }
- b.glInitNames{}
- b.glLoadName{}
- b.glPushName{}
- b.glPopName{}
- --[[ *********************************************
- b.glDrawRangeElements{}
- b.glTexImage3D{}
- b.glTexSubImage3D{}
- b.glCopyTexSubImage3D{}
- b.glColorTable{}
- b.glColorSubTable{}
- b.glColorTableParameteriv{}
- b.glColorTableParameterfv{}
- b.glCopyColorSubTable{}
- b.glCopyColorTable{}
- b.glGetColorTable{}
- b.glGetColorTableParameterfv{}
- b.glGetColorTableParameteriv{}
- b.glBlendEquation{}
- b.glBlendColor{}
- b.glHistogram{}
- b.glResetHistogram{}
- b.glGetHistogram{}
- b.glGetHistogramParameterfv{}
- b.glGetHistogramParameteriv{}
- b.glMinmax{}
- b.glResetMinmax{}
- b.glGetMinmax{}
- b.glGetMinmaxParameterfv{}
- b.glGetMinmaxParameteriv{}
- b.glConvolutionFilter1D{}
- b.glConvolutionFilter2D{}
- b.glConvolutionParameterf{}
- b.glConvolutionParameterfv{}
- b.glConvolutionParameteri{}
- b.glConvolutionParameteriv{}
- b.glCopyConvolutionFilter1D{}
- b.glCopyConvolutionFilter2D{}
- b.glGetConvolutionFilter{}
- b.glGetConvolutionParameterfv{}
- b.glGetConvolutionParameteriv{}
- b.glSeparableFilter2D{}
- b.glGetSeparableFilter{}
- b.glActiveTexture{}
- b.glClientActiveTexture{}
- b.glCompressedTexImage1D{}
- b.glCompressedTexImage2D{}
- b.glCompressedTexImage3D{}
- b.glCompressedTexSubImage1D{}
- b.glCompressedTexSubImage2D{}
- b.glCompressedTexSubImage3D{}
- b.glGetCompressedTexImage{}
- b.glMultiTexCoord1d{}
- b.glMultiTexCoord1dv{}
- b.glMultiTexCoord1f{}
- b.glMultiTexCoord1fv{}
- b.glMultiTexCoord1i{}
- b.glMultiTexCoord1iv{}
- b.glMultiTexCoord1s{}
- b.glMultiTexCoord1sv{}
- b.glMultiTexCoord2d{}
- b.glMultiTexCoord2dv{}
- b.glMultiTexCoord2f{}
- b.glMultiTexCoord2fv{}
- b.glMultiTexCoord2i{}
- b.glMultiTexCoord2iv{}
- b.glMultiTexCoord2s{}
- b.glMultiTexCoord2sv{}
- b.glMultiTexCoord3d{}
- b.glMultiTexCoord3dv{}
- b.glMultiTexCoord3f{}
- b.glMultiTexCoord3fv{}
- b.glMultiTexCoord3i{}
- b.glMultiTexCoord3iv{}
- b.glMultiTexCoord3s{}
- b.glMultiTexCoord3sv{}
- b.glMultiTexCoord4d{}
- b.glMultiTexCoord4dv{}
- b.glMultiTexCoord4f{}
- b.glMultiTexCoord4fv{}
- b.glMultiTexCoord4i{}
- b.glMultiTexCoord4iv{}
- b.glMultiTexCoord4s{}
- b.glMultiTexCoord4sv{}
- b.glLoadTransposeMatrixd{}
- b.glLoadTransposeMatrixf{}
- b.glMultTransposeMatrixd{}
- b.glMultTransposeMatrixf{}
- b.glSampleCoverage{}
- b.glActiveTextureARB{}
- b.glClientActiveTextureARB{}
- b.glMultiTexCoord1dARB{}
- b.glMultiTexCoord1dvARB{}
- b.glMultiTexCoord1fARB{}
- b.glMultiTexCoord1fvARB{}
- b.glMultiTexCoord1iARB{}
- b.glMultiTexCoord1ivARB{}
- b.glMultiTexCoord1sARB{}
- b.glMultiTexCoord1svARB{}
- b.glMultiTexCoord2dARB{}
- b.glMultiTexCoord2dvARB{}
- b.glMultiTexCoord2fARB{}
- b.glMultiTexCoord2fvARB{}
- b.glMultiTexCoord2iARB{}
- b.glMultiTexCoord2ivARB{}
- b.glMultiTexCoord2sARB{}
- b.glMultiTexCoord2svARB{}
- b.glMultiTexCoord3dARB{}
- b.glMultiTexCoord3dvARB{}
- b.glMultiTexCoord3fARB{}
- b.glMultiTexCoord3fvARB{}
- b.glMultiTexCoord3iARB{}
- b.glMultiTexCoord3ivARB{}
- b.glMultiTexCoord3sARB{}
- b.glMultiTexCoord3svARB{}
- b.glMultiTexCoord4dARB{}
- b.glMultiTexCoord4dvARB{}
- b.glMultiTexCoord4fARB{}
- b.glMultiTexCoord4fvARB{}
- b.glMultiTexCoord4iARB{}
- b.glMultiTexCoord4ivARB{}
- b.glMultiTexCoord4sARB{}
- b.glMultiTexCoord4svARB{}
- b.glCreateDebugObjectMESA{}
- b.glClearDebugLogMESA{}
- b.glGetDebugLogMESA{}
- b.glGetDebugLogLengthMESA{}
- b.glProgramCallbackMESA{}
- b.glGetProgramRegisterfvMESA{}
- b.glBlendEquationSeparateATI{}
- ********************************************* ]]
- b.gluBeginCurve{}
- b.gluBeginPolygon{}
- b.gluBeginSurface{}
- b.gluBeginTrim{}
--- gluBuild1DMipmapLevels { Buffer=true } -- not present in MinGW glu.h
- b.gluBuild1DMipmaps{ Buffer=true }
--- gluBuild2DMipmapLevels { Buffer=true } -- not present in MinGW glu.h
- b.gluBuild2DMipmaps{ Buffer=true }
--- gluBuild3DMipmapLevels { Buffer=true } -- not present in MinGW glu.h
--- gluBuild3DMipmaps { Buffer=true } -- not present in MinGW glu.h
--- gluCheckExtension -- not present in MinGW glu.h
- b.gluCylinder{}
- b.gluDeleteNurbsRenderer{}
- b.gluDeleteQuadric{}
- b.gluDeleteTess{}
- b.gluDisk{}
- b.gluEndCurve{}
- b.gluEndPolygon{}
- b.gluEndSurface{}
- b.gluEndTrim{}
- b.gluErrorString{}
- b.gluGetNurbsProperty{ [3] = { Returns=1 } }
- b.gluGetString{}
- b.gluGetTessProperty{ [3] = { Returns=1 } }
- b.gluLoadSamplingMatrices { [2] = { Array=16 }, [3] = { Array=16 }, [4] = { Array=4 } }
- b.gluLookAt{}
- local makeud = [[@T **ud = (@T **)lua_newuserdata(L, sizeof(@T *));
-*ud = @b;
-if(*ud == NULL) return luaL_error(L, "out of memory");
-luaL_getmetatable(L, "@T"); lua_setmetatable(L, -2);]]
- b.gluNewQuadric{ return_code = makeud:gsub('@T', 'GLUquadric') }
- b.gluNewNurbsRenderer{ return_code = makeud:gsub('@T', 'GLUnurbs') }
- b.gluNewTess{ return_code = makeud:gsub('@T', 'GLUtesselator') }
- b.gluNextContour{}
--- gluNurbsCallback TODO
--- gluNurbsCallbackData
--- gluNurbsCallbackDataEXT
--- gluNurbsCurve TODO
- b.gluNurbsProperty{}
--- gluNurbsSurface TODO
- b.gluOrtho2D{}
- b.gluPartialDisk{}
- b.gluPerspective{}
- b.gluPickMatrix{ Array=4 }
- b.gluProject{ [4] = { Array=16 }, [5] = { Array=16 }, [6] = { Array=4 }, [7] = { Returns=1 }, [8] = { Returns=1 }, [9] = { Returns=1 } }
--- gluPwlCurve TODO
--- gluQuadricCallback TODO
- b.gluQuadricDrawStyle{}
- b.gluQuadricNormals{}
- b.gluQuadricOrientation{}
- b.gluQuadricTexture{}
- b.gluScaleImage{ Buffer=true }
- b.gluSphere{}
- b.gluTessBeginContour{}
--- gluTessBeginPolygon TODO
--- gluTessCallback TODO
- b.gluTessEndContour{}
- b.gluTessEndPolygon{}
- b.gluTessNormal{}
- b.gluTessProperty{}
--- gluTessVertex TODO
- b.gluUnProject{ [4] = { Array=16 }, [5] = { Array=16 }, [6] = { Array=4 }, [7] = { Returns=1 }, [8] = { Returns=1 }, [9] = { Returns=1 } }
- -- argh! gluUnProject4 isn't present in MinGW libglu32.a
- --b.gluUnProject4{ [5] = { Array=16 }, [6] = { Array=16 }, [7] = { Array=4 }, [10] = { Returns=1 }, [11] = { Returns=1 }, [12] = { Returns=1 }, [13] = { Returns=1 } }
-
- local function regitem(n,v) io.write(' { "', n, '", ', v, ' },\n') end
- io.write[[
-int luaopen_gl(lua_State *L) {
- int i;
- const luaL_Reg reg_gl[] = {
-]]
- for _,f in ipairs(bindlist) do if not f:match('^glu') then
- regitem(f:sub(3), 'b_'..f)
- if boundinfo[f].suffix then
- regitem(f:sub(3, -1-boundinfo[f].suffix), 'b_'..f) end
- end end
- io.write[[
- { NULL, NULL }
- };
- const luaL_Reg reg_glu[] = {
-]]
- for _,f in ipairs(bindlist) do if f:match('^glu') and not f:match('^gluDelete') then
- regitem(f:sub(4), 'b_'..f)
- if boundinfo[f].suffix then
- regitem(f:sub(4, -1-boundinfo[f].suffix), 'b_'..f) end
- end end
- io.write[[
- { NULL, NULL }
- };
- struct {
- const char *name;
- lua_Number value;
- } const_gl[] = {
-]]
- for c in Input:gmatch('\n# *define *GL_[^\n]*') do
- regitem(c:match('GL_([%w_]*)'), c:match('GL_[%w_]* *(.*)'))
- end
- io.write[[
- { NULL, 0 }
- }, const_glu[] = {
-]]
- for c in Input:gmatch('\n# *define *GLU_[^\n]*') do
- regitem(c:match('GLU_([%w_]*)'), c:match('GLU_[%w_]* *(.*)'))
- end
- io.write[[
- { NULL, 0 }
- };
-
- lua_settop(L, 0);
-
- luaL_register(L, "glu", reg_glu);
- lua_pushvalue(L, 1); lua_setglobal(L, "GLU");
- for(i = 0; const_glu[i].name; i++) {
- lua_pushnumber(L, const_glu[i].value);
- lua_setfield(L, 1, const_glu[i].name);
- }
- luaL_newmetatable(L, "GLUtesselator");
- lua_pushvalue(L, 1); lua_setfield(L, -2, "__index");
- lua_pushcfunction(L, b_gluDeleteTess); lua_setfield(L, -2, "__gc");
- luaL_newmetatable(L, "GLUnurbs");
- lua_pushvalue(L, 1); lua_setfield(L, -2, "__index");
- lua_pushcfunction(L, b_gluDeleteNurbsRenderer); lua_setfield(L, -2, "__gc");
- luaL_newmetatable(L, "GLUquadric");
- lua_pushvalue(L, 1); lua_setfield(L, -2, "__index");
- lua_pushcfunction(L, b_gluDeleteQuadric); lua_setfield(L, -2, "__gc");
- lua_settop(L, 0);
-
- luaL_register(L, "gl", reg_gl);
- lua_pushvalue(L, 1); lua_setglobal(L, "GL");
- for(i = 0; const_gl[i].name; i++) {
- lua_pushnumber(L, const_gl[i].value);
- lua_setfield(L, 1, const_gl[i].name);
- }
-
- return 1;
-}
-]]
-end
-
-check_funcs = {}
-
-return_codes = {}
-
-Arg = {}
-
-function Arg.Counter(bound, narg)
- local atype = bound.info.argtypes[narg]
- bound.add.vars = atype .. ' c'..narg..' = ' ..
- (bound.info[narg].check_func or check_funcs[atype]):gsub('@n', narg)..';\n'
- return 'c'..narg
-end
-
-function Arg.Buffer(bound, narg)
- local atype = bound.info.argtypes[narg]
- return '('..atype..')check_'..(atype:match('^const') and 'const_' or '')..
- 'ptr(L, '..narg..')'
-end
-
-local function arg_size(bound, narg, size, defaults)
- local atype = bound.info.argtypes[narg]
- local base = atype:gsub('const', ''):gsub('[* ]', '')
-
- if type(size) == 'string' then -- dynamic size
- bound.add.vars = base..' *a'..narg..';\n'
- bound.add.argget = 'a'..narg..' = ('..base..' *)malloc('..
- size..' * sizeof('..base..'));\n'..
- 'if(a'..narg..' == NULL) luaL_error(L, "out of memory");\n'..
- 'memset(a'..narg..', 0, '..size..' * sizeof('..base..'));\n'
- bound.add.cleanup = 'free((void *)a'..narg..');\n'
- else -- static size
- if defaults == true then -- prepare defaults
- defaults = '{ '..string.rep('0, ', size):sub(1, -3)..' }' end
- bound.add.vars = base..' a'..narg..'['..size..']'..
- (defaults and ' = '..defaults or '')..';\n'
- end
-end
-
-function Arg.Returns(bound, narg)
- local size = bound.info[narg].Returns
- local base = bound.info.argtypes[narg]:gsub('const', ''):gsub('[* ]', '')
- local push = return_codes[base]
- arg_size(bound, narg, size, true)
-
- bound.ints.i = true
- bound.ints['r'..narg] = 'luaL_optinteger(L, '..narg..', '..size..')'
- bound.add.argput =
- 'if(r'..narg..' == 1) {\n'..
- ' '..push:gsub('@b', 'a'..narg..'[0]')..'\n}\n'..
- 'else {\n'..
- ' lua_createtable(L, r'..narg..', 0);\n'..
- ' for(i = 0; i < r'..narg..'; i++) {\n'..
- ' '..push:gsub('@b', 'a'..narg..'[i]')..'\n'..
- ' lua_rawseti(L, -2, i+1);\n'..
- ' }\n}\n'
- bound.num_ret = bound.num_ret + 1
- return 'a'..narg
-end
-
-function Arg.Array(bound, narg)
- local size = bound.info[narg].Array
- local defaults = bound.info[narg].defaults
- local base = bound.info.argtypes[narg]:gsub('const', ''):gsub('[* ]', '')
- arg_size(bound, narg, size, defaults)
-
- bound.ints.i = true
-
- if narg == #bound.info.argtypes then
- -- last array arg (can be used unpacked)
- bound.add.argget =
- 'if(lua_istable(L, '..narg..') || lua_isnoneornil(L, '..narg..')) {\n'..
- ' luaL_checktype(L, '..narg..', LUA_TTABLE);\n'..
- ' for(i = 0; i < '..size..'; i++) {\n'..
- ' lua_rawgeti(L, '..narg..', i+1);\n'..
- ' '..(defaults and 'if(!lua_isnil(L, -1)) ' or '')..
- 'a'..narg..'[i] = '..check_funcs[base]:gsub('@n', '-1')..';\n'..
- ' lua_pop(L, 1);\n }\n'..
- '}\nelse {\n'..
- ' for(i = 0; i < '..size..(defaults and
- ' && !lua_isnoneornil(L, i+'..narg..')' or '')..'; i++)\n'..
- ' a'..narg..'[i] = '..check_funcs[base]:gsub('@n', 'i+'..narg)..';\n'..
- '}\n'
- else
- bound.add.argget =
- 'luaL_checktype(L, '..narg..', LUA_TTABLE);\n'..
- 'for(i = 0; i < '..size..'; i++) {\n'..
- ' lua_rawgeti(L, '..narg..', i+1);\n'..
- ' '..(defaults and 'if(!lua_isnil(L, -1)) ' or '')..
- 'a'..narg..'[i] = '..check_funcs[base]:gsub('@n', '-1')..';\n'..
- ' lua_pop(L, 1);\n}\n'
- end
- return 'a'..narg
-end
-
-
-function Bind(fn, info)
- bindlist[#bindlist+1] = fn
- boundinfo[fn] = info
-
- setmetatable(info, { __index = assert(prototypes[fn] or info.prototype,
- fn:quote().."(): unknown function prototype") })
- local bound = { add = {}, info = info, num_ret = 0, ints = {},
- vars = '', argget = '', argput = '', cleanup = '' }
- setmetatable(bound.add, { __newindex = function (t,k,v)
- bound[k] = bound[k] .. v end })
-
- -- parse arguments
- local args = {}
- for narg = 1, #info.argtypes do
- local atype = info.argtypes[narg]
- local argstr = nil
- bound.narg = narg
- bound.argerr = fn.."() arg "..narg..": "
-
- -- implicit argument info
- if info.argtypes[narg]:match('%*') and not info[narg] then
- info[narg] = info end
- if not info[narg] then info[narg] = {} end
-
- local check_fn = info[narg].check_func or check_funcs[atype]
- if check_fn then argstr = check_fn:gsub('@n', narg) end
- if check_fn and info[narg].opt then argstr =
- '(lua_isnoneornil(L, '..narg..') ? '..info[narg].opt..' : '..argstr..')' end
-
- -- execute Arg.* functions to handle the argument
- for k,v in pairs(info[narg]) do
- if Arg[k] then argstr = Arg[k](bound, narg) end
- end
-
- args[#args+1] = assert(argstr, bound.argerr.."no handler defined for "..
- tostring(info.argtypes[narg]))
- end
-
- -- create base call
- local base_call = (info.base_call or fn..'(@a)'):
- gsub('@a', table.concat(args, ', ')):gsub('@A(%d+)',
- function (m) return args[tonumber(m)] end)
- local return_code = assert(info.return_code or return_codes[info.return_type],
- fn.."(): undefined return_code - return type "..tostring(info.return_type))
- if not return_code:match('@v') then bound.num_ret = bound.num_ret+1 end
- base_call = return_code:gsub('@[vb]', base_call)
- bound.add.cleanup = 'return ' .. bound.num_ret .. ';\n'
-
- local ints = {}
- for k,_ in pairs(bound.ints) do ints[#ints+1] = k end
- table.sort(ints)
- for i,k in ipairs(ints) do if bound.ints[k] ~= true then
- ints[i] = k..' = '..bound.ints[k] end end
- ints = (#ints > 0 and 'int '..table.concat(ints, ', ')..';\n' or '')
-
- local result_str = bound.vars .. ints .. bound.argget ..
- base_call..'\n' .. bound.argput .. bound.cleanup
- return 'int b_'..fn..'(lua_State *L) {\n'..
- ' '..result_str:gsub('\n', '\n '):gsub(' *$', '')..'}'
-end
-
-bindlist = {} -- an array of function names to bind.
-prototypes = {} -- a table with prototype info about each function.
-boundinfo = {} -- a table with binding info about bound functions.
-
--- load and parse the header data from stdin.
-Input = { '\n' }; local n = 1
-for l in io.lines() do
- n = n+1; Input[n] = l:sub(-1, -1) == '\\' and l:sub(1, -2) or l..'\n'
-end
-Input = table.concat(Input):gsub('/%*.-%*/', '')
-
--- parse the headers to get function prototypes.
-for proto in Input:gsub('#.-\n', ''):gsub('%s+', ' '):gsub(' +%*', '*')
- :gsub('extern +"C" +(%b{})', function (m) return m:sub(2, -2) end)
- :gsub('(struct) *[\w_]* *%b{}', '%1 '):gsub('(enum) *[\w_]* *%b{}', '%1 ')
- :gsub('(union) *[\w_]* *%b{}', '%1 '):gsub('%b{}', ';'):gsub('^', '\n')
- :gsub('%s*;%s*', ';\n'):gmatch('\n[^(\n]+%b();') do
- local args = proto:match('%((.*)%);?$'):gsub('^ *void *$', '')
- local atypes = {}
- for arg in args:gmatch('[^,]+') do
- arg = arg:gsub('^ +', ''):gsub(' +$', '')
- local atype = arg:match('^ *(%S+)')
- if atype == 'const' then atype = arg:match('^ *(const %S+)') end
- if arg:match('%*') then atype = arg:gsub('%*.*', '*') end
- atypes[#atypes+1] = atype
- end
- local header = (' '..proto:match('^[^(]*'):gsub('%s+', ' ')..' ')
- :gsub(' extern ', ' '):gsub(' static ', ' '):gsub(' [A-Z_]+ ', ' ')
- :gsub(' _*inline_* ', ' '):gsub(' _*INLINE_* ', ' '):gsub(' +', ' ')
- if header:match('%S') then
- prototypes[header:match('(%S+) *$')] = { argtypes = atypes,
- return_type = header:gsub(' *(%S+) *$', ''):gsub('^%s+', '') } end
-end
-
-if arg[1] == "lsdllib" then write_output_lsdllib()
-elseif arg[1] == "lgllib" then write_output_lgllib()
-else error"usage: gengl.lua (lsdllib|lgllib)" end
diff --git a/src/glproto.c b/src/glproto.c
deleted file mode 100644
index e793779..0000000
--- a/src/glproto.c
+++ b/dev/null
@@ -1,17 +0,0 @@
-
-#include <SDL.h>
-#include <SDL_opengl.h>
-
-#include "glproto.h"
-
-#define GL_FUNC(ret, name, args) ret (APIENTRYP P##name) args = NULL;
-#include "glproto.h"
-#undef GL_FUNC
-
-int glproto_connect() {
-#define GL_FUNC(ret, name, args) if(!(P##name = SDL_GL_GetProcAddress(#name))) return SDL_SetError("can't find OpenGL function: %s", #name), 0;
-#include "glproto.h"
-#undef GL_FUNC
- return 1;
-}
-
diff --git a/src/glproto.h b/src/glproto.h
deleted file mode 100644
index 91af62f..0000000
--- a/src/glproto.h
+++ b/dev/null
@@ -1,22 +0,0 @@
-
-#ifndef GLPROTO_H
-#define GLPROTO_H
-
-#include <SDL_opengl.h>
-
-#define GL_FUNC(ret, name, args) extern ret (APIENTRYP P##name) args
-#include "glproto.h"
-#undef GL_FUNC
-
-int glproto_connect();
-
-#endif
-
-/* list of dynamic GL function prototypes */
-#ifdef GL_FUNC
-
-/* NOTE: (from gl.h specifications to GL_FUNCs) s/GLAPI (.+) GLAPIENTRY (\w+)(\(.*\))/GL_FUNC(\1, \2, \3)/g */
-
-/* currently empty; functions from GL extensions will be added here */
-
-#endif
diff --git a/src/launcher.lua b/src/launcher.lua
deleted file mode 100644
index a7eb4db..0000000
--- a/src/launcher.lua
+++ b/dev/null
@@ -1,195 +0,0 @@
-Launcher=[==[ -- ULT launcher --
-
-local PData, PUser, PExe, _, _, _, Pak, Appdir, Arg0 = ... -- from main()
-_, _, _, _WIN32, _SOUND, _DEBUG = ...
-
--- remove unwanted parts of standard libraries
-if not _DEBUG then _ = {}; if jit then jit.util = nil end
- for i in ('traceback getinfo debug sethook gethook'):gmatch('%S+') do
- _[i] = debug[i] end; debug = _ end
-local rwfromfile, mkdir, remove = SDL.RWFromFile, io.mkdir, os.remove
-io = { dirent = io.dirent, stat = io.stat, out = io.out }
-os.execute, os.rename, os.remove = nil
-package.loaders = { package.loaders[1] }
-function SDL.RWFromFile(f) return rwfromfile(f, 'rb') end
-
--- parse command-line arguments
-local function sep(s) return _WIN32 and s:gsub('/','\\') or s end
-local DATA, USER = nil, nil; _ARG = {}
-for i,v in ipairs{select(10, ...)} do local a, b = v:sub(1, 10), v:sub(11)
- if a == '-'..'-datadir=' then DATA = b
- elseif a == '-'..'-userdir=' then USER = b else _ARG[#_ARG+1] = v end end
-
-local try = { (PExe or Arg0):gsub('[/\\]*[^/\\]*$', '')..'/data', '.', PData }
-for _,d in ipairs(try) do if io.stat(sep(d..Pak:gsub('%.pak', '.info')))
- or io.stat(sep(d..Pak)) and not DATA then DATA = d end end
-assert(DATA, "can't find "..Pak:gsub('^/', '').." in "..
- table.concat(try, ", "))
-
-if not USER then -- find USER
- if PUser then PUser = PUser:gsub('\\', '/'):gsub('/$', '')
- if io.stat(sep(PUser)) then USER = PUser..'/'..Appdir
- else io.out("warning: can't open directory '"..PUser.."'\n") end
- elseif os.getenv('HOME') then local home = os.getenv('HOME')
- if io.stat(sep(home)) then USER = home..'/.'..Appdir:lower()
- else io.out("warning: can't open directory '"..home.."'\n") end
- end
- if not USER then USER = './userdata'
- io.out("warning: couldn't find user's data dir, using ./userdata\n") end
-end
-
--- find and load core/FS.lua from USER, DATA or Pak
-if io.stat(sep(USER..'/core/FS.lua')) then
- assert(loadfile(sep(USER..'/core/FS.lua')))('FS')
-elseif io.stat(sep(DATA..'/core/FS.lua')) then
- assert(loadfile(sep(DATA..'/core/FS.lua')))('FS')
-else
- require'Unzip'
- local f = SDL.RWFromFile(DATA..Pak, 'rb')
- local e = assert(Unzip.archive(DATA..Pak, f)['core/FS.lua'],
- "core/FS.lua not found in "..DATA..Pak)
- assert(loadstring(assert(Unzip.entry(e, f):read()), '@core/FS.lua'))('FS')
-end
-FS.init(DATA, USER, rwfromfile, mkdir, remove)
-
-function Report(e) if e then io.out(debug.traceback(e, 2)..'\n') end end
-xpcall(assert(loadstring(assert(FS.load('userrc.lua'):read()), '@userrc.lua')), Report)
-xpcall(assert(loadstring(assert(FS.load('start.lua'):read()), '@start.lua')), Report)
-
-]==] -- this lines in Unzip by checking how many does Launcher have
-Unzip=string.rep('\n', 1+select(2, Launcher:gsub('\n', '')))..[==[-- Unzip.lua
-
-local _G = _G
-local assert = assert
-local RWFromNewMem, uncompressZip = SDL.RWFromNewMem, zlib.uncompressZip
-
-module(...)
-
--- TODO: modify Unzip.lua to allow "core\FS.lua" too
-
-function entry(entry, rw)
- if not entry.data_offset then
- -- extralen in CD may not be the same as extralen in local header.
- -- thus, the data offset can't be computed from CD data. instead, it is
- -- computed the first time an entry is opened.
- assert(rw:seek('set', entry.header)); local header = assert(rw:read(4))
- assert(header == 'PK\3\4' or header == 'ULT\4', "data corrupted")
- assert(rw:seek('cur', 22)) -- unused data, already was in central dir
- local fnamelen, extralen = assert(rw:read(4)):unpack('<BB')
- -- header length is 30+fnamelen+extralen, data begins after header
- entry.data_offset = entry.header + 30 + fnamelen + extralen
- end
-
- assert(rw:seek('set', entry.data_offset))
- local result = RWFromNewMem(entry.orig_size)
- if entry.method == 0 then
- assert(result:write(assert(rw:read(entry.cmp_size)), entry.cmp_size))
- else
- uncompressZip(result:baseptr(), entry.orig_size,
- assert(rw:read(entry.cmp_size)), entry.cmp_size)
- end
- assert(result:seek('set'))
- return result
-end
-
-function archive(fname, rw)
- local entries = {}
-
- fname = (fname and fname..': ' or '')
- local err_corrupted = fname.."data corrupted"
- local err_not_pak = fname.."not a PAK file"
- local err_unsupported = fname.."PAK uses unsupported features"
-
- -- limitation: the data must start at the beginning - no SFX header allowed
- assert(rw:seek('set')); local header = assert(rw:read(4))
- assert(header == 'PK\3\4' or header == 'ULT\4', err_not_pak)
-
- -- parse end of central dir (see APPNOTE.TXT section V-I)
- -- (limitation: no archive-wide comments)
- assert(rw:seek('end', -22))
- -- APPNOTE.TXT section V-I
- local header = assert(rw:read(4))
- assert(header == 'PK\5\6' or header == 'UL\5T', err_unsupported)
- local disk_n, cd_disk_n, local_num_entries, num_entries, cd_size,
- cd_offset = assert(rw:read(16)):unpack('<BBBBCC')
- assert(disk_n == 0, err_unsupported)
- assert(cd_disk_n == 0, err_unsupported)
-
- -- parse central dir (see APPNOTE.TXT section V-F)
- assert(rw:seek('set', cd_offset))
- for i = 1, num_entries do
- assert(assert(rw:read(4)) == 'PK\1\2', err_corrupted) -- header
- local _, _, flags, method, _, _, _, cmp_size, orig_size, fnamelen,
- extralen, commentlen, _, _, _, header_offset =
- assert(rw:read(42)):unpack('<6B3C5BCC')
- -- limitation: only STORED (no compression) and DEFLATE methods
- assert(method == 0 or method == 8, err_unsupported)
- local ename = assert(rw:read(fnamelen))
- assert(rw:read(extralen + commentlen)) -- unused
- local entry = { method = method, cmp_size = cmp_size,
- orig_size = orig_size, header = header_offset, name = ename }
-
- entries[#entries+1] = ename; entries[ename] = entry
- end
-
- return entries
-end
-
-]==]
-
---[[ The launcher.h generator
- The ULT launcher is a Lua program embedded in './ult' that's called
- immediately after initializing the libraries. This generator changes Lua
- code to a C string that can be #include'd. It also removes comments and
- whitespace (to make it smaller), or compiles it into bytecode. (The source
- form of the launcher can always be found above.) The generator also adds
- the LuaJIT optimizer.
- Usage: lua launcher.lua [launcher.h] [jit/opt.lua path]
- If launcher.h isn't specified or is -, the result is printed on stdout.
- ]]
-
-if arg[1] and arg[1] ~= '' and arg[1] ~= '-' then io.output(arg[1]) end
-io.write('/* launcher.h - standard ULT launcher */\n',
- '/* DO NOT EDIT - auto-generated by stdpgen.lua */\n',
- '/* regenerate with "lua launcher.lua launcher.h" */\n')
-function quote(s)
- return '"'..s:gsub([[\]], [[\134]]):gsub([["]], [[\"]])
- :gsub('\n', [[\n]]):gsub('\t', [[\t]]):gsub('%z', [[\000]]):gsub('[^ -~]',
- function (c) return ([[\%03o]]):format(c:byte()) end)..'"'
-end
-function dump_str(id, str)
- str = quote(str)
- io.write('static const char lua_', id, '[] = \n')
- local i = 1; while i <= #str do
- local line = str:sub(i, i+76):gsub('\\[0-7]?[0-7]?$', '')
- io.write((i ~= 1 and '\\\n' or '')..line)
- i = i + #line
- end
- io.write';\n'
-end
-function dump_bin(id, str)
- io.write('static const char lua_', id, '[] = {\n')
- local len = 0
- local function wr(s)
- if len + #s > 79 then io.write'\n'; len = 0 end
- io.write(s); len = len + #s
- end
- for i = 1, #str do wr(tostring(str:byte(i))); wr',' end
- wr'0'; wr'};'; io.write'\n'
-end
-function read_file(f) return assert(assert(io.open(f)):read'*a') end
-function smaller(s)
- return s:gsub('\n +', '\n'):gsub(' *%-%-[^\n]*', '') end
-function bytecode_dump(s, fn)
- return string.dump(assert(loadstring(s, '@'..fn:gsub('.*/', '')))) end
-local dir = arg[0]:gsub('[^\\/]*[\\/]?$', '') -- TODO autodetect opt.lua in launcher.lua's dir
-dump_bin('launcher', bytecode_dump(Launcher, 'launcher'))
-dump_bin('unzip', bytecode_dump(Unzip, 'Unzip.lua'))
-if arg[2] then
- dump_str('jit_opt', smaller(read_file(arg[2]):gsub(
- 'io%.stderr:write%(([^,]*),([^,]*),([^)]*)%)', 'io.out(%1..%2..%3)')))
- dump_str('jit_opt_inline', smaller(read_file(arg[2]:gsub('opt', 'opt_inline'))))
-else
- dump_str('jit_opt', 'module(...); function start() end')
- dump_str('jit_opt_inline', ' ')
-end
diff --git a/src/lbitlib.c b/src/lbitlib.c
deleted file mode 100644
index ea61992..0000000
--- a/src/lbitlib.c
+++ b/dev/null
@@ -1,69 +0,0 @@
-/* Bitwise operations library
- by Reuben Thomas <rrt@sc3d.org> 2000-2007
- http://luaforge.net/projects/bitlib
- (excerpt from README:)
- bitlib is a C library for Lua 5.x that provides bitwise operations. It
- is copyright Reuben Thomas 2000-2007, and is released under the MIT
- license, like Lua (see http://www.lua.org/copyright.html; it's
- basically the same as the BSD license). There is no warranty.
-
- Visit the URL above for full version (with Makefile and docs etc).
- This is just lbitlib.c, the library source file.
-*/
-
-#include <inttypes.h>
-#include <lauxlib.h>
-#include <lua.h>
-
-typedef int32_t Integer;
-typedef uint32_t UInteger;
-
-#define checkUInteger(L, n) ((UInteger)luaL_checknumber((L), (n)))
-
-#define TDYADIC(name, op, type1, type2) \
- static int bit_ ## name(lua_State* L) { \
- lua_pushnumber(L, (Integer)((type1)checkUInteger(L, 1) op (type2)checkUInteger(L, 2))); \
- return 1; \
- }
-
-#define MONADIC(name, op, type) \
- static int bit_ ## name(lua_State* L) { \
- lua_pushnumber(L, (Integer)(op (type)checkUInteger(L, 1))); \
- return 1; \
- }
-
-#define VARIADIC(name, op, type) \
- static int bit_ ## name(lua_State *L) { \
- int n = lua_gettop(L), i; \
- Integer w = (type)checkUInteger(L, 1); \
- for (i = 2; i <= n; i++) \
- w op (type)checkUInteger(L, i); \
- lua_pushnumber(L, (Integer)w); \
- return 1; \
- }
-
-MONADIC(cast, +, Integer)
-MONADIC(bnot, ~, Integer)
-VARIADIC(band, &=, Integer)
-VARIADIC(bor, |=, Integer)
-VARIADIC(bxor, ^=, Integer)
-TDYADIC(lshift, <<, Integer, UInteger)
-TDYADIC(rshift, >>, UInteger, UInteger)
-TDYADIC(arshift, >>, Integer, UInteger)
-
-static const struct luaL_reg bitlib[] = {
- {"cast", bit_cast},
- {"bnot", bit_bnot},
- {"band", bit_band},
- {"bor", bit_bor},
- {"bxor", bit_bxor},
- {"lshift", bit_lshift},
- {"rshift", bit_rshift},
- {"arshift", bit_arshift},
- {NULL, NULL}
-};
-
-LUALIB_API int luaopen_bit (lua_State *L) {
- luaL_openlib(L, "bit", bitlib, 0);
- return 1;
-}
diff --git a/src/lbuflib.c b/src/lbuflib.c
deleted file mode 100644
index bb9f7f9..0000000
--- a/src/lbuflib.c
+++ b/dev/null
@@ -1,409 +0,0 @@
-
-#include <ctype.h>
-#include <string.h>
-#include <stdint.h>
-
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-
-/*
-Description of the 'format' field.
-- (...) are comments.
-- whitespace is ignored.
-- numbers are numeric arguments, noted as "*" below. unless otherwise stated,
- these are the number of repetitions of the next command. "4 i" == "iiii"
-- native types:
- "f" float
- "F" double
- "n" lua_Integer
- "N" lua_Number
- "h"/"H" char (uppercase = unsigned)
- "w"/"W" short
- "i"/"I" int
- "l"/"L" long
- "a"/"A" int1_t
- "b"/"B" int2_t
- "c"/"C" int4_t
- "d"/"D" int8_t
-- other data: (not aligned)
- "x" padding (1-byte; ignore when unpacking, fill with zeroes when packing)
- "*s" string of given length (when packing, arg is optional)
- "z"/"0z" zero-terminated string
- "*z" zero-terminated string of given length, but with padded zeroes
- (arg is the exact number of bytes that will be read/written)
- (when packing, if arg < length, write only arg bytes)
- "St" (where t is some native integer type, e.g. "SC")
- the integer, and a string of that length
-- special flags:
- ">" big endian
- "<" little endian
- "=" native endian
- "*!" alignment (when without n, use native) (currently can't be turned off)
- (n is the maximum alignment. for example, 4! is Linux-like alignment where
- even 8-byte doubles are 4-byte aligned)
-
------------------
-
-API:
- string.pack([outptr, [stopptr|maxlen]], fmt, {data}|data...) -> outptr ? none : outstr
- string.unpack(instr|inptr, [stopptr|maxlen], fmt, [bool rettable], [offset from 0]) ->
- rettable ? {data},newpos : data...,newpos
-
-the rest was moved to SDL itself:
- rw:read(num) (num=nil means read all) -> outstr
- rw:write(str, [num]) (num=nil means whole str) -> true (or nil,error,nwrote)
- rw:seek(["end"|"set"|"cur"], [offset]) -> none
- SDL.RWFromNewMem(len) -> rw
- SDL.RWFromMem(ptr, len) -> rw
- rw:baseptr() -> ptr
- rw:hereptr() -> ptr
- rw:disown()
- SDL.IMG_Load_RW(rw, freesrc)
- SDL.LoadWAV_RW(rw, freesrc)
-*/
-
-
-// how many bytes is 'double' is aligned to
-struct dummyalign { char c; double d; };
-#define MAXALIGN (sizeof(struct dummyalign) - sizeof(double))
-
-// FIXME: in the original struct.c from ~roberto, this is used instead:
-// #define NEW_MAXALIGN (MAXALIGN > sizeof(int) ? MAXALIGN : sizeof(int))
-// why? is the current approach invalid? IMHO, if MAXALIGN < sizeof(int),
-// the platform probably doesn't align at all, and MAXALIGN is correct.
-
-struct PackState {
- int swap;
- int align; // max alignment for the packed data
- int usestring;
- char token;
- int num_arg;
-
- const char *p_format;
-
- lua_State *L;
-};
-
-static void doswap(char *a, size_t n) {
- int i, j;
- for (i=0, j=n-1, n=n/2; n--; i++, j--) {
- char t = a[i]; a[i] = a[j]; a[j] = t;
- }
-}
-
-static int doalign(int offset, int align, int maxalign) {
- if(align > maxalign) align = maxalign;
- return (align - (offset % align)) % align;
-}
-
-static void get_next_token(struct PackState *st) {
- char input;
- st->usestring = 0;
- if(st->token == 's' || st->token == 'z') st->token = 0, st->num_arg = 0;
- if(st->num_arg && st->token) {
- st->num_arg--;
- return;
- }
- while(isspace(*st->p_format) || *st->p_format == '(') {
- if(*st->p_format == '(') {
- while(*st->p_format != ')' && *st->p_format != '\0') st->p_format++;
- if(*st->p_format == '\0') luaL_error(st->L, "comment not terminated");
- }
- st->p_format++;
- }
- if(*st->p_format == '\0') {
- if(st->num_arg) luaL_error(st->L, "trailing number at end of format");
- st->token = -1; return; // end of format string
- }
- if(*st->p_format >= '0' && *st->p_format <= '9') {
- st->token = 0;
- st->num_arg = *st->p_format - '0';
- st->p_format++;
- while(*st->p_format >= '0' && *st->p_format <= '9') {
- st->num_arg = 10*st->num_arg + *st->p_format-'0';
- st->p_format++;
- }
- get_next_token(st); return;
- }
- input = *st->p_format;
- st->p_format++;
- if(strchr("S=<>", input) && st->num_arg != 0)
- luaL_error(st->L, "unexpected number before '%c'", input);
- if(input == '!') { // used alignment
- st->align = (st->num_arg ? st->num_arg : MAXALIGN);
- st->num_arg = 0;
- get_next_token(st); return;
- }
- if(input == '=') { // native endian, don't swap
- st->swap = 0;
- get_next_token(st); return;
- }
- if(input == '<') { // little-endian packed
- int arch_is_le = 1;
- st->swap = !(*(char *)&arch_is_le);
- get_next_token(st); return;
- }
- if(input == '>') { // big-endian packed
- int arch_is_le = 1;
- st->swap = (*(char *)&arch_is_le);
- get_next_token(st); return;
- }
- if(input == 'S') { // string with prepended packed length
- get_next_token(st);
- if(!strchr("hHwWiIlLaAbBcCdD", st->token))
- luaL_error(st->L, "expected integer type after 'S'");
- if(st->num_arg)
- luaL_error(st->L, "unexpected number after 'S'");
- st->usestring = 1;
- return;
- }
- if(strchr("zxsfFnNhHwWiIlLaAbBcCdD", input)) { // supported chars
- if(st->num_arg != 0 && input != 's' && input != 'z')
- st->num_arg--;
- st->token = input;
- return;
- }
- luaL_error(st->L, "unexpected character '%c'", input);
-}
-
-#define UNPACK(OP,T) \
- case OP: { \
- T val; int size = sizeof(val); \
- if(st.align && !st.usestring) \
- pos += doalign(pos, size, st.align); \
- if(maxlen != -1 && pos+size > maxlen) \
- luaL_error(L, "unexpected end of input at '%c'", st.token); \
- memcpy(&val, data+pos, size); \
- pos += size; \
- if(st.swap) doswap((char *)&val, size); \
- if(st.usestring) { \
- if(maxlen != -1 && pos+val > maxlen) \
- luaL_error(L, "unexpected end of input in 'S' string"); \
- lua_pushlstring(L, data+pos, val); \
- pos += val; \
- } \
- else \
- lua_pushnumber(L, (lua_Number)val); \
- break; \
- }
-
-static int str_unpack(lua_State *L) {
- const char *data = NULL;
- int offset = 0, pos = 0, fmtarg = 2, intable = 0;
- size_t maxlen = (size_t)-1;
- struct PackState st;
- memset(&st, 0, sizeof st);
- st.L = L;
- if(lua_type(L, 1) == LUA_TLIGHTUSERDATA)
- data = lua_touserdata(L, 1);
- else
- data = luaL_checklstring(L, 1, &maxlen);
- if(lua_type(L, 1) == LUA_TLIGHTUSERDATA &&
- lua_type(L, 2) == LUA_TLIGHTUSERDATA) {
- const char *stop = lua_touserdata(L, 2);
- if(stop < data) luaL_error(L, "stop pointer is sooner than start pointer");
- maxlen = stop - data; fmtarg++;
- }
- else if(lua_isnumber(L, 2)) {
- maxlen = luaL_checkinteger(L, 2); fmtarg++;
- }
- st.p_format = luaL_checkstring(L, fmtarg);
- if(lua_isboolean(L, fmtarg+1) && lua_toboolean(L, fmtarg+1)) {
- intable = 1; fmtarg++;
- }
- if(lua_isnumber(L, fmtarg+1)) {
- offset = luaL_checkinteger(L, fmtarg+1);
- if(maxlen != -1 && offset > maxlen)
- luaL_error(L, "unexpected end of input at offset");
- // offset isn't just an increment to pos because alignment is computed
- // against pos. this way, pos is always 0 at the beginning.
- data += offset;
- if(maxlen != -1) maxlen -= offset;
- }
- lua_settop(L, 0);
- if(intable)
- lua_newtable(L);
- while(1) {
- get_next_token(&st);
- if(st.token == -1) return lua_pushinteger(L, pos+offset), lua_gettop(L);
- if(st.token != 'x')
- luaL_checkstack(L, 1, "too many results");
- switch(st.token) {
- case 'x':
- if(maxlen != -1 && pos+1 > maxlen)
- luaL_error(L, "unexpected end of input at '%c'", st.token);
- pos++;
- break;
-
- case 'z':
- if(st.num_arg == 0) {
- while((maxlen == -1 || pos+st.num_arg < maxlen) &&
- data[pos+st.num_arg] != 0)
- st.num_arg++;
- st.num_arg++; // the "\0" itself
- }
- // no break
- case 's':
- if(maxlen != -1 && pos+st.num_arg > maxlen)
- luaL_error(L, "unexpected end of input at '%c'", st.token);
- if(st.token == 'z')
- lua_pushstring(L, data+pos);
- else
- lua_pushlstring(L, data+pos, st.num_arg);
- pos += st.num_arg;
- break;
-
- UNPACK('f', float)
- UNPACK('F', double)
- UNPACK('n', lua_Integer)
- UNPACK('N', lua_Number)
- UNPACK('h', char)
- UNPACK('H', unsigned char)
- UNPACK('w', short)
- UNPACK('W', unsigned short)
- UNPACK('i', int)
- UNPACK('I', unsigned int)
- UNPACK('l', long)
- UNPACK('L', unsigned long)
- UNPACK('a', int8_t)
- UNPACK('A', uint8_t)
- UNPACK('b', int16_t)
- UNPACK('B', uint16_t)
- UNPACK('c', int32_t)
- UNPACK('C', uint32_t)
- UNPACK('d', int64_t)
- UNPACK('D', uint64_t)
- }
- if(st.token != 'x' && intable) {
- lua_rawseti(L, 1, intable);
- intable++;
- }
- }
-}
-
-#define OUTPUT(str, size) do { \
- if(out) { \
- if(maxlen != -1 && pos+size > maxlen) \
- luaL_error(L, "not enough space in output at '%c'", st.token); \
- memcpy(out+pos, str, size); \
- } \
- else \
- luaL_addlstring(&b, (const char *)str, size); \
- pos += size; \
-} while(0)
-
-#define PACK(OP,T) \
- case OP: { \
- T val; int size = sizeof(val); const char *usedstr = NULL; \
- if(intable) lua_rawgeti(L, intable, arg); \
- if(st.usestring) { \
- usedstr = luaL_checklstring(L, intable ? -1 : arg, &len); \
- val = len; \
- } \
- else val = (T)luaL_checknumber(L, intable ? -1 : arg); \
- if(intable) lua_pop(L, 1); \
- if(st.align && !st.usestring) { \
- int myalign = doalign(pos, size, st.align); \
- while(myalign--) OUTPUT("\0", 1); \
- } \
- if(st.swap) doswap((char *)&val, size); \
- OUTPUT(&val, size); \
- if(st.usestring) OUTPUT(usedstr, len); \
- break; \
- }
-
-static int str_pack(lua_State *L) {
- luaL_Buffer b;
- char *out = NULL; int pos = 0, maxlen = -1;
- int intable = 0, arg = 1;
- size_t len;
- struct PackState st;
- memset(&st, 0, sizeof st);
- st.L = L;
- if(lua_type(L, arg) == LUA_TLIGHTUSERDATA) { // outptr
- out = lua_touserdata(L, arg); arg++;
- }
- if(lua_type(L, arg) == LUA_TLIGHTUSERDATA) { // stopptr
- maxlen = (char *)lua_touserdata(L, arg) - out; arg++;
- }
- else if(lua_type(L, arg) == LUA_TNUMBER) {
- maxlen = luaL_checkinteger(L, arg); arg++;
- }
- if(!out) {
- lua_pushnil(L); // mark to separate arguments from the string buffer
- luaL_buffinit(L, &b);
- }
- st.p_format = luaL_checkstring(L, arg);
- if(lua_type(L, arg+1) == LUA_TTABLE) {
- intable = arg+1;
- arg = 0;
- }
- while(1) {
- get_next_token(&st);
- if(st.token == -1) break;
- if(st.token != 'x') arg++;
- switch(st.token) {
- case 'x':
- OUTPUT("\0", 1);
- break;
-
- case 's': case 'z': {
- const char *tmp;
- if(intable) lua_rawgeti(L, intable, arg);
- tmp = luaL_checklstring(L, intable ? -1 : arg, &len);
- if(intable) lua_pop(L, 1);
- if(st.num_arg != 0 && st.token == 's' && st.num_arg != len)
- luaL_error(L, "incorrect string length for 's'");
- if(st.num_arg != 0 && st.num_arg < len)
- len = st.num_arg;
- OUTPUT(tmp, len);
- if(st.token == 'z' && st.num_arg == 0)
- st.num_arg = len + 1; // add one "\0"
- while(st.num_arg > len) {
- OUTPUT("\0", 1);
- len++;
- }
- break;
- }
-
- PACK('f', float)
- PACK('F', double)
- PACK('n', lua_Integer)
- PACK('N', lua_Number)
- PACK('h', char)
- PACK('H', unsigned char)
- PACK('w', short)
- PACK('W', unsigned short)
- PACK('i', int)
- PACK('I', unsigned int)
- PACK('l', long)
- PACK('L', unsigned long)
- PACK('a', int8_t)
- PACK('A', uint8_t)
- PACK('b', int16_t)
- PACK('B', uint16_t)
- PACK('c', int32_t)
- PACK('C', uint32_t)
- PACK('d', int64_t)
- PACK('D', uint64_t)
- }
- }
- if(out) return 0;
- luaL_pushresult(&b);
- return 1;
-}
-
-int luaopen_buf(lua_State *L) {
- const luaL_Reg reg_buf[] = {
- { "pack", str_pack },
- { "unpack", str_unpack },
- { NULL, NULL }
- };
-
- lua_settop(L, 0);
-
- luaL_register(L, LUA_STRLIBNAME, reg_buf);
- return 1;
-}
-
diff --git a/src/leiolib.c b/src/leiolib.c
deleted file mode 100644
index b9c03f4..0000000
--- a/src/leiolib.c
+++ b/dev/null
@@ -1,100 +0,0 @@
-
-/* NOTE: At the moment, this file isn't ported to MSVC. MinGW can be used to build it under Win32. */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <dirent.h>
-
-#include <lua.h>
-#include <lauxlib.h>
-#include <lualib.h>
-
-
-static int make_error(lua_State *L, const char *format, const char *filename) {
- int en = errno;
- lua_pushnil(L);
- if(filename)
- lua_pushfstring(L, format, filename, strerror(en));
- else
- lua_pushfstring(L, format, strerror(en));
- lua_pushinteger(L, en);
- return 3;
-}
-
-
-static int extio_dirent(lua_State *L) {
- DIR *dp;
- struct dirent *ep;
- int i = 0;
-
- dp = opendir(luaL_checkstring(L, 1));
- if (dp == NULL)
- return make_error(L, "opendir: %s: %s", luaL_checkstring(L, 1));
- lua_newtable(L);
- while ((ep = readdir(dp)) != NULL) {
- lua_pushstring(L, ep->d_name);
- lua_rawseti(L, -2, ++i);
- }
- closedir(dp);
- return 1;
-}
-
-
-static int extio_stat(lua_State *L) {
- const char *filename = luaL_checkstring(L, 1);
- struct stat sbuf;
- if(stat(filename, &sbuf) != 0)
- return make_error(L, "stat: %s: %s", filename);
- lua_pushinteger(L, sbuf.st_size);
- lua_pushboolean(L, S_ISREG(sbuf.st_mode));
- lua_pushboolean(L, S_ISDIR(sbuf.st_mode));
- return 3;
-}
-
-
-static int extio_mkdir(lua_State *L) {
- const char *filename = luaL_checkstring(L, 1);
- struct stat sbuf;
- if(stat(filename, &sbuf) == 0) { /* the directory already exists */
- lua_pushboolean(L, 1);
- return 1;
- }
-#ifdef _WIN32
- if(mkdir(filename) != 0)
-#else
- if(mkdir(filename, 0755) != 0)
-#endif
- return make_error(L, "mkdir: %s: %s", filename);
- lua_pushboolean(L, 1);
- return 1;
-}
-
-
-static int extio_out(lua_State *L) {
- size_t l;
- const char *s = luaL_checklstring(L, 1, &l);
- if(fwrite(s, sizeof(char), l, stderr) != l)
- return make_error(L, "%s", NULL);
- lua_pushboolean(L, 1);
- return 1;
-}
-
-
-int luaopen_extio(lua_State *L) {
- const luaL_Reg reg_io[] = {
- { "dirent", extio_dirent },
- { "stat", extio_stat },
- { "mkdir", extio_mkdir },
- { "out", extio_out },
- { NULL, NULL }
- };
-
- lua_settop(L, 0);
-
- luaL_register(L, "io", reg_io);
- return 1;
-}
-
-
diff --git a/src/lftgllib.c b/src/lftgllib.c
deleted file mode 100644
index b3c060f..0000000
--- a/src/lftgllib.c
+++ b/dev/null
@@ -1,191 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <lua.h>
-#include <lauxlib.h>
-
-#include <SDL_rwops.h>
-
-#include "ftgl.h"
-
-
-/* from lsdllib.c */
-SDL_RWops *checkrwops (lua_State *L, int narg);
-int rwops_disown_fn (lua_State *L);
-
-/* from launcher.c */
-FT_Library get_ft_library ();
-
-
-/* Freetype reads from the font file even after FT_Open_Face finishes, so it has to be kept open. */
-struct font_userdata_t {
- FTGL_Font *font;
- SDL_RWops *rw;
- FT_Open_Args args;
-};
-
-// SDL_RWops/FT_Stream interface is from SDL_ttf 2.0.9, available under GNU LGPL at www.libsdl.org
-static unsigned long RWread(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count) {
- SDL_RWops *src = (SDL_RWops *)stream->descriptor.pointer;
- SDL_RWseek(src, (int)offset, SEEK_SET);
- if(count == 0)
- return 0;
- return SDL_RWread(src, buffer, 1, (int)count);
-}
-
-static int ftgl_create(lua_State *L) {
- FT_Face face;
- struct font_userdata_t *handle;
-
- SDL_RWops *rw = checkrwops(L, 1);
- rwops_disown_fn(L);
- luaL_argcheck(L, SDL_RWtell(rw) >= 0, 1, "can't seek in RWops");
- luaL_checkinteger(L, 2); luaL_checkinteger(L, 3); luaL_checkinteger(L, 4);
-
- handle = (struct font_userdata_t *)lua_newuserdata(L, sizeof(struct font_userdata_t));
- handle->rw = rw;
- handle->args.flags = FT_OPEN_STREAM;
- handle->args.stream = (FT_Stream)malloc(sizeof(*handle->args.stream));
- if(handle->args.stream == NULL) luaL_error(L, "out of memory");
- memset(handle->args.stream, 0, sizeof(*handle->args.stream));
- handle->args.stream->read = RWread;
- handle->args.stream->descriptor.pointer = rw;
- SDL_RWseek(rw, 0, SEEK_END); handle->args.stream->size = SDL_RWtell(rw);
- SDL_RWseek(rw, 0, SEEK_SET);
- if(FT_Open_Face(get_ft_library(), &handle->args, 0, &face) != 0)
- luaL_error(L, "error opening font face (FT_Open_Face failed)");
- if(FT_Set_Char_Size(face, 0, luaL_checkinteger(L, 2)*64, 0, 96) != 0)
- luaL_error(L, "error opening font face (FT_Set_Char_Size failed)");
- handle->font = FTGL_Create(face, luaL_checkinteger(L, 3), luaL_checkinteger(L, 4), lua_toboolean(L, 5));
- if(handle->font == NULL) luaL_error(L, "out of memory");
- luaL_getmetatable(L, "FTGL_Font"); lua_setmetatable(L, -2);
- return 1;
-}
-
-
-#if 0
-static int my_ftgl_create(SDL_RWops *rw, struct font_userdata_t *handle, unsigned int font_size, int initial_texture_size, unsigned int texture_id, int use_kerning) {
- FT_Face face;
-
- handle->rw = rw;
- handle->args.flags = FT_OPEN_STREAM;
- handle->args.stream = (FT_Stream)malloc(sizeof(*handle->args.stream));
- if(handle->args.stream == NULL) return -1;
- memset(handle->args.stream, 0, sizeof(*handle->args.stream));
- handle->args.stream->read = RWread;
- handle->args.stream->descriptor.pointer = rw;
- SDL_RWseek(rw, 0, SEEK_END); handle->args.stream->size = SDL_RWtell(rw);
- SDL_RWseek(rw, 0, SEEK_SET);
- if(FT_Open_Face(get_ft_library(), &handle->args, 0, &face) != 0)
- return -2;
- if(FT_Set_Char_Size(face, 0, font_size*64, 0, 96) != 0)
- return -3;
- handle->font = FTGL_Create(face, initial_texture_size, texture_id, use_kerning);
- if(handle->font == NULL) return -1;
- return 0;
-}
-
-static int ftgl_create(lua_State *L) {
-
- SDL_RWops *rw = checkrwops(L, 1);
- rwops_disown_fn(L);
- luaL_argcheck(L, SDL_RWtell(rw) >= 0, 1, "can't seek in RWops");
-
- struct font_userdata_t *handle = (struct font_userdata_t *)lua_newuserdata(L, sizeof(struct font_userdata_t));
- int status = my_ftgl_create(rw, handle, luaL_checkinteger(L, 2), luaL_checkinteger(L, 3), luaL_checkinteger(L, 4));
-
- if(status == -1) luaL_error(L, "out of memory");
- else if(status == -2) luaL_error(L, "error opening font face (FT_Open_Face failed)");
- else if(status == -3) luaL_error(L, "error opening font face (FT_Set_Char_Size failed)");
-
- luaL_getmetatable(L, "FTGL_Font"); lua_setmetatable(L, -2);
- return 1;
-}
-#endif
-
-
-static int ftgl_gc(lua_State *L) {
- struct font_userdata_t *handle = (struct font_userdata_t *)luaL_checkudata(L, 1, "FTGL_Font");
- if(handle->font) {
- if(handle->font->face)
- FT_Done_Face(handle->font->face);
- FTGL_Destroy(handle->font);
- handle->font = NULL;
- }
- if(handle->args.stream) {
- free((void *)handle->args.stream);
- handle->args.stream = NULL;
- }
- if(handle->rw) {
- SDL_RWclose(handle->rw);
- handle->rw = NULL;
- }
- return 0;
-}
-
-
-static FTGL_Font* getfont(lua_State *L) {
- struct font_userdata_t *handle = (struct font_userdata_t *)luaL_checkudata(L, 1, "FTGL_Font");
- luaL_argcheck(L, handle->font, 1, "expected FTGL font");
- return handle->font;
-}
-
-
-static int ftgl_index(lua_State *L) {
- const char *name = lua_tostring(L, 2);
- FTGL_Font *font = getfont(L);
- if(!lua_isstring(L, 2))
- return 0;
- luaL_getmetatable(L, "FTGL_Font");
- lua_pushvalue(L, 2); lua_rawget(L, -2);
- if(!lua_isnil(L, -1))
- return 1;
-#define accessor(x,t) if(strcmp(name, #x) == 0) return lua_push##t (L, font->x), 1
- accessor(height, integer);
- accessor(ascent, integer);
- accessor(descent, integer);
- accessor(texture_size, integer);
- accessor(texture, integer);
- accessor(use_kerning, boolean);
- return 0;
-}
-
-
-static int ftgl_prepare(lua_State *L) {
- long result = FTGL_Prepare(getfont(L), luaL_checkstring(L, 2));
- if(result == -1) luaL_error(L, "out of memory");
- lua_pushinteger(L, result); return 1;
-}
-
-
-static int ftgl_print(lua_State *L) {
- int u = lua_isnumber(L, 3) ? lua_tointeger(L, 3) : (lua_isstring(L, 3) ? *lua_tostring(L, 3) : 0);
- FTGL_Print(getfont(L), luaL_checkstring(L, 2), u); return 0;
-}
-
-
-int luaopen_ftgl(lua_State *L) {
- const luaL_Reg reg_font[] = {
- { "prepare", ftgl_prepare },
- { "print", ftgl_print },
- { "__gc", ftgl_gc },
- { "__index", ftgl_index },
- { NULL, NULL }
- };
-
- lua_settop(L, 0);
-
- luaL_getmetatable(L, "SDL_RWops");
- if(!lua_istable(L, 1))
- luaL_error(L, "SDL not found (required by FTGL)");
- lua_pushcfunction(L, ftgl_create);
- lua_setfield(L, 1, "font");
-
- luaL_newmetatable(L, "FTGL_Font");
- luaL_register(L, NULL, reg_font);
-
- lua_settop(L, 1);
- return 1;
-}
-
diff --git a/src/lxlib.c b/src/lxlib.c
deleted file mode 100644
index 2f708e5..0000000
--- a/src/lxlib.c
+++ b/dev/null
@@ -1,88 +0,0 @@
-/*
- * EXPERIMENTAL
- * This file is WIP. It shouldn't be used in the binary yet.
- */
-
-#include <lua.h>
-#include <lauxlib.h>
-
-#include <stdio.h> /* fwrite, stderr */
-#include <errno.h> /* errno */
-#include <string.h> /* strerror */
-
-
-static int x_printerr (lua_State *L) {
- int n = lua_gettop(L); /* number of arguments */
- int i;
- lua_getglobal(L, "tostring");
- for (i=1; i<=n; i++) {
- const char *s;
- size_t len;
- lua_pushvalue(L, -1); /* function to be called */
- lua_pushvalue(L, i); /* value to print */
- lua_call(L, 1, 1);
- s = lua_tolstring(L, -1, &len); /* get result */
- if (s == NULL)
- return luaL_error(L, LUA_QL("tostring") " must return a string to "
- LUA_QL("printerr"));
- if(fwrite(s, sizeof(char), len, stderr) != len)
- return luaL_error(L, "fwrite: %s", strerror(errno));
- lua_pop(L, 1); /* pop result */
- }
- return 0;
-}
-
-/*
-function print(...)
- local args = xselect(...)
- for i = 1, args.n do
- if i > 1 then printerr"\t" end; printerr(args[i]); end
- printerr"\n"
-end
-
-function selectdemo(...)
- local args = xselect(...)
- -- do something with args
- return unpack(args, 1, args.n or #args)
-end
-*/
-
-
-/* xselect(...) == { n=num_args, ... } */
-static int x_xselect (lua_State *L) {
- int i;
- int n = lua_gettop(L);
- lua_createtable(L, n, 0);
- lua_pushinteger(L, n);
- lua_setfield(L, -2, "n");
- for(i = 1; i <= n; i++) {
- lua_pushvalue(L, n);
- lua_rawseti(L, -2, n);
- }
- return 1;
-}
-
-
-/* pcall + xpcall = apcall(err, f, args...) */
-static int x_apcall (lua_State *L) {
- int status;
- luaL_checkany(L, 2);
- status = lua_pcall(L, lua_gettop(L) - 2, LUA_MULTRET, 1);
- lua_pushboolean(L, (status == 0));
- lua_replace(L, 1);
- return lua_gettop(L); /* return status + all results */
-}
-
-
-int luaopen_xbase (lua_State *L) {
- const luaL_Reg reg_xbase[] = {
- { "printerr", x_printerr },
- { "xselect", x_xselect },
- { "apcall", x_apcall },
- { NULL, NULL }
- };
-
- luaL_register(L, "_G", reg_xbase);
- return 1;
-}
-
diff --git a/src/lzlib.c b/src/lzlib.c
deleted file mode 100644
index 099ddc1..0000000
--- a/src/lzlib.c
+++ b/dev/null
@@ -1,99 +0,0 @@
-
-#include <stdlib.h>
-
-#include <lua.h>
-#include <lauxlib.h>
-
-#include <zlib.h>
-
-
-/* from lsdllib.c */
-void* check_const_ptr(lua_State *L, int narg);
-void* check_ptr(lua_State *L, int narg);
-
-
-static int lzlib_compress(lua_State *L) {
- uLong destLen = luaL_checkinteger(L, 2);
- int status = compress(check_ptr(L, 1), &destLen, check_const_ptr(L, 3), luaL_checkinteger(L, 4));
- if(status == Z_MEM_ERROR) luaL_error(L, "out of memory");
- if(status == Z_BUF_ERROR) luaL_error(L, "too small output buffer");
- lua_pushinteger(L, destLen);
- return 1;
-}
-
-static int lzlib_uncompress(lua_State *L) {
- uLong destLen = luaL_checkinteger(L, 2);
- int status = uncompress(check_ptr(L, 1), &destLen, check_const_ptr(L, 3), luaL_checkinteger(L, 4));
- if(status == Z_MEM_ERROR) luaL_error(L, "out of memory");
- if(status == Z_BUF_ERROR) luaL_error(L, "too small output buffer");
- if(status == Z_DATA_ERROR) luaL_error(L, "malformed data");
- lua_pushinteger(L, destLen);
- return 1;
-}
-
-static int lzlib_compressBound(lua_State *L) {
- lua_pushinteger(L, compressBound(luaL_checkint(L, 1)));
- return 1;
-}
-
-static int uncompressZip(Bytef* dest, uLongf* destLen,
- const Bytef* source, uLong sourceLen) {
- /* Normal uncompress() can't uncompress ZIPs. This is a modified version
- * which can. The only difference that it replaces inflateInit(&stream)
- * with inflateInit2(&stream, -MAX_WBITS). See also inflateInit2 docs in
- * zlib.h (why oh why isn't it on zlib.net?) for an explanation.
- * Reference: Ur-Quan Masters 0.6.2, src/sc2code/libs/uio/zip/zip.c
- */
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
- stream.next_out = dest; stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0;
-
- err = inflateInit2(&stream, -MAX_WBITS); /* THE MAGIC */
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
-
- return inflateEnd(&stream);
-}
-
-static int lzlib_uncompressZip(lua_State *L) {
- uLong destLen = luaL_checkinteger(L, 2);
- int status = uncompressZip(check_ptr(L, 1), &destLen, check_const_ptr(L, 3), luaL_checkinteger(L, 4));
- if(status == Z_MEM_ERROR) luaL_error(L, "out of memory");
- if(status == Z_BUF_ERROR) luaL_error(L, "too small output buffer");
- if(status == Z_DATA_ERROR) luaL_error(L, "malformed data");
- lua_pushinteger(L, destLen);
- return 1;
-}
-
-
-int luaopen_zlib(lua_State *L) {
- const luaL_Reg reg_zlib[] = {
- { "compress", lzlib_compress },
- { "uncompress", lzlib_uncompress },
- { "compressBound", lzlib_compressBound },
- { "uncompressZip", lzlib_uncompressZip },
- { NULL, NULL }
- };
-
- lua_settop(L, 0);
-
- luaL_register(L, "zlib", reg_zlib);
- return 1;
-}
-
-
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 78b5ffc..0000000
--- a/src/main.c
+++ b/dev/null
@@ -1,213 +0,0 @@
-/*
-** General Lua launcher
-** by Tomi Belan, 2007
-** licenced under Apache License 2.0, see file LICENSE
-** derived from lua.c (Lua stand-alone interpreter)
-** (see its Copyright Notice in lua.h)
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-
-#include <SDL.h>
-#include <SDL_mixer.h>
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#ifdef _WIN32
-#define WINVER 0x0500
-#include <windows.h>
-#include <shlobj.h>
-#endif
-
-#ifndef PAK_FILE
-#define PAK_FILE "karel.pak"
-#endif
-#ifndef APP_DIR
-#define APP_DIR "Karel"
-#endif
-
-#include "launcher.h"
-
-
-#define LIB(id) int luaopen_##id(lua_State *);
- LIB(bit) LIB(SDL) LIB(gl) LIB(ftgl) LIB(extio) LIB(zlib) LIB(buf)
-#undef LIB
-
-
-static lua_State *globalL = NULL;
-
-static const char *progname = "error";
-
-static FT_Library freetype = NULL;
-
-static const luaL_Reg mylibs[] = {
- {"", luaopen_base},
- {LUA_LOADLIBNAME, luaopen_package},
- {LUA_TABLIBNAME, luaopen_table},
- /*{LUA_IOLIBNAME, luaopen_io},*/
- {LUA_OSLIBNAME, luaopen_os},
- {LUA_STRLIBNAME, luaopen_string},
- {LUA_MATHLIBNAME, luaopen_math},
- {LUA_DBLIBNAME, luaopen_debug},
-#ifdef LUA_JITLIBNAME
- {LUA_JITLIBNAME, luaopen_jit},
-#endif
-#define LIB(id) { #id, luaopen_##id },
- LIB(bit) LIB(SDL) LIB(gl) LIB(ftgl) LIB(extio) LIB(zlib) LIB(buf)
- /* ftgl requires gl, gl requires SDL, buf requires SDL */
-#undef LIB
- { NULL, NULL }
-};
-
-
-#define err_message(msg) (fprintf(stderr, "%s: %s\n", progname, (msg)), fflush(stderr), EXIT_FAILURE)
-
-static int report (lua_State *L, int status) {
- if (status && !lua_isnil(L, -1)) {
- const char *msg = lua_tostring(L, -1);
- err_message(msg ? msg : "(error message is not a string)");
- lua_pop(L, 1);
- }
- return status;
-}
-
-
-FT_Library get_ft_library () {
- /* this allows access to the FT_Library object from outside main.c. */
- return freetype;
-}
-
-
-static void sigint_luahook (lua_State *L, lua_Debug *ar) {
- (void)ar; /* unused arg. */
- lua_sethook(L, NULL, 0, 0);
- luaL_error(L, "interrupted!");
-}
-
-static void sigint_handler (int i) {
- err_message("got SIGINT, raising exception (use ^C again if it gets stuck)");
- signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
- terminate process (default action) */
- lua_sethook(globalL, sigint_luahook, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
-}
-
-
-static void close_freetype () {
- FT_Done_FreeType(freetype);
- freetype = NULL;
-}
-
-static void close_lua () {
- lua_gc(globalL, LUA_GCCOLLECT, 0);
- lua_close(globalL);
-}
-
-
-int main (int argc, char **argv) {
- lua_State *L;
- int sound = 0;
- int i;
-
- if (argv[0] && argv[0][0])
- progname = argv[0];
-
- /* initialize SDL, SDL_mixer, Freetype and Lua */
- if(argc > 100)
- return err_message("Too many command-line arguments");
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0)
- return err_message("Could not initialize SDL");
- atexit(SDL_Quit);
- sound = (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 4096) == 0);
- if (!sound)
- err_message("Could not initialize sound"); /* this error isn't fatal */
- atexit(Mix_CloseAudio);
- if (FT_Init_FreeType(&freetype) != 0)
- return err_message("Could not initialize Freetype");
- atexit(close_freetype);
- if ((globalL = L = lua_open()) == NULL)
- return err_message("Could not initialize Lua");
- atexit(close_lua);
-
- /* initialize Lua libraries */
- lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
- for (i = 0; mylibs[i].func; i++) {
- lua_pushcfunction(L, mylibs[i].func);
- lua_pushstring(L, mylibs[i].name);
- if (report(L, lua_pcall(L, 1, 0, 0)))
- return EXIT_FAILURE;
- }
- lua_gc(L, LUA_GCRESTART, 0);
- lua_getglobal(L, "package");
- lua_getfield(L, -1, "preload");
- if(report(L, luaL_loadbuffer(L, lua_unzip, sizeof(lua_unzip)/sizeof(char)-1, "=Unzip.lua")))
- return EXIT_FAILURE;
- lua_setfield(L, -2, "Unzip");
-#ifdef LUA_JITLIBNAME
- if(report(L, luaL_loadbuffer(L, lua_jit_opt, sizeof(lua_jit_opt)/sizeof(char)-1, "=jit.opt")))
- return EXIT_FAILURE;
- lua_setfield(L, -2, "jit.opt");
- if(report(L, luaL_loadbuffer(L, lua_jit_opt_inline, sizeof(lua_jit_opt_inline)/sizeof(char)-1, "=jit.opt_inline")))
- return EXIT_FAILURE;
- lua_setfield(L, -2, "jit.opt_inline");
- if(report(L, luaL_dostring(L, "require'jit.opt'.start()")))
- return EXIT_FAILURE;
-#endif
- lua_pop(L, 2); /* package, package.preload */
-
- /* load and run the program */
- /* arguments for the launcher:
- * 1. DATAPATH - where files are installed by 'make install'
- * 2. path of the Application Data directory (Windows only)
- * 3. path of the executable (Windows only)
- * 4. whether we're under Windows
- * 5. whether sound is initialized
- * 6. whether debug build is active (whatever that means)
- * 7. name of the main .pak datafile
- * 8. program name (how to name the user data directory)
- * 9.-... argv[0], argv[1], etc
- */
- if(report(L, luaL_loadbuffer(L, lua_launcher, sizeof(lua_launcher)/sizeof(char)-1, "=launcher")))
- return EXIT_FAILURE;
- lua_pushliteral(L, DATAPATH);
-#ifdef __WIN32__
- char pbuf[MAX_PATH];
- if(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, pbuf) == S_OK)
- lua_pushstring(L, pbuf);
- else lua_pushnil(L);
- if(GetModuleFileName(NULL, pbuf, MAX_PATH) > 0)
- lua_pushstring(L, pbuf);
- else lua_pushnil(L);
- lua_pushboolean(L, 1);
-#else
- lua_pushnil(L);
- lua_pushnil(L);
- lua_pushboolean(L, 0);
-#endif
- lua_pushboolean(L, sound);
-#ifdef DEBUG
- lua_pushboolean(L, 1);
-#else
- lua_pushboolean(L, 0);
-#endif
- lua_pushliteral(L, "/" PAK_FILE);
- lua_pushliteral(L, APP_DIR);
- lua_checkstack(L, argc); /* safe: argc <= 100, see above */
- for(i = 0; i < argc; i++) lua_pushstring(L, argv[i]);
-
- /* load and run the program */
- signal(SIGINT, sigint_handler);
- if(report(L, lua_pcall(L, 8 + argc, 0, 0)))
- return EXIT_FAILURE;
-
- return EXIT_SUCCESS;
-}
-
diff --git a/src/makepak.sh b/src/makepak.sh
deleted file mode 100644
index 1681cd6..0000000
--- a/src/makepak.sh
+++ b/dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-
-if [ "$BASH_VERSION" ] && [ "${BASH_VERSION:0:1}" == "2" ]; then
- echo "ERROR: too old bash version"
- if [ -f /msys.bat ]; then
- echo -n "Download a msysCORE update from <http://sf.net/projects/mingw>"
- fi
- exit 1
-fi
-
-zip2pak () { # usage: zip2pak file.zip >file.pak
- # .pak files are actually simple .zip archives. to make it harder to
- # open them and prevent spoiling resourceful players, this obfuscates
- # them by replacing some bytes at the beginning and in the EOCD header.
- # (NOTE: this assumes there's no zip comment.)
- echo -n $'ULT\4'; tail -c+5 "$1" | head -c-22
- echo -n $'UL\5T'; tail -c18 "$1"
-}
-pak2zip () { # usage: pak2zip file.pak >file.zip
- echo -n $'PK\3\4'; tail -c+5 "$1" | head -c-22
- echo -n $'PK\5\6'; tail -c18 "$1"
-}
-makepak () { # usage: makepak file.info [--zip]
- local B; B="${1##*/}"; B="${B%.*}"
- echo "Creating ${1%.*}.pak"
- rm -f "${1%.*}.pak"
- local oldwd="`pwd`"; cd "`dirname "$1"`"
- read line < "$B.info" || return 1
- if [ "${line#-- FILES }" != "$line" ]; then eval "FILES=(${line#-- FILES })"
- else FILES=(*); fi
- ${ZIP:-zip -r -D} "$B.pak" "$B.info" "${FILES[@]}"
- if [ "$2" != "--zip" ]; then
- mv "$B.pak" "$B.pak~" && zip2pak "$B.pak~" >"$B.pak" && rm "$B.pak~"; fi
- cd "$oldwd"
-}
-
-[ -f "$1" ] && [ ! "$2" ] && set - --makepak "$@"
-if [ "$1" != "${1#--}" ] && [ "`type -t "${1#--}"`" == "function" ]; then
- fn=${1#--}; shift; "$fn" "$@"
-elif [ "$1" == "" ]; then
- [ -f ../Makefile -a ! -d data ] && dir=../data || dir=data
- find "$dir" -name '*.info' -exec "$0" {} \;
-else
- echo "Usage: $0 [ [--makepak] input.info | --zip2pak input.zip >output.pak | --pak2zip input.pak >output.zip ]"
-fi
diff --git a/ult b/ult
new file mode 160000
+Subproject 957ab96c21fbe5d4ade91b4805232f4c0189be2