This commit is contained in:
Alexander Deynichenko
2013-02-25 07:23:44 +04:00
parent 35ff18a6a1
commit 03b62f3315
809 changed files with 211135 additions and 0 deletions

62
tools/AUTHORS Normal file
View File

@@ -0,0 +1,62 @@
PLIB was originally written by Steve Baker as a solo project - but
has subsequently been greatly enhanced and expanded by a 'cast of
thousands'.
Most important of all - the 'official' PLIB developers:
Alex Perry
Curtis Olson
Ben Woodhead
Dave McClurg
Gerard Decatrel
Gil Carter
Giancarlo Niccolai
James Jones
John Fay ("Mr. PUI")
Juergen Marquardt
Mark Vallevand
Marten Stromberg
Nathan Matias
Norman Vine
Per Liedman
Sam Stickland
Sebastian Ude
Steve Baker <--- Hmmm - must sort this list by SECOND name!
Will Lachance
Wolfram Kuss
Apologies to anyone I've left out - please let me know
who you are and I'll add you in.
Christopher St.John
Christian Mayer
Darrell Walisser
Dave Heil
Erik Hofman
Kevin Thompson
Karl Kremer
Negative0 <---- Who? Some kind of 1's complement arithmetic fanatic?
Mark Danks
Michael Kurth
Sean Palmer
Simon Britnell
Themie Gouthas
Tony Knienieder
Trent Gamblin
Special mention must go to:
Daryll Strauss (GLIDE port to Linux)
David Bucciarelli (Mesa -> GLIDE interface)
Brian Paul (Mesa)
Curtis Olson (FlightGear guru and all-round "Mr Nice Guy",
who nagged me into writing most of this stuff!)
Vasily Lewis (Tireless maintainer and sysadmin at Woodsoup
where PLIB was first hosted)
Toru Egashira (Who wrote a program called 'NSPmod' which was
the original basis of the SL 'MOD' player -
although the original code has been almost
entirely rewritten in the process of merging
it with SL.
Everyone at OPENGL-GAMEDEV-L and 3Dfx.glide.linux

340
tools/COPYING Normal file
View File

@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

0
tools/ChangeLog Normal file
View File

182
tools/INSTALL Normal file
View File

@@ -0,0 +1,182 @@
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, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, 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 at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
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. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
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'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

8
tools/Makefile.am Normal file
View File

@@ -0,0 +1,8 @@
SUBDIRS = src
EXTRA_DIST = autogen.sh README tools.dsw
dist-hook:
tar cf - doc \
| ( cd $(distdir) ; tar xf - )

0
tools/NEWS Normal file
View File

0
tools/README Normal file
View File

19
tools/autogen.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/sh
OSTYPE=`uname -s`
AMFLAGS="--add-missing"
if test "$OSTYPE" = "IRIX" -o "$OSTYPE" = "IRIX64"; then
AMFLAGS=$AMFLAGS" --include-deps";
fi
echo "Running aclocal"
aclocal
echo "Running automake"
automake $AMFLAGS
echo "Running autoconf"
autoconf
echo "======================================"
echo "Now you are ready to run './configure'"
echo "======================================"

161
tools/configure.in Normal file
View File

@@ -0,0 +1,161 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/af2rgb/af2rgb.cxx)
AM_INIT_AUTOMAKE(plib_tools, 1.7.0)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_LANG_CPLUSPLUS
dnl Command line arguments.
dnl Don't use AC_HELP_STRING here as old versions of autoconf do not
dnl understand it.
AC_ARG_WITH(GL,
[ --with-GL=DIR set the prefix directory where GL resides],
GL_PREFIX=$withval, GL_PREFIX=auto)
if test "x$GL_PREFIX" != "xauto"; then
LDFLAGS="$LDFLAGS -L$GL_PREFIX/lib"
CPPFLAGS="$CPPFLAGS -I$GL_PREFIX/include"
fi
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
dnl Checks for library functions.
dnl check for OpenGL related libraries
AC_CANONICAL_HOST
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
LIBS="$LIBS -lwinmm -lglut32 -lglu32 -lopengl32"
;;
*-apple-darwin*)
dnl Mac OS X
LIBS="$LIBS -framework GLUT -lobjc -framework OpenGL -framework Carbon"
;;
*)
dnl Check for X11
AC_PATH_XTRA
LDFLAGS="$LDFLAGS $X_LIBS"
LIBS="$LIBS $X_PRE_LIBS -lXi -lXmu -lXext -lX11 $X_EXTRA_LIBS -lm"
dnl Reasonable stuff non-windoze variants ... :-)
AC_CHECK_LIB(pthread, pthread_create)
AC_CHECK_LIB(GL, glNewList)
if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
dnl if no GL, check for MesaGL
AC_CHECK_LIB(MesaGL, glNewList,,
AC_MSG_ERROR([could not find working GL library]))
fi
AC_CHECK_LIB(GLU, gluLookAt)
if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
dnl if no GLU, check for MesaGLU
AC_CHECK_LIB(MesaGLU, gluLookAt,,
AC_MSG_ERROR([could not find working GLU library]))
fi
dnl check for glut...or freeglut
AC_CHECK_LIB(freeglut, glutGetModifiers)
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xno" ; then
dnl if no freeglut, check for Real GLUT
AC_CHECK_LIB(glut, glutGetModifiers,,
AC_MSG_ERROR([could not find working GLUT library]))
fi
AC_CHECK_LIB(dl, dlclose)
dnl Check SGI audio library
AC_CHECK_LIB(audio, ALopenport, SND_LIBS="-laudio")
;;
esac
dnl Check PLIB library
AC_CHECK_LIB(plibul, ulInit, true,
AC_MSG_ERROR([there seems to be a problem with the PLIB libraries]))
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER(windows.h, AC_DEFINE(WIN32))
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*-apple-darwin*)
dnl Mac OS X
AC_CHECK_HEADERS(OpenGL/gl.h OpenGL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GLUT/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*)
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xyes"; then
AC_CHECK_HEADER(GL/freeglut.h, AC_DEFINE(FREEGLUT_IS_PRESENT),
AC_MSG_ERROR([freeglut header file not found]))
else
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
fi
;;
esac
AC_CHECK_HEADER(plib/ul.h,, AC_MSG_ERROR([PLIB header files not found]))
dnl Warning flags
WFLAG="-Wall"
case "$host" in
mips-sgi-irix*)
if test "x$CXX" = "xCC"; then
WFLAG="-fullwarn";
fi
;;
*)
if test "x$CXX" = "xicpc" || test "x$CXX" = "xicc"; then
WFLAG="-w1"
fi
;;
esac
CFLAGS="$CFLAGS $WFLAG"
CXXFLAGS="$CXXFLAGS $WFLAG"
AC_OUTPUT( \
Makefile \
src/Makefile \
src/af2rgb/Makefile \
)

65
tools/doc/index.html Normal file
View File

@@ -0,0 +1,65 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>PLIB Tools Home Page</TITLE>
</HEAD>
<BODY text="#B5A642" link="#8FFF8F" vlink="#18A515" alink="#20336B" bgcolor="#005000" background="../../doc/marble.png">
<TABLE>
<TR>
<TD>
<IMG SRC="../../doc/plib_logo.png" ALT="PLIB Logo" width=256 height=245>
<br>
</TD>
<TD>
<center>
<H1>
<FONT SIZE=9>S</FONT><FONT SIZE=5>TEVE'S</FONT>
<FONT SIZE=9>P</FONT><FONT SIZE=5>ORTABLE</FONT>
<FONT SIZE=9>G</FONT><FONT SIZE=5>AME</FONT>
<FONT SIZE=9>T</FONT><FONT SIZE=5>OOLS</FONT>
<FONT SIZE=9>P</FONT><FONT SIZE=5>AGE.</FONT>
</H1>
</center>
</TD>
<TD>
<ul>
When the only tool you have is a hammer<br>
every problem starts to look like a nail.
</ul>
<center>
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=382&type=1" width="88" height="31" border="0" ALT="Sourceforge Logo"></A>
</center>
</TD>
</TR>
</TABLE>
<H1>Useful Utility Tools for PLIB Applications.</H1>
This is a suite of tools that will hopefully prove useful for the
developers or users of PLIB-based applications. Currently, there is only one tool:
<H1>The "af2rgb" texture converter.</H1>
This portable utility converts textures, that is 2D bitmaps. It converts *.?af files as used with (old) Micro$oft
Flightsimulator into .rgb files that are understood by all plib versions. New plib versions can handle
*.?af textures, so this tool is only needed if you want to use the textures
with an old (for example 1.2.0) version of plib.
<BR><BR>
The usage is very simple:<BR>
Go into the path of the textures you want to convert and call af2rgb.
The program will handle all *.?af files in that path (and ignore all other files).
As a parameter, give it the path where the new textures shall be placed.
If you don't give it a path, then they will be written into the current dir.
The new filename is always lowercase, so that the case is defined for the Un*x crowd.
The first letter of the extension is added to the filename, so that it is unique.
For example, lets say you have navion.1af and Navion.2af in your path. Af2rgb will create files
called navion1.rgb and navion2.rgb.
<hr>
<ADDRESS>
<A HREF="http://www.sjbaker.org">
Steve J. Baker.</A>
&lt;<A HREF="mailto:sjbaker1@airmail.net">sjbaker1@airmail.net</A>&gt;
</ADDRESS>
</BODY>
</HTML>

10
tools/src/Makefile.am Normal file
View File

@@ -0,0 +1,10 @@
SUBDIRS = af2rgb
bin_PROGRAMS = plibconvert
plibconvert_SOURCES = plibconvert.cxx
plibconvert_LDADD = -lplibssg -lplibsg -lplibul

View File

@@ -0,0 +1,8 @@
noinst_PROGRAMS = af2rgb
af2rgb_SOURCES = af2rgb.cxx
af2rgb_LDADD = -lplibssg -lplibsg -lplibul
EXTRA_DIST = af2rgb.dsp

206
tools/src/af2rgb/af2rgb.cxx Normal file
View File

@@ -0,0 +1,206 @@
// Convert textures made for MSFS to rgb textures.
// Written by Wolfram Kuss (w_kus@rz-online.de) in dec 2000 / jan 2001
// with some help by Marten Str<74>mberg.
//
// Published as part of Steve Baker's PLIB
// License is GPL
#include <stdlib.h>
#include <stdio.h>
#include <plib/ul.h>
#include <plib/ssgMSFSPalette.h>
// *.?af textures are always 256 x 256:
#define XSIZE 256
#define YSIZE 256
#define ZSIZE 4
static unsigned char texelsR [ XSIZE * YSIZE ];
static unsigned char texelsG [ XSIZE * YSIZE ];
static unsigned char texelsB [ XSIZE * YSIZE ];
static unsigned char texelsA [ XSIZE * YSIZE ];
static FILE *fd;
static size_t writeByte (unsigned char x )
{
return fwrite ( & x, sizeof(unsigned char), 1, fd ) ;
}
static size_t writeShort (unsigned short x )
{
if (ulIsLittleEndian) // this is the other way round compared to normally.
// obviously, this is because the .rgb format comes from SGI.
ulEndianSwap(&x);
return fwrite( & x, sizeof(unsigned short), 1, fd ) ;
}
static size_t writeInt (unsigned int x)
{
if (ulIsLittleEndian) // this is the other way round compared to normally.
// obviously, this is because the .rgb format comes from SGI.
ulEndianSwap(&x);
return fwrite( & x, sizeof(unsigned int), 1, fd ) ;
}
#define SGI_IMG_MAGIC 0x01DA
static int writeTexelsIntoSGI ( const char *fname )
{
fd = fopen ( fname, "wb" ) ;
size_t NoWritten = 0;
if ( fd == NULL )
{
ulSetError(UL_WARNING, "ssgLoadTexture: Failed to open '%s' for writing.", fname ) ;
return false;
}
// ******* write the header *****************
NoWritten += writeShort (SGI_IMG_MAGIC) ;
NoWritten += writeByte (0) ; // don't use RLE
NoWritten += writeByte (1) ; // bpp
NoWritten += writeShort (3) ; // dimension
NoWritten += writeShort ( XSIZE ) ;
NoWritten += writeShort ( YSIZE ) ;
NoWritten += writeShort ( ZSIZE ) ;
NoWritten += writeInt ( 0 ) ;
NoWritten += writeInt ( 255 ) ;
NoWritten += writeInt ( 0 ) ; /* Dummy field */
int i ;
for ( i = 0 ; i < 80 ; i++ )
NoWritten += writeByte ( 0 ) ; /* Name field */
NoWritten += writeInt ( 0 ) ; // colormap
for ( i = 0 ; i < 404 ; i++ )
NoWritten += writeByte ( 0 ) ; /* Dummy field */
// ************ write the body ****************
NoWritten += fwrite ( texelsR, XSIZE, YSIZE, fd ) ;
NoWritten += fwrite ( texelsG, XSIZE, YSIZE, fd ) ;
NoWritten += fwrite ( texelsB, XSIZE, YSIZE, fd ) ;
NoWritten += fwrite ( texelsA, XSIZE, YSIZE, fd ) ;
if(NoWritten!=91+404+4*YSIZE)
{ ulSetError(UL_WARNING, "Only %ld records written instead of %d. Proceed at your own risc\n",
(long)NoWritten, 91+404+4*YSIZE);
return false;
}
fclose ( fd ) ;
return true;
}
int loadMDLIntoTexels ( const char *fname )
// returns TRUE on success
{
FILE *tfile;
if ( (tfile = fopen(fname, "rb")) == NULL) {
ulSetError(UL_WARNING, "ssgLoadTexture: Failed to load '%s'.", fname );
return false;
}
fseek(tfile, 0, SEEK_END);
unsigned long file_length = ftell(tfile);
if (file_length != 65536) {
ulSetError(UL_WARNING, "ssgLoadTexture: Wrong size of '%s'.", fname );
return false;
} else {
fseek(tfile, 0, SEEK_SET);
int c = 0;
for (int y = 0; y < 256; y++) {
for (int x = 0; x < 256; x++) {
unsigned char b;
if ( fread(&b, 1, 1, tfile) != 1)
return false;
texelsR[c] = ssgFsTexPalette[b*4 ];
texelsG[c] = ssgFsTexPalette[b*4 + 1];
texelsB[c] = ssgFsTexPalette[b*4 + 2];
texelsA[c] = ssgFsTexPalette[b*4 + 3];
c++;
}
}
fclose(tfile);
}
return true;
}
void DoAllFiles( char *sDirectoryP )
{ char newname [ 1024 ], sDirectory[1024], sFullPath[1024]; // todo fixme
strcpy( sDirectory, sDirectoryP);
if ( ( sDirectoryP[ strlen(sDirectoryP)-1 ] != '\\') &&
( sDirectoryP[ strlen(sDirectoryP)-1 ] != '/') )
strcat( sDirectory, "/");
// ************** For all *.?af files in the current dir ************
ulDir* dirp = ulOpenDir(".");
if ( dirp != NULL )
{
ulDirEnt* dp;
while ( (dp = ulReadDir(dirp)) != NULL )
{
if ( !dp->d_isdir )
{ size_t len = strlen(dp->d_name );
if ( len >4 )
if ((dp->d_name[len-1] == 'f') || (dp->d_name[len-1] == 'F'))
if ((dp->d_name[len-2] == 'a') || (dp->d_name[len-2] == 'A'))
if ((dp->d_name[len-4] == '.') || (dp->d_name[len-4] == '.'))
{ strcpy( newname, dp->d_name );
unsigned int i;
for (i=0; i<len; i++)
newname [i] = tolower ( newname [i] );
newname[len-4] = newname[len-3];
newname[len-3] = '.';
newname[len-2] = 'r';
newname[len-1] = 'g';
newname[len] = 'b';
newname[len+1] = 0;
ulSetError(UL_DEBUG, "%s %s\n",dp->d_name, newname);
// ********** convert it **************
if ( loadMDLIntoTexels ( dp->d_name ))
{ strcpy(sFullPath, sDirectory);
strcat(sFullPath, newname);
writeTexelsIntoSGI ( sFullPath ); //lint !e534
}
}
}
}
ulCloseDir(dirp);
}
}
// converts all *.?af files from the current dir to *.rgb in the dir givven in the argument
int main(int argc, char* argv[])
{
if ( argc > 2 )
ulSetError(UL_WARNING, "All arguments after the first are ignored!" );
if ( argc >= 2 )
DoAllFiles( argv[1] );
else
DoAllFiles(".");
return 0;
}

102
tools/src/af2rgb/af2rgb.dsp Normal file
View File

@@ -0,0 +1,102 @@
# Microsoft Developer Studio Project File - Name="af2rgb" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=af2rgb - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "af2rgb.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "af2rgb.mak" CFG="af2rgb - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "af2rgb - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "af2rgb - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "af2rgb - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sg.lib ssg.lib ul.lib opengl32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\\"
!ELSEIF "$(CFG)" == "af2rgb - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sg_d.lib ssg_d.lib ul_d.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\\"
!ENDIF
# Begin Target
# Name "af2rgb - Win32 Release"
# Name "af2rgb - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\af2rgb.cxx
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

18
tools/src/afm2txf/README Normal file
View File

@@ -0,0 +1,18 @@
It's definitely a tool of the "duct tape and fishing line" variety. :)
It expects to find a ghostscript interpreter and ImageMagick's "mogrify"
program on the command line, takes a .afm font metrics file as its sole
argument, and expects that the font therein is accessible to ghostscript.
Basically, it should work out of the box on most linux distributions,
and nowhere else without a lot of work.
If you have a TrueType font that you want to generate:
export GS_FONTPATH=<wherever the font is>
ttf2afm yourfont.ttf > whatever.afm
font.pl whatever.afm
Wait for a while (at 16x downsampling, this takes 1-2 minutes on my
Athlon 1800+), and the .txf file will appear in the current directory.
It will have the Postscript language name of the font.
Andy

283
tools/src/afm2txf/afm2txf.pl Executable file
View File

@@ -0,0 +1,283 @@
#!/usr/bin/perl -w
# afm2txf.pl 0.2
#
# Generates .txf font textures from Type 1 fonts
# Requirements: Ghostscript, ImageMagick
#
# Usage:
# afm2txf.pl whatever.afm
#
# Changelog:
# 0.2 (06/28/2002): Generate fonts with proper padding
# 0.1 (06/28/2002): Initial version
#
# Copyright (C) 2002 Andrew James Ross
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
use strict;
my $METRICS = shift or die; # AFM file
# Texture size
my $TEXSIZ = 256;
# Padding around each character, for mipmap separation
my $PADDING = 4;
# Antialiasing multiplier. Should be 16 for production work. As low
# as 4 works well for testing.
my $DOWNSAMPLE = 16;
# The 94 printable ASCII characters (and the space) and their
# postscript glyph names. We use names because not all postscript
# fonts are encoded using ASCII. AFM metrics generated by ttf2afm, in
# fact, don't have any numerical character IDs at all. In principle,
# this mechanism will work for any 8 bit font encoding, you just have
# to do the legwork of figuring out the name to ID mapping.
my %CHARS = ('space'=>32, 'exclam'=>33, 'quotedbl'=>34,
'numbersign'=>35, 'dollar'=>36, 'percent'=>37,
'ampersand'=>38, 'quotesingle'=>39, 'parenleft'=>40,
'parenright'=>41, 'asterisk'=>42, 'plus'=>43,
'comma'=>44, 'hyphen'=>45, 'period'=>46, 'slash'=>47,
'zero'=>48, 'one'=>49, 'two'=>50, 'three'=>51,
'four'=>52, 'five'=>53, 'six'=>54, 'seven'=>55,
'eight'=>56, 'nine'=>57, 'colon'=>58, 'semicolon'=>59,
'less'=>60, 'equal'=>61, 'greater'=>62, 'question'=>63,
'at'=>64, 'A'=>65, 'B'=>66, 'C'=>67, 'D'=>68, 'E'=>69,
'F'=>70, 'G'=>71, 'H'=>72, 'I'=>73, 'J'=>74, 'K'=>75,
'L'=>76, 'M'=>77, 'N'=>78, 'O'=>79, 'P'=>80, 'Q'=>81,
'R'=>82, 'S'=>83, 'T'=>84, 'U'=>85, 'V'=>86, 'W'=>87,
'X'=>88, 'Y'=>89, 'Z'=>90, 'bracketleft'=>91,
'backslash'=>92, 'bracketright'=>93, 'asciicircum'=>94,
'underscore'=>95, 'grave'=>96, 'a'=>97, 'b'=>98, 'c'=>99,
'd'=>100, 'e'=>101, 'f'=>102, 'g'=>103, 'h'=>104,
'i'=>105, 'j'=>106, 'k'=>107, 'l'=>108, 'm'=>109,
'n'=>110, 'o'=>111, 'p'=>112, 'q'=>113, 'r'=>114,
's'=>115, 't'=>116, 'u'=>117, 'v'=>118, 'w'=>119,
'x'=>120, 'y'=>121, 'z'=>122, 'braceleft'=>123,
'bar'=>124, 'braceright'=>125, 'asciitilde'=>126);
my %metrics = ();
my %positions = ();
#
# Parse the font metrics. This is a 5 element array. All numbers are
# expressed as a fraction of the line spacing.
# 0: nominal width (distance to the next character)
# 1, 2: Coordinates of the lower left corner of the bounding box,
# relative to the nominal position.
# 3, 4: Size of the bounding box
#
print STDERR "Reading font metrics...\n";
my $FONT;
my @lines = `cat $METRICS`
or die "Couldn't read metrics";
foreach my $m (grep {/^(C|FontName) /} @lines) {
chomp $m;
if($m =~ /^FontName ([^\s]*)/) { $FONT = $1; next; }
die "No name: $m" if $m !~ /N\s+([^\s]+)\s+;/;
my $name = $1;
die "No box: $m"
if $m !~ /B\s+([-0-9]+)\s+([-0-9]+)\s+([-0-9]+)\s+([-0-9]+)\s+;/;
my ($left, $bottom, $right, $top) = ($1/1000, $2/1000, $3/1000, $4/1000);
die "No width: $m" if $m !~ /WX\s+([-0-9]+)/;
my $nomwid = $1/1000; # nominal, not physical width!
# The coordinates of the corner relative to the character
# "position"
my ($x, $y) = (-$left, -$bottom);
my ($w, $h) = ($right-$left, $top-$bottom);
$metrics{$name} = [$nomwid, $x, $y, $w, $h];
}
die "No FontName found in metrics" if not defined $FONT;
#
# Find the height of the tallest character, and print some warnings
#
my $maxhgt = 0;
foreach my $c (keys %CHARS) {
if(!defined $metrics{$c}) {
print STDERR "% WARNING: no metrics for char $c. Skipping.\n";
next;
}
if($metrics{$c}->[4] > $maxhgt) { $maxhgt = $metrics{$c}->[4]; }
}
if($maxhgt == 0) {
print STDERR "No usable characters found. Bailing out.\n";
exit 1;
}
#
# Do the layout. Keep increasing the row count until the characters
# just fit. This isn't terribly elegant, but it's simple.
#
print STDERR "Laying out";
my $rows = 1;
my $PS;
my $LINEHGT;
while(!defined ($PS = genPostscript($rows))) { $rows++; }
print STDERR " ($rows rows)\n";
#
# Call ghostscript to render
#
print STDERR "Rendering Postscript...\n";
my $res = $TEXSIZ * $DOWNSAMPLE;
my $pid = open PS, "|gs -r$res -g${res}x${res} -sDEVICE=ppm -sOutputFile=$FONT.ppm > /dev/null";
die "Couldn't spawn ghostscript interpreter" if !defined $pid;
print PS join("\n", @$PS), "\n";
close PS;
waitpid($pid, 0);
#
# Downsample with ImageMagick
#
print STDERR "Antialiasing image...\n";
system("mogrify -geometry ${TEXSIZ}x${TEXSIZ} $FONT.ppm") == 0
or die "Couldn't rescale $FONT.ppm";
#
# Generate the .txf file
#
print STDERR "Generating textured font file...\n";
# Prune undefined glyphs
foreach my $c (keys %metrics) {
delete $metrics{$c} if !defined $CHARS{$c};
}
sub round { sprintf "%.0f", $_[0] }
open TXF, ">$FONT.txf" or die;
print TXF pack "V", 0x667874ff;
print TXF pack "V", 0x12345678;
print TXF pack "V", 0;
print TXF pack "V", $TEXSIZ;
print TXF pack "V", $TEXSIZ;
print TXF pack "V", round($TEXSIZ * $LINEHGT);
print TXF pack "V", 0;
print TXF pack "V", scalar(keys(%metrics));
my @chars = sort { $CHARS{$a} <=> $CHARS{$b} } (keys %metrics);
foreach my $c (@chars) {
my $m = $metrics{$c};
my $p = $positions{$c};
my $step = round($m->[0] * $LINEHGT * $TEXSIZ);
# Pad the bounding box, to handle areas that outside. This can
# happen due to thick lines in the font path, or be an artifact of
# the downsampling.
my $w = round($m->[3] * $LINEHGT * $TEXSIZ + 2*$PADDING);
my $h = round($m->[4] * $LINEHGT * $TEXSIZ + 2*$PADDING);
my $xoff = -round($m->[1] * $LINEHGT * $TEXSIZ - $PADDING);
my $yoff = -round($m->[2] * $LINEHGT * $TEXSIZ - $PADDING);
my $x = round($p->[0] * $TEXSIZ - $PADDING);
my $y = round($p->[1] * $TEXSIZ - $PADDING);
print TXF pack "v", $CHARS{$c};
print TXF pack "C", $w;
print TXF pack "C", $h;
print TXF pack "c", $xoff;
print TXF pack "c", $yoff;
print TXF pack "C", $step;
print TXF pack "C", 0;
print TXF pack "v", $x;
print TXF pack "v", $y;
}
# Read in the .ppm file, dump the duplicate color values (ghostscript
# won't generate pgm's) and write to the end of the .txf. Remember to
# swap the order of the rows; OpenGL textures are bottom-up.
open PPM, "$FONT.ppm" or die;
seek PPM, -3*$TEXSIZ*$TEXSIZ, 2 or die;
my @rows = ();
my $pixel;
for(my $r=0; $r<$TEXSIZ; $r++) {
my @row = ();
for(my $c=0; $c<$TEXSIZ; $c++) {
read PPM, $pixel, 3 or die;
push @row, substr($pixel, 0, 1);
}
push @rows, \@row;
}
close PPM;
for(my $r=(@rows - 1); $r>=0; $r--) {
print TXF join('', @{$rows[$r]});
}
close TXF;
# Clean up
#system("rm $FONT.ppm");
########################################################################
########################################################################
########################################################################
sub genPostscript {
my $rows = shift;
my $rowhgt = 1/$rows;
my @PS = ();
# The canonical "point size" number, in texture space
$LINEHGT = ($rowhgt - 2*$PADDING/$TEXSIZ) / $maxhgt;
# Get to where we want. Draw the whole thing in a 1 inch square at
# the bottom left of the "page".
push @PS, "72 72 scale";
# Fill the square with black
push @PS, "0 setgray";
push @PS, "-1 -1 moveto";
push @PS, "-1 1 lineto 1 1 lineto 1 -1 lineto";
push @PS, "closepath";
push @PS, "fill";
# Draw in white
push @PS, "1 setgray";
# Generate our PUSH @PS, font
push @PS, "/$FONT findfont $LINEHGT scalefont setfont";
my $x = $PADDING/$TEXSIZ;
my $y = 1 - $rowhgt + $PADDING/$TEXSIZ;
my @chars = sort { $CHARS{$a} <=> $CHARS{$b} } (keys %CHARS);
foreach my $c (@chars) {
my $m = $metrics{$c};
next if !defined $m;
my $id = sprintf "%2.2x", $CHARS{$c};
# No space?
my $w = $m->[3]*$LINEHGT;
if($x + $w + $PADDING/$TEXSIZ > 1) {
$x = $PADDING/$TEXSIZ;
$y -= $rowhgt;
return undef if $y < 0;
}
# Record where in the texture the box ended up
$positions{$c} = [$x, $y];
my $vx = $x + $m->[1]*$LINEHGT;
my $vy = $y + $m->[2]*$LINEHGT;
push @PS, "$vx $vy moveto";
push @PS, "<$id> show";
# Next box...
$x += $w + 2*$PADDING/$TEXSIZ;
}
push @PS, "showpage";
return \@PS;
}

99
tools/src/plibconvert.cxx Normal file
View File

@@ -0,0 +1,99 @@
// plibconvert.cxx
//
// Written by Bram Stolk
// Published as part of Steve Baker's PLIB under GPL
//
// Build with :
// g++ -o plibconvert plibconvert.cxx -lplibssg -lplibsg -lplibul -lGL
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/glx.h>
#include <plib/ssg.h>
int main(int argc, char *argv[])
{
if (argc!=3)
{
fprintf(stderr,"Usage: %s source destination\n", argv[0]);
exit(1);
}
assert(strcmp(argv[1], argv[2]));
#ifdef GLX_VERSION_1_3
// Although we will not be doing any rendering, we must create
// a valid rendering context before we can call ssgInit()
Display *dpy = XOpenDisplay(0);
int scn=DefaultScreen(dpy);
int cnt;
GLXFBConfig *configs = glXGetFBConfigs(dpy, scn, &cnt);
if (!configs)
{
perror("glXGetFBConfigs");
exit(1);
}
fprintf(stderr,"glXGetFBConfigs returned %p (%d matches)\n", configs, cnt);
assert(cnt);
GLXFBConfig fbc = configs[0];
XVisualInfo *vinf = glXGetVisualFromFBConfig(dpy, fbc);
if (!vinf)
{
perror("glXGetVisualFromFBConfig");
exit(1);
}
fprintf
(
stderr,
"visualid=0x%lx (depth=%d,R/G/B=%lx/%lx/%lx)\n",
vinf->visualid,
vinf->depth,
vinf->red_mask,
vinf->green_mask,
vinf->blue_mask
);
GLXContext cx = glXCreateNewContext(dpy, fbc, GLX_RGBA_TYPE, 0, GL_TRUE);
if (!cx)
{
perror("glXCreateNewContext");
exit(1);
}
else
{
fprintf(stderr,"glX context created\n");
}
int attrlist[] =
{
GLX_PBUFFER_WIDTH, 1,
GLX_PBUFFER_HEIGHT, 1,
0
};
GLXPbuffer pBuffer = glXCreatePbuffer(dpy, fbc, attrlist);
fprintf(stderr,"pBuffer = %lx\n", pBuffer);
bool ok=glXMakeContextCurrent(dpy, pBuffer, pBuffer, cx);
if (!ok)
{
perror("glXMakeContextCurrent");
exit(1);
}
// Initialize plib
fprintf(stderr,"Initializing plib...\n");
ssgInit();
ssgTexturePath ( "." ) ;
ssgModelPath ( "." ) ;
ssgEntity *e = ssgLoad(argv[1]); // Load
e->print(stdout); // Inform
ssgSave(argv[2], e); // Store
#else
fprintf(stderr,"This util uses a pbuffer as context for plib. To build the source, you need glx protocol 1.3 or higher.\n");
#endif
}

93
tools/src/txfdump/txfdump.pl Executable file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/perl -w
use strict;
## txfdump.pl - A .txf font file parser and image extractor
##
## Usage: txfdump.pl blahblah.txf
##
## Human readable font metric information will be printed to stdout,
## and a blahblah.pgm file will be written containing the texture
## image from the file. Note that the resulting image will be
## vertically reflected, owing to the difference between cartesian x/y
## coordinates used by .txf and the screen raster convention of the
## .pgm format (well, and the author's laziness). Load it up in your
## favorite viewer and flip it if you care.
##
## Copyright (C) 2002 Andrew James Ross
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2 as
## published by the Free Software Foundation.
my $file = shift or die;
open TXF, $file or die;
# Start out assuming intel byte order
# These get used in the getshort/getint functions below
my $shortType = "v";
my $longType = "V";
sub getsbyte { my $v=getbyte(); if($v>127) { $v-=256; } return $v; }
sub getbyte { my $val; read TXF, $val, 1 or die; return ord $val; }
sub getshort { my $val; read TXF, $val, 2 or die; return unpack $shortType, $val; }
sub getint { my $val; read TXF, $val, 4 or die; return unpack $longType, $val; }
# Check the magic number; it is endian-independant
my $magic = sprintf "0x%8.8x", getint();
die "Bad magic number ($magic)" if $magic ne "0x667874ff";
# Read the next four bytes to determine endianness
my $endian = sprintf "0x%8.8x", getint();
if($endian eq "0x12345678") {
} elsif($endian eq "0x78563412") {
# Network byte order
$shortType = "n";
$longType = "N";
} else {
die "Bad endianness tag ($endian)";
}
# Read the rest of the header
my $format = getint();
my $texwid = getint();
my $texhgt = getint();
my $linehgt = getint();
my $unk = getint();
my $nglyph = getint();
printf "Magic $magic Endian $endian Format 0x%8.8x\n", $format;
print "Texture: ${texwid}x$texhgt Line: $linehgt Glyphs: $nglyph Unk: $unk\n";
# Read each glyph's metadata
for(my $i=0; $i<$nglyph; $i++) {
print "Glyph $i\n";
my $c = getshort();
print " char: $c ('", chr($c), "')\n";
print " width: ", getbyte(), "\n";
print " height: ", getbyte(), "\n";
print " xoff: ", getsbyte(), "\n";
print " yoff: ", getsbyte(), "\n";
print " step: ", getbyte(), "\n";
print " unk: ", getbyte(), "\n";
print " X: ", getshort(), "\n";
print " Y: ", getshort(), "\n";
}
# The rest of the file is an image. Write it out as a .pgm file with
# the same name as the font file.
$file =~ s/\.txf$/.pgm/;
open PGM, ">$file" or die;
print PGM "P2\n$texwid $texhgt\n255\n";
if($format == 0) {
for(my $i=0; $i<($texwid*$texhgt); $i++) { print PGM getbyte(), " "; }
} else {
for(my $i=0; $i<($texwid*$texhgt/8); $i++) {
my $byte = getbyte();
for(my $j=0; $j<8; $j++) {
print PGM ($byte & (1<<$j)) ? "255 " : "0 ";
}
}
}

29
tools/tools.dsw Normal file
View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "af2rgb"=.\SRC\AF2RGB\af2rgb.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################