remove plib
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
Changes for SM:
|
||||
|
||||
Implement missing sgFullXformPnt4.
|
||||
|
||||
Turn off debug info and runtime checks, so the .libs built in VC7
|
||||
will work in VC6.
|
||||
|
||||
Point output libs to the top-level plib dir, which is where they are
|
||||
in the distributed .tar.gz's on the plib website.
|
||||
@@ -1,66 +0,0 @@
|
||||
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
|
||||
|
||||
Then, the non-registered contributors:
|
||||
|
||||
(Apologies to anyone I've left
|
||||
out - please let me know who
|
||||
you are and I'll add you in.)
|
||||
|
||||
Andrew Ross
|
||||
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
|
||||
|
||||
@@ -1,496 +0,0 @@
|
||||
|
||||
SPECIAL NOTICE:
|
||||
|
||||
As a special exception Steve Baker gives permission to link these
|
||||
libraries with proprietary software and distribute the resulting
|
||||
executable without including that proprietary code in any distribution
|
||||
as the LGPL would normally dictate.
|
||||
|
||||
This exception is ONLY granted in the case of an embedded system in
|
||||
which there is no possibility of an end user re-linking or recompiling
|
||||
against new versions of this library that may appear in the future.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, 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 library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, 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 companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, 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 library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete 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 distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
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 Library or any portion
|
||||
of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
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 Library, 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 Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you 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.
|
||||
|
||||
If distribution of 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 satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. 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.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library 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.
|
||||
|
||||
9. 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 Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
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.
|
||||
|
||||
11. 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 Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library 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 Library.
|
||||
|
||||
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.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library 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.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library 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 Library
|
||||
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 Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
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
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. 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 LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
@@ -1,943 +0,0 @@
|
||||
|
||||
PLIB Change Log.
|
||||
================
|
||||
|
||||
PLIB v1.6.0 (Sept 2nd 2002)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
It's been over a year since the last PLIB release
|
||||
and we have been somewhat lax about maintaining a
|
||||
list of changes.
|
||||
|
||||
Some highlights are:
|
||||
|
||||
* Significant improvements and cleanup throughout PLIB,
|
||||
especially in PUI.
|
||||
|
||||
* ssgAux library added - includes handy classes for
|
||||
more sophisticated effects layered on top of SSG.
|
||||
|
||||
+ Standard shapes like cubes, spheres,
|
||||
cylinders and teapots.
|
||||
|
||||
+ Water waves.
|
||||
|
||||
+ Fire.
|
||||
|
||||
+ Particle Systems
|
||||
|
||||
+ Lens Flare.
|
||||
|
||||
* More example programs.
|
||||
|
||||
* P-Guide GUI builder for PUI.
|
||||
|
||||
* JS promoted to a full library.
|
||||
|
||||
PLIB v1.5.1 (July 21st 2001)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Added ssgTween and ssgTweenController
|
||||
|
||||
* Added puFileSelector - henceforth puFilePicker is deprecated.
|
||||
|
||||
* Added ulList
|
||||
|
||||
* Added VRML loader (this one works!)
|
||||
|
||||
* Numerous bug fixes in other loaders.
|
||||
|
||||
* Added TopHat support to JS
|
||||
|
||||
* Added support for >3 simultaneous sounds in SL.
|
||||
(You have to explicitly enable that though - it's not
|
||||
the default)
|
||||
|
||||
* Fixed bugs in util's directory handling.
|
||||
|
||||
* puInput and puListBox now cope better with text that
|
||||
is too big for the widget
|
||||
|
||||
* puListBox (and hence puFileSelector and puFilePicker)
|
||||
works with both large and small font sizes.
|
||||
|
||||
* puDial changed to be derived from puSlider - many
|
||||
consequences of that change will be visible in the
|
||||
application. (eg output range is 0..1 and not 0..360)
|
||||
|
||||
* PUI widgets are now 'sticky' so that if you are
|
||||
dragging a slider along a puSlider and your mouse
|
||||
slips off the edge of it, it'll still have "focus".
|
||||
|
||||
* Added sgLerpAnglesVec3 to linearly interpolate
|
||||
angles allowing for the nasty wrap-around-360
|
||||
problem.
|
||||
|
||||
* Added sgLineSegment3ToLine3, sgDistSquaredToLineVec3
|
||||
sgDistSquaredToLineSegmentVec3, sgDistToLineVec3 and
|
||||
sgDistToLineSegmentVec3. Also sgLine3 and sgLineSegment3
|
||||
structures.
|
||||
|
||||
* Added a 'Gallery' page to the documentation to show
|
||||
potential developers the range of applications that use
|
||||
PLIB - and also to promote things our developers have done.
|
||||
To save download time and CVS space, the actual images
|
||||
are not in the PLIB tarball.
|
||||
|
||||
PLIB v1.4.2 (July 21st 2001)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Changes in NET to allow compilation under RedHat 7.1
|
||||
|
||||
* Fixed a small bug in ssgaSphere
|
||||
|
||||
* Fixes a small bug in puFilePicker
|
||||
|
||||
PLIB v1.4.1 (June 25th 2001)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Converted MSVC project files to 'BINARY' in the CVS archive
|
||||
because some versions of MSVC don't line UNIX-style line endings.
|
||||
|
||||
* Many improvements and bug fixes to puFileSelector and puListBox.
|
||||
|
||||
* Minor fix to NET to accomodate Solaris users.
|
||||
|
||||
* Fixed puMenuBar so it highlights as you drag the mouse across it.
|
||||
|
||||
* Fixed ulOpenDir so it returns NULL on error on non-MSVC systems
|
||||
|
||||
* Changed colour of text on buttons in documentation to make them
|
||||
easier to read by colour-blind users.
|
||||
|
||||
PLIB v1.5.0 (June 20th 2001)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Just a 'place holder' - actually identical to 1.4.0.
|
||||
|
||||
PLIB v1.4.0 (June 20th 2001)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Fixed example programs so they don't use the obsolete _SSG_TYPE
|
||||
tags.
|
||||
|
||||
* Removed multiplie <HEAD> tags on web pages.
|
||||
|
||||
* Updated 'AUTHORS' file.
|
||||
|
||||
* Added 'demos' to the CVS repository.
|
||||
|
||||
PLIB v1.3.3 (June 18th 2001)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Various warnings cleaned up under MSVC.
|
||||
|
||||
* Fixed function prototypes for the Quaternion functions in SG
|
||||
|
||||
* Fixed bug in sgEulerToQuat where the angles were not being
|
||||
converted from degrees to radians.
|
||||
|
||||
* Changed PUI to make sliders and dial widgets grab a hold
|
||||
of the mouse focus and not release it until the button is
|
||||
released. This is a subtle but important behavioural change.
|
||||
|
||||
* puDial's are now derived from puSlider's - one side-effect of
|
||||
that is that they now return 0..1 rather than 0..360 and no
|
||||
longer support the maximum and minimum range functions.
|
||||
|
||||
PLIB v1.3.2 (June 13th 2001)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* This CHANGES file has regrettably not been well maintained,
|
||||
hence there a numerous changes not listed here.
|
||||
|
||||
* File loaders now require app to pass 'ssgLoaderOptions'
|
||||
rather than other ad-hoc callback function hooks.
|
||||
|
||||
* Added Active Widget Implementation (pui)
|
||||
|
||||
* Added puFilePicker
|
||||
|
||||
* Added Ref Counting to ssgState
|
||||
|
||||
* Added puBiSlider and puTriSlider
|
||||
|
||||
* Added some missing 'AUTHORS' entries.
|
||||
|
||||
* puDial widget (was actually in 1.3.1 but got
|
||||
missed in the 'CHANGES' file)
|
||||
|
||||
* Fixed a problem in the configure.in that prevented
|
||||
ssgAux from building.
|
||||
|
||||
* Moved the 'name' and 'user_data' (with associated
|
||||
set/get member functions) from ssgEntity down into
|
||||
ssgBase so that these functions will work with ssgState
|
||||
and ssgTexture objects. This is needed for PrettyPoly.
|
||||
|
||||
PLIB v1.3.1 (Sept 15th 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Changed License conditions to specifically permit
|
||||
use of PLIB outside of LGPL for embedded applications.
|
||||
|
||||
* There is now a task and bug tracking system for PLIB
|
||||
on Sourceforge.
|
||||
|
||||
* Configuration/Install tool changed to support CygWin
|
||||
better than in the past.
|
||||
|
||||
* PLIB examples' data files consolidated into a single
|
||||
'examples/data' directory.
|
||||
|
||||
* PLIB's documentation is now under CVS.
|
||||
|
||||
* Added 'SSGAUX' library - include <plib/ssgAux.h>
|
||||
and link to /usr/lib/libplibssgaux.a
|
||||
|
||||
* Aux library has 'ssga' classes to add high level
|
||||
shapes such as cylinders, cubes and spheres (two
|
||||
different kinds).
|
||||
|
||||
* Lots of new example programs.
|
||||
+ New PUI 'complex' uses multiple windows.
|
||||
+ Cute 'waving flag' demo
|
||||
+ Working Quaternions versus Eulers demo
|
||||
+ Model viewer (this is actually a useful
|
||||
program - as well as a demo).
|
||||
|
||||
* More const-correctness throughout library.
|
||||
|
||||
* OPTIONAL support for PNG image loading (you have
|
||||
to compile PLIB specially to get this because it
|
||||
introduces an additional dependancy).
|
||||
|
||||
* PLIB now checks that a valid OpenGL rendering
|
||||
context exists when the various ssgInit/puInit/etc
|
||||
routines are called.
|
||||
|
||||
* PUI hasi:
|
||||
+ better support for multiple windows,
|
||||
+ a new function to allow the deletion of an object
|
||||
within one of it's own callbacks.
|
||||
+ the ability to operate in a separate OpenGL
|
||||
coordinate space.
|
||||
+ puFilePicker and puListBox
|
||||
+ enhancements to puSlider
|
||||
|
||||
* SL has a completely new audio driver for SGI's IRIX.
|
||||
Unfortunately, we don't think it fixes the long-standing
|
||||
timing problems for audio under IRIX.
|
||||
|
||||
* SSG's ssgVtxArray and ssgIndexArray now use 'short's for
|
||||
indices - which is more efficient on most OpenGL's.
|
||||
|
||||
* Several bugs fixed in SSG - also some changes to make it
|
||||
more suited to embedded use in game consoles and such.
|
||||
|
||||
* Many improvements to SSG's post-processing tools that are
|
||||
typically applied to scene graph fragments after loading
|
||||
from disk.
|
||||
|
||||
* SSG now permits you to disable MIPmapping for selected
|
||||
textures.
|
||||
|
||||
* SSG's print() functions now work for more classes and
|
||||
produce more useful output.
|
||||
|
||||
* Code for ssgVtxArray streamlined.
|
||||
|
||||
* Added a 'Lookat' function for SSG's camera model.
|
||||
|
||||
* ssgSelectors can now have more than 32 kids.
|
||||
|
||||
* ssgContext had incorrect defaults for the camera
|
||||
orientation.
|
||||
|
||||
* Some loaders were not sharing ssgState's between
|
||||
polygons - that's fixed.
|
||||
|
||||
* 3DS loader has had numerous improvements...but the
|
||||
limitations of this format are becoming evident.
|
||||
|
||||
* All error/warning handling is now done through a
|
||||
centralized handler that can be redirected (eg to
|
||||
send errors to a popup window or something)
|
||||
|
||||
* Some bugs fixed in ASE loader. It now uses
|
||||
ssgVtxArray primitives.
|
||||
|
||||
* Added a loader for the Quake 'MD2' format. It
|
||||
seems to work amazingly well.
|
||||
|
||||
* Added 'UL' library. Applications MUST link to
|
||||
-lplibul (/usr/lib/libplibul.a) - and should
|
||||
include <plib/ul.h> and call ulInit() before
|
||||
making UL calls.
|
||||
|
||||
If you use automake/autoconf, then it's easy
|
||||
to make applications that will compile and link
|
||||
under both PLIB 1.2 and 1.3/1.4, just add this:
|
||||
|
||||
AC_CHECK_LIB(plibul, ulInit,,,)
|
||||
|
||||
libplibul currently contains:
|
||||
|
||||
+ Fast, portable clock/timer routines.
|
||||
+ Low level networking code.
|
||||
+ Some directory searching routines.
|
||||
|
||||
* Documents and Examples are now under CVS.
|
||||
|
||||
* Added Tools and Auxlibs folders for future
|
||||
work.
|
||||
|
||||
|
||||
PLIB v1.3.0 (July 1st 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Unstable version of 1.2.0, no significant code
|
||||
changes.
|
||||
|
||||
PLIB v1.2.0 (July 1st 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Stable version of 1.1.12, no significant code
|
||||
changes.
|
||||
|
||||
PLIB v1.1.12 (June 24th 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed some compilation problems for Macintosh/Codewarrior
|
||||
which treats 'xor' and 'or' as reserved words!! Yikes!
|
||||
Thanks to Darrell Walisser for that piece of nasty news.
|
||||
|
||||
* Fixed some problems in slMODinst.cxx that were causing
|
||||
compilation warnings under windoze (thanks to Bram Stolk)
|
||||
|
||||
* Changed SL to open audio devices with O_NONBLOCK -
|
||||
thanks to Trent Gamblin for spotting this one.
|
||||
|
||||
* Added configure.in check for libdl to cover bug in ld.so
|
||||
under Linux. Application programs under Linux need to
|
||||
link to libdl.so in order to work around this.
|
||||
Ben Woodhead <zander@isn.net> added this.
|
||||
|
||||
* Added Borland project files, thanks to Dave Heil for
|
||||
contributing these.
|
||||
|
||||
* Swapped order of multiplication in sgMultMat4. Thanks to
|
||||
Lucas Ackerman for spotting this one.
|
||||
|
||||
* Added a unique ID field to every node in the scene graph.
|
||||
This helps out some picking algorithms in PPE.
|
||||
|
||||
* Added some more ifdefs to make PLIB Audio/JS components
|
||||
to make them work under NetBSD. (They already work with
|
||||
FreeBSD and OpenBSD). Many thanks to Rene Hexel!
|
||||
|
||||
* Fixed a ref() problem with ssgVtxTable::clone - thanks
|
||||
to Will Weisser for catching that one!
|
||||
|
||||
* Added checks to ensure that a valid OpenGL rendering
|
||||
context exists before ssgInit/puiInit/fnt-loaders are
|
||||
called.
|
||||
|
||||
* Added Dave McClurg's ASE loader and matching writer.
|
||||
If you use the new 'ssgLoad()/ssgSave()' functions,
|
||||
it'll "just work" - if you prefer you can call
|
||||
ssgLoadASE/ssgSaveASE analogously to all the other
|
||||
loaders.
|
||||
|
||||
* Several fixes to the quaternion code in SG were
|
||||
contributed by "Negative0" <negative0@earthlink.net>
|
||||
(Who was that masked man?)
|
||||
|
||||
PLIB v1.1.11 (Feb 9th 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed a tiny problem with double-sided polygons.
|
||||
|
||||
PLIB v1.1.10 (Feb 9th 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added ssgLoad and ssgSave that look at the
|
||||
filename extension and call the appropriate
|
||||
lower level load/save routine.
|
||||
|
||||
* Added a 'clone' function for all SSG classes.
|
||||
|
||||
* PLIB now managed under CVS at SourceForge.
|
||||
|
||||
http://sourceforge.net/project/?group_id=382
|
||||
|
||||
* Added a collection of line/plane, plane/plane
|
||||
and line/line intersection routines to SG.
|
||||
Thanks to Norman Vine for most of them.
|
||||
|
||||
* Fixed a bug in SSG file loader that would
|
||||
prevent recognition of obsolete SSG file
|
||||
types.
|
||||
|
||||
PLIB v1.1.9 (Jan 28th 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed bug that caused the ref counts of the
|
||||
various vertex arrays in an ssgVtxTable to
|
||||
be incorrectly set to zero when that VtxTable
|
||||
is loaded from an '.ssg' format file.
|
||||
This tended to crash SSG with an assertion
|
||||
failure whenever you deleted an object
|
||||
loaded from a '.ssg' file.
|
||||
|
||||
* Added the current texture map filename to
|
||||
ssgSimpleState and ssgStateSelector - which
|
||||
means that...
|
||||
|
||||
* The SSG file format finally works correctly.
|
||||
Note that any SSG files you might have created
|
||||
before this release won't work anymore...but
|
||||
then they didn't work correctly before.
|
||||
|
||||
PLIB v1.1.8 (Jan 23rd 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added ssgContext. This makes it a lot easier
|
||||
to write programs that need to render multiple
|
||||
eyepoints in quick succession.
|
||||
|
||||
* Added functionality to ssgVtxTable to enable
|
||||
applications to construct a vertex table and
|
||||
then add the vertex arrays instead of doing
|
||||
it all in one step.
|
||||
|
||||
PLIB v1.1.7 (Jan 20th 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Ooops! 1.1.6 accidentally went out set up to
|
||||
REQUIRE the 'freeglut' library instead of the
|
||||
original GLUT. That's fixed now - it'll pick
|
||||
up on whichever you have installed and use
|
||||
freeglut if you have both. (This only really
|
||||
selects which header PLIB will use - you can
|
||||
still link your application against either
|
||||
GLUT)
|
||||
|
||||
freeglut is here:
|
||||
http://freeglut.sourceforge.net
|
||||
|
||||
PLIB v1.1.6 (Jan 19th 2000)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Changed ssgSaveSSG and ssgSaveAC to return
|
||||
TRUE on success, FALSE otherwise. Neither
|
||||
function is really working well enough for
|
||||
'primetime' use.
|
||||
|
||||
* Added an optimisation to sgInvertMat4 (thanks
|
||||
to Norman Vine).
|
||||
|
||||
* Changed all Makefile.am's to refer to top_srcdir
|
||||
rather than top_builddir - I have no idea why that
|
||||
matters - but Steve Lamont <spl@szechuan.ucsd.edu>
|
||||
says it matters - so I fixed it!
|
||||
|
||||
* Fixed a bug in PUI's default colour scheme picker
|
||||
that caused text on dark coloured backgrounds to
|
||||
be black instead of white.
|
||||
|
||||
PLIB v1.1.5 (Dec 20th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Optimised sgMakeNormal (thanks to Klaus Hartmann!)
|
||||
* Added 'Orthographic' rendering modes to SSG...this
|
||||
is a work in progress - so no documentation yet - sorry!
|
||||
|
||||
PLIB v1.1.4 (Dec 3rd 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Moved pre- and post-draw callbacks from ssgLeaf
|
||||
to all ssgEntities.
|
||||
* Changed user-data - all userdata must be derived
|
||||
from ssgBase so that it can be ref-counted and
|
||||
automatically deleted when no longer referenced.
|
||||
* Added some specialised highlighting code for
|
||||
the PPE tool.
|
||||
|
||||
PLIB v1.1.3 (Nov 28th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added some missing 'get' functions to SSG.
|
||||
* Added a way to load the current view frustum
|
||||
and modelview matrices into OpenGL.
|
||||
* Removed dependancy of SSG on GLUT.
|
||||
* Added ssgVtxTable - which will ultimately
|
||||
replace ssgVTable. The main difference is
|
||||
that ssgVtxTables don't support indexing and
|
||||
add reference counted vertex data tables.
|
||||
* ssgLoadAC changed to use the new ssgVtxTable.
|
||||
* Added pre- and post-draw callbacks to ssgLeaf.
|
||||
|
||||
PLIB v1.1.2 (Nov 8th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed double declaration of sgdTransposeNegateMat4
|
||||
that prevented SG from compiling under Windoze.
|
||||
* Split examples and documentation off into a
|
||||
separate tarball.
|
||||
|
||||
PLIB v1.1.1 (Nov 6th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added routines to SG to interconvert sgd and sg
|
||||
data types.
|
||||
* Matrix inversion routines added to SG.
|
||||
* Attempt to work around possible compiler
|
||||
error in ssgLoad3Ds - this shows up in some
|
||||
versions of CygWin under Windoze and exhibits
|
||||
itself as an out-of-memory error when loading
|
||||
3DStudio models.
|
||||
|
||||
PLIB v1.1.0 (Oct 29th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* This is actually identical to 1.0.20 except
|
||||
that it installs its headers in /usr/include/plib
|
||||
and its libraries in /usr/lib. To avoid name-space
|
||||
pollution in /usr/lib, the libraries are renamed
|
||||
as follows:
|
||||
|
||||
libssg.a --> libplibssg.a
|
||||
libsg.a --> libplibsg.a
|
||||
libfnt.a --> libplibfnt.a
|
||||
|
||||
...you get the idea I'm sure.
|
||||
|
||||
* With this release, I'm going to the even-number-stable,
|
||||
odd-number-experimental numbering scheme. Hence,
|
||||
I'll be adding bug fixes only to the 1.0.xx series.
|
||||
When 1.1.xx has been enhanced - and is again stable,
|
||||
it'll become 1.2.0 and 1.3.0 will be the experimental
|
||||
version.
|
||||
|
||||
PLIB v1.0.20 (Oct 29th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed problem with memory leakage in SSG, the
|
||||
ref count of branch nodes was including the
|
||||
parent nodes as well as the children. Revised
|
||||
instructions on deleting nodes added to manual.
|
||||
|
||||
* Added sgDistanceSquaredVec2/3/4 to SG. (Christian
|
||||
Mayer asked *so* nicely).
|
||||
|
||||
* Added Per Liedman's latest 3D studio file loader.
|
||||
This is a truly awesomely useful thing. Thanks Per!
|
||||
|
||||
* This will be the last version to install in
|
||||
/usr/local/plib.
|
||||
|
||||
PLIB v1.0.19 (Oct 16th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added bunches of missing 'const' directives to SG and
|
||||
parts of SSG. Thanks to Christian Mayer for this one.
|
||||
|
||||
* Fixed a bug in FNT that should allow more than two
|
||||
lines of text to be output with a single call to
|
||||
puFont::drawString. Thanks to Sylvan Clebsch for this one.
|
||||
|
||||
* Added a 'saturation' limit to js.h - intended for those
|
||||
joysticks that don't generate a full range of output.
|
||||
Thanks again to Sylvan Clebsch!
|
||||
|
||||
* Keiji Kato provided a patch to SL for the Windoze
|
||||
platform that fixes some kind of a slowdown problem
|
||||
when playing sounds on WinNT-4 machines.
|
||||
|
||||
PLIB v1.0.18 (Oct 3rd 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Removed GIF files from all the Web pages. Rassin-frassin
|
||||
Unisys...grumble >:-(
|
||||
|
||||
* Fixed a problem that caused too many joystick axes to be
|
||||
reported by JS. Thanks to Paolo Leoncini - good catch!
|
||||
|
||||
* Added new Quaternion interpolation routines and reduced
|
||||
complexity of quaternion multiplication routines. Thanks
|
||||
to Sylvan Clebsch.
|
||||
|
||||
* ssgEntity (and hence most SSG classes) didn't make a copy
|
||||
of strings passed to setName() - hence there was a tendancy
|
||||
to leak name memory as objects were deleted. That's fixed
|
||||
but be aware that 'name' is now copied.
|
||||
|
||||
* As requested by Christian Mayer, sgAddScaleVec functions
|
||||
have been added into SG.
|
||||
|
||||
* Fixed up some compilation warnings in ssgStateSelector.cxx,
|
||||
fnt.cxx and ssgSaveAC.cxx. (Thanks to Sylvan Clebsch for those)
|
||||
|
||||
* Fixed a potential problem in ssgModelPath/ssgTexturePath that
|
||||
would blow up if you ever passed a local string variable to
|
||||
them. Be sure not to call either function before ssgInit() - OK!
|
||||
|
||||
PLIB v1.0.17 (Aug 23rd 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added new ssgState derivitive "ssgStateSelector".
|
||||
Check out SSG documents for details.
|
||||
|
||||
* Stopped warning about unused variable 'ww' in FNT and SSG.
|
||||
|
||||
* Fixed bug in puValue::setValue(char*) that prevented empty
|
||||
strings from changing the current string state for the puValue.
|
||||
(Thanks to Sylvan Clebsch for finding that one)
|
||||
|
||||
* Removed the 'test' program for PUI (it was never meant to
|
||||
be in the release).
|
||||
|
||||
* Added error return to Font loaders (Thanks to Norman Vine).
|
||||
|
||||
PLIB v1.0.16 (Aug 13th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed compiler warning in slMODfile.cxx
|
||||
|
||||
* Fixed a bunch of compile errors in slScheduler.cxx due to
|
||||
some default arguments that got left in place by mistake.
|
||||
|
||||
PLIB v1.0.15 (Aug 12th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Minor fix to SL to make it compile under CygWin.
|
||||
Thanks to Norman Vine for that one.
|
||||
|
||||
* MacOS port of SL is now complete! Many thanks to
|
||||
Darrell Walisser <dwaliss1@purdue.edu>
|
||||
|
||||
* Fixed a problem with const correctness when compiling with
|
||||
gcc 2.95.
|
||||
|
||||
* Moved a lot of SL functions from inline to non-inline...
|
||||
they had grown over time from one liners into 10 liners.
|
||||
|
||||
* In SM, changed 'not_working' to 'notWorking' to make it
|
||||
look more like SL.
|
||||
|
||||
* Fixed bug that caused SL to crash if you played MOD music
|
||||
without a sound card (Thanks to Daryll Strauss for finding
|
||||
that one).
|
||||
|
||||
* Fixed bug in puButton constructor that makes menus come
|
||||
out with irregular height.
|
||||
|
||||
* Fixed recurrent crashing problem with the PUI 'complex'
|
||||
demo program.
|
||||
|
||||
PLIB v1.0.14 (Aug 4th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* The use of PROXY textures seems to break both nVidia and G200
|
||||
Mesa ports for Linux - so I have temporarily commented out
|
||||
that code. If you need it, find the code in src/ssg/ssgImageLoader.cxx
|
||||
and src/fnt/fntTXF.cxx and re-instate the code that's ifdef'ed out
|
||||
using #ifdef PROXY_TEXTURES_ARE_NOT_BROKEN
|
||||
|
||||
* Significant fixes to SL to make it work with /dev/audio under
|
||||
SOLARIS. Thanks to Steve Brown for his patch.
|
||||
|
||||
* Somehow the FNT documentation became corrupted in 1.0.13,
|
||||
it's fixed now though.
|
||||
|
||||
* FNT and PUI now allow '\n' characters inside strings to
|
||||
signify carriage-return + line-feed. Thanks to Shane Arnott
|
||||
for this one.
|
||||
|
||||
* Added parameters to FNT routines to allow the application
|
||||
to pick which OpenGL texture filtering to apply.
|
||||
|
||||
* Fixed some minor name-space pollution in PUI.
|
||||
|
||||
* Fixed a bug in ssgBaseTransform that causes ssgGetLastTransform
|
||||
to mess up on the first call.
|
||||
|
||||
* Fixed a bug in measuring the bounding box of text containing
|
||||
space characters in the FNT component. Thanks to Alexander A.
|
||||
Babichev for this one.
|
||||
|
||||
* Lots of minor syntax changes for MSVC,
|
||||
|
||||
PLIB v1.0.13 (July 8th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Included a JS patch from Karl Heinz Kremer <khk@khk.net> that
|
||||
adds support for the latest Linux joystick driver. For those
|
||||
who have the latest driver, this will increase the number of
|
||||
joystick axes from 2 to 6.Beware though that the detection of
|
||||
which kind of driver is present is currently done at compile
|
||||
time which could be a problem for binary distributed code.
|
||||
|
||||
* Added a simple terrain demo (examples/ssg/majik)- originally
|
||||
put together to give the good people in the Majik group
|
||||
something to play with.
|
||||
Check out *their* good stuff at: http://majik.netti.fi
|
||||
|
||||
* Improved state handling in SSG. Also added ssgForceBasicState().
|
||||
|
||||
* JS library should work with FreeBSD. (Thanks to Stephen Montgomery-Smith)
|
||||
|
||||
* Texture loaders in SSG and FNT changed to use GL_PROXY texture
|
||||
tests instead of being hard-coded to crappy 256x256 limits.
|
||||
|
||||
* Since puiAlone is sadly outdated, I have ceased to distribute it.
|
||||
If you need it, the last version is with plib-1.0.12 on the PLIB
|
||||
homepage.
|
||||
|
||||
* Changed definition of SG_PI to be a 'float', fixed the precision
|
||||
of SGD_PI to be double.
|
||||
|
||||
* Removed strncasecmp - because it's not universally implemented.
|
||||
|
||||
* Changed an ifdef in SL to allow it to compile under FreeBSD.
|
||||
|
||||
* Added an 'puArrowButton' call - just like a puButton - but
|
||||
shaped like an arrow.
|
||||
|
||||
* Added an 'ssgGetVersion' call.
|
||||
|
||||
* Deleted ssgAnimation class (it was never completely
|
||||
implemented anyway).
|
||||
|
||||
* Added ssgTimedSelector (which takes over the functions
|
||||
I'd planned to add to ssgAnimation).
|
||||
|
||||
* I didn't rename the file ssgAnimation.cxx to ssgTimedSelector.cxx
|
||||
because I couldn't stand to change all the MSVC project thingies.
|
||||
|
||||
* Numerous fixes for the Mac:
|
||||
|
||||
* Fixed a byte-swapping problem with the BMP
|
||||
texture loader.
|
||||
|
||||
* Changed some arrays from local to 'new/delete' because
|
||||
the Mac CodeWarrior compiler can't cope with more than
|
||||
32Kb of local memory in a single function or class.
|
||||
|
||||
* Provided conditional compilation for Mac file naming
|
||||
conventions in a couple of places. It's not enough though.
|
||||
|
||||
PLIB v1.0.12 (June 3rd 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added a set of MSVC project files.
|
||||
|
||||
* More portability issues resolved.
|
||||
|
||||
* Lots more actually.
|
||||
|
||||
* Official Acronym "IBFITNR" (It'll Be Fixed In The Next Release)
|
||||
now adopted.
|
||||
|
||||
PLIB v1.0.11 (May 30th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed a problem with LoadAC creating 2-point tstrips.
|
||||
|
||||
* Fixed an assert in SSG's deRef.
|
||||
|
||||
* The tables inside an ssgVTable are now 'protected' rather
|
||||
than 'private'.
|
||||
|
||||
* Added new code to slScheduler to allow applications to
|
||||
replay MOD files.
|
||||
|
||||
* Reorganized slSamplePlayer to be derived from a new
|
||||
abstract base class slPlayer. Added new private class
|
||||
slMODPlayer for replaying MOD files.
|
||||
|
||||
* Added a demo program for the new SL MOD player.
|
||||
|
||||
* Added ssgRangeSelector class to allow level-of-detail
|
||||
management. This isn't well tested yet - but it's
|
||||
really simple code - so it should be OK.
|
||||
|
||||
PLIB v1.0.10 (May 10th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Ooops! A fatal error in my strcasecmp code.
|
||||
1.0.9 and 1.0.10 should have *died* on most
|
||||
machines!
|
||||
|
||||
PLIB v1.0.9 (May 9th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Error in SGI version of slSample.cxx cleared up (Thanks Devrim!)
|
||||
|
||||
* Made some changes for MSVC.
|
||||
|
||||
PLIB v1.0.8 (May 3rd 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* A couple of warnings eliminated from SL when compiled
|
||||
under CygWin.
|
||||
|
||||
* Added a contribution from Simon Britnell <ughbash@yahoo.com>
|
||||
to allow programs to search the SSG scene graph by name or
|
||||
path. (Thanks Simon!)
|
||||
|
||||
* Fixed a bug in sgIdentityQuat (Thanks Kevin!)
|
||||
|
||||
* Following the first release of Tux-aqfh, I was snowed under with
|
||||
little fixes.
|
||||
|
||||
+ strcasecmp should be stricmp on some machines...but alas, not
|
||||
on others. The heck with it - I'll just write my own!
|
||||
|
||||
+ fntFont wasn't pushing/popping GL state correctly.
|
||||
|
||||
+ More minor hacks to make for clean compiles under IRIX.
|
||||
|
||||
+ puInterface's destructor was only deleting half of it's
|
||||
child node.
|
||||
|
||||
+ Missing contructor functions for various SG classes.
|
||||
|
||||
+ SSG culling functions were not testing for empty
|
||||
bounding spheres.
|
||||
|
||||
+ Minor compilation warnings for slSample.cxx
|
||||
|
||||
+ example/sl/example.cxx used M_PI - which is a no-no under
|
||||
Windoze.
|
||||
|
||||
|
||||
PLIB v1.0.7 (May 3rd 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Removed a bunch of redundant NOTICE, CHANGES
|
||||
and REAME files. All that stuff is now maintained
|
||||
in the top level directory.
|
||||
|
||||
* SG used to be set up so you could compile it
|
||||
in double precision with the drop of an option.
|
||||
However, some applications need both float and
|
||||
double support - so SG now has duplicate functions
|
||||
for double-precision that start 'sgd'.
|
||||
|
||||
* Changed the structure of the FNT library to move
|
||||
font sizes from the fntFont/fntTexFont class into
|
||||
the fntRenderer class. This corrects a poor design
|
||||
decision because it was hard to create fonts in
|
||||
multiple point sizes and slants without using
|
||||
multiple identical texture maps (BAD!). RTFM.
|
||||
|
||||
* Added a bunch of TXF fonts into examples/fnt/data
|
||||
and changed the fnt_test program to cycle through
|
||||
them whenever you press a key.
|
||||
|
||||
* PUI can now use FNT fonts - which is good news
|
||||
because now you can use TXF fonts for better
|
||||
variety and speed compared to GLUT fonts.
|
||||
This means that PUI programs now need to
|
||||
link with -lpui -lfnt -lsg
|
||||
|
||||
* The PUI 'complex' example program now uses
|
||||
the sorority font.
|
||||
|
||||
* I added a 'rendering callback' to some
|
||||
PUI widgets as suggested by Eero Pajarre. The
|
||||
idea is to allow you to do arbitary OpenGL
|
||||
rendering onto a PUI widget...however, I'm
|
||||
not convinced that this is a good idea. In
|
||||
any case, you can put icons on widgets more
|
||||
easily by defining custom fonts using FNT.
|
||||
|
||||
|
||||
PLIB v1.0.6 (May 1st 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Added a complete new component library called
|
||||
FNT that allows texturemapped fonts to be
|
||||
loaded and rendered nicely.
|
||||
|
||||
* More small configure/compile problems fixed.
|
||||
|
||||
* Added Quaternions to the SG library thanks
|
||||
to a fine contribution from Kevin Thompson
|
||||
<kevinbthompson@yahoo.com>
|
||||
|
||||
* Fixed a bug in JS under Windoze that made
|
||||
three axis sticks return garbage in the
|
||||
third axis and swapped the order of the
|
||||
third and fourth axes for >3 axis sticks.
|
||||
|
||||
|
||||
PLIB v1.0.5 (April 21st 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed another IRIX compile problem in pu.h
|
||||
|
||||
* Found that configure script was not enabling
|
||||
full warning levels...as a result, fixed a
|
||||
dozen minor warnings in SSG.
|
||||
|
||||
* SSG's image loader now loads 8 bit and 24 bit
|
||||
uncompressed BMP files. This seems to work
|
||||
for RGB images - but I can't seem to build
|
||||
BMP images with Alpha planes using any of
|
||||
the tools I have.
|
||||
|
||||
|
||||
PLIB v1.0.4 (April 20th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Restructured SSG texture image loader to permit
|
||||
use of other file formats than SGI.
|
||||
|
||||
* In the event that a texture doesn't load, SSG will
|
||||
now insert a red and white chequerboard.
|
||||
|
||||
* Another round of changes to configure.in should
|
||||
solve the CygWin issues.
|
||||
|
||||
* Added in some *ancient* fixes to PUI - that kind
|
||||
people donated and I somehow forgot all about (oops!)
|
||||
|
||||
|
||||
PLIB v1.0.3 (April 18th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Fixed to compile cleanly under IRIX 6.2 using the
|
||||
official SGI C++ compiler.
|
||||
|
||||
* More fixes for MSVC under Windoze.
|
||||
|
||||
* OpenGL logo added to HTML documents following
|
||||
request from opengl.org
|
||||
|
||||
|
||||
PLIB v1.0.2 (April 14th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Yet more minor build tweaks - CygWin wasn't defining WIN32,
|
||||
that should work now.
|
||||
|
||||
* JS should now work with Windoze - and with sticks with
|
||||
up to 6 axes. Under Linux, the presence of the joystick
|
||||
driver (or at least it's header files) is now mandatory,
|
||||
PLIB won't build without it.
|
||||
|
||||
* The JS demo program has been fixed to display all of the
|
||||
axes of all of the joysticks.
|
||||
|
||||
* PUI now supports valuators - this is where the value of
|
||||
a widget is set using the address of one of the application's
|
||||
variables. Once the valuator is set, the PUI widget's display
|
||||
will always the same as the valuator - and any changes to the
|
||||
widget will also change the value stored at that address.
|
||||
This saves you from creating a bunch of callbacks when buttons
|
||||
and sliders have no side-effects apart from changing some
|
||||
global variable.
|
||||
|
||||
|
||||
PLIB v1.0.1 (April 11th 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Some minor portability issues cleared up.
|
||||
|
||||
* More minor build process errors corrected.
|
||||
|
||||
|
||||
PLIB v1.0 (April 1st 1999)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* All the separate libraries that I support in the
|
||||
public domain are now rolled into a single tarball
|
||||
under the new name 'PLIB'.
|
||||
|
||||
* Although this is the first release of PLIB. The sub-
|
||||
libraries: SL, JS and PUI had previous releases - this
|
||||
is the first Beta of SG and SSG.
|
||||
|
||||
* Directory layouts for all of the component libraries
|
||||
have been somewhat rationalized.
|
||||
|
||||
* I have shifted from a completely open license to
|
||||
LGPL on the advice of several OpenSource authors.
|
||||
Any earlier releases of these libraries that you
|
||||
may happen to have remain free of LGPL restrictions.
|
||||
If any contributors to the earlier code have objections
|
||||
to this arrangement, please let me know and I'll arrange
|
||||
to remove their code from subsequent copies.
|
||||
|
||||
* With help from Curtis Olson, we now have proper 'configure'
|
||||
scripts to streamline the build process.
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
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.
|
||||
|
||||
OpenGL Configure
|
||||
================
|
||||
|
||||
Configure is not able to find the OpenGL headers and libraries. In this
|
||||
case please add
|
||||
|
||||
./configure --with-GL=PREFIX
|
||||
|
||||
Examples
|
||||
|
||||
./configure --with-GL=/usr/local
|
||||
|
||||
This will look in the /usr/local/include for headers (GL/ is not needed)
|
||||
and /usr/local/lib for the libraries.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
Compiling for Windows with MSVC
|
||||
===============================
|
||||
|
||||
You can easily compile plib with MSVC 6. First, you have to set some paths
|
||||
in tools\options\directories. In "include" set the plib path itself (and,
|
||||
if needed the parent). Then, in "library paths" add the plib path itself again
|
||||
so that packages that use plib will find it. The building process will copy
|
||||
the finished *.lib files and any header files that are visible to projects
|
||||
using plib into the plib path.
|
||||
|
||||
There is a workspace (*.dsw file) for plib, for examples, for tools
|
||||
(including only af2rgb) and for each of the demos: exposer, p-guide
|
||||
and ttt3d. Simply open one of them (starting with plib itself, of course)
|
||||
in MSVC, choose what you want to compile (build/set active configuration)
|
||||
and then compile (F7). if you want to compile or even create a project
|
||||
that uses plib, please note that the plib workspaces have "multi threading"
|
||||
enabled. Either enable this as well in your project or disable it for
|
||||
plib. A missmatch leads to errors.
|
||||
|
||||
|
||||
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.
|
||||
@@ -1,25 +0,0 @@
|
||||
Known bugs and limitations in PLIB version 1.6.0
|
||||
|
||||
More in depth stuff can be found in TODO_AFTER135.
|
||||
|
||||
* ssgLOS is really broken.
|
||||
|
||||
* ssgStripify and ssgFlatten might well have bugs in them.
|
||||
A known bug of ssgStripify is that : since it rearranges and
|
||||
merges leaf nodes, ssgSelectors are messed up
|
||||
|
||||
* Sometimes cr*p values appear in 3D files, for example .ac files.
|
||||
The reason seems to be that sometimes the loader handles colours
|
||||
differently than the writer.
|
||||
|
||||
* Several, general smalish .MDL loader bugs are known; Look in TODO_AFTER135
|
||||
|
||||
* Scaling does not work (intentionally). Uniform scaling may be
|
||||
enabled by uncommenting "radius *= sgLengthVec3(m[0])" in
|
||||
sgSphere::orthoXform. It is currently disabled because that extra
|
||||
calculation would degrade performance on non-scaled matrices.
|
||||
Scaling really makes a mess of SSG bounding sphere tests
|
||||
|
||||
* .ssg files should not be used for long term storage. It will probably
|
||||
change in incompatible ways.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
SUBDIRS = src
|
||||
|
||||
EXTRA_DIST = KNOWN_BUGS NOTICE README README.GLUT \
|
||||
README.win32 README.mac TODO-1.6 TODO-2.0 \
|
||||
TODO_AFTER135 autogen.sh \
|
||||
plib.dsp plib.dsw transferCvs2WebSite
|
||||
|
||||
@@ -1,324 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = .
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
|
||||
SUBDIRS = src
|
||||
|
||||
EXTRA_DIST = KNOWN_BUGS NOTICE README README.GLUT README.win32 README.mac TODO-1.6 TODO-2.0 TODO_AFTER135 autogen.sh plib.dsp plib.dsw transferCvs2WebSite
|
||||
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
|
||||
Makefile.in NEWS aclocal.m4 config.guess config.sub configure \
|
||||
configure.in install-sh missing mkinstalldirs
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
$(ACLOCAL_M4): configure.in
|
||||
cd $(srcdir) && $(ACLOCAL)
|
||||
|
||||
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
|
||||
cd $(srcdir) && $(AUTOCONF)
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
rev="$$subdir $$rev"; \
|
||||
test "$$subdir" = "." && dot_seen=yes; \
|
||||
done; \
|
||||
test "$$dot_seen" = "no" && rev=". $$rev"; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
-rm -rf $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
|
||||
mkdir $(distdir)/=build
|
||||
mkdir $(distdir)/=inst
|
||||
dc_install_base=`cd $(distdir)/=inst && pwd`; \
|
||||
cd $(distdir)/=build \
|
||||
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist
|
||||
-rm -rf $(distdir)
|
||||
@banner="$(distdir).tar.gz is ready for distribution"; \
|
||||
dashes=`echo "$$banner" | sed s/./=/g`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
echo "$$dashes"
|
||||
dist: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
|
||||
-rm -rf $(distdir)
|
||||
dist-all: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
|
||||
-rm -rf $(distdir)
|
||||
distdir: $(DISTFILES)
|
||||
-rm -rf $(distdir)
|
||||
mkdir $(distdir)
|
||||
-chmod 777 $(distdir)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
installcheck-am:
|
||||
installcheck: installcheck-recursive
|
||||
install-exec-am:
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am:
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile
|
||||
all-redirect: all-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-tags clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-tags distclean-generic clean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -f config.status
|
||||
|
||||
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
-rm -f config.status
|
||||
|
||||
.PHONY: install-data-recursive uninstall-data-recursive \
|
||||
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
|
||||
uninstalldirs-recursive all-recursive check-recursive \
|
||||
installcheck-recursive info-recursive dvi-recursive \
|
||||
mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
|
||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all installdirs-am \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,23 +0,0 @@
|
||||
NOTICE: The PLIB Portable Interactive Applications Library distribution
|
||||
contains source code that is released as OpenSource under the GNU
|
||||
Library Public License. These programs are thus freely distributable
|
||||
without licensing fees. These programs are provided without guarantee
|
||||
or warrantee expressed or implied.
|
||||
|
||||
If you use PLIB in a commercial or shareware product, it would be nice
|
||||
if you gave credit where it is due. If you make any neat modifications
|
||||
or improvements to PLIB, I would greatly appreciate a copy of the
|
||||
improved code or at least a source patch.
|
||||
|
||||
Note that PLIB uses an addition to the LGPL:
|
||||
|
||||
As a special exception Steve Baker gives permission to link these
|
||||
libraries with proprietary software and distribute the resulting
|
||||
executable without including that proprietary code in any distribution
|
||||
as the LGPL would normally dictate.
|
||||
|
||||
This exception is ONLY granted in the case of an embedded system in
|
||||
which there is no possibility of an end user re-linking or recompiling
|
||||
against new versions of this library that may appear in the future."
|
||||
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
|
||||
Portability Libraries.
|
||||
======================
|
||||
by Steve Baker.
|
||||
|
||||
All the documentation and installation instructions
|
||||
are now online at:
|
||||
|
||||
http://plib.sourceforge.net
|
||||
|
||||
They are also downloadable - along with example
|
||||
programs and demos from the same site.
|
||||
|
||||
|
||||
SUPPORT:
|
||||
|
||||
Please don't email me (Steve Baker) directly - I
|
||||
get *WAY* too much mail as it is! Instead, please
|
||||
sign up to the PLIB user's mailing list. Instructions
|
||||
can be found here:
|
||||
|
||||
http://plib.sourceforge.net
|
||||
|
||||
|
||||
LICENSING:
|
||||
|
||||
These libraries are offered as OpenSource freeware
|
||||
under the provisions of the GNU Library Public
|
||||
License (LGPL). Those terms and conditions are
|
||||
detailed in the file 'LICENSE' in this directory.
|
||||
|
||||
I have added a short preamble to LGPL that removes
|
||||
no rights from ordinary users but offers special
|
||||
dispensation to allow PLIB to be used under certain
|
||||
commercial conditions (such as Games Consoles) where
|
||||
the constraints of LGPL are impossible to meet.
|
||||
|
||||
| As a special exception Steve Baker gives permission to link these
|
||||
| libraries with proprietary software and distribute the resulting
|
||||
| executable without including that proprietary code in any distribution
|
||||
| as the LGPL would normally dictate.
|
||||
|
|
||||
| This exception is ONLY granted in the case of an embedded system in
|
||||
| which there is no possibility of an end user re-linking or recompiling
|
||||
| against new versions of this library that may appear in the future.
|
||||
|
||||
|
||||
REQUIREMENTS:
|
||||
|
||||
In addition to the libraries that I provide, you
|
||||
will also need OpenGL (OpenGL 1.1 or later -
|
||||
Mesa 3.0 or later) and GLUT (The OpenGL utilities
|
||||
toolkit - version 3.7 or later) and a hardware 3D
|
||||
graphics accellerator that supports OpenGL.
|
||||
|
||||
|
||||
WHAT DO YOU GET?
|
||||
|
||||
The following libraries are provided:
|
||||
|
||||
JS -- A Joystick interface.
|
||||
PUI -- A simple GUI built on top of OpenGL.
|
||||
SG -- Some Standard Geometry functions (vector and
|
||||
matrix math, spheres, boxes, frustra, etc)
|
||||
SL -- A Games-oriented Sound Library.
|
||||
FNT -- OpenGL texture-mapped font Library.
|
||||
SSG -- A Simple Scene Graph API built on top of OpenGL.
|
||||
NET -- Some Networking functions for games.
|
||||
UTIL-- Utilities - things that your OS would normally
|
||||
handle - but these functions are portable.
|
||||
|
||||
|
||||
DIRECTORY STRUCTURE:
|
||||
|
||||
PLIB expects to be installed in one standard place:
|
||||
|
||||
/usr/lib
|
||||
|
||||
...with header files at:
|
||||
|
||||
/usr/include/plib
|
||||
|
||||
|
||||
PORTABILITY and DEPENDANCIES:
|
||||
|
||||
Although all these libraries are designed to be easily
|
||||
portable (and more importantly so that programs using
|
||||
them can be UTTERLY portable), some of them have not
|
||||
yet been ported to all operating systems.
|
||||
|
||||
JS -- Currently Linux/Windows/BSD only.
|
||||
|
||||
UTIL-- Should be portable to POSIX-compliant
|
||||
OS's ... and Windows.
|
||||
|
||||
SG -- Totally portable, no dependancies.
|
||||
|
||||
PUI -- Requires GLUT and OpenGL also FNT and SG.
|
||||
There is now an option to compile PUI without
|
||||
GLUT - but that is not the default.
|
||||
|
||||
NET -- Should be portable to POSIX-compliant
|
||||
OS's.
|
||||
|
||||
FNT and SSG -- Require OpenGL, SG and UTIL.
|
||||
|
||||
SL -- This has now been ported onto:
|
||||
|
||||
Linux
|
||||
FreeBSD
|
||||
OpenBSD
|
||||
M$ Windows (NT,95,98 - so far)
|
||||
MacOS
|
||||
SGI IRIX
|
||||
Sun Solaris
|
||||
Any operating system that supports OSS (The
|
||||
Open Sound System).
|
||||
|
||||
NOTE: SL has a subsidiary library 'SM' that
|
||||
can be used to control the audio mixer - but
|
||||
that is not portable beyond Linux. You might
|
||||
get it to work under OSS-based sound systems
|
||||
too. Don't use SM if you want to write portable
|
||||
code.
|
||||
|
||||
No other requirements.
|
||||
|
||||
|
||||
STABILITY AND RELIABILITY:
|
||||
|
||||
SSG, SG, SL, JS and PUI have all been in use for a long time
|
||||
in a huge number of applications - so they are reliable
|
||||
and unlikely to change much in the future.
|
||||
|
||||
UTIL and FNT are pretty simple and should be very stable.
|
||||
|
||||
SSGAUX is still fairly new though - new features added
|
||||
to it should not destroy older features though - so
|
||||
you can use it with confidence.
|
||||
|
||||
|
||||
AUX LIBRARIES AND TOOLS:
|
||||
|
||||
The 'tools' directory contains a number of useful tools
|
||||
and utility programs that are either built using PLIB or
|
||||
which are specifically useful when writing PLIB programs.
|
||||
|
||||
|
||||
COMPILING/LINKING WITH PLIB
|
||||
|
||||
In your source code, add any combination of:
|
||||
|
||||
#include <plib/ul.h>
|
||||
#include <plib/js.h>
|
||||
#include <plib/sg.h>
|
||||
#include <plib/fnt.h>
|
||||
#include <plib/pu.h>
|
||||
#include <plib/ssg.h>
|
||||
#include <plib/sl.h>
|
||||
#include <plib/net.h>
|
||||
#include <plib/ssgAux.h>
|
||||
|
||||
Add any of these to your link line:
|
||||
|
||||
-lplibjs -lplibssgaux -lplibssg -lplibsl -lplibpu
|
||||
-lplibfnt -lplibnet -lplibsg -lplibul
|
||||
|
||||
Under UNIX/Linux, you'll also need:
|
||||
|
||||
-lglut -lGLU -lGL -L/usr/X11/lib -lX11 -lXext -lXmu -lm
|
||||
|
||||
|
||||
Steve Baker.
|
||||
<sjbaker1@airmail.net>
|
||||
http://www.sjbaker.org
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
Though PUI depends on GLUT or freeglut by default, it is possible to
|
||||
build a GLUT-free PUI library by passing --without-glut to the configure
|
||||
script if you can live with a couple of limitations:
|
||||
|
||||
|
||||
Since there is no longer any way for PUI to glutGet() the screen
|
||||
dimensions, your application must tell PUI every time it changes the
|
||||
screen size:
|
||||
|
||||
puSetWindowSize ( int width, int height ) ;
|
||||
|
||||
|
||||
Spreading PUI widgets across multiple Windows does (at the moment) not
|
||||
work without GLUT.
|
||||
|
||||
|
||||
Without GLUT, PUI can also not create the default PUI fonts from the
|
||||
seven GLUT bitmap fonts like it normally would. Instead, it tries to load
|
||||
some textured fonts in the puInit routine. Hence, you have to ensure that
|
||||
the Courier.txf, Times-Roman.txf and Helvetica.txf files from
|
||||
examples/src/fnt/data/ are in the current directory when using the
|
||||
GLUT-free PUI library.
|
||||
|
||||
|
||||
- Sebastian Ude, August 2002
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
PLIB Project files for CodeWarrior
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
NOTE from Steve:
|
||||
It seems that the CodeWarrior project files for
|
||||
PLIB are considerably larger than the entire source
|
||||
distribution (450Kb!)
|
||||
|
||||
Hence, since Mac/CodeWarrior users are not exactly
|
||||
commonplace, I'm not going to include the project
|
||||
files into the distro and cause everyone else prolonged
|
||||
download times.
|
||||
|
||||
I suggest you contact Darrell Walisser <dwaliss1@purdue.edu>
|
||||
should you need to build PLIB in this setting.
|
||||
|
||||
Sorry!
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
|
||||
PLIB for Windoze.
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Let me first say that I (Steve Baker) don't own a copy
|
||||
of Windoze - so I have little or no ability to help
|
||||
Windoze owners with PLIB problems. It's especially
|
||||
important therefore that you direct problems and
|
||||
queries to the PLIB mailing lists. Subscription
|
||||
information is on the PLIB homepage:
|
||||
|
||||
http://plib.sourceforge.net
|
||||
|
||||
|
||||
CygWin:
|
||||
~~~~~~~
|
||||
The simplest way to build PLIB for Windoze is to
|
||||
use the CygWin compiler and toolset. Since that
|
||||
environment is pretty close to UNIX/Linux, the
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
...mechanism works perfectly.
|
||||
|
||||
|
||||
MingW32:
|
||||
~~~~~~~~
|
||||
A couple of people have asked about doing a MingW32 port - but
|
||||
as far as I can tell, the "configure/make/make install" approach
|
||||
*should* work.
|
||||
|
||||
|
||||
Microsoft Visual C++:
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
All you need to do is open the workspace "plib.dsw" in MSVC++,
|
||||
select the "plib" project (using Set Active Project in the Project
|
||||
menu), and build it (using "Rebuild All" in the Build menu).
|
||||
|
||||
In the examples folder, open the workspace "plib_examples.dsw".
|
||||
Each example has a seperate project in the workspace. Select
|
||||
the one you want and build it. Then you should be able to hit
|
||||
the Go icon on the toolbar and try it out.
|
||||
|
||||
For your own application, please note that the plib workspace
|
||||
leaves all the necessary includes (*.h) and libraries (*.lib)
|
||||
in the plib root directory (same as workspace). The debug
|
||||
libraries are given a '_d' suffix. Where ever you put those
|
||||
files, make sure #include <plib/ul.h> works so your code is
|
||||
more portable.
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
NEW FEATURES:
|
||||
|
||||
Structure section
|
||||
|
||||
* SSG needs RTTI to replace the rapidly vanishing SSG_TYPE bits resource.
|
||||
|
||||
* I'd like to see the FGFS sky model moved into ssgAux so everyone can use
|
||||
it. We got part of the way towards that - but it was never finished.
|
||||
|
||||
* I'd like to have a ROAM engine built into ssgAux for terrain rendering.
|
||||
(maybe not *literally* ROAM - but something very like it).
|
||||
|
||||
SSG section
|
||||
|
||||
* Support for bump maps, cubic environment maps, etc, etc on hardware
|
||||
that supports it.
|
||||
|
||||
* Support for multi-texture.
|
||||
|
||||
* Import some kind of Skin & Bones animation into ssgAux (using the
|
||||
ExPoser code - or something even better).
|
||||
|
||||
|
||||
Loader section
|
||||
|
||||
* MORE file readers and writer.
|
||||
For example, a reader/loader for WWII Fighters would be nice.
|
||||
|
||||
* No file writers for about 2/3rds of the file formats we support.
|
||||
|
||||
* I want the PPE material editor's file format built into SSG so we can
|
||||
load and save material lists.
|
||||
|
||||
* Model formats
|
||||
* VRML
|
||||
* XML version of ssg
|
||||
* WWII (I think thats the name)
|
||||
|
||||
SG section
|
||||
|
||||
* function to get the angle between two vectors
|
||||
|
||||
* plot points on a vector (walking in a straight line)
|
||||
|
||||
* Expand SG with more intersection and distance-measuring tricks.
|
||||
|
||||
|
||||
PUI section
|
||||
|
||||
* PUI should also be implemented with RTTI as well.
|
||||
|
||||
* Movable widgets
|
||||
|
||||
* PUI is still somewhat tied to GLUT...that should go. It'll need a
|
||||
way to get the window dimensions - and at least one built-in font
|
||||
before we can do that.
|
||||
|
||||
SL section
|
||||
|
||||
* Re-implement SL on top of OpenAL.
|
||||
|
||||
* Write players for more modern MOD-like music formats.
|
||||
|
||||
Examples section
|
||||
|
||||
* More example programs - more complete demo games and tools.
|
||||
|
||||
* More documentation for all the new features.
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
[ Put in tasks here that probably won't get done before PLIB 2.0 or change
|
||||
the API in a way that could break existing applications ]
|
||||
|
||||
PUI section
|
||||
|
||||
* Remove deprecated puFilePicker widget
|
||||
|
||||
* Remove deprecated old label and legend places
|
||||
|
||||
* Remove deprecated PUSTYLE_RADIO
|
||||
|
||||
* Remove deprecated 'int puValue::getValue ( void )' function
|
||||
(Application developers: Use 'puValue::getIntegerValue' instead)
|
||||
|
||||
* Remove deprecated 'int puObject::getDefaultValue ( void )' function
|
||||
(Application developers: Use 'puValue::getDefaultIntegerValue' instead)
|
||||
|
||||
* Line up widget constructors (explicit size vs. max coordinates issue)
|
||||
|
||||
* Change function parameters taking a 0/1 FALSE/TRUE value from 'int'
|
||||
to 'bool'
|
||||
|
||||
* In puDeactivateWidget (), invoke the active widget's down callback
|
||||
(Can't be realized prior to 2.0 since it could break existing programs
|
||||
relying on the old behaviour)
|
||||
|
||||
* Implement puiAUX for complex widgets [ unclear ]
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
|
||||
+============+
|
||||
| TO BE DONE |
|
||||
+============+
|
||||
|
||||
A tasks and bugs are now being tracked by sourceforge. Please
|
||||
goto: http://sourceforge.net/projects/plib/
|
||||
|
||||
* Have a look into known_bugs and fix them.
|
||||
|
||||
* Lines in ASCII files are terminated...
|
||||
|
||||
With '\n' under UNIX/Linux
|
||||
With '\r' under MacOS
|
||||
With BOTH under Windoze.
|
||||
|
||||
Hence, UNIX/Linux does no conversions of either '\r' or '\n'.
|
||||
and MAC swaps '\r' and '\n' on input.
|
||||
and Windoze dumps '\r' if it follows a '\n'.
|
||||
|
||||
This is a mess - so I'm changing all the ASCII I/O code
|
||||
to allow either or both '\n' or '\r' and I'm reading the
|
||||
ASCII files in BINARY mode.
|
||||
|
||||
* Array deletion requires '[]' after 'delete' on Mac.
|
||||
|
||||
* Some of the MSVC-project files for plib_examples seem to be
|
||||
broken, for example some miss a "winmm.lib".
|
||||
|
||||
* Check whether the new ssgStripify works with TuxKart
|
||||
See Steves post from 11.12.2000 15:12 for a problem description
|
||||
|
||||
|
||||
|
||||
The abbreviation NIV14 means not in Version 1.4.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Bugs:
|
||||
=====
|
||||
|
||||
- When creating fgfsTux, sometimes .ac, .dxf,
|
||||
.ase and .obj saved zero objects, although
|
||||
there were objects. For example, PLIB
|
||||
created this .ac file:
|
||||
----------- snip ------------
|
||||
AC3Db
|
||||
OBJECT world
|
||||
kids 0
|
||||
OBJECT group
|
||||
kids 0
|
||||
----------- snip ------------
|
||||
This seems to happen after ssgFlatten.
|
||||
- WK: Create a sphere in ppe. Save it as .ASE. See that values like
|
||||
diffuse colour are cr*p. Try to load it. It crashes. This could be
|
||||
one or - probably - two bugs. I don't think this is a ppe problem.
|
||||
The loader complains that number of faces is -2.
|
||||
The problem seems to be the writer.
|
||||
|
||||
*new remark*: About the diffuse values: I think it has to do with
|
||||
colour material, a loader (.ASE?) loading colours into a colour
|
||||
list and writing colours from the ssgSimpleState where they are
|
||||
undefined. I think the same bug is in .AC
|
||||
|
||||
- WK: I have a crash in ssgFlatten if I load .ac files with
|
||||
unused materials (not reproducable?)
|
||||
- Loading and saving lines in .OBJ doesn't work. Maybe NIV14.
|
||||
- Sam wrote:
|
||||
Has anyone here debugged with plib under Windoze 2000 and MSVC++?
|
||||
I get a whole bunch of
|
||||
"Free Heap block modifed after it was free"
|
||||
warnings with the ssgFlatten and ssgStripify.
|
||||
I'll try and hunt this one down.
|
||||
...
|
||||
I think it may be because I'm using MFC which (if I remember
|
||||
correctly) enables a bunch more memory checks. Also I'm doing
|
||||
#ifdef _WIN32
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#endif
|
||||
- Not all loaders use ssgLoaderOptions::begin. Don't all have to?
|
||||
|
||||
- Search for todo, fix, fixme, kludge.
|
||||
|
||||
|
||||
|
||||
Misc:
|
||||
=====
|
||||
|
||||
- Look whether scaling works. [see current discussion]
|
||||
If not and if we can't/don't want to make it work, for example
|
||||
because of performance issues we need a warning in the docs and
|
||||
IMHO PLIB should "write out" a warning if an unallowed matrix is
|
||||
sent to it.
|
||||
Update: Scaling does not work (intentionally). Uniform scaling may be
|
||||
enabled by uncommenting "radius *= sgLengthVec3(m[0])" in
|
||||
sgSphere::orthoXform. It is currently disabled because that extra
|
||||
calculation would degrade performance on non-scaled matrices.
|
||||
- Reduce lint warnings. Lint is an error checking tool that gives warnings
|
||||
where things *could be* wrong as opposed to the compiler that tells
|
||||
you where they are wrong.
|
||||
|
||||
- It would be great if we had one or even two working native .ssg
|
||||
file formats. Currently (16.12.2001) the format work most of the time, but not all
|
||||
entities are implemented.
|
||||
- We should write the GetWrapU/GetWrapV function, since
|
||||
loading /writing .ssg files can't work 100% without it.
|
||||
- When saving, there is often a warning that "ref count doesn't
|
||||
tally with parent count"
|
||||
- Go through the mailing list for unfinished business.
|
||||
- Someone, preferably a native english speaker with ssg-knowledge,
|
||||
should go through the new ssg-doc and fix any mistakes. It should be
|
||||
fairly complete by now.
|
||||
- Add Per's new Formats to the doc?
|
||||
- For the other parts of plib, people should bring the doc up to
|
||||
date.
|
||||
- There is a bug in the 3Dfx driver for Linux (tdfx_dri-4.0.1-1) that
|
||||
causes the "complex" example program to crash in "fxSetupBlend".
|
||||
This is fixed in more recent DRI snapshots (requires kernel 2.4.x).
|
||||
|
||||
|
||||
Probably after 1.4.0:
|
||||
=====================
|
||||
- In fgfsTux, not a large object, you get a DList overflow
|
||||
with the standard values for its size. Can we make its
|
||||
size dynamic?
|
||||
- Look at handling of normals. For example, loaders,
|
||||
stripify etc should only recalculate missing normals.
|
||||
Have *one* function that recalculates normals.
|
||||
|
||||
|
||||
|
||||
It would be nice if people would volunteer for tasks.
|
||||
|
||||
Vendored
-117
@@ -1,117 +0,0 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4
|
||||
|
||||
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl This program is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
dnl PARTICULAR PURPOSE.
|
||||
|
||||
# Do all the work for Automake. This macro actually does too much --
|
||||
# some checks are only needed if your package does certain things.
|
||||
# But this isn't really a big deal.
|
||||
|
||||
# serial 1
|
||||
|
||||
dnl Usage:
|
||||
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
VERSION=[$2]
|
||||
AC_SUBST(VERSION)
|
||||
dnl test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
ifelse([$3],,
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
|
||||
AC_REQUIRE([AM_SANITY_CHECK])
|
||||
AC_REQUIRE([AC_ARG_PROGRAM])
|
||||
dnl FIXME This is truly gross.
|
||||
missing_dir=`cd $ac_aux_dir && pwd`
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])])
|
||||
|
||||
#
|
||||
# Check to make sure that the build environment is sane.
|
||||
#
|
||||
|
||||
AC_DEFUN(AM_SANITY_CHECK,
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftestfile
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
|
||||
if test "[$]*" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftestfile`
|
||||
fi
|
||||
if test "[$]*" != "X $srcdir/configure conftestfile" \
|
||||
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
|
||||
|
||||
# If neither matched, then we have a broken ls. This can happen
|
||||
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||
# broken ls alias from the environment. This has actually
|
||||
# happened. Such a system could not be considered "sane".
|
||||
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||
alias in your environment])
|
||||
fi
|
||||
|
||||
test "[$]2" = conftestfile
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
rm -f conftest*
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
|
||||
dnl The program must properly implement --version.
|
||||
AC_DEFUN(AM_MISSING_PROG,
|
||||
[AC_MSG_CHECKING(for working $2)
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
if ($2 --version) < /dev/null > /dev/null 2>&1; then
|
||||
$1=$2
|
||||
AC_MSG_RESULT(found)
|
||||
else
|
||||
$1="$3/missing $2"
|
||||
AC_MSG_RESULT(missing)
|
||||
fi
|
||||
AC_SUBST($1)])
|
||||
|
||||
# Define a conditional.
|
||||
|
||||
AC_DEFUN(AM_CONDITIONAL,
|
||||
[AC_SUBST($1_TRUE)
|
||||
AC_SUBST($1_FALSE)
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
else
|
||||
$1_TRUE='#'
|
||||
$1_FALSE=
|
||||
fi])
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/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 "======================================"
|
||||
-1129
File diff suppressed because it is too large
Load Diff
Vendored
-1247
File diff suppressed because it is too large
Load Diff
Vendored
-3839
File diff suppressed because it is too large
Load Diff
@@ -1,420 +0,0 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT(src/js/js.h)
|
||||
AM_INIT_AUTOMAKE(plib, 1.6.0)
|
||||
|
||||
# This AC_PREFIX_DEFAULT will place the library files
|
||||
# into /usr/lib - but will put the include files into
|
||||
# /usr/include - when /usr/include/plib would be less
|
||||
# polluting to the filename space.
|
||||
#
|
||||
# There is probably a better way to do this.
|
||||
|
||||
AC_PREFIX_DEFAULT(/usr)
|
||||
|
||||
if echo $includedir | egrep "plib$" > /dev/null; then
|
||||
echo "includedir is" $includedir "libdir is" $libdir
|
||||
else
|
||||
includedir="${includedir}/plib"
|
||||
echo "includedir changed to" $includedir "libdir is" $libdir
|
||||
fi
|
||||
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CXXCPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_RANLIB
|
||||
|
||||
|
||||
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)
|
||||
|
||||
AC_ARG_WITH(glut,
|
||||
[ --without-glut build GLUT-free PUI library (highly experimental!)],,
|
||||
with_glut=yes)
|
||||
|
||||
|
||||
AC_ARG_ENABLE(fnt,
|
||||
[ --enable-fnt build FNT library (OpenGL needed) default: yes],,
|
||||
enable_fnt=yes)
|
||||
|
||||
AC_ARG_ENABLE(js,
|
||||
[ --enable-js build JS library default: yes],,
|
||||
enable_js=yes)
|
||||
|
||||
AC_ARG_ENABLE(net,
|
||||
[ --enable-net build NET library default: yes],,
|
||||
enable_net=yes)
|
||||
|
||||
AC_ARG_ENABLE(pui,
|
||||
[ --enable-pui build PUI library (OpenGL, GLUT needed) default: yes],,
|
||||
enable_pui=yes)
|
||||
|
||||
AC_ARG_ENABLE(sg,
|
||||
[ --enable-sg build SG library default: yes],,
|
||||
enable_sg=yes)
|
||||
|
||||
AC_ARG_ENABLE(sl,
|
||||
[ --enable-sl build SL library default: yes],,
|
||||
enable_sl=yes)
|
||||
|
||||
AC_ARG_ENABLE(ssg,
|
||||
[ --enable-ssg build SSG library (OpenGL needed) default: yes],,
|
||||
enable_ssg=yes)
|
||||
|
||||
AC_ARG_ENABLE(ssgaux,
|
||||
[ --enable-ssgaux build ssgAux library (OpenGL needed) default: yes],,
|
||||
enable_ssgaux=yes)
|
||||
|
||||
AC_ARG_ENABLE(ul,
|
||||
[ --enable-ul build UTIL library default: yes],,
|
||||
enable_ul=yes)
|
||||
|
||||
|
||||
dnl Dependancy checking
|
||||
|
||||
if test "x$enable_fnt" = "xyes"; then
|
||||
need_opengl=yes
|
||||
|
||||
if test "x$enable_sg" = "xno"; then
|
||||
AC_MSG_WARN([cannot build FNT library without SG library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build FNT library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_js" = "xyes"; then
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build JS library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_net" = "xyes"; then
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build NET library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_pui" = "xyes"; then
|
||||
need_opengl=yes
|
||||
|
||||
if test "x$with_glut" = "xno"; then
|
||||
AC_DEFINE(PU_NOT_USING_GLUT,,
|
||||
[If defined, PUI does not use GLUT (highly experimental)])
|
||||
else
|
||||
need_glut=yes
|
||||
fi
|
||||
|
||||
if test "x$enable_fnt" = "xno"; then
|
||||
AC_MSG_WARN([cannot build PUI library without FNT library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
if test "x$enable_sg" = "xno"; then
|
||||
AC_MSG_WARN([cannot build PUI library without SG library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build PUI library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_sg" = "xyes"; then
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build SG library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_sl" = "xyes"; then
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build SL library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_ssg" = "xyes"; then
|
||||
need_opengl=yes
|
||||
|
||||
if test "x$enable_sg" = "xno"; then
|
||||
AC_MSG_WARN([cannot build SSG library without SG library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build SSG library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_ssgaux" = "xyes"; then
|
||||
need_opengl=yes
|
||||
|
||||
if test "x$enable_ssg" = "xno"; then
|
||||
AC_MSG_WARN([cannot build ssgAux library without SSG library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
if test "x$enable_sg" = "xno"; then
|
||||
AC_MSG_WARN([cannot build ssgAux library without SG library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
if test "x$enable_ul" = "xno"; then
|
||||
AC_MSG_WARN([cannot build ssgAux library without UL library enabled])
|
||||
dependancy_problem=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$dependancy_problem" = "xyes"; then
|
||||
AC_MSG_ERROR([dependancy problems detected])
|
||||
fi
|
||||
|
||||
|
||||
AM_CONDITIONAL(BUILD_FNT, test "x$enable_fnt" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_JS, test "x$enable_js" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_NET, test "x$enable_net" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_PUI, test "x$enable_pui" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_SG, test "x$enable_sg" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_SL, test "x$enable_sl" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_SSG, test "x$enable_ssg" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_SSGAUX, test "x$enable_ssgaux" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_UL, test "x$enable_ul" = "xyes")
|
||||
|
||||
if test "x$need_opengl" = "xyes" && test "x$GL_PREFIX" != "xauto"; then
|
||||
LDFLAGS="$LDFLAGS -L$GL_PREFIX/lib"
|
||||
CPPFLAGS="$CPPFLAGS -I$GL_PREFIX/include"
|
||||
fi
|
||||
|
||||
|
||||
dnl Checks for library functions.
|
||||
dnl check for OpenGL related libraries
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
case "${host}" in
|
||||
*-*-cygwin* | *-*-mingw32*)
|
||||
dnl CygWin under Windoze.
|
||||
|
||||
dnl Multimedia library
|
||||
LIBS="$LIBS -lwinmm"
|
||||
|
||||
if test "x$need_opengl" = "xyes"; then
|
||||
dnl OpenGL libraries
|
||||
|
||||
if test "x$need_glut" = "xyes"; then
|
||||
LIBS="$LIBS -lglut32 -lglu32"
|
||||
fi
|
||||
LIBS="$LIBS -lopengl32"
|
||||
fi
|
||||
;;
|
||||
*-apple-darwin*)
|
||||
dnl Mac OS X
|
||||
|
||||
if test "x$need_opengl" = "xyes"; then
|
||||
dnl OpenGL libraries
|
||||
|
||||
if test "x$need_glut" = "xyes"; then
|
||||
LIBS="$LIBS -framework GLUT -lobjc"
|
||||
fi
|
||||
LIBS="$LIBS -framework OpenGL"
|
||||
fi
|
||||
|
||||
dnl Sound libraries
|
||||
LIBS="$LIBS -framework Carbon"
|
||||
;;
|
||||
*)
|
||||
if test "x$need_opengl" = "xyes"; then
|
||||
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 =========================================================
|
||||
dnl if test "x$x_includes" != "x"; then
|
||||
dnl CPPFLAGS="$CPPFLAGS -I$x_includes"
|
||||
dnl fi
|
||||
dnl =========================================================
|
||||
|
||||
dnl Reasonable stuff non-windoze variants ... :-)
|
||||
|
||||
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
|
||||
|
||||
if test "x$need_glut" = "xyes"; then
|
||||
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
|
||||
|
||||
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
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(dl, dlclose)
|
||||
|
||||
dnl Check SGI audio library
|
||||
AC_CHECK_LIB(audio, ALopenport)
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
dnl Checks for header files.
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
AC_CHECK_HEADER(windows.h, AC_DEFINE(WIN32))
|
||||
|
||||
if test "x$need_opengl" = "xyes"; then
|
||||
dnl Check for OpenGl header files
|
||||
|
||||
case "${host}" in
|
||||
*-*-cygwin* | *-*-mingw32*)
|
||||
dnl CygWin under Windoze.
|
||||
|
||||
AC_CHECK_HEADER(GL/gl.h,,
|
||||
AC_MSG_ERROR([OpenGL header file not found]))
|
||||
|
||||
if test "x$need_glut" = "xyes"; then
|
||||
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
|
||||
AC_MSG_ERROR([GLUT header file not found]))
|
||||
fi
|
||||
;;
|
||||
*-apple-darwin*)
|
||||
dnl Mac OS X
|
||||
|
||||
AC_CHECK_HEADER(OpenGL/gl.h,,
|
||||
AC_MSG_ERROR([OpenGL header file not found]))
|
||||
|
||||
if test "x$need_glut" = "xyes"; then
|
||||
AC_CHECK_HEADER(GLUT/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
|
||||
AC_MSG_ERROR([GLUT header file not found]))
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_CHECK_HEADER(GL/gl.h,,
|
||||
AC_MSG_ERROR([OpenGL header file not found]))
|
||||
|
||||
if test "x$need_glut" = "xyes"; then
|
||||
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
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
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"
|
||||
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
|
||||
dnl check for socklen_t (in Unix98)
|
||||
AC_MSG_CHECKING(for socklen_t)
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
socklen_t x;
|
||||
],[],[
|
||||
AC_MSG_RESULT(yes)],[
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
int accept (int, struct sockaddr *, size_t *);
|
||||
],[],[
|
||||
AC_MSG_RESULT(size_t)
|
||||
AC_DEFINE(socklen_t,size_t)], [
|
||||
AC_MSG_RESULT(int)
|
||||
AC_DEFINE(socklen_t,int)])])
|
||||
|
||||
|
||||
AC_OUTPUT( \
|
||||
Makefile \
|
||||
src/Makefile \
|
||||
src/js/Makefile \
|
||||
src/util/Makefile \
|
||||
src/pui/Makefile \
|
||||
src/sg/Makefile \
|
||||
src/sl/Makefile \
|
||||
src/ssg/Makefile \
|
||||
src/ssgAux/Makefile \
|
||||
src/fnt/Makefile \
|
||||
src/net/Makefile )
|
||||
|
||||
if test "x$need_glut" = "xyes"; then
|
||||
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xyes"; then
|
||||
glut_msg="yes (found freeglut)"
|
||||
else
|
||||
glut_msg="yes (found GLUT)"
|
||||
fi
|
||||
else
|
||||
if test "x$with_glut" = "xno"; then
|
||||
glut_msg="no (experimental GLUT-free PUI, see README.GLUT)"
|
||||
else
|
||||
glut_msg="no"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT(
|
||||
[PLIB configuration information:
|
||||
|
||||
Building FNT library: $enable_fnt
|
||||
Building JS library: $enable_js
|
||||
Building NET library: $enable_net
|
||||
Building PUI library: $enable_pui
|
||||
Building SG library: $enable_sg
|
||||
Building SL library: $enable_sl
|
||||
Building SSG library: $enable_ssg
|
||||
Building ssgAux library: $enable_ssgaux
|
||||
Building UTIL library: $enable_ul
|
||||
|
||||
Need GLUT: $glut_msg
|
||||
])
|
||||
|
||||
@@ -1,295 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FNT_H_
|
||||
#define _FNT_H_ 1
|
||||
|
||||
#include "sg.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenGL/gl.h>
|
||||
#else
|
||||
# include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define FNTMAX_CHAR 256
|
||||
#define FNT_TRUE 1
|
||||
#define FNT_FALSE 0
|
||||
|
||||
|
||||
class fntFont
|
||||
{
|
||||
public:
|
||||
fntFont () ;
|
||||
|
||||
virtual ~fntFont () ;
|
||||
|
||||
virtual void getBBox ( const char *s, float pointsize, float italic,
|
||||
float *left, float *right,
|
||||
float *bot , float *top ) = 0 ;
|
||||
virtual void putch ( sgVec3 curpos, float pointsize, float italic, char c ) = 0 ;
|
||||
virtual void puts ( sgVec3 curpos, float pointsize, float italic, const char *s ) = 0 ;
|
||||
virtual void begin () = 0 ;
|
||||
virtual void end () = 0 ;
|
||||
|
||||
virtual int load ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) = 0 ;
|
||||
|
||||
virtual void setFixedPitch ( int fix ) = 0 ;
|
||||
virtual int isFixedPitch () const = 0 ;
|
||||
|
||||
virtual void setWidth ( float w ) = 0 ;
|
||||
virtual void setGap ( float g ) = 0 ;
|
||||
|
||||
virtual float getWidth () const = 0 ;
|
||||
virtual float getGap () const = 0 ;
|
||||
|
||||
virtual int hasGlyph ( char c ) const = 0 ;
|
||||
} ;
|
||||
|
||||
|
||||
class fntTexFont : public fntFont
|
||||
{
|
||||
private:
|
||||
GLuint texture ;
|
||||
int bound ;
|
||||
int fixed_pitch ;
|
||||
|
||||
float width ; /* The width of a character in fixed-width mode */
|
||||
float gap ; /* Set the gap between characters */
|
||||
|
||||
int exists [ FNTMAX_CHAR ] ; /* TRUE if character exists in tex-map */
|
||||
|
||||
/*
|
||||
The quadrilaterals that describe the characters
|
||||
in the font are drawn with the following texture
|
||||
and spatial coordinates. The texture coordinates
|
||||
are in (S,T) space, with (0,0) at the bottom left
|
||||
of the image and (1,1) at the top-right.
|
||||
|
||||
The spatial coordinates are relative to the current
|
||||
'cursor' position. They should be scaled such that
|
||||
1.0 represent the height of a capital letter. Hence,
|
||||
characters like 'y' which have a descender will be
|
||||
given a negative v_bot. Most capitals will have
|
||||
v_bot==0.0 and v_top==1.0.
|
||||
*/
|
||||
|
||||
/* Nominal baseline widths */
|
||||
|
||||
float widths [ FNTMAX_CHAR ] ;
|
||||
|
||||
/* Texture coordinates */
|
||||
|
||||
float t_top [ FNTMAX_CHAR ] ; /* Top edge of each character [0..1] */
|
||||
float t_bot [ FNTMAX_CHAR ] ; /* Bottom edge of each character [0..1] */
|
||||
float t_left [ FNTMAX_CHAR ] ; /* Left edge of each character [0..1] */
|
||||
float t_right [ FNTMAX_CHAR ] ; /* Right edge of each character [0..1] */
|
||||
|
||||
/* Vertex coordinates. */
|
||||
|
||||
float v_top [ FNTMAX_CHAR ] ;
|
||||
float v_bot [ FNTMAX_CHAR ] ;
|
||||
float v_left [ FNTMAX_CHAR ] ;
|
||||
float v_right [ FNTMAX_CHAR ] ;
|
||||
|
||||
void bind_texture ()
|
||||
{
|
||||
glEnable ( GL_TEXTURE_2D ) ;
|
||||
#ifdef GL_VERSION_1_1
|
||||
glBindTexture ( GL_TEXTURE_2D, texture ) ;
|
||||
#else
|
||||
/* For ancient SGI machines */
|
||||
glBindTextureEXT ( GL_TEXTURE_2D, texture ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
float low_putch ( sgVec3 curpos, float pointsize, float italic, char c ) ;
|
||||
|
||||
int loadTXF ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) ;
|
||||
public:
|
||||
|
||||
fntTexFont ()
|
||||
{
|
||||
bound = FNT_FALSE ;
|
||||
fixed_pitch = FNT_TRUE ;
|
||||
texture = 0 ;
|
||||
width = 1.0f ;
|
||||
gap = 0.1f ;
|
||||
|
||||
memset ( exists, FNT_FALSE, FNTMAX_CHAR * sizeof(int) ) ;
|
||||
}
|
||||
|
||||
fntTexFont ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) : fntFont ()
|
||||
{
|
||||
bound = FNT_FALSE ;
|
||||
fixed_pitch = FNT_TRUE ;
|
||||
texture = 0 ;
|
||||
width = 1.0f ;
|
||||
gap = 0.1f ;
|
||||
|
||||
memset ( exists, FNT_FALSE, FNTMAX_CHAR * sizeof(int) ) ;
|
||||
load ( fname, mag, min ) ;
|
||||
}
|
||||
|
||||
~fntTexFont ()
|
||||
{
|
||||
if ( texture != 0 )
|
||||
{
|
||||
#ifdef GL_VERSION_1_1
|
||||
glDeleteTextures ( 1, &texture ) ;
|
||||
#else
|
||||
/* For ancient SGI machines */
|
||||
glDeleteTexturesEXT ( 1, &texture ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int load ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) ;
|
||||
|
||||
void setFixedPitch ( int fix ) { fixed_pitch = fix ; }
|
||||
int isFixedPitch () const { return fixed_pitch ; }
|
||||
|
||||
void setWidth ( float w ) { width = w ; }
|
||||
void setGap ( float g ) { gap = g ; }
|
||||
|
||||
float getWidth () const { return width ; }
|
||||
float getGap () const { return gap ; }
|
||||
|
||||
|
||||
void setGlyph ( char c, float wid,
|
||||
float tex_left, float tex_right,
|
||||
float tex_bot , float tex_top ,
|
||||
float vtx_left, float vtx_right,
|
||||
float vtx_bot , float vtx_top ) ;
|
||||
void setGlyph ( char c,
|
||||
float tex_left, float tex_right,
|
||||
float tex_bot , float tex_top ,
|
||||
float vtx_left, float vtx_right,
|
||||
float vtx_bot , float vtx_top ) /* deprecated */
|
||||
{
|
||||
setGlyph ( c, vtx_right,
|
||||
tex_left, tex_right, tex_bot, tex_top,
|
||||
vtx_left, vtx_right, vtx_bot, vtx_top ) ;
|
||||
}
|
||||
|
||||
int getGlyph ( char c, float* wid,
|
||||
float *tex_left = NULL, float *tex_right = NULL,
|
||||
float *tex_bot = NULL, float *tex_top = NULL,
|
||||
float *vtx_left = NULL, float *vtx_right = NULL,
|
||||
float *vtx_bot = NULL, float *vtx_top = NULL) ;
|
||||
int getGlyph ( char c,
|
||||
float *tex_left = NULL, float *tex_right = NULL,
|
||||
float *tex_bot = NULL, float *tex_top = NULL,
|
||||
float *vtx_left = NULL, float *vtx_right = NULL,
|
||||
float *vtx_bot = NULL, float *vtx_top = NULL) /* deprecated */
|
||||
{
|
||||
return getGlyph ( c, NULL,
|
||||
tex_left, tex_right, tex_bot, tex_top,
|
||||
vtx_left, vtx_right, vtx_bot, vtx_top ) ;
|
||||
}
|
||||
|
||||
int hasGlyph ( char c ) const { return exists[ c ] ; }
|
||||
|
||||
void getBBox ( const char *s, float pointsize, float italic,
|
||||
float *left, float *right,
|
||||
float *bot , float *top ) ;
|
||||
|
||||
void begin ()
|
||||
{
|
||||
bind_texture () ;
|
||||
bound = FNT_TRUE ;
|
||||
}
|
||||
|
||||
void end ()
|
||||
{
|
||||
bound = FNT_FALSE ;
|
||||
}
|
||||
|
||||
void puts ( sgVec3 curpos, float pointsize, float italic, const char *s ) ;
|
||||
|
||||
void putch ( sgVec3 curpos, float pointsize, float italic, char c )
|
||||
{
|
||||
if ( ! bound )
|
||||
bind_texture () ;
|
||||
|
||||
low_putch ( curpos, pointsize, italic, c ) ;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
class fntRenderer
|
||||
{
|
||||
fntFont *font ;
|
||||
|
||||
sgVec3 curpos ;
|
||||
|
||||
float pointsize ;
|
||||
float italic ;
|
||||
|
||||
public:
|
||||
fntRenderer ()
|
||||
{
|
||||
start2f ( 0.0f, 0.0f ) ;
|
||||
font = NULL ;
|
||||
pointsize = 10 ;
|
||||
italic = 0 ;
|
||||
}
|
||||
|
||||
void start3fv ( sgVec3 pos ) { sgCopyVec3 ( curpos, pos ) ; }
|
||||
void start2fv ( sgVec2 pos ) { sgCopyVec2 ( curpos, pos ) ; curpos[2]=0.0f ; }
|
||||
void start2f ( float x, float y ) { sgSetVec3 ( curpos, x, y, 0.0f ) ; }
|
||||
void start3f ( float x, float y, float z ) { sgSetVec3 ( curpos, x, y, z ) ; }
|
||||
|
||||
void getCursor ( float *x, float *y, float *z ) const
|
||||
{
|
||||
if ( x != NULL ) *x = curpos [ 0 ] ;
|
||||
if ( y != NULL ) *y = curpos [ 1 ] ;
|
||||
if ( z != NULL ) *z = curpos [ 2 ] ;
|
||||
}
|
||||
|
||||
void setFont ( fntFont *f ) { font = f ; }
|
||||
fntFont *getFont () const { return font ; }
|
||||
|
||||
void setSlant ( float i ) { italic = i ; }
|
||||
void setPointSize ( float p ) { pointsize = p ; }
|
||||
|
||||
float getSlant () const { return italic ; }
|
||||
float getPointSize () const { return pointsize ; }
|
||||
|
||||
void begin () { font->begin () ; }
|
||||
void end () { font->end () ; }
|
||||
|
||||
void putch ( char c ) { font->putch ( curpos, pointsize, italic, c ) ; }
|
||||
void puts ( const char *s ) { font->puts ( curpos, pointsize, italic, s ) ; }
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,251 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
@@ -1,749 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef __INCLUDED_JS_H__
|
||||
#define __INCLUDED_JS_H__ 1
|
||||
|
||||
#include "ul.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> // -dw- for memcpy
|
||||
|
||||
#ifdef macintosh
|
||||
# include <InputSprocket.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
FreeBSD port - courtesy of Stephen Montgomery-Smith
|
||||
<stephen@math.missouri.edu>
|
||||
|
||||
NetBSD mods - courtesy Rene Hexel.
|
||||
|
||||
The next lines are to define BSD
|
||||
see http://www.freebsd.org/handbook/porting.html for why we do this
|
||||
*/
|
||||
//lint -save -e620
|
||||
|
||||
#if (defined(__unix__) || defined(unix)) && !defined(USG)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
# if defined( __CYGWIN32__ ) || defined( __CYGWIN__ )
|
||||
# define NEAR /* */
|
||||
# define FAR /* */
|
||||
# endif
|
||||
# include <mmsystem.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
# include <machine/joystick.h>
|
||||
# define JS_DATA_TYPE joystick
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# elif defined(__linux__)
|
||||
# include <sys/ioctl.h>
|
||||
# include <linux/joystick.h>
|
||||
# include <errno.h>
|
||||
|
||||
/* check the joystick driver version */
|
||||
|
||||
# ifdef JS_VERSION
|
||||
# if JS_VERSION >= 0x010000
|
||||
# define JS_NEW
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# else
|
||||
# ifndef JS_DATA_TYPE
|
||||
|
||||
/*
|
||||
Not Windoze and no joystick driver...
|
||||
|
||||
Well - we'll put these values in and that should
|
||||
allow the code to at least compile. The JS open
|
||||
routine should error out and shut off all the code
|
||||
downstream anyway
|
||||
*/
|
||||
|
||||
struct JS_DATA_TYPE
|
||||
{
|
||||
int buttons ;
|
||||
int x ;
|
||||
int y ;
|
||||
} ;
|
||||
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define JS_TRUE 1
|
||||
#define JS_FALSE 0
|
||||
|
||||
#ifdef WIN32
|
||||
# define _JS_MAX_AXES 8 /* X,Y,Z,R,U,V,POV_X,POV_Y */
|
||||
#elif defined (macintosh)
|
||||
# define _JS_MAX_AXES 9
|
||||
#else
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
# define _JS_MAX_AXES 2
|
||||
# else
|
||||
# define _JS_MAX_AXES 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
class jsJoystick
|
||||
{
|
||||
#ifdef macintosh
|
||||
|
||||
#define isp_num_axis 9
|
||||
#define isp_num_needs 41
|
||||
|
||||
ISpElementReference isp_elem[isp_num_needs];
|
||||
ISpNeed isp_needs [isp_num_needs];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
int id ;
|
||||
#endif*/
|
||||
#ifdef WIN32
|
||||
JOYINFOEX js ;
|
||||
UINT js_id ;
|
||||
#else
|
||||
# ifdef JS_NEW
|
||||
js_event js ;
|
||||
int tmp_buttons ;
|
||||
float tmp_axes [ _JS_MAX_AXES ] ;
|
||||
# else
|
||||
JS_DATA_TYPE js ;
|
||||
# endif
|
||||
char fname [ 128 ] ;
|
||||
int fd ;
|
||||
#endif
|
||||
|
||||
int error ;
|
||||
char name [ 128 ] ;
|
||||
int num_axes ;
|
||||
int num_buttons ;
|
||||
|
||||
float dead_band [ _JS_MAX_AXES ] ;
|
||||
float saturate [ _JS_MAX_AXES ] ;
|
||||
float center [ _JS_MAX_AXES ] ;
|
||||
float max [ _JS_MAX_AXES ] ;
|
||||
float min [ _JS_MAX_AXES ] ;
|
||||
|
||||
void open ()
|
||||
{
|
||||
name [0] = '\0' ;
|
||||
|
||||
#ifdef macintosh
|
||||
|
||||
/*
|
||||
FIXME: get joystick name in Mac
|
||||
*/
|
||||
|
||||
OSStatus err;
|
||||
|
||||
err = ISpStartup ();
|
||||
|
||||
if ( err == noErr ) {
|
||||
|
||||
#define ISP_CHECK_ERR(x) if (x != noErr) { setError(); return; }
|
||||
|
||||
setError ();
|
||||
|
||||
// initialize the needs structure
|
||||
ISpNeed temp_isp_needs[isp_num_needs] =
|
||||
{
|
||||
{"\pX-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pY-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pZ-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pR-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 4", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 5", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 6", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 7", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 8", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
|
||||
{"\pButton 0", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 1", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 2", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 3", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 4", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 5", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 6", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 7", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 8", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 9", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 10", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 11", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 12", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 13", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 14", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 15", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 16", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 17", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 18", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 19", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 20", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 21", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 22", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 23", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 24", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 25", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 26", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 27", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 28", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 29", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 30", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 31", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
memcpy (isp_needs, temp_isp_needs, sizeof (temp_isp_needs) );
|
||||
|
||||
|
||||
// next two calls allow keyboard and mouse to emulate other input devices (gamepads, joysticks, etc)
|
||||
|
||||
/*
|
||||
err = ISpDevices_ActivateClass (kISpDeviceClass_Keyboard);
|
||||
ISP_CHECK_ERR(err)
|
||||
|
||||
|
||||
err = ISpDevices_ActivateClass (kISpDeviceClass_Mouse);
|
||||
ISP_CHECK_ERR(err)
|
||||
*/
|
||||
|
||||
err = ISpElement_NewVirtualFromNeeds (isp_num_needs, isp_needs, isp_elem, 0);
|
||||
ISP_CHECK_ERR(err)
|
||||
|
||||
err = ISpInit (isp_num_needs, isp_needs, isp_elem, 'PLIB', nil, 0, 128, 0);
|
||||
ISP_CHECK_ERR(err)
|
||||
|
||||
num_buttons = isp_num_needs - isp_num_axis;
|
||||
num_axes = isp_num_axis;
|
||||
|
||||
for ( int i = 0; i < num_axes; i++ ) {
|
||||
|
||||
dead_band[i] = 0;
|
||||
saturate [i] = 1;
|
||||
center[i] = kISpAxisMiddle;
|
||||
max [i] = kISpAxisMaximum;
|
||||
min [i] = kISpAxisMinimum;
|
||||
}
|
||||
|
||||
error = false;
|
||||
}
|
||||
else {
|
||||
setError ();
|
||||
num_buttons = num_axes = 0;
|
||||
}
|
||||
|
||||
#elif defined( WIN32 )
|
||||
|
||||
JOYCAPS jsCaps ;
|
||||
|
||||
js . dwFlags = JOY_RETURNALL ;
|
||||
js . dwSize = sizeof ( js ) ;
|
||||
|
||||
memset ( &jsCaps, 0, sizeof(jsCaps) ) ;
|
||||
|
||||
error = ( joyGetDevCaps( js_id, &jsCaps, sizeof(jsCaps) )
|
||||
!= JOYERR_NOERROR ) ;
|
||||
if ( jsCaps.wNumAxes == 0 )
|
||||
{
|
||||
num_axes = 0 ;
|
||||
setError () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy ( name, jsCaps.szPname, sizeof(name) ) ;
|
||||
|
||||
// Windows joystick drivers may provide any combination of
|
||||
// X,Y,Z,R,U,V,POV - not necessarily the first n of these.
|
||||
if ( jsCaps.wCaps & JOYCAPS_HASPOV ) {
|
||||
num_axes = _JS_MAX_AXES ;
|
||||
min[7] = -1.0 ; max[7] = 1.0 ; // POV Y
|
||||
min[6] = -1.0 ; max[6] = 1.0 ; // POV X
|
||||
} else {
|
||||
num_axes = 6 ;
|
||||
}
|
||||
min[5] = (float)jsCaps.wVmin ; max[5] = (float)jsCaps.wVmax ;
|
||||
min[4] = (float)jsCaps.wUmin ; max[4] = (float)jsCaps.wUmax ;
|
||||
min[3] = (float)jsCaps.wRmin ; max[3] = (float)jsCaps.wRmax ;
|
||||
min[2] = (float)jsCaps.wZmin ; max[2] = (float)jsCaps.wZmax ;
|
||||
min[1] = (float)jsCaps.wYmin ; max[1] = (float)jsCaps.wYmax ;
|
||||
min[0] = (float)jsCaps.wXmin ; max[0] = (float)jsCaps.wXmax ;
|
||||
}
|
||||
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
{
|
||||
center [ i ] = ( max[i] + min[i] ) / 2.0f ;
|
||||
dead_band [ i ] = 0.0f ;
|
||||
saturate [ i ] = 1.0f ;
|
||||
}
|
||||
|
||||
#else
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
FILE *joyfile;
|
||||
char joyfname[1024];
|
||||
int noargs, in_no_axes;
|
||||
# endif
|
||||
|
||||
/* Default for older Linux systems. */
|
||||
|
||||
num_axes = 2 ;
|
||||
num_buttons = 32 ;
|
||||
|
||||
# ifdef JS_NEW
|
||||
for ( int i = 0 ; i < _JS_MAX_AXES ; i++ )
|
||||
tmp_axes [ i ] = 0.0f ;
|
||||
|
||||
tmp_buttons = 0 ;
|
||||
# endif
|
||||
|
||||
// fd = ::open ( fname, O_RDONLY | O_NONBLOCK ) ;
|
||||
fd = ::open ( fname, O_RDONLY ) ;
|
||||
|
||||
error = ( fd < 0 ) ;
|
||||
|
||||
if ( error )
|
||||
return ;
|
||||
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
|
||||
/*
|
||||
FIXME: get joystick name for BSD
|
||||
*/
|
||||
|
||||
float axes[_JS_MAX_AXES];
|
||||
int buttons[_JS_MAX_AXES];
|
||||
rawRead ( buttons, axes );
|
||||
error = axes[0] < -1000000000.0f;
|
||||
if ( error )
|
||||
return ;
|
||||
|
||||
sprintf(joyfname,"%s/.joy%drc",::getenv( "HOME" ),id);
|
||||
|
||||
joyfile = fopen(joyfname,"r");
|
||||
error = joyfile == NULL;
|
||||
if ( error )
|
||||
return ;
|
||||
noargs = fscanf(joyfile,"%d%f%f%f%f%f%f",&in_no_axes,
|
||||
&min[0],¢er[0],&max[0],
|
||||
&min[1],¢er[1],&max[1]);
|
||||
error = noargs != 7 || in_no_axes != _JS_MAX_AXES;
|
||||
fclose(joyfile);
|
||||
if ( error )
|
||||
return ;
|
||||
|
||||
for ( int i = 0 ; i < _JS_MAX_AXES ; i++ )
|
||||
{
|
||||
dead_band [ i ] = 0.0f ;
|
||||
saturate [ i ] = 1.0f ;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
/*
|
||||
Set the correct number of axes for the linux driver
|
||||
*/
|
||||
|
||||
# ifdef JS_NEW
|
||||
ioctl ( fd, JSIOCGAXES , & num_axes ) ;
|
||||
ioctl ( fd, JSIOCGBUTTONS, & num_buttons ) ;
|
||||
ioctl ( fd, JSIOCGNAME ( sizeof(name) ), name ) ;
|
||||
fcntl ( fd, F_SETFL, O_NONBLOCK ) ;
|
||||
|
||||
if ( num_axes > _JS_MAX_AXES )
|
||||
num_axes = _JS_MAX_AXES ;
|
||||
# endif
|
||||
|
||||
/*
|
||||
The Linux driver seems to return 512 for all axes
|
||||
when no stick is present - but there is a chance
|
||||
that could happen by accident - so it's gotta happen
|
||||
on both axes for at least 100 attempts.
|
||||
*/
|
||||
|
||||
#ifndef JS_NEW
|
||||
int counter = 0 ;
|
||||
|
||||
do
|
||||
{
|
||||
rawRead ( NULL, center ) ;
|
||||
counter++ ;
|
||||
} while ( ! error &&
|
||||
counter < 100 &&
|
||||
center[0] == 512.0f &&
|
||||
center[1] == 512.0f ) ;
|
||||
|
||||
if ( counter >= 100 )
|
||||
setError() ;
|
||||
#endif
|
||||
|
||||
for ( int i = 0 ; i < _JS_MAX_AXES ; i++ )
|
||||
{
|
||||
#ifdef JS_NEW
|
||||
max [ i ] = 32767.0f ;
|
||||
center [ i ] = 0.0f ;
|
||||
min [ i ] = -32767.0f ;
|
||||
#else
|
||||
max [ i ] = center [ i ] * 2.0f ;
|
||||
min [ i ] = 0.0f ;
|
||||
#endif
|
||||
dead_band [ i ] = 0.0f ;
|
||||
saturate [ i ] = 1.0f ;
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void close ()
|
||||
{
|
||||
#if !defined( WIN32 ) && !defined( macintosh )
|
||||
if ( ! error )
|
||||
::close ( fd ) ;
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
|
||||
ISpSuspend ();
|
||||
ISpStop ();
|
||||
ISpShutdown ();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
float fudge_axis ( float value, int axis ) const
|
||||
{
|
||||
if ( value < center[axis] )
|
||||
{
|
||||
float xx = ( value - center[ axis ] ) /
|
||||
( center [ axis ] - min [ axis ] ) ;
|
||||
|
||||
if ( xx < -saturate [ axis ] )
|
||||
return -1.0f ;
|
||||
|
||||
if ( xx > -dead_band [ axis ] )
|
||||
return 0.0f ;
|
||||
|
||||
xx = ( xx + dead_band [ axis ] ) /
|
||||
( saturate [ axis ] - dead_band [ axis ] ) ;
|
||||
|
||||
return ( xx < -1.0f ) ? -1.0f : xx ;
|
||||
}
|
||||
else
|
||||
{
|
||||
float xx = ( value - center [ axis ] ) /
|
||||
( max [ axis ] - center [ axis ] ) ;
|
||||
|
||||
if ( xx > saturate [ axis ] )
|
||||
return 1.0f ;
|
||||
|
||||
if ( xx < dead_band [ axis ] )
|
||||
return 0.0f ;
|
||||
|
||||
xx = ( xx - dead_band [ axis ] ) /
|
||||
( saturate [ axis ] - dead_band [ axis ] ) ;
|
||||
|
||||
return ( xx > 1.0f ) ? 1.0f : xx ;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
jsJoystick ( int ident = 0 )
|
||||
{
|
||||
#ifdef WIN32
|
||||
switch ( ident )
|
||||
{
|
||||
case 0 : js_id = JOYSTICKID1 ; open () ; break ;
|
||||
case 1 : js_id = JOYSTICKID2 ; open () ; break;
|
||||
default : num_axes = 0 ; setError () ; break ;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
//id = ident;
|
||||
sprintf ( fname, "/dev/joy%d", ident ) ;
|
||||
# elif defined(__linux__)
|
||||
sprintf ( fname, "/dev/input/js%d", ident ) ;
|
||||
if ( access ( fname, F_OK ) != 0 )
|
||||
sprintf ( fname, "/dev/js%d", ident ) ;
|
||||
# else
|
||||
sprintf ( fname, "/dev/js%d", ident ) ; /* FIXME */
|
||||
# endif
|
||||
open () ;
|
||||
#endif
|
||||
}
|
||||
|
||||
~jsJoystick ()
|
||||
{
|
||||
close () ;
|
||||
}
|
||||
|
||||
const char* getName () const { return name ; }
|
||||
int getNumAxes () const { return num_axes ; }
|
||||
int notWorking () const { return error ; }
|
||||
void setError () { error = JS_TRUE ; }
|
||||
|
||||
float getDeadBand ( int axis ) const { return dead_band [ axis ] ; }
|
||||
void setDeadBand ( int axis, float db ) { dead_band [ axis ] = db ; }
|
||||
|
||||
float getSaturation ( int axis ) const { return saturate [ axis ] ; }
|
||||
void setSaturation ( int axis, float st ) { saturate [ axis ] = st ; }
|
||||
|
||||
void setMinRange ( float *axes ) { memcpy ( min , axes, num_axes * sizeof(float) ) ; }
|
||||
void setMaxRange ( float *axes ) { memcpy ( max , axes, num_axes * sizeof(float) ) ; }
|
||||
void setCenter ( float *axes ) { memcpy ( center, axes, num_axes * sizeof(float) ) ; }
|
||||
|
||||
void getMinRange ( float *axes ) const { memcpy ( axes, min , num_axes * sizeof(float) ) ; }
|
||||
void getMaxRange ( float *axes ) const { memcpy ( axes, max , num_axes * sizeof(float) ) ; }
|
||||
void getCenter ( float *axes ) const { memcpy ( axes, center, num_axes * sizeof(float) ) ; }
|
||||
|
||||
void read ( int *buttons, float *axes )
|
||||
{
|
||||
if ( error )
|
||||
{
|
||||
if ( buttons )
|
||||
*buttons = 0 ;
|
||||
|
||||
if ( axes )
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
axes[i] = 0.0f ;
|
||||
}
|
||||
|
||||
float raw_axes [ _JS_MAX_AXES ] ;
|
||||
|
||||
rawRead ( buttons, raw_axes ) ;
|
||||
|
||||
if ( axes )
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
axes[i] = fudge_axis ( raw_axes[i], i ) ;
|
||||
}
|
||||
|
||||
void rawRead ( int *buttons, float *axes )
|
||||
{
|
||||
if ( error )
|
||||
{
|
||||
if ( buttons )
|
||||
*buttons = 0 ;
|
||||
|
||||
if ( axes )
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
axes[i] = 1500.0f ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
#ifdef macintosh
|
||||
|
||||
int i;
|
||||
int err;
|
||||
UInt32 state;
|
||||
|
||||
if (buttons) {
|
||||
|
||||
*buttons = 0;
|
||||
|
||||
for (i = 0; i < num_buttons; i++) {
|
||||
|
||||
err = ISpElement_GetSimpleState (isp_elem[i + isp_num_axis ], &state);
|
||||
ISP_CHECK_ERR (err)
|
||||
|
||||
*buttons |= state << i;
|
||||
}
|
||||
}
|
||||
|
||||
if (axes) {
|
||||
|
||||
for (i = 0; i < num_axes; i++) {
|
||||
|
||||
err = ISpElement_GetSimpleState (isp_elem[ i ], &state);
|
||||
ISP_CHECK_ERR (err);
|
||||
|
||||
axes [i] = (float) state;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined ( WIN32 )
|
||||
MMRESULT status = joyGetPosEx ( js_id, &js ) ;
|
||||
|
||||
if ( status != JOYERR_NOERROR )
|
||||
{
|
||||
setError() ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
{
|
||||
*buttons = (int) js . dwButtons ;
|
||||
}
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
/* WARNING - Fall through case clauses!! */
|
||||
//lint -save -e616
|
||||
|
||||
switch ( num_axes )
|
||||
{
|
||||
case 8:
|
||||
// Generate two POV axes from the POV hat angle.
|
||||
// Low 16 bits of js.dwPOV gives heading (clockwise from ahead) in
|
||||
// hundredths of a degree, or 0xFFFF when idle.
|
||||
if ( (js.dwPOV & 0xFFFF) == 0xFFFF ) {
|
||||
axes[6] = 0.0;
|
||||
axes[7] = 0.0;
|
||||
} else {
|
||||
// This is the contentious bit: how to convert angle to X/Y.
|
||||
// wk: I know of no define for PI that we could use here:
|
||||
// SG_PI would pull in sg, M_PI is undefined for MSVC
|
||||
// But the accuracy of the value of PI is very unimportant at this point.
|
||||
float s = (float)sin((js.dwPOV & 0xFFFF) * (0.01 * 3.1415926535f / 180));
|
||||
float c = (float)cos((js.dwPOV & 0xFFFF) * (0.01 * 3.1415926535f / 180));
|
||||
// Convert to coordinates on a square so that North-East
|
||||
// is (1,1) not (.7,.7), etc.
|
||||
// s and c cannot both be zero so we won't divide by zero.
|
||||
if (fabs(s) < fabs(c)) {
|
||||
axes[6] = (c < 0.0) ? -s/c : s/c;
|
||||
axes[7] = (c < 0.0) ? -1.0f : 1.0f;
|
||||
} else {
|
||||
axes[6] = (s < 0.0) ? -1.0f : 1.0f;
|
||||
axes[7] = (s < 0.0) ? -c/s : c/s;
|
||||
}
|
||||
}
|
||||
case 6: axes[5] = (float) js . dwVpos ;
|
||||
case 5: axes[4] = (float) js . dwUpos ;
|
||||
case 4: axes[3] = (float) js . dwRpos ;
|
||||
case 3: axes[2] = (float) js . dwZpos ;
|
||||
case 2: axes[1] = (float) js . dwYpos ;
|
||||
case 1: axes[0] = (float) js . dwXpos ;
|
||||
break;
|
||||
default:
|
||||
ulSetError ( UL_WARNING, "PLIB_JS: Wrong num_axes. Joystick input is now invalid" ) ;
|
||||
|
||||
}
|
||||
//lint -restore
|
||||
}
|
||||
#else
|
||||
|
||||
# ifdef JS_NEW
|
||||
|
||||
while (1)
|
||||
{
|
||||
int status = ::read ( fd, &js, sizeof(js_event) ) ;
|
||||
|
||||
if ( status != sizeof(js_event) )
|
||||
{
|
||||
/* use the old values */
|
||||
|
||||
if ( buttons ) *buttons = tmp_buttons ;
|
||||
if ( axes ) memcpy ( axes, tmp_axes, sizeof(float) * num_axes ) ;
|
||||
|
||||
if ( errno == EAGAIN )
|
||||
return ;
|
||||
|
||||
perror( fname ) ;
|
||||
setError () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
switch ( js.type & ~JS_EVENT_INIT )
|
||||
{
|
||||
case JS_EVENT_BUTTON :
|
||||
if ( js.value == 0 ) /* clear the flag */
|
||||
tmp_buttons &= ~(1 << js.number) ;
|
||||
else
|
||||
tmp_buttons |= (1 << js.number) ;
|
||||
break ;
|
||||
|
||||
case JS_EVENT_AXIS:
|
||||
if ( js.number < num_axes )
|
||||
{
|
||||
tmp_axes [ js.number ] = (float) js.value ;
|
||||
|
||||
if ( axes )
|
||||
memcpy ( axes, tmp_axes, sizeof(float) * num_axes ) ;
|
||||
}
|
||||
break ;
|
||||
|
||||
default:
|
||||
ulSetError ( UL_WARNING, "PLIB_JS: Unrecognised /dev/js return!?!" ) ;
|
||||
|
||||
/* use the old values */
|
||||
|
||||
if ( buttons ) *buttons = tmp_buttons ;
|
||||
if ( axes ) memcpy ( axes, tmp_axes, sizeof(float) * num_axes ) ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
*buttons = tmp_buttons ;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
int status = ::read ( fd, &js, JS_RETURN ) ;
|
||||
|
||||
if ( status != JS_RETURN )
|
||||
{
|
||||
perror ( fname ) ;
|
||||
setError () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
*buttons = ( js.b1 ? 1 : 0 ) | ( js.b2 ? 2 : 0 ) ;
|
||||
# else
|
||||
*buttons = js.buttons ;
|
||||
# endif
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
axes[0] = (float) js.x ;
|
||||
axes[1] = (float) js.y ;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
} ;
|
||||
|
||||
extern void jsInit () ;
|
||||
|
||||
//lint -restore
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# 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, 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.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing - GNU libit 0.0"
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aclocal)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`acinclude.m4' or \`configure.in'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`configure.in'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`acconfig.h' or \`configure.in'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case "$f" in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
bison|yacc)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f y.tab.h ]; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if [ ! -f y.tab.c ]; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex|flex)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f lex.yy.c ]; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
|
||||
fi
|
||||
touch $file
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and you do not seem to have it handy on your
|
||||
system. You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequirements for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,40 +0,0 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
# $Id$
|
||||
|
||||
errstatus=0
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d
|
||||
do
|
||||
pathcomp="$pathcomp$d"
|
||||
case "$pathcomp" in
|
||||
-* ) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp"
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# mkinstalldirs ends here
|
||||
@@ -1,63 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="plib" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Generic Project" 0x010a
|
||||
|
||||
CFG=plib - 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 "plib.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 "plib.mak" CFG="plib - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "plib - Win32 Release" (based on "Win32 (x86) Generic Project")
|
||||
!MESSAGE "plib - Win32 Debug" (based on "Win32 (x86) Generic Project")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "plib"
|
||||
# PROP Scc_LocalPath "."
|
||||
MTL=midl.exe
|
||||
|
||||
!IF "$(CFG)" == "plib - 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 Target_Dir ""
|
||||
|
||||
!ELSEIF "$(CFG)" == "plib - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "plib___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "plib___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "plib - Win32 Release"
|
||||
# Name "plib - Win32 Debug"
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,207 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "fnt"=.\src\fnt\fnt.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
fnt
|
||||
.\src\fnt
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "js"=.\src\js\js.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
js
|
||||
.\src\js
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "net"=.\src\net\net.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
net
|
||||
.\src\net
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "plib"=.\plib.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
plib
|
||||
.
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name fnt
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name js
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name sg
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name sl
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name ssg
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name pui
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name ul
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name ssgAux
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name net
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "pui"=.\src\pui\pui.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
pui
|
||||
.\src\pui
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name sg
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "sg"=.\src\sg\sg.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
sg
|
||||
.\src\sg
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "sl"=.\src\sl\sl.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
sl
|
||||
.\src\sl
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "ssg"=.\src\ssg\ssg.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
ssg
|
||||
.\src\ssg
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "ssgAux"=.\src\ssgAux\ssgAux.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
ssgAux
|
||||
.\src\ssgaux
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "ul"=.\src\util\ul.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
ul
|
||||
.\src\util
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 7.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fnt", "src\fnt\fnt.vcproj", "{C38984FE-606C-4AB7-A085-0B4B67380DB2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js", "src\js\js.vcproj", "{BF3C0B09-CA52-4474-971A-789C28D58B62}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "net", "src\net\net.vcproj", "{B5945775-CD67-47BD-9B76-BC23FF7F82C9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plib", "plib.vcproj", "{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pui", "src\pui\pui.vcproj", "{9BB9135A-A912-4F97-9BEC-D176525A96D7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sg", "src\sg\sg.vcproj", "{78153ECD-1959-4F37-AECC-942ECB2BDF6C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sl", "src\sl\sl.vcproj", "{FD40B4F6-A143-4088-BCC0-31747992C2C9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssg", "src\ssg\ssg.vcproj", "{70AE43E6-807B-4E59-893B-61EAE79F99BD}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssgAux", "src\ssgAux\ssgAux.vcproj", "{EEA08291-2AE0-49FA-853D-073961AFC7BA}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ul", "src\util\ul.vcproj", "{35562F7E-DEB3-414C-B994-9967BFFE2D90}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
ConfigName.0 = Debug
|
||||
ConfigName.1 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectDependencies) = postSolution
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.0 = {B5945775-CD67-47BD-9B76-BC23FF7F82C9}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.1 = {EEA08291-2AE0-49FA-853D-073961AFC7BA}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.2 = {35562F7E-DEB3-414C-B994-9967BFFE2D90}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.3 = {9BB9135A-A912-4F97-9BEC-D176525A96D7}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.4 = {70AE43E6-807B-4E59-893B-61EAE79F99BD}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.5 = {FD40B4F6-A143-4088-BCC0-31747992C2C9}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.6 = {78153ECD-1959-4F37-AECC-942ECB2BDF6C}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.7 = {BF3C0B09-CA52-4474-971A-789C28D58B62}
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.8 = {C38984FE-606C-4AB7-A085-0B4B67380DB2}
|
||||
{9BB9135A-A912-4F97-9BEC-D176525A96D7}.0 = {78153ECD-1959-4F37-AECC-942ECB2BDF6C}
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{C38984FE-606C-4AB7-A085-0B4B67380DB2}.Debug.ActiveCfg = Debug|Win32
|
||||
{C38984FE-606C-4AB7-A085-0B4B67380DB2}.Debug.Build.0 = Debug|Win32
|
||||
{C38984FE-606C-4AB7-A085-0B4B67380DB2}.Release.ActiveCfg = Release|Win32
|
||||
{C38984FE-606C-4AB7-A085-0B4B67380DB2}.Release.Build.0 = Release|Win32
|
||||
{BF3C0B09-CA52-4474-971A-789C28D58B62}.Debug.ActiveCfg = Debug|Win32
|
||||
{BF3C0B09-CA52-4474-971A-789C28D58B62}.Debug.Build.0 = Debug|Win32
|
||||
{BF3C0B09-CA52-4474-971A-789C28D58B62}.Release.ActiveCfg = Release|Win32
|
||||
{BF3C0B09-CA52-4474-971A-789C28D58B62}.Release.Build.0 = Release|Win32
|
||||
{B5945775-CD67-47BD-9B76-BC23FF7F82C9}.Debug.ActiveCfg = Debug|Win32
|
||||
{B5945775-CD67-47BD-9B76-BC23FF7F82C9}.Debug.Build.0 = Debug|Win32
|
||||
{B5945775-CD67-47BD-9B76-BC23FF7F82C9}.Release.ActiveCfg = Release|Win32
|
||||
{B5945775-CD67-47BD-9B76-BC23FF7F82C9}.Release.Build.0 = Release|Win32
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.Debug.ActiveCfg = Debug|Win32
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.Debug.Build.0 = Debug|Win32
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.Release.ActiveCfg = Release|Win32
|
||||
{DF80EB7B-C8DC-4FE4-8AA9-9127D94C5FC8}.Release.Build.0 = Release|Win32
|
||||
{9BB9135A-A912-4F97-9BEC-D176525A96D7}.Debug.ActiveCfg = Debug|Win32
|
||||
{9BB9135A-A912-4F97-9BEC-D176525A96D7}.Debug.Build.0 = Debug|Win32
|
||||
{9BB9135A-A912-4F97-9BEC-D176525A96D7}.Release.ActiveCfg = Release|Win32
|
||||
{9BB9135A-A912-4F97-9BEC-D176525A96D7}.Release.Build.0 = Release|Win32
|
||||
{78153ECD-1959-4F37-AECC-942ECB2BDF6C}.Debug.ActiveCfg = Debug|Win32
|
||||
{78153ECD-1959-4F37-AECC-942ECB2BDF6C}.Debug.Build.0 = Debug|Win32
|
||||
{78153ECD-1959-4F37-AECC-942ECB2BDF6C}.Release.ActiveCfg = Release|Win32
|
||||
{78153ECD-1959-4F37-AECC-942ECB2BDF6C}.Release.Build.0 = Release|Win32
|
||||
{FD40B4F6-A143-4088-BCC0-31747992C2C9}.Debug.ActiveCfg = Debug|Win32
|
||||
{FD40B4F6-A143-4088-BCC0-31747992C2C9}.Debug.Build.0 = Debug|Win32
|
||||
{FD40B4F6-A143-4088-BCC0-31747992C2C9}.Release.ActiveCfg = Release|Win32
|
||||
{FD40B4F6-A143-4088-BCC0-31747992C2C9}.Release.Build.0 = Release|Win32
|
||||
{70AE43E6-807B-4E59-893B-61EAE79F99BD}.Debug.ActiveCfg = Debug|Win32
|
||||
{70AE43E6-807B-4E59-893B-61EAE79F99BD}.Debug.Build.0 = Debug|Win32
|
||||
{70AE43E6-807B-4E59-893B-61EAE79F99BD}.Release.ActiveCfg = Release|Win32
|
||||
{70AE43E6-807B-4E59-893B-61EAE79F99BD}.Release.Build.0 = Release|Win32
|
||||
{EEA08291-2AE0-49FA-853D-073961AFC7BA}.Debug.ActiveCfg = Debug|Win32
|
||||
{EEA08291-2AE0-49FA-853D-073961AFC7BA}.Debug.Build.0 = Debug|Win32
|
||||
{EEA08291-2AE0-49FA-853D-073961AFC7BA}.Release.ActiveCfg = Release|Win32
|
||||
{EEA08291-2AE0-49FA-853D-073961AFC7BA}.Release.Build.0 = Release|Win32
|
||||
{35562F7E-DEB3-414C-B994-9967BFFE2D90}.Debug.ActiveCfg = Debug|Win32
|
||||
{35562F7E-DEB3-414C-B994-9967BFFE2D90}.Debug.Build.0 = Debug|Win32
|
||||
{35562F7E-DEB3-414C-B994-9967BFFE2D90}.Release.ActiveCfg = Release|Win32
|
||||
{35562F7E-DEB3-414C-B994-9967BFFE2D90}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="plib"
|
||||
SccProjectName="plib"
|
||||
SccLocalPath="."
|
||||
Keyword="MakeFileProj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="10"
|
||||
UseOfMFC="0">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="10"
|
||||
UseOfMFC="0">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -1,718 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SL_H__
|
||||
#define __SL_H__ 1
|
||||
|
||||
#include "slPortability.h"
|
||||
|
||||
#ifdef SL_USING_OSS_AUDIO
|
||||
#define SLDSP_DEFAULT_DEVICE "/dev/dsp"
|
||||
#elif defined(WIN32)
|
||||
#define SLDSP_DEFAULT_DEVICE "dsp"
|
||||
#elif defined(BSD)
|
||||
#define SLDSP_DEFAULT_DEVICE "/dev/audio"
|
||||
#elif defined(sgi)
|
||||
#define SLDSP_DEFAULT_DEVICE "dsp" // dummy ...
|
||||
#elif defined(SOLARIS)
|
||||
#define SLDSP_DEFAULT_DEVICE "/dev/audio"
|
||||
#elif defined(macintosh) || defined(__APPLE__)
|
||||
#define SLDSP_DEFAULT_DEVICE "dsp" // dummy
|
||||
#else
|
||||
#error "Port me !"
|
||||
#endif
|
||||
|
||||
# define SL_TRUE 1
|
||||
# define SL_FALSE 0
|
||||
|
||||
typedef unsigned char Uchar ;
|
||||
typedef unsigned short Ushort ;
|
||||
|
||||
#define SL_DEFAULT_SAMPLING_RATE 11025
|
||||
|
||||
class slSample ;
|
||||
class slPlayer ;
|
||||
class slSamplePlayer ;
|
||||
class slEnvelope ;
|
||||
class slScheduler ;
|
||||
class slDSP ;
|
||||
|
||||
extern const char *__slPendingError ;
|
||||
|
||||
class slDSP
|
||||
{
|
||||
private:
|
||||
|
||||
int stereo ;
|
||||
int rate ;
|
||||
int bps ;
|
||||
|
||||
int error ;
|
||||
int fd ;
|
||||
|
||||
#if defined (__NetBSD__) || defined(__OpenBSD__)
|
||||
audio_info_t ainfo; // ioctl structure
|
||||
audio_offset_t audio_offset; // offset in audiostream
|
||||
long counter; // counter-written packets
|
||||
#elif defined(SOLARIS)
|
||||
audio_info_t ainfo;
|
||||
long counter;
|
||||
#elif defined(SL_USING_OSS_AUDIO)
|
||||
audio_buf_info buff_info ;
|
||||
#elif defined(sgi)
|
||||
ALconfig config; // configuration stuff
|
||||
ALport port; // .. we are here
|
||||
#elif defined(macintosh) || defined(__APPLE__)
|
||||
|
||||
// Size of the data chunks written with write().
|
||||
// This should be a multiple of 1024.
|
||||
#define BUFFER_SIZE 8192
|
||||
|
||||
// Size of storage space for sound data.
|
||||
// This should be evenly divisible by BUFFER_SIZE.
|
||||
#define VIRTUAL_BUFFER_SIZE 131072
|
||||
|
||||
SndChannelPtr sndChannel ; // sound channel we are using
|
||||
ExtSoundHeader extSndHeader ; // sound header for bufferCmd
|
||||
SndCommand currentCmd ; // command we are sending to chnl
|
||||
OSErr osErr ;
|
||||
|
||||
char *buf ; // buffer containing sound data
|
||||
char *rpos ; // read position for buffer
|
||||
char *wpos ; // write position for buffer
|
||||
char *ptr ; // ptr to data from write()
|
||||
|
||||
float bytesPerSample ; // conversions
|
||||
float bytesPerSecond ;
|
||||
float secondsPerPacket ;
|
||||
|
||||
float secLeft ; // seconds left in buffer
|
||||
float secUsed ; // seconds used in buffer
|
||||
UnsignedWide lastTime ; // used for timing in secondsUsed()
|
||||
UnsignedWide currTime ;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(WIN32) && !defined(macintosh)
|
||||
int ioctl ( int cmd, int param = 0 )
|
||||
{
|
||||
if ( error ) return param ;
|
||||
|
||||
if ( ::ioctl ( fd, cmd, & param ) == -1 )
|
||||
{
|
||||
perror ( "slDSP: ioctl" ) ;
|
||||
error = SL_TRUE ;
|
||||
}
|
||||
|
||||
return param ;
|
||||
}
|
||||
|
||||
#elif defined(WIN32)
|
||||
|
||||
#define BUFFER_COUNT (3*8)
|
||||
#define BUFFER_SIZE (1024*1)
|
||||
|
||||
friend void CALLBACK waveOutProc( HWAVEOUT hwo, UINT uMsg,
|
||||
DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 );
|
||||
HWAVEOUT hWaveOut; // device handle
|
||||
WAVEFORMATEX Format; // open needs this
|
||||
MMTIME mmt; // timing
|
||||
WAVEHDR *wavehdr[ BUFFER_COUNT ]; // for round robin ..
|
||||
int curr_header; // index of actual wavehdr
|
||||
int counter; // counter-written packets
|
||||
DWORD written; // counter-written samples
|
||||
|
||||
#endif
|
||||
|
||||
void open ( const char *device, int _rate, int _stereo, int _bps ) ;
|
||||
void close () ;
|
||||
void getBufferInfo () ;
|
||||
void write ( void *buffer, size_t length ) ;
|
||||
|
||||
protected:
|
||||
|
||||
void setError () { error = SL_TRUE ; }
|
||||
int getDriverBufferSize () ;
|
||||
|
||||
public:
|
||||
|
||||
slDSP ( int _rate = SL_DEFAULT_SAMPLING_RATE,
|
||||
int _stereo = SL_FALSE, int _bps = 8 )
|
||||
{
|
||||
open ( SLDSP_DEFAULT_DEVICE, _rate, _stereo, _bps ) ;
|
||||
}
|
||||
|
||||
slDSP ( const char *device, int _rate = SL_DEFAULT_SAMPLING_RATE,
|
||||
int _stereo = SL_FALSE, int _bps = 8 )
|
||||
{
|
||||
open ( device, _rate, _stereo, _bps ) ;
|
||||
}
|
||||
|
||||
~slDSP () { close () ; }
|
||||
|
||||
float secondsRemaining () ;
|
||||
float secondsUsed () ;
|
||||
|
||||
void play ( void *buffer, size_t length ) { write ( buffer, length ) ; }
|
||||
|
||||
/* This was a typo - but people use it */
|
||||
int not_working() const { return error ; }
|
||||
|
||||
int notWorking () const { return error ; }
|
||||
|
||||
int getBps () const { return bps ; }
|
||||
int getRate () const { return rate ; }
|
||||
int getStereo() const { return stereo ; }
|
||||
|
||||
void sync () ;
|
||||
void stop () ;
|
||||
} ;
|
||||
|
||||
|
||||
class slSample
|
||||
{
|
||||
int ref_count ;
|
||||
protected:
|
||||
|
||||
char *comment;
|
||||
int rate ;
|
||||
int bps ;
|
||||
int stereo ;
|
||||
|
||||
Uchar *buffer ;
|
||||
int length ;
|
||||
|
||||
void init ()
|
||||
{
|
||||
ref_count = 0 ;
|
||||
comment = NULL ;
|
||||
buffer = NULL ;
|
||||
length = 0 ;
|
||||
rate = SL_DEFAULT_SAMPLING_RATE ;
|
||||
bps = 8 ;
|
||||
stereo = SL_FALSE ;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
slSample () { init () ; }
|
||||
|
||||
slSample ( const Uchar *buff, int leng )
|
||||
{
|
||||
init () ;
|
||||
setBuffer ( buff, leng ) ;
|
||||
}
|
||||
|
||||
slSample ( const char *fname, const class slDSP *dsp = NULL )
|
||||
{
|
||||
if ( dsp != NULL && dsp->notWorking () )
|
||||
dsp = NULL ;
|
||||
|
||||
init () ;
|
||||
loadFile ( fname ) ;
|
||||
autoMatch ( dsp ) ;
|
||||
}
|
||||
|
||||
~slSample ()
|
||||
{
|
||||
if ( ref_count != 0 && __slPendingError == NULL )
|
||||
__slPendingError =
|
||||
"slSample: FATAL ERROR - Application deleted a sample while it was playing." ;
|
||||
|
||||
delete [] buffer ;
|
||||
}
|
||||
|
||||
void ref () { ref_count++ ; }
|
||||
void unRef () { ref_count-- ; }
|
||||
|
||||
int getPlayCount () const { return ref_count ; }
|
||||
|
||||
char *getComment () const { return comment ; }
|
||||
|
||||
void setComment ( const char *nc )
|
||||
{
|
||||
delete [] comment ;
|
||||
comment = new char [ strlen ( nc ) + 1 ] ;
|
||||
strcpy ( comment, nc ) ;
|
||||
}
|
||||
|
||||
Uchar *getBuffer () const { return buffer ; }
|
||||
int getLength () const { return length ; }
|
||||
|
||||
void autoMatch ( const slDSP *dsp ) ;
|
||||
|
||||
void setBuffer ( const Uchar *buff, int leng )
|
||||
{
|
||||
delete [] buffer ;
|
||||
|
||||
buffer = new Uchar [ leng ] ;
|
||||
|
||||
if ( buff != NULL )
|
||||
memcpy ( buffer, buff, leng ) ;
|
||||
|
||||
length = leng ;
|
||||
}
|
||||
|
||||
/* These routines only set flags - use changeXXX () to convert a sound */
|
||||
|
||||
void setRate ( int r ) { rate = r ; }
|
||||
void setBps ( int b ) { bps = b ; }
|
||||
void setStereo ( int s ) { stereo = s ; }
|
||||
|
||||
int getRate () const { return rate ; }
|
||||
int getBps () const { return bps ; }
|
||||
int getStereo () const { return stereo ; }
|
||||
|
||||
float getDuration () const { return (float) getLength() /
|
||||
(float) ( (getStereo()?2.0f:1.0f)*
|
||||
(getBps()/8.0f)*getRate() ) ; }
|
||||
|
||||
int loadFile ( const char *fname ) ;
|
||||
|
||||
int loadRawFile ( const char *fname ) ;
|
||||
int loadAUFile ( const char *fname ) ;
|
||||
int loadWavFile ( const char *fname ) ;
|
||||
|
||||
void changeRate ( int r ) ;
|
||||
void changeBps ( int b ) ;
|
||||
void changeStereo ( int s ) ;
|
||||
void changeToUnsigned () ;
|
||||
|
||||
void adjustVolume ( float vol ) ;
|
||||
|
||||
void print ( FILE *fd ) const
|
||||
{
|
||||
if ( buffer == NULL )
|
||||
{
|
||||
fprintf ( fd, "Empty sample buffer\n" ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf ( fd, "\"%s\"\n",(getComment() == NULL ||
|
||||
getComment()[0]=='\0') ? "Sample" : comment ) ;
|
||||
fprintf ( fd, "%s, %d bits per sample.\n",
|
||||
getStereo() ? "Stereo" : "Mono", getBps() ) ;
|
||||
fprintf ( fd, "%gKHz sample rate.\n", (float) getRate() / 1000.0f ) ;
|
||||
fprintf ( fd, "%d bytes of samples == %g seconds duration.\n", getLength(), getDuration() ) ;
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
enum slSampleStatus
|
||||
{
|
||||
SL_SAMPLE_WAITING, /* Sound hasn't started playing yet */
|
||||
SL_SAMPLE_RUNNING, /* Sound has started playing */
|
||||
SL_SAMPLE_DONE , /* Sound is complete */
|
||||
SL_SAMPLE_PAUSED /* Sound hasn't started playing yet */
|
||||
} ;
|
||||
|
||||
|
||||
enum slPreemptMode
|
||||
{
|
||||
SL_SAMPLE_CONTINUE, /* Don't allow yourself to be preempted */
|
||||
SL_SAMPLE_ABORT , /* Abort playing the sound when preempted */
|
||||
SL_SAMPLE_RESTART , /* Restart the sound when load permits */
|
||||
SL_SAMPLE_MUTE , /* Continue silently until load permits */
|
||||
SL_SAMPLE_DELAY /* Pause until load permits */
|
||||
} ;
|
||||
|
||||
|
||||
enum slReplayMode
|
||||
{
|
||||
SL_SAMPLE_LOOP, /* Loop sound so that it plays forever */
|
||||
SL_SAMPLE_ONE_SHOT /* Play sound just once */
|
||||
} ;
|
||||
|
||||
enum slEvent
|
||||
{
|
||||
SL_EVENT_COMPLETE, /* Sound finished playing */
|
||||
SL_EVENT_LOOPED, /* Sound looped back to the start */
|
||||
SL_EVENT_PREEMPTED /* Sound was preempted */
|
||||
} ;
|
||||
|
||||
typedef void (*slCallBack) ( slSample *, slEvent, int ) ;
|
||||
|
||||
class slEnvelope
|
||||
{
|
||||
protected:
|
||||
|
||||
float *time ;
|
||||
float *value ;
|
||||
int nsteps ;
|
||||
int ref_count ;
|
||||
|
||||
slReplayMode replay_mode ;
|
||||
|
||||
int getStepDelta ( float *_time, float *delta ) const ;
|
||||
|
||||
public:
|
||||
|
||||
slEnvelope ( int _nsteps, slReplayMode _rm, float *_times, float *_values )
|
||||
{
|
||||
ref_count = 0 ;
|
||||
nsteps = _nsteps ;
|
||||
time = new float [ nsteps ] ;
|
||||
value = new float [ nsteps ] ;
|
||||
memcpy ( time , _times , sizeof(float) * nsteps ) ;
|
||||
memcpy ( value, _values, sizeof(float) * nsteps ) ;
|
||||
|
||||
replay_mode = _rm ;
|
||||
}
|
||||
|
||||
|
||||
slEnvelope ( int _nsteps = 1, slReplayMode _rm = SL_SAMPLE_ONE_SHOT )
|
||||
{
|
||||
ref_count = 0 ;
|
||||
nsteps = _nsteps ;
|
||||
time = new float [ nsteps ] ;
|
||||
value = new float [ nsteps ] ;
|
||||
|
||||
for ( int i = 0 ; i < nsteps ; i++ )
|
||||
time [ i ] = value [ i ] = 0.0 ;
|
||||
|
||||
replay_mode = _rm ;
|
||||
}
|
||||
|
||||
~slEnvelope ()
|
||||
{
|
||||
if ( ref_count != 0 && __slPendingError == NULL )
|
||||
__slPendingError =
|
||||
"slEnvelope: FATAL ERROR - Application deleted an envelope while it was playing.\n" ;
|
||||
|
||||
delete [] time ;
|
||||
delete [] value ;
|
||||
}
|
||||
|
||||
void ref () { ref_count++ ; }
|
||||
void unRef () { ref_count-- ; }
|
||||
|
||||
int getPlayCount () const { return ref_count ; }
|
||||
|
||||
void setStep ( int n, float _time, float _value )
|
||||
{
|
||||
if ( n >= 0 && n < nsteps )
|
||||
{
|
||||
time [ n ] = _time ;
|
||||
value [ n ] = _value ;
|
||||
}
|
||||
}
|
||||
|
||||
float getStepValue ( int s ) const { return value [ s ] ; }
|
||||
float getStepTime ( int s ) const { return time [ s ] ; }
|
||||
|
||||
int getNumSteps () const { return nsteps ; }
|
||||
|
||||
float getValue ( float _time ) const ;
|
||||
|
||||
void applyToPitch ( Uchar *dst, slPlayer *src, int nframes, int start, int next_env ) ;
|
||||
void applyToInvPitch ( Uchar *dst, slPlayer *src, int nframes, int start, int next_env ) ;
|
||||
void applyToVolume ( Uchar *dst, Uchar *src, int nframes, int start ) ;
|
||||
void applyToInvVolume ( Uchar *dst, Uchar *src, int nframes, int start ) ;
|
||||
} ;
|
||||
|
||||
#define SL_MAX_PRIORITY 16
|
||||
#define SL_MAX_SAMPLES 16
|
||||
#define SL_MAX_CALLBACKS (SL_MAX_SAMPLES * 2)
|
||||
#define SL_MAX_ENVELOPES 4
|
||||
#define SL_MAX_MIXERINPUTS 10
|
||||
|
||||
enum slEnvelopeType
|
||||
{
|
||||
SL_PITCH_ENVELOPE , SL_INVERSE_PITCH_ENVELOPE ,
|
||||
SL_VOLUME_ENVELOPE, SL_INVERSE_VOLUME_ENVELOPE,
|
||||
SL_FILTER_ENVELOPE, SL_INVERSE_FILTER_ENVELOPE,
|
||||
SL_PAN_ENVELOPE , SL_INVERSE_PAN_ENVELOPE ,
|
||||
SL_ECHO_ENVELOPE , SL_INVERSE_ECHO_ENVELOPE ,
|
||||
|
||||
SL_NULL_ENVELOPE
|
||||
} ;
|
||||
|
||||
struct slPendingCallBack
|
||||
{
|
||||
slCallBack callback ;
|
||||
slSample *sample ;
|
||||
slEvent event ;
|
||||
int magic ;
|
||||
} ;
|
||||
|
||||
class slPlayer
|
||||
{
|
||||
protected:
|
||||
|
||||
slEnvelope *env [ SL_MAX_ENVELOPES ] ;
|
||||
slEnvelopeType env_type [ SL_MAX_ENVELOPES ] ;
|
||||
int env_start_time [ SL_MAX_ENVELOPES ] ;
|
||||
|
||||
slReplayMode replay_mode ;
|
||||
slPreemptMode preempt_mode ;
|
||||
slSampleStatus status ;
|
||||
int priority ;
|
||||
|
||||
slCallBack callback ;
|
||||
int magic ;
|
||||
|
||||
virtual void low_read ( int nframes, Uchar *dest ) = 0 ;
|
||||
virtual void skip ( int nframes ) = 0 ;
|
||||
|
||||
public:
|
||||
|
||||
slPlayer ( slReplayMode rp_mode = SL_SAMPLE_ONE_SHOT,
|
||||
int pri = 0, slPreemptMode pr_mode = SL_SAMPLE_DELAY,
|
||||
int _magic = 0, slCallBack cb = NULL )
|
||||
{
|
||||
magic = _magic ;
|
||||
callback = cb ;
|
||||
|
||||
for ( int i = 0 ; i < SL_MAX_ENVELOPES ; i++ )
|
||||
{
|
||||
env [ i ] = NULL ;
|
||||
env_type [ i ] = SL_NULL_ENVELOPE ;
|
||||
}
|
||||
|
||||
status = SL_SAMPLE_WAITING ;
|
||||
replay_mode = rp_mode ;
|
||||
preempt_mode = pr_mode ;
|
||||
priority = pri ;
|
||||
}
|
||||
|
||||
virtual ~slPlayer () ;
|
||||
|
||||
slPreemptMode getPreemptMode () const { return preempt_mode ; }
|
||||
|
||||
int getPriority () const
|
||||
{
|
||||
return ( isRunning() &&
|
||||
preempt_mode == SL_SAMPLE_CONTINUE ) ? (SL_MAX_PRIORITY+1) :
|
||||
priority ;
|
||||
}
|
||||
|
||||
void addEnvelope ( int i, slEnvelope *_env, slEnvelopeType _type ) ;
|
||||
|
||||
virtual void pause ()
|
||||
{
|
||||
if ( status != SL_SAMPLE_DONE )
|
||||
status = SL_SAMPLE_PAUSED ;
|
||||
}
|
||||
|
||||
virtual void resume ()
|
||||
{
|
||||
if ( status == SL_SAMPLE_PAUSED )
|
||||
status = SL_SAMPLE_RUNNING ;
|
||||
}
|
||||
|
||||
virtual void reset ()
|
||||
{
|
||||
status = SL_SAMPLE_WAITING ;
|
||||
}
|
||||
|
||||
virtual void start ()
|
||||
{
|
||||
status = SL_SAMPLE_RUNNING ;
|
||||
}
|
||||
|
||||
virtual void stop ()
|
||||
{
|
||||
status = SL_SAMPLE_DONE ;
|
||||
}
|
||||
|
||||
int getMagic () const { return magic ; }
|
||||
int isWaiting () const { return status == SL_SAMPLE_WAITING ; }
|
||||
int isPaused () const { return status == SL_SAMPLE_PAUSED ; }
|
||||
int isRunning () const { return status == SL_SAMPLE_RUNNING ; }
|
||||
int isDone () const { return status == SL_SAMPLE_DONE ; }
|
||||
|
||||
virtual int preempt ( int delay ) ;
|
||||
|
||||
virtual slSample *getSample () const = 0 ;
|
||||
|
||||
void read ( int nframes, Uchar *dest, int next_env = 0 ) ;
|
||||
} ;
|
||||
|
||||
|
||||
class MODfile ;
|
||||
|
||||
class slMODPlayer : public slPlayer
|
||||
{
|
||||
MODfile *mf ;
|
||||
|
||||
void low_read ( int nframes, Uchar *dest ) ;
|
||||
void init ( const char *fname ) ;
|
||||
public:
|
||||
|
||||
slMODPlayer ( const char *fname, slReplayMode rp_mode = SL_SAMPLE_ONE_SHOT,
|
||||
int pri = 0, slPreemptMode pr_mode = SL_SAMPLE_DELAY,
|
||||
int _magic = 0, slCallBack cb = NULL ) :
|
||||
slPlayer ( rp_mode, pri, pr_mode, _magic, cb )
|
||||
{
|
||||
init ( fname ) ;
|
||||
reset () ;
|
||||
}
|
||||
|
||||
~slMODPlayer () ;
|
||||
|
||||
int preempt ( int delay ) ;
|
||||
virtual slSample *getSample () const { return NULL ; }
|
||||
|
||||
void skip ( int nframes ) ;
|
||||
} ;
|
||||
|
||||
|
||||
class slSamplePlayer : public slPlayer
|
||||
{
|
||||
int lengthRemaining ; /* Sample frames remaining until repeat */
|
||||
Uchar *bufferPos ; /* Sample frame to replay next */
|
||||
slSample *sample ;
|
||||
|
||||
void low_read ( int nframes, Uchar *dest ) ;
|
||||
|
||||
public:
|
||||
|
||||
slSamplePlayer ( slSample *s, slReplayMode rp_mode = SL_SAMPLE_ONE_SHOT,
|
||||
int pri = 0, slPreemptMode pr_mode = SL_SAMPLE_DELAY,
|
||||
int _magic = 0, slCallBack cb = NULL ) :
|
||||
slPlayer ( rp_mode, pri, pr_mode, _magic, cb )
|
||||
{
|
||||
sample = s ;
|
||||
|
||||
if ( sample ) sample -> ref () ;
|
||||
|
||||
reset () ;
|
||||
}
|
||||
|
||||
~slSamplePlayer () ;
|
||||
|
||||
int preempt ( int delay ) ;
|
||||
|
||||
void reset ()
|
||||
{
|
||||
slPlayer::reset () ;
|
||||
|
||||
lengthRemaining = sample->getLength () ;
|
||||
bufferPos = sample->getBuffer () ;
|
||||
}
|
||||
|
||||
void start ()
|
||||
{
|
||||
slPlayer::start () ;
|
||||
|
||||
lengthRemaining = sample->getLength () ;
|
||||
bufferPos = sample->getBuffer () ;
|
||||
}
|
||||
|
||||
void stop ()
|
||||
{
|
||||
slPlayer::stop () ;
|
||||
|
||||
lengthRemaining = 0 ;
|
||||
bufferPos = NULL ;
|
||||
}
|
||||
|
||||
slSample *getSample () const { return sample ; }
|
||||
|
||||
void skip ( int nframes ) ;
|
||||
} ;
|
||||
|
||||
|
||||
class slScheduler : public slDSP
|
||||
{
|
||||
slPendingCallBack pending_callback [ SL_MAX_CALLBACKS ] ;
|
||||
int num_pending_callbacks ;
|
||||
|
||||
float safety_margin ;
|
||||
|
||||
int mixer_buffer_size, mixer_gain ;
|
||||
|
||||
Uchar *mixer_buffer ;
|
||||
Uchar *mixer_inputs [ SL_MAX_MIXERINPUTS + 1 ] ;
|
||||
|
||||
Uchar *mixer ;
|
||||
int amount_left ;
|
||||
|
||||
slPlayer *player [ SL_MAX_SAMPLES ] ;
|
||||
slPlayer *music ;
|
||||
|
||||
void init () ;
|
||||
|
||||
void realUpdate ( int dump_first = SL_FALSE ) ;
|
||||
|
||||
void initBuffers () ;
|
||||
|
||||
int now ;
|
||||
|
||||
static slScheduler *current ;
|
||||
|
||||
public:
|
||||
|
||||
slScheduler ( int _rate = SL_DEFAULT_SAMPLING_RATE ) : slDSP ( _rate, SL_FALSE, 8 ) { init () ; }
|
||||
slScheduler ( const char *device,
|
||||
int _rate = SL_DEFAULT_SAMPLING_RATE ) : slDSP ( device, _rate, SL_FALSE, 8 ) { init () ; }
|
||||
~slScheduler () ;
|
||||
|
||||
static slScheduler *getCurrent () { return current ; }
|
||||
|
||||
int getTimeNow () const { return now ; }
|
||||
float getElapsedTime ( int then ) const { return (float)(now-then)/(float)getRate() ; }
|
||||
|
||||
void setMaxConcurrent ( int mc );
|
||||
int getMaxConcurrent () const ;
|
||||
|
||||
void flushCallBacks () ;
|
||||
void addCallBack ( slCallBack c, slSample *s, slEvent e, int m ) ;
|
||||
|
||||
void update () { realUpdate ( SL_FALSE ) ; }
|
||||
void dumpUpdate () { realUpdate ( SL_TRUE ) ; }
|
||||
|
||||
void resumeSample ( slSample *s = NULL, int magic = 0 ) ;
|
||||
void resumeMusic ( int magic = 0 ) ;
|
||||
void pauseSample ( slSample *s = NULL, int magic = 0 ) ;
|
||||
void pauseMusic ( int magic = 0 ) ;
|
||||
void stopSample ( slSample *s = NULL, int magic = 0 ) ;
|
||||
void stopMusic ( int magic = 0 ) ;
|
||||
|
||||
void addSampleEnvelope ( slSample *s = NULL, int magic = 0,
|
||||
int slot = 1, slEnvelope *e = NULL,
|
||||
slEnvelopeType t = SL_VOLUME_ENVELOPE ) ;
|
||||
void addMusicEnvelope ( int magic = 0,
|
||||
int slot = 1, slEnvelope *e = NULL,
|
||||
slEnvelopeType t = SL_VOLUME_ENVELOPE ) ;
|
||||
int loopSample ( slSample *s, int pri = 0,
|
||||
slPreemptMode mode = SL_SAMPLE_MUTE,
|
||||
int magic = 0, slCallBack cb = NULL ) ;
|
||||
int loopMusic ( const char *fname, int pri = 0,
|
||||
slPreemptMode mode = SL_SAMPLE_MUTE,
|
||||
int magic = 0, slCallBack cb = NULL ) ;
|
||||
int playSample ( slSample *s, int pri = 1,
|
||||
slPreemptMode mode = SL_SAMPLE_ABORT,
|
||||
int magic = 0, slCallBack cb = NULL ) ;
|
||||
int playMusic ( const char *fname, int pri = 1,
|
||||
slPreemptMode mode = SL_SAMPLE_ABORT,
|
||||
int magic = 0, slCallBack cb = NULL ) ;
|
||||
|
||||
void setSafetyMargin ( float seconds ) { safety_margin = seconds ; }
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SLPORTABILITY_H__
|
||||
#define __SLPORTABILITY_H__ 1
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* OS specific includes and defines ... */
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
#include "ul.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* the next lines are to define BSD */
|
||||
/* see http://www.freebsd.org/handbook/porting.html for why we do this */
|
||||
#if (defined(__unix__) || defined(unix)) && !defined(USG)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
#include <Sound.h>
|
||||
#include <Timer.h>
|
||||
#ifdef __MWERKS__
|
||||
#include <unix.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#ifdef __CYGWIN32__
|
||||
# define NEAR /* */
|
||||
# define FAR /* */
|
||||
# define WHERE_EVER_YOU_ARE /* Curt: optional, but it reminds me of a song */
|
||||
#endif
|
||||
#include <mmsystem.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#if (defined(__linux__) || defined(BSD)) && !defined(__NetBSD__)
|
||||
#define SL_USING_OSS_AUDIO 1
|
||||
#endif
|
||||
|
||||
#ifdef SL_USING_OSS_AUDIO
|
||||
# if defined(__linux__)
|
||||
# include <linux/soundcard.h>
|
||||
# elif defined(__FreeBSD__)
|
||||
# include <machine/soundcard.h>
|
||||
# else
|
||||
/*
|
||||
Tom thinks this file may be <sys/soundcard.h> under some
|
||||
unixen - but that isn't where the OSS manuals say it
|
||||
should be.
|
||||
|
||||
If you ever find out the truth, please email me:
|
||||
Steve Baker <sjbaker1@airmail.net>
|
||||
*/
|
||||
# include <soundcard.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__NetBSD__) || defined(__OpenBSD__)
|
||||
# include <sys/audioio.h>
|
||||
#endif
|
||||
|
||||
/* Tom */
|
||||
|
||||
#ifdef sgi
|
||||
# include <audio.h>
|
||||
#endif
|
||||
|
||||
#if defined(__svr4__) || defined(__SVR4)
|
||||
# include <sys/audioio.h>
|
||||
# include <sys/stropts.h>
|
||||
# define SOLARIS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SM_H__
|
||||
#define __SM_H__ 1
|
||||
|
||||
#include "slPortability.h"
|
||||
|
||||
#ifdef SL_USING_OSS_AUDIO
|
||||
#define SMMIXER_DEFAULT_DEVICE "/dev/mixer"
|
||||
#elif defined(WIN32)
|
||||
#define SMMIXER_DEFAULT_DEVICE "mixer"
|
||||
#else
|
||||
#endif
|
||||
|
||||
|
||||
# define SM_TRUE 1
|
||||
# define SM_FALSE 0
|
||||
|
||||
typedef unsigned char Uchar ;
|
||||
typedef unsigned short Ushort ;
|
||||
|
||||
|
||||
class smMixer
|
||||
{
|
||||
private:
|
||||
|
||||
int devices ;
|
||||
int error ;
|
||||
int fd ;
|
||||
|
||||
#ifdef SL_USING_OSS_AUDIO
|
||||
|
||||
int ioctl ( int cmd, int param = 0 )
|
||||
{
|
||||
if ( error ) return param ;
|
||||
|
||||
if ( ::ioctl ( fd, cmd, & param ) == -1 )
|
||||
{
|
||||
perror ( "smMixer: ioctl" ) ;
|
||||
error = SM_TRUE ;
|
||||
}
|
||||
|
||||
return param ;
|
||||
}
|
||||
#endif
|
||||
void open ( const char *device ) ;
|
||||
void close () ;
|
||||
|
||||
public:
|
||||
|
||||
/* Tom */
|
||||
|
||||
smMixer ();
|
||||
smMixer ( const char *device );
|
||||
~smMixer ();
|
||||
|
||||
int notWorking () const ;
|
||||
int not_working () const { return notWorking () ; } /* Originally a typo! */
|
||||
|
||||
/* Volume controls are in integer percentages */
|
||||
|
||||
int getVolume ( int channel );
|
||||
void setVolume ( int channel, int volume );
|
||||
|
||||
void getVolume ( int channel, int *left, int *right );
|
||||
void setVolume ( int channel, int left, int right );
|
||||
|
||||
void setTreble ( int treble );
|
||||
void setBass ( int bass );
|
||||
|
||||
void setMasterVolume ( int volume );
|
||||
void setSynthVolume ( int volume );
|
||||
void setPCMVolume ( int volume );
|
||||
void setSpeakerVolume( int volume );
|
||||
void setLineVolume ( int volume );
|
||||
void setMicVolume ( int volume );
|
||||
void setCDVolume ( int volume );
|
||||
|
||||
void setMasterVolume ( int left, int right );
|
||||
void setSynthVolume ( int left, int right );
|
||||
void setPCMVolume ( int left, int right );
|
||||
void setSpeakerVolume( int left, int right );
|
||||
void setLineVolume ( int left, int right );
|
||||
void setMicVolume ( int left, int right );
|
||||
void setCDVolume ( int left, int right );
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
SUBDIRS = util js sl pui sg ssg fnt ssgAux net
|
||||
@@ -1,276 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
|
||||
SUBDIRS = util js sl pui sg ssg fnt ssgAux net
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $(MAKEFLAGS); amf=$$2; \
|
||||
dot_seen=no; \
|
||||
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
rev="$$subdir $$rev"; \
|
||||
test "$$subdir" = "." && dot_seen=yes; \
|
||||
done; \
|
||||
test "$$dot_seen" = "no" && rev=". $$rev"; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = src
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
installcheck-am:
|
||||
installcheck: installcheck-recursive
|
||||
install-exec-am:
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am:
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile
|
||||
all-redirect: all-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-tags clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-tags distclean-generic clean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
|
||||
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
|
||||
.PHONY: install-data-recursive uninstall-data-recursive \
|
||||
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
|
||||
uninstalldirs-recursive all-recursive check-recursive \
|
||||
installcheck-recursive info-recursive dvi-recursive \
|
||||
mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
|
||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all installdirs-am \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,14 +0,0 @@
|
||||
if BUILD_FNT
|
||||
|
||||
lib_LIBRARIES = libplibfnt.a
|
||||
|
||||
include_HEADERS = fnt.h
|
||||
|
||||
libplibfnt_a_SOURCES = fnt.cxx fntTXF.cxx fntLocal.h
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/sg -I$(top_srcdir)/src/util
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = fnt.dsp
|
||||
|
||||
@@ -1,322 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
|
||||
@BUILD_FNT_TRUE@lib_LIBRARIES = libplibfnt.a
|
||||
|
||||
@BUILD_FNT_TRUE@include_HEADERS = fnt.h
|
||||
|
||||
@BUILD_FNT_TRUE@libplibfnt_a_SOURCES = fnt.cxx fntTXF.cxx fntLocal.h
|
||||
|
||||
@BUILD_FNT_TRUE@INCLUDES = -I$(top_srcdir)/src/sg -I$(top_srcdir)/src/util
|
||||
|
||||
EXTRA_DIST = fnt.dsp
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(lib_LIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
libplibfnt_a_LIBADD =
|
||||
@BUILD_FNT_TRUE@libplibfnt_a_OBJECTS = fnt.o fntTXF.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
HEADERS = $(include_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(libplibfnt_a_SOURCES)
|
||||
OBJECTS = $(libplibfnt_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .cxx .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/fnt/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-libLIBRARIES:
|
||||
|
||||
clean-libLIBRARIES:
|
||||
-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
|
||||
|
||||
distclean-libLIBRARIES:
|
||||
|
||||
maintainer-clean-libLIBRARIES:
|
||||
|
||||
install-libLIBRARIES: $(lib_LIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
@$(POST_INSTALL)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||
done
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
libplibfnt.a: $(libplibfnt_a_OBJECTS) $(libplibfnt_a_DEPENDENCIES)
|
||||
-rm -f libplibfnt.a
|
||||
$(AR) cru libplibfnt.a $(libplibfnt_a_OBJECTS) $(libplibfnt_a_LIBADD)
|
||||
$(RANLIB) libplibfnt.a
|
||||
.cxx.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
install-includeHEADERS: $(include_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(includedir)
|
||||
@list='$(include_HEADERS)'; for p in $$list; do \
|
||||
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
|
||||
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
|
||||
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
uninstall-includeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(include_HEADERS)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = src/fnt
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
fnt.o: fnt.cxx fntLocal.h fnt.h ../../src/sg/sg.h ../../src/util/ul.h
|
||||
fntTXF.o: fntTXF.cxx fntLocal.h fnt.h ../../src/sg/sg.h \
|
||||
../../src/util/ul.h
|
||||
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am: install-libLIBRARIES
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am: install-includeHEADERS
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am: uninstall-libLIBRARIES uninstall-includeHEADERS
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES) $(HEADERS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-libLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-libLIBRARIES clean-compile clean-tags clean-generic \
|
||||
mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-libLIBRARIES distclean-compile distclean-tags \
|
||||
distclean-generic clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-libLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-libLIBRARIES distclean-libLIBRARIES \
|
||||
clean-libLIBRARIES maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
|
||||
install-libLIBRARIES mostlyclean-compile distclean-compile \
|
||||
clean-compile maintainer-clean-compile uninstall-includeHEADERS \
|
||||
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
|
||||
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,246 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "fntLocal.h"
|
||||
|
||||
fntFont:: fntFont () {}
|
||||
fntFont::~fntFont () {}
|
||||
|
||||
int fntTexFont::load ( const char *fname, GLenum mag, GLenum min )
|
||||
{
|
||||
const char *p ;
|
||||
|
||||
for ( p = & fname [ strlen ( fname ) -1 ] ;
|
||||
p != fname && *p != '.' && *p != '/' ; p-- )
|
||||
/* Do nothing */ ;
|
||||
|
||||
if ( strcmp ( p, ".txf" ) == 0 ) {
|
||||
return loadTXF ( fname, mag, min ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"fnt::load: Error - Unrecognised file format for '%s'", fname ) ;
|
||||
return FNT_FALSE ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
float fntTexFont::low_putch ( sgVec3 curpos, float pointsize,
|
||||
float italic, char c )
|
||||
{
|
||||
unsigned int cc = (unsigned char) c ;
|
||||
|
||||
/* Auto case-convert if character is absent from font. */
|
||||
|
||||
if ( ! exists [ cc ] )
|
||||
{
|
||||
if ( cc >= 'A' && cc <= 'Z' )
|
||||
cc = cc - 'A' + 'a' ;
|
||||
else
|
||||
if ( cc >= 'a' && cc <= 'z' )
|
||||
cc = cc - 'a' + 'A' ;
|
||||
|
||||
if ( cc == ' ' )
|
||||
{
|
||||
curpos [ 0 ] += pointsize / 2.0f ;
|
||||
return pointsize / 2.0f ;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
We might want to consider making some absent characters from
|
||||
others (if they exist): lowercase 'l' could be made into digit '1'
|
||||
or letter 'O' into digit '0'...or vice versa. We could also
|
||||
make 'b', 'd', 'p' and 'q' by mirror-imaging - this would
|
||||
save a little more texture memory in some fonts.
|
||||
*/
|
||||
|
||||
if ( ! exists [ cc ] )
|
||||
return 0.0f ;
|
||||
|
||||
glBegin ( GL_TRIANGLE_STRIP ) ;
|
||||
glTexCoord2f ( t_left [cc], t_bot[cc] ) ;
|
||||
glVertex3f ( curpos[0] + v_left [cc] * pointsize,
|
||||
curpos[1] + v_bot [cc] * pointsize,
|
||||
curpos[2] ) ;
|
||||
|
||||
glTexCoord2f ( t_left [cc], t_top[cc] ) ;
|
||||
glVertex3f ( curpos[0] + (italic + v_left [cc]) * pointsize,
|
||||
curpos[1] + v_top [cc] * pointsize,
|
||||
curpos[2] ) ;
|
||||
|
||||
glTexCoord2f ( t_right[cc], t_bot[cc] ) ;
|
||||
glVertex3f ( curpos[0] + v_right[cc] * pointsize,
|
||||
curpos[1] + v_bot [cc] * pointsize,
|
||||
curpos[2] ) ;
|
||||
|
||||
glTexCoord2f ( t_right[cc], t_top[cc] ) ;
|
||||
glVertex3f ( curpos[0] + (italic + v_right[cc]) * pointsize,
|
||||
curpos[1] + v_top [cc] * pointsize,
|
||||
curpos[2] ) ;
|
||||
glEnd () ;
|
||||
|
||||
float ww = ( gap + ( fixed_pitch ? width : widths[cc] ) ) * pointsize ;
|
||||
curpos[0] += ww ;
|
||||
return ww ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fntTexFont::setGlyph ( char c, float wid,
|
||||
float tex_left, float tex_right,
|
||||
float tex_bot , float tex_top ,
|
||||
float vtx_left, float vtx_right,
|
||||
float vtx_bot , float vtx_top )
|
||||
{
|
||||
unsigned int cc = (unsigned char) c ;
|
||||
|
||||
exists[cc] = FNT_TRUE ;
|
||||
|
||||
widths[cc] = wid;
|
||||
|
||||
t_left[cc] = tex_left ; t_right[cc] = tex_right ;
|
||||
t_bot [cc] = tex_bot ; t_top [cc] = tex_top ;
|
||||
|
||||
v_left[cc] = vtx_left ; v_right[cc] = vtx_right ;
|
||||
v_bot [cc] = vtx_bot ; v_top [cc] = vtx_top ;
|
||||
}
|
||||
|
||||
|
||||
int fntTexFont::getGlyph ( char c, float* wid,
|
||||
float *tex_left, float *tex_right,
|
||||
float *tex_bot , float *tex_top ,
|
||||
float *vtx_left, float *vtx_right,
|
||||
float *vtx_bot , float *vtx_top )
|
||||
{
|
||||
unsigned int cc = (unsigned char) c ;
|
||||
|
||||
if ( ! exists[cc] ) return FNT_FALSE ;
|
||||
|
||||
if ( wid != NULL ) *wid = widths [cc] ;
|
||||
|
||||
if ( tex_left != NULL ) *tex_left = t_left [cc] ;
|
||||
if ( tex_right != NULL ) *tex_right = t_right[cc] ;
|
||||
if ( tex_bot != NULL ) *tex_bot = t_bot [cc] ;
|
||||
if ( tex_top != NULL ) *tex_top = t_top [cc] ;
|
||||
|
||||
if ( vtx_left != NULL ) *vtx_left = v_left [cc] ;
|
||||
if ( vtx_right != NULL ) *vtx_right = v_right[cc] ;
|
||||
if ( vtx_bot != NULL ) *vtx_bot = v_bot [cc] ;
|
||||
if ( vtx_top != NULL ) *vtx_top = v_top [cc] ;
|
||||
|
||||
return FNT_TRUE ;
|
||||
}
|
||||
|
||||
|
||||
void fntTexFont::getBBox ( const char *s,
|
||||
float pointsize, float italic,
|
||||
float *left, float *right,
|
||||
float *bot , float *top )
|
||||
{
|
||||
float h_pos = 0.0f ;
|
||||
float v_pos = 0.0f ;
|
||||
float l, r, b, t ;
|
||||
|
||||
l = r = b = t = 0.0f ;
|
||||
|
||||
while ( *s != '\0' )
|
||||
{
|
||||
if ( *s == '\n' )
|
||||
{
|
||||
h_pos = 0.0f ;
|
||||
v_pos -= 1.333f ;
|
||||
s++ ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
unsigned int cc = (unsigned char) *(s++) ;
|
||||
|
||||
if ( ! exists [ cc ] )
|
||||
{
|
||||
if ( cc >= 'A' && cc <= 'Z' )
|
||||
cc = cc - 'A' + 'a' ;
|
||||
else
|
||||
if ( cc >= 'a' && cc <= 'z' )
|
||||
cc = cc - 'a' + 'A' ;
|
||||
|
||||
if ( cc == ' ' )
|
||||
{
|
||||
r += 0.5f ;
|
||||
h_pos += 0.5f ;
|
||||
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! exists [ cc ] )
|
||||
continue ;
|
||||
|
||||
if ( italic >= 0 )
|
||||
{
|
||||
if ( l > h_pos + v_left [cc] ) l = h_pos + v_left [cc] ;
|
||||
if ( r < gap + h_pos + v_right[cc]+italic ) r = gap + h_pos + v_right[cc] + italic ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( l > h_pos + v_left [cc]+italic ) l = h_pos + v_left [cc] + italic ;
|
||||
if ( r < gap + h_pos + v_right[cc] ) r = gap + h_pos + v_right[cc] ;
|
||||
}
|
||||
|
||||
|
||||
if ( b > v_pos + v_bot [cc] ) b = v_pos + v_bot [cc] ;
|
||||
if ( t < v_pos + v_top [cc] ) t = v_pos + v_top [cc] ;
|
||||
|
||||
h_pos += gap + ( fixed_pitch ? width : widths[cc] ) ;
|
||||
}
|
||||
|
||||
if ( left != NULL ) *left = l * pointsize ;
|
||||
if ( right != NULL ) *right = r * pointsize ;
|
||||
if ( top != NULL ) *top = t * pointsize ;
|
||||
if ( bot != NULL ) *bot = b * pointsize ;
|
||||
}
|
||||
|
||||
|
||||
void fntTexFont::puts ( sgVec3 curpos, float pointsize, float italic, const char *s )
|
||||
{
|
||||
SGfloat origx = curpos[0] ;
|
||||
|
||||
if ( ! bound )
|
||||
bind_texture () ;
|
||||
|
||||
while ( *s != '\0' )
|
||||
{
|
||||
if (*s == '\n')
|
||||
{
|
||||
curpos[0] = origx ;
|
||||
curpos[1] -= pointsize * 1.333f ;
|
||||
}
|
||||
else
|
||||
low_putch ( curpos, pointsize, italic, *s ) ;
|
||||
|
||||
s++ ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="fnt" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=fnt - 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 "fnt.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 "fnt.mak" CFG="fnt - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "fnt - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "fnt - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "fnt"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "fnt - 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 Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\sg" /I "..\util" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=Copy Library to plib directory
|
||||
PostBuild_Cmds=copy release\*.lib ..\..\*.* copy fnt.h ..\..\fnt.h
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "fnt - 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 Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /Zi /Od /I "..\sg" /I "..\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug\fnt_d.lib"
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=Copy Library to plib directory
|
||||
PostBuild_Cmds=copy debug\*.lib ..\..\*.* copy fnt.h ..\..\fnt.h
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "fnt - Win32 Release"
|
||||
# Name "fnt - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\fnt.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\fnt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\fntLocal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\fntTXF.cxx
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,295 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FNT_H_
|
||||
#define _FNT_H_ 1
|
||||
|
||||
#include "sg.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenGL/gl.h>
|
||||
#else
|
||||
# include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define FNTMAX_CHAR 256
|
||||
#define FNT_TRUE 1
|
||||
#define FNT_FALSE 0
|
||||
|
||||
|
||||
class fntFont
|
||||
{
|
||||
public:
|
||||
fntFont () ;
|
||||
|
||||
virtual ~fntFont () ;
|
||||
|
||||
virtual void getBBox ( const char *s, float pointsize, float italic,
|
||||
float *left, float *right,
|
||||
float *bot , float *top ) = 0 ;
|
||||
virtual void putch ( sgVec3 curpos, float pointsize, float italic, char c ) = 0 ;
|
||||
virtual void puts ( sgVec3 curpos, float pointsize, float italic, const char *s ) = 0 ;
|
||||
virtual void begin () = 0 ;
|
||||
virtual void end () = 0 ;
|
||||
|
||||
virtual int load ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) = 0 ;
|
||||
|
||||
virtual void setFixedPitch ( int fix ) = 0 ;
|
||||
virtual int isFixedPitch () const = 0 ;
|
||||
|
||||
virtual void setWidth ( float w ) = 0 ;
|
||||
virtual void setGap ( float g ) = 0 ;
|
||||
|
||||
virtual float getWidth () const = 0 ;
|
||||
virtual float getGap () const = 0 ;
|
||||
|
||||
virtual int hasGlyph ( char c ) const = 0 ;
|
||||
} ;
|
||||
|
||||
|
||||
class fntTexFont : public fntFont
|
||||
{
|
||||
private:
|
||||
GLuint texture ;
|
||||
int bound ;
|
||||
int fixed_pitch ;
|
||||
|
||||
float width ; /* The width of a character in fixed-width mode */
|
||||
float gap ; /* Set the gap between characters */
|
||||
|
||||
int exists [ FNTMAX_CHAR ] ; /* TRUE if character exists in tex-map */
|
||||
|
||||
/*
|
||||
The quadrilaterals that describe the characters
|
||||
in the font are drawn with the following texture
|
||||
and spatial coordinates. The texture coordinates
|
||||
are in (S,T) space, with (0,0) at the bottom left
|
||||
of the image and (1,1) at the top-right.
|
||||
|
||||
The spatial coordinates are relative to the current
|
||||
'cursor' position. They should be scaled such that
|
||||
1.0 represent the height of a capital letter. Hence,
|
||||
characters like 'y' which have a descender will be
|
||||
given a negative v_bot. Most capitals will have
|
||||
v_bot==0.0 and v_top==1.0.
|
||||
*/
|
||||
|
||||
/* Nominal baseline widths */
|
||||
|
||||
float widths [ FNTMAX_CHAR ] ;
|
||||
|
||||
/* Texture coordinates */
|
||||
|
||||
float t_top [ FNTMAX_CHAR ] ; /* Top edge of each character [0..1] */
|
||||
float t_bot [ FNTMAX_CHAR ] ; /* Bottom edge of each character [0..1] */
|
||||
float t_left [ FNTMAX_CHAR ] ; /* Left edge of each character [0..1] */
|
||||
float t_right [ FNTMAX_CHAR ] ; /* Right edge of each character [0..1] */
|
||||
|
||||
/* Vertex coordinates. */
|
||||
|
||||
float v_top [ FNTMAX_CHAR ] ;
|
||||
float v_bot [ FNTMAX_CHAR ] ;
|
||||
float v_left [ FNTMAX_CHAR ] ;
|
||||
float v_right [ FNTMAX_CHAR ] ;
|
||||
|
||||
void bind_texture ()
|
||||
{
|
||||
glEnable ( GL_TEXTURE_2D ) ;
|
||||
#ifdef GL_VERSION_1_1
|
||||
glBindTexture ( GL_TEXTURE_2D, texture ) ;
|
||||
#else
|
||||
/* For ancient SGI machines */
|
||||
glBindTextureEXT ( GL_TEXTURE_2D, texture ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
float low_putch ( sgVec3 curpos, float pointsize, float italic, char c ) ;
|
||||
|
||||
int loadTXF ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) ;
|
||||
public:
|
||||
|
||||
fntTexFont ()
|
||||
{
|
||||
bound = FNT_FALSE ;
|
||||
fixed_pitch = FNT_TRUE ;
|
||||
texture = 0 ;
|
||||
width = 1.0f ;
|
||||
gap = 0.1f ;
|
||||
|
||||
memset ( exists, FNT_FALSE, FNTMAX_CHAR * sizeof(int) ) ;
|
||||
}
|
||||
|
||||
fntTexFont ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) : fntFont ()
|
||||
{
|
||||
bound = FNT_FALSE ;
|
||||
fixed_pitch = FNT_TRUE ;
|
||||
texture = 0 ;
|
||||
width = 1.0f ;
|
||||
gap = 0.1f ;
|
||||
|
||||
memset ( exists, FNT_FALSE, FNTMAX_CHAR * sizeof(int) ) ;
|
||||
load ( fname, mag, min ) ;
|
||||
}
|
||||
|
||||
~fntTexFont ()
|
||||
{
|
||||
if ( texture != 0 )
|
||||
{
|
||||
#ifdef GL_VERSION_1_1
|
||||
glDeleteTextures ( 1, &texture ) ;
|
||||
#else
|
||||
/* For ancient SGI machines */
|
||||
glDeleteTexturesEXT ( 1, &texture ) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int load ( const char *fname, GLenum mag = GL_NEAREST,
|
||||
GLenum min = GL_LINEAR_MIPMAP_LINEAR ) ;
|
||||
|
||||
void setFixedPitch ( int fix ) { fixed_pitch = fix ; }
|
||||
int isFixedPitch () const { return fixed_pitch ; }
|
||||
|
||||
void setWidth ( float w ) { width = w ; }
|
||||
void setGap ( float g ) { gap = g ; }
|
||||
|
||||
float getWidth () const { return width ; }
|
||||
float getGap () const { return gap ; }
|
||||
|
||||
|
||||
void setGlyph ( char c, float wid,
|
||||
float tex_left, float tex_right,
|
||||
float tex_bot , float tex_top ,
|
||||
float vtx_left, float vtx_right,
|
||||
float vtx_bot , float vtx_top ) ;
|
||||
void setGlyph ( char c,
|
||||
float tex_left, float tex_right,
|
||||
float tex_bot , float tex_top ,
|
||||
float vtx_left, float vtx_right,
|
||||
float vtx_bot , float vtx_top ) /* deprecated */
|
||||
{
|
||||
setGlyph ( c, vtx_right,
|
||||
tex_left, tex_right, tex_bot, tex_top,
|
||||
vtx_left, vtx_right, vtx_bot, vtx_top ) ;
|
||||
}
|
||||
|
||||
int getGlyph ( char c, float* wid,
|
||||
float *tex_left = NULL, float *tex_right = NULL,
|
||||
float *tex_bot = NULL, float *tex_top = NULL,
|
||||
float *vtx_left = NULL, float *vtx_right = NULL,
|
||||
float *vtx_bot = NULL, float *vtx_top = NULL) ;
|
||||
int getGlyph ( char c,
|
||||
float *tex_left = NULL, float *tex_right = NULL,
|
||||
float *tex_bot = NULL, float *tex_top = NULL,
|
||||
float *vtx_left = NULL, float *vtx_right = NULL,
|
||||
float *vtx_bot = NULL, float *vtx_top = NULL) /* deprecated */
|
||||
{
|
||||
return getGlyph ( c, NULL,
|
||||
tex_left, tex_right, tex_bot, tex_top,
|
||||
vtx_left, vtx_right, vtx_bot, vtx_top ) ;
|
||||
}
|
||||
|
||||
int hasGlyph ( char c ) const { return exists[ c ] ; }
|
||||
|
||||
void getBBox ( const char *s, float pointsize, float italic,
|
||||
float *left, float *right,
|
||||
float *bot , float *top ) ;
|
||||
|
||||
void begin ()
|
||||
{
|
||||
bind_texture () ;
|
||||
bound = FNT_TRUE ;
|
||||
}
|
||||
|
||||
void end ()
|
||||
{
|
||||
bound = FNT_FALSE ;
|
||||
}
|
||||
|
||||
void puts ( sgVec3 curpos, float pointsize, float italic, const char *s ) ;
|
||||
|
||||
void putch ( sgVec3 curpos, float pointsize, float italic, char c )
|
||||
{
|
||||
if ( ! bound )
|
||||
bind_texture () ;
|
||||
|
||||
low_putch ( curpos, pointsize, italic, c ) ;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
class fntRenderer
|
||||
{
|
||||
fntFont *font ;
|
||||
|
||||
sgVec3 curpos ;
|
||||
|
||||
float pointsize ;
|
||||
float italic ;
|
||||
|
||||
public:
|
||||
fntRenderer ()
|
||||
{
|
||||
start2f ( 0.0f, 0.0f ) ;
|
||||
font = NULL ;
|
||||
pointsize = 10 ;
|
||||
italic = 0 ;
|
||||
}
|
||||
|
||||
void start3fv ( sgVec3 pos ) { sgCopyVec3 ( curpos, pos ) ; }
|
||||
void start2fv ( sgVec2 pos ) { sgCopyVec2 ( curpos, pos ) ; curpos[2]=0.0f ; }
|
||||
void start2f ( float x, float y ) { sgSetVec3 ( curpos, x, y, 0.0f ) ; }
|
||||
void start3f ( float x, float y, float z ) { sgSetVec3 ( curpos, x, y, z ) ; }
|
||||
|
||||
void getCursor ( float *x, float *y, float *z ) const
|
||||
{
|
||||
if ( x != NULL ) *x = curpos [ 0 ] ;
|
||||
if ( y != NULL ) *y = curpos [ 1 ] ;
|
||||
if ( z != NULL ) *z = curpos [ 2 ] ;
|
||||
}
|
||||
|
||||
void setFont ( fntFont *f ) { font = f ; }
|
||||
fntFont *getFont () const { return font ; }
|
||||
|
||||
void setSlant ( float i ) { italic = i ; }
|
||||
void setPointSize ( float p ) { pointsize = p ; }
|
||||
|
||||
float getSlant () const { return italic ; }
|
||||
float getPointSize () const { return pointsize ; }
|
||||
|
||||
void begin () { font->begin () ; }
|
||||
void end () { font->end () ; }
|
||||
|
||||
void putch ( char c ) { font->putch ( curpos, pointsize, italic, c ) ; }
|
||||
void puts ( const char *s ) { font->puts ( curpos, pointsize, italic, s ) ; }
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="fnt"
|
||||
SccProjectName="fnt"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\sg,..\util"
|
||||
PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Release/fnt.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Release\fnt.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Copy Library to plib directory"
|
||||
CommandLine="copy release\*.lib ..\..\*.*
|
||||
copy fnt.h ..\..\fnt.h
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\sg,..\util"
|
||||
PreprocessorDefinitions="WIN32,_DEBUG,_LIB"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="2"
|
||||
PrecompiledHeaderFile=".\Debug/fnt.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="Debug\fnt_d.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Copy Library to plib directory"
|
||||
CommandLine="copy debug\*.lib ..\..\*.*
|
||||
copy fnt.h ..\..\fnt.h
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\fnt.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fnt.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fntLocal.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\fntTXF.cxx">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "fnt.h"
|
||||
|
||||
|
||||
extern int isSwapped ;
|
||||
extern FILE *curr_image_fd ;
|
||||
|
||||
|
||||
inline void _fnt_swab_short ( unsigned short *x )
|
||||
{
|
||||
if ( isSwapped )
|
||||
*x = (( *x >> 8 ) & 0x00FF ) |
|
||||
(( *x << 8 ) & 0xFF00 ) ;
|
||||
}
|
||||
|
||||
|
||||
inline void _fnt_swab_int ( unsigned int *x )
|
||||
{
|
||||
if ( isSwapped )
|
||||
*x = (( *x >> 24 ) & 0x000000FF ) |
|
||||
(( *x >> 8 ) & 0x0000FF00 ) |
|
||||
(( *x << 8 ) & 0x00FF0000 ) |
|
||||
(( *x << 24 ) & 0xFF000000 ) ;
|
||||
}
|
||||
|
||||
|
||||
inline void _fnt_swab_int_array ( int *x, int leng )
|
||||
{
|
||||
if ( ! isSwapped )
|
||||
return ;
|
||||
|
||||
for ( int i = 0 ; i < leng ; i++ )
|
||||
{
|
||||
*x = (( *x >> 24 ) & 0x000000FF ) |
|
||||
(( *x >> 8 ) & 0x0000FF00 ) |
|
||||
(( *x << 8 ) & 0x00FF0000 ) |
|
||||
(( *x << 24 ) & 0xFF000000 ) ;
|
||||
x++ ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline unsigned char _fnt_readByte ()
|
||||
{
|
||||
unsigned char x ;
|
||||
fread ( & x, sizeof(unsigned char), 1, curr_image_fd ) ;
|
||||
return x ;
|
||||
}
|
||||
|
||||
inline unsigned short _fnt_readShort ()
|
||||
{
|
||||
unsigned short x ;
|
||||
fread ( & x, sizeof(unsigned short), 1, curr_image_fd ) ;
|
||||
_fnt_swab_short ( & x ) ;
|
||||
return x ;
|
||||
}
|
||||
|
||||
inline unsigned int _fnt_readInt ()
|
||||
{
|
||||
unsigned int x ;
|
||||
fread ( & x, sizeof(unsigned int), 1, curr_image_fd ) ;
|
||||
_fnt_swab_int ( & x ) ;
|
||||
return x ;
|
||||
}
|
||||
|
||||
|
||||
#define FNT_BYTE_FORMAT 0
|
||||
#define FNT_BITMAP_FORMAT 1
|
||||
|
||||
struct TXF_Glyph
|
||||
{
|
||||
unsigned short ch ;
|
||||
unsigned char w ;
|
||||
unsigned char h ;
|
||||
signed char x_off ;
|
||||
signed char y_off ;
|
||||
signed char step ;
|
||||
signed char unknown ;
|
||||
short x ;
|
||||
short y ;
|
||||
|
||||
sgVec2 tx0 ; sgVec2 vx0 ;
|
||||
sgVec2 tx1 ; sgVec2 vx1 ;
|
||||
sgVec2 tx2 ; sgVec2 vx2 ;
|
||||
sgVec2 tx3 ; sgVec2 vx3 ;
|
||||
} ;
|
||||
|
||||
|
||||
@@ -1,363 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "fntLocal.h"
|
||||
|
||||
#ifndef WIN32
|
||||
# if defined(macintosh)
|
||||
# include <agl.h>
|
||||
# elif defined(__APPLE__)
|
||||
# include <OpenGL/CGLCurrent.h>
|
||||
# else
|
||||
# include <GL/glx.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static bool glIsValidContext ( void )
|
||||
{
|
||||
#if defined(CONSOLE)
|
||||
return true ;
|
||||
#elif defined(WIN32)
|
||||
return ( wglGetCurrentContext () != NULL ) ;
|
||||
#elif defined(macintosh)
|
||||
return ( aglGetCurrentContext () != NULL ) ;
|
||||
#elif defined(__APPLE__)
|
||||
return ( CGLGetCurrentContext () != NULL ) ;
|
||||
#else
|
||||
return ( glXGetCurrentContext () != NULL ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
FILE *curr_image_fd ;
|
||||
int isSwapped = FALSE ;
|
||||
|
||||
static void tex_make_mip_maps ( GLubyte *image, int xsize,
|
||||
int ysize, int zsize )
|
||||
{
|
||||
GLubyte *texels [ 20 ] ; /* One element per level of MIPmap */
|
||||
|
||||
for ( int l = 0 ; l < 20 ; l++ )
|
||||
texels [ l ] = NULL ;
|
||||
|
||||
texels [ 0 ] = image ;
|
||||
|
||||
int lev ;
|
||||
|
||||
for ( lev = 0 ; (( xsize >> (lev+1) ) != 0 ||
|
||||
( ysize >> (lev+1) ) != 0 ) ; lev++ )
|
||||
{
|
||||
/* Suffix '1' is the higher level map, suffix '2' is the lower level. */
|
||||
|
||||
int l1 = lev ;
|
||||
int l2 = lev+1 ;
|
||||
int w1 = xsize >> l1 ;
|
||||
int h1 = ysize >> l1 ;
|
||||
int w2 = xsize >> l2 ;
|
||||
int h2 = ysize >> l2 ;
|
||||
|
||||
if ( w1 <= 0 ) w1 = 1 ;
|
||||
if ( h1 <= 0 ) h1 = 1 ;
|
||||
if ( w2 <= 0 ) w2 = 1 ;
|
||||
if ( h2 <= 0 ) h2 = 1 ;
|
||||
|
||||
texels [ l2 ] = new GLubyte [ w2 * h2 * zsize ] ;
|
||||
|
||||
for ( int x2 = 0 ; x2 < w2 ; x2++ )
|
||||
for ( int y2 = 0 ; y2 < h2 ; y2++ )
|
||||
for ( int c = 0 ; c < zsize ; c++ )
|
||||
{
|
||||
int x1 = x2 + x2 ;
|
||||
int x1_1 = ( x1 + 1 ) % w1 ;
|
||||
int y1 = y2 + y2 ;
|
||||
int y1_1 = ( y1 + 1 ) % h1 ;
|
||||
|
||||
int t1 = texels [ l1 ] [ (y1 * w1 + x1 ) * zsize + c ] ;
|
||||
int t2 = texels [ l1 ] [ (y1_1 * w1 + x1 ) * zsize + c ] ;
|
||||
int t3 = texels [ l1 ] [ (y1 * w1 + x1_1) * zsize + c ] ;
|
||||
int t4 = texels [ l1 ] [ (y1_1 * w1 + x1_1) * zsize + c ] ;
|
||||
|
||||
texels [ l2 ] [ (y2 * w2 + x2) * zsize + c ] =
|
||||
( t1 + t2 + t3 + t4 ) / 4 ;
|
||||
}
|
||||
}
|
||||
|
||||
texels [ lev+1 ] = NULL ;
|
||||
|
||||
if ( ! ((xsize & (xsize-1))==0) ||
|
||||
! ((ysize & (ysize-1))==0) )
|
||||
{
|
||||
ulSetError ( UL_FATAL,
|
||||
"TXFloader: TXF Map is not a power-of-two in size!" ) ;
|
||||
}
|
||||
|
||||
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 ) ;
|
||||
|
||||
int map_level = 0 ;
|
||||
|
||||
#ifdef PROXY_TEXTURES_ARE_NOT_BROKEN
|
||||
int ww ;
|
||||
|
||||
do
|
||||
{
|
||||
glTexImage2D ( GL_PROXY_TEXTURE_2D,
|
||||
map_level, zsize, xsize, ysize, FALSE /* Border */,
|
||||
(zsize==1)?GL_LUMINANCE:
|
||||
(zsize==2)?GL_LUMINANCE_ALPHA:
|
||||
(zsize==3)?GL_RGB:
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, NULL ) ;
|
||||
|
||||
glGetTexLevelParameteriv ( GL_PROXY_TEXTURE_2D, 0,GL_TEXTURE_WIDTH, &ww ) ;
|
||||
|
||||
if ( ww == 0 )
|
||||
{
|
||||
delete [] texels [ 0 ] ;
|
||||
xsize >>= 1 ;
|
||||
ysize >>= 1 ;
|
||||
|
||||
for ( int l = 0 ; texels [ l ] != NULL ; l++ )
|
||||
texels [ l ] = texels [ l+1 ] ;
|
||||
|
||||
if ( xsize < 64 && ysize < 64 )
|
||||
{
|
||||
ulSetError ( UL_FATAL,
|
||||
"FNT: OpenGL will not accept a font texture?!?" ) ;
|
||||
}
|
||||
}
|
||||
} while ( ww == 0 ) ;
|
||||
#endif
|
||||
|
||||
for ( int i = 0 ; texels [ i ] != NULL ; i++ )
|
||||
{
|
||||
int w = xsize>>i ;
|
||||
int h = ysize>>i ;
|
||||
|
||||
if ( w <= 0 ) w = 1 ;
|
||||
if ( h <= 0 ) h = 1 ;
|
||||
|
||||
glTexImage2D ( GL_TEXTURE_2D,
|
||||
map_level, zsize, w, h, FALSE /* Border */,
|
||||
(zsize==1)?GL_LUMINANCE:
|
||||
(zsize==2)?GL_LUMINANCE_ALPHA:
|
||||
(zsize==3)?GL_RGB:
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, (GLvoid *) texels[i] ) ;
|
||||
map_level++ ;
|
||||
delete [] texels [ i ] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int fntTexFont::loadTXF ( const char *fname, GLenum mag, GLenum min )
|
||||
{
|
||||
if ( ! glIsValidContext () )
|
||||
{
|
||||
ulSetError ( UL_FATAL,
|
||||
"FNT font loader called without a valid OpenGL context.");
|
||||
}
|
||||
|
||||
FILE *fd ;
|
||||
|
||||
if ( (fd = fopen ( fname, "rb" )) == NULL )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"fntLoadTXF: Failed to open '%s' for reading.", fname ) ;
|
||||
return FNT_FALSE ;
|
||||
}
|
||||
|
||||
curr_image_fd = fd ;
|
||||
|
||||
unsigned char magic [ 4 ] ;
|
||||
|
||||
if ( (int)fread ( &magic, sizeof (unsigned int), 1, fd ) != 1 )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"fntLoadTXF: '%s' an empty file!", fname ) ;
|
||||
return FNT_FALSE ;
|
||||
}
|
||||
|
||||
if ( magic [ 0 ] != 0xFF || magic [ 1 ] != 't' ||
|
||||
magic [ 2 ] != 'x' || magic [ 3 ] != 'f' )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"fntLoadTXF: '%s' is not a 'txf' font file.", fname ) ;
|
||||
return FNT_FALSE ;
|
||||
}
|
||||
|
||||
isSwapped = FALSE ;
|
||||
int endianness = _fnt_readInt () ;
|
||||
|
||||
isSwapped = ( endianness != 0x12345678 ) ;
|
||||
|
||||
int format = _fnt_readInt () ;
|
||||
int tex_width = _fnt_readInt () ;
|
||||
int tex_height = _fnt_readInt () ;
|
||||
int max_height = _fnt_readInt () ;
|
||||
_fnt_readInt () ;
|
||||
int num_glyphs = _fnt_readInt () ;
|
||||
|
||||
int w = tex_width ;
|
||||
int h = tex_height ;
|
||||
|
||||
float xstep = 0.5f / (float) w ;
|
||||
float ystep = 0.5f / (float) h ;
|
||||
|
||||
int i, j ;
|
||||
|
||||
/*
|
||||
Load the TXF_Glyph array
|
||||
*/
|
||||
|
||||
TXF_Glyph glyph ;
|
||||
|
||||
for ( i = 0 ; i < num_glyphs ; i++ )
|
||||
{
|
||||
glyph . ch = _fnt_readShort () ;
|
||||
|
||||
glyph . w = _fnt_readByte () ;
|
||||
glyph . h = _fnt_readByte () ;
|
||||
glyph . x_off = _fnt_readByte () ;
|
||||
glyph . y_off = _fnt_readByte () ;
|
||||
glyph . step = _fnt_readByte () ;
|
||||
glyph . unknown = _fnt_readByte () ;
|
||||
glyph . x = _fnt_readShort () ;
|
||||
glyph . y = _fnt_readShort () ;
|
||||
|
||||
setGlyph ( (char) glyph.ch,
|
||||
(float) glyph.step / (float) max_height,
|
||||
(float) glyph.x / (float) w + xstep,
|
||||
(float)( glyph.x + glyph.w ) / (float) w + xstep,
|
||||
(float) glyph.y / (float) h + ystep,
|
||||
(float)( glyph.y + glyph.h ) / (float) h + ystep,
|
||||
(float) glyph.x_off / (float) max_height,
|
||||
(float)( glyph.x_off + glyph.w ) / (float) max_height,
|
||||
(float) glyph.y_off / (float) max_height,
|
||||
(float)( glyph.y_off + glyph.h ) / (float) max_height ) ;
|
||||
}
|
||||
|
||||
exists [ ' ' ] = FALSE ;
|
||||
|
||||
/*
|
||||
Load the image part of the file
|
||||
*/
|
||||
|
||||
int ntexels = w * h ;
|
||||
|
||||
unsigned char *teximage ;
|
||||
unsigned char *texbitmap ;
|
||||
|
||||
switch ( format )
|
||||
{
|
||||
case FNT_BYTE_FORMAT:
|
||||
{
|
||||
unsigned char *orig = new unsigned char [ ntexels ] ;
|
||||
|
||||
if ( (int)fread ( orig, 1, ntexels, fd ) != ntexels )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"fntLoadTXF: Premature EOF in '%s'.", fname ) ;
|
||||
return FNT_FALSE ;
|
||||
}
|
||||
|
||||
teximage = new unsigned char [ 2 * ntexels ] ;
|
||||
|
||||
for ( i = 0 ; i < ntexels ; i++ )
|
||||
{
|
||||
teximage [ i*2 ] = orig [ i ] ;
|
||||
teximage [ i*2 + 1 ] = orig [ i ] ;
|
||||
}
|
||||
|
||||
delete [] orig ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case FNT_BITMAP_FORMAT:
|
||||
{
|
||||
int stride = (w + 7) >> 3;
|
||||
|
||||
texbitmap = new unsigned char [ stride * h ] ;
|
||||
|
||||
if ( (int)fread ( texbitmap, 1, stride * h, fd ) != stride * h )
|
||||
{
|
||||
delete [] texbitmap ;
|
||||
ulSetError ( UL_WARNING,
|
||||
"fntLoadTXF: Premature EOF in '%s'.", fname ) ;
|
||||
return FNT_FALSE ;
|
||||
}
|
||||
|
||||
teximage = new unsigned char [ 2 * ntexels ] ;
|
||||
|
||||
for ( i = 0 ; i < 2 * ntexels ; i++ )
|
||||
teximage [ i ] = 0 ;
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
for (j = 0; j < w; j++)
|
||||
if (texbitmap[i * stride + (j >> 3)] & (1 << (j & 7)))
|
||||
{
|
||||
teximage[(i * w + j) * 2 ] = 255;
|
||||
teximage[(i * w + j) * 2 + 1] = 255;
|
||||
}
|
||||
|
||||
delete [] texbitmap ;
|
||||
}
|
||||
break ;
|
||||
|
||||
default:
|
||||
ulSetError ( UL_WARNING,
|
||||
"fntLoadTXF: Unrecognised format type in '%s'.", fname ) ;
|
||||
return FNT_FALSE ;
|
||||
}
|
||||
|
||||
fclose ( fd ) ;
|
||||
|
||||
fixed_pitch = FALSE ;
|
||||
|
||||
#ifdef GL_VERSION_1_1
|
||||
glGenTextures ( 1, & texture ) ;
|
||||
glBindTexture ( GL_TEXTURE_2D, texture ) ;
|
||||
#else
|
||||
/* This is only useful on some ancient SGI hardware */
|
||||
glGenTexturesEXT ( 1, & texture ) ;
|
||||
glBindTextureEXT ( GL_TEXTURE_2D, texture ) ;
|
||||
#endif
|
||||
|
||||
tex_make_mip_maps ( teximage, w, h, 2 ) ;
|
||||
|
||||
glTexEnvi ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
|
||||
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag ) ;
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min ) ;
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ) ;
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ) ;
|
||||
#ifdef GL_VERSION_1_1
|
||||
glBindTexture ( GL_TEXTURE_2D, 0 ) ;
|
||||
#else
|
||||
glBindTextureEXT ( GL_TEXTURE_2D, 0 ) ;
|
||||
#endif
|
||||
|
||||
return FNT_TRUE ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
if BUILD_JS
|
||||
|
||||
lib_LIBRARIES = libplibjs.a
|
||||
|
||||
include_HEADERS = js.h
|
||||
|
||||
libplibjs_a_SOURCES = js.cxx
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/util
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = js.dsp
|
||||
|
||||
|
||||
@@ -1,316 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
|
||||
@BUILD_JS_TRUE@lib_LIBRARIES = libplibjs.a
|
||||
|
||||
@BUILD_JS_TRUE@include_HEADERS = js.h
|
||||
|
||||
@BUILD_JS_TRUE@libplibjs_a_SOURCES = js.cxx
|
||||
|
||||
@BUILD_JS_TRUE@INCLUDES = -I$(top_srcdir)/src/util
|
||||
|
||||
EXTRA_DIST = js.dsp
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(lib_LIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
libplibjs_a_LIBADD =
|
||||
@BUILD_JS_TRUE@libplibjs_a_OBJECTS = js.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
HEADERS = $(include_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(libplibjs_a_SOURCES)
|
||||
OBJECTS = $(libplibjs_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .cxx .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/js/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-libLIBRARIES:
|
||||
|
||||
clean-libLIBRARIES:
|
||||
-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
|
||||
|
||||
distclean-libLIBRARIES:
|
||||
|
||||
maintainer-clean-libLIBRARIES:
|
||||
|
||||
install-libLIBRARIES: $(lib_LIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
@$(POST_INSTALL)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||
done
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
libplibjs.a: $(libplibjs_a_OBJECTS) $(libplibjs_a_DEPENDENCIES)
|
||||
-rm -f libplibjs.a
|
||||
$(AR) cru libplibjs.a $(libplibjs_a_OBJECTS) $(libplibjs_a_LIBADD)
|
||||
$(RANLIB) libplibjs.a
|
||||
.cxx.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
install-includeHEADERS: $(include_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(includedir)
|
||||
@list='$(include_HEADERS)'; for p in $$list; do \
|
||||
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
|
||||
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
|
||||
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
uninstall-includeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(include_HEADERS)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = src/js
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
js.o: js.cxx js.h ../../src/util/ul.h
|
||||
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am: install-libLIBRARIES
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am: install-includeHEADERS
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am: uninstall-libLIBRARIES uninstall-includeHEADERS
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES) $(HEADERS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-libLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-libLIBRARIES clean-compile clean-tags clean-generic \
|
||||
mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-libLIBRARIES distclean-compile distclean-tags \
|
||||
distclean-generic clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-libLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-libLIBRARIES distclean-libLIBRARIES \
|
||||
clean-libLIBRARIES maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
|
||||
install-libLIBRARIES mostlyclean-compile distclean-compile \
|
||||
clean-compile maintainer-clean-compile uninstall-includeHEADERS \
|
||||
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
|
||||
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
*/
|
||||
|
||||
#include "js.h"
|
||||
|
||||
void jsInit () {}
|
||||
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="js" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=js - 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 "js.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 "js.mak" CFG="js - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "js - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "js - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "js"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "js - 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 Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\util" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=Copy Library to plib directory
|
||||
PostBuild_Cmds=copy release\*.lib ..\..\*.* copy js.h ..\..\js.h
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "js - 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 Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /Zi /Od /I "..\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug\js_d.lib"
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=Copy Library to plib directory
|
||||
PostBuild_Cmds=copy debug\*.lib ..\..\*.* copy js.h ..\..\js.h
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "js - Win32 Release"
|
||||
# Name "js - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\js.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\js.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,749 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef __INCLUDED_JS_H__
|
||||
#define __INCLUDED_JS_H__ 1
|
||||
|
||||
#include "ul.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> // -dw- for memcpy
|
||||
|
||||
#ifdef macintosh
|
||||
# include <InputSprocket.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
FreeBSD port - courtesy of Stephen Montgomery-Smith
|
||||
<stephen@math.missouri.edu>
|
||||
|
||||
NetBSD mods - courtesy Rene Hexel.
|
||||
|
||||
The next lines are to define BSD
|
||||
see http://www.freebsd.org/handbook/porting.html for why we do this
|
||||
*/
|
||||
//lint -save -e620
|
||||
|
||||
#if (defined(__unix__) || defined(unix)) && !defined(USG)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
# if defined( __CYGWIN32__ ) || defined( __CYGWIN__ )
|
||||
# define NEAR /* */
|
||||
# define FAR /* */
|
||||
# endif
|
||||
# include <mmsystem.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
# include <machine/joystick.h>
|
||||
# define JS_DATA_TYPE joystick
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# elif defined(__linux__)
|
||||
# include <sys/ioctl.h>
|
||||
# include <linux/joystick.h>
|
||||
# include <errno.h>
|
||||
|
||||
/* check the joystick driver version */
|
||||
|
||||
# ifdef JS_VERSION
|
||||
# if JS_VERSION >= 0x010000
|
||||
# define JS_NEW
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# else
|
||||
# ifndef JS_DATA_TYPE
|
||||
|
||||
/*
|
||||
Not Windoze and no joystick driver...
|
||||
|
||||
Well - we'll put these values in and that should
|
||||
allow the code to at least compile. The JS open
|
||||
routine should error out and shut off all the code
|
||||
downstream anyway
|
||||
*/
|
||||
|
||||
struct JS_DATA_TYPE
|
||||
{
|
||||
int buttons ;
|
||||
int x ;
|
||||
int y ;
|
||||
} ;
|
||||
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define JS_TRUE 1
|
||||
#define JS_FALSE 0
|
||||
|
||||
#ifdef WIN32
|
||||
# define _JS_MAX_AXES 8 /* X,Y,Z,R,U,V,POV_X,POV_Y */
|
||||
#elif defined (macintosh)
|
||||
# define _JS_MAX_AXES 9
|
||||
#else
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
# define _JS_MAX_AXES 2
|
||||
# else
|
||||
# define _JS_MAX_AXES 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
class jsJoystick
|
||||
{
|
||||
#ifdef macintosh
|
||||
|
||||
#define isp_num_axis 9
|
||||
#define isp_num_needs 41
|
||||
|
||||
ISpElementReference isp_elem[isp_num_needs];
|
||||
ISpNeed isp_needs [isp_num_needs];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
int id ;
|
||||
#endif*/
|
||||
#ifdef WIN32
|
||||
JOYINFOEX js ;
|
||||
UINT js_id ;
|
||||
#else
|
||||
# ifdef JS_NEW
|
||||
js_event js ;
|
||||
int tmp_buttons ;
|
||||
float tmp_axes [ _JS_MAX_AXES ] ;
|
||||
# else
|
||||
JS_DATA_TYPE js ;
|
||||
# endif
|
||||
char fname [ 128 ] ;
|
||||
int fd ;
|
||||
#endif
|
||||
|
||||
int error ;
|
||||
char name [ 128 ] ;
|
||||
int num_axes ;
|
||||
int num_buttons ;
|
||||
|
||||
float dead_band [ _JS_MAX_AXES ] ;
|
||||
float saturate [ _JS_MAX_AXES ] ;
|
||||
float center [ _JS_MAX_AXES ] ;
|
||||
float max [ _JS_MAX_AXES ] ;
|
||||
float min [ _JS_MAX_AXES ] ;
|
||||
|
||||
void open ()
|
||||
{
|
||||
name [0] = '\0' ;
|
||||
|
||||
#ifdef macintosh
|
||||
|
||||
/*
|
||||
FIXME: get joystick name in Mac
|
||||
*/
|
||||
|
||||
OSStatus err;
|
||||
|
||||
err = ISpStartup ();
|
||||
|
||||
if ( err == noErr ) {
|
||||
|
||||
#define ISP_CHECK_ERR(x) if (x != noErr) { setError(); return; }
|
||||
|
||||
setError ();
|
||||
|
||||
// initialize the needs structure
|
||||
ISpNeed temp_isp_needs[isp_num_needs] =
|
||||
{
|
||||
{"\pX-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pY-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pZ-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pR-Axis", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 4", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 5", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 6", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 7", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
{"\pAxis 8", 128, 0, 0, kISpElementKind_Axis, kISpElementLabel_None, 0, 0, 0, 0 },
|
||||
|
||||
{"\pButton 0", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 1", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 2", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 3", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 4", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 5", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 6", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 7", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 8", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 9", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 10", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 11", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 12", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 13", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 14", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 15", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 16", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 17", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 18", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 19", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 20", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 21", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 22", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 23", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 24", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 25", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 26", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 27", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 28", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 29", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 30", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
{"\pButton 31", 128, 0, 0, kISpElementKind_Button, kISpElementLabel_Btn_Select, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
memcpy (isp_needs, temp_isp_needs, sizeof (temp_isp_needs) );
|
||||
|
||||
|
||||
// next two calls allow keyboard and mouse to emulate other input devices (gamepads, joysticks, etc)
|
||||
|
||||
/*
|
||||
err = ISpDevices_ActivateClass (kISpDeviceClass_Keyboard);
|
||||
ISP_CHECK_ERR(err)
|
||||
|
||||
|
||||
err = ISpDevices_ActivateClass (kISpDeviceClass_Mouse);
|
||||
ISP_CHECK_ERR(err)
|
||||
*/
|
||||
|
||||
err = ISpElement_NewVirtualFromNeeds (isp_num_needs, isp_needs, isp_elem, 0);
|
||||
ISP_CHECK_ERR(err)
|
||||
|
||||
err = ISpInit (isp_num_needs, isp_needs, isp_elem, 'PLIB', nil, 0, 128, 0);
|
||||
ISP_CHECK_ERR(err)
|
||||
|
||||
num_buttons = isp_num_needs - isp_num_axis;
|
||||
num_axes = isp_num_axis;
|
||||
|
||||
for ( int i = 0; i < num_axes; i++ ) {
|
||||
|
||||
dead_band[i] = 0;
|
||||
saturate [i] = 1;
|
||||
center[i] = kISpAxisMiddle;
|
||||
max [i] = kISpAxisMaximum;
|
||||
min [i] = kISpAxisMinimum;
|
||||
}
|
||||
|
||||
error = false;
|
||||
}
|
||||
else {
|
||||
setError ();
|
||||
num_buttons = num_axes = 0;
|
||||
}
|
||||
|
||||
#elif defined( WIN32 )
|
||||
|
||||
JOYCAPS jsCaps ;
|
||||
|
||||
js . dwFlags = JOY_RETURNALL ;
|
||||
js . dwSize = sizeof ( js ) ;
|
||||
|
||||
memset ( &jsCaps, 0, sizeof(jsCaps) ) ;
|
||||
|
||||
error = ( joyGetDevCaps( js_id, &jsCaps, sizeof(jsCaps) )
|
||||
!= JOYERR_NOERROR ) ;
|
||||
if ( jsCaps.wNumAxes == 0 )
|
||||
{
|
||||
num_axes = 0 ;
|
||||
setError () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy ( name, jsCaps.szPname, sizeof(name) ) ;
|
||||
|
||||
// Windows joystick drivers may provide any combination of
|
||||
// X,Y,Z,R,U,V,POV - not necessarily the first n of these.
|
||||
if ( jsCaps.wCaps & JOYCAPS_HASPOV ) {
|
||||
num_axes = _JS_MAX_AXES ;
|
||||
min[7] = -1.0 ; max[7] = 1.0 ; // POV Y
|
||||
min[6] = -1.0 ; max[6] = 1.0 ; // POV X
|
||||
} else {
|
||||
num_axes = 6 ;
|
||||
}
|
||||
min[5] = (float)jsCaps.wVmin ; max[5] = (float)jsCaps.wVmax ;
|
||||
min[4] = (float)jsCaps.wUmin ; max[4] = (float)jsCaps.wUmax ;
|
||||
min[3] = (float)jsCaps.wRmin ; max[3] = (float)jsCaps.wRmax ;
|
||||
min[2] = (float)jsCaps.wZmin ; max[2] = (float)jsCaps.wZmax ;
|
||||
min[1] = (float)jsCaps.wYmin ; max[1] = (float)jsCaps.wYmax ;
|
||||
min[0] = (float)jsCaps.wXmin ; max[0] = (float)jsCaps.wXmax ;
|
||||
}
|
||||
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
{
|
||||
center [ i ] = ( max[i] + min[i] ) / 2.0f ;
|
||||
dead_band [ i ] = 0.0f ;
|
||||
saturate [ i ] = 1.0f ;
|
||||
}
|
||||
|
||||
#else
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
FILE *joyfile;
|
||||
char joyfname[1024];
|
||||
int noargs, in_no_axes;
|
||||
# endif
|
||||
|
||||
/* Default for older Linux systems. */
|
||||
|
||||
num_axes = 2 ;
|
||||
num_buttons = 32 ;
|
||||
|
||||
# ifdef JS_NEW
|
||||
for ( int i = 0 ; i < _JS_MAX_AXES ; i++ )
|
||||
tmp_axes [ i ] = 0.0f ;
|
||||
|
||||
tmp_buttons = 0 ;
|
||||
# endif
|
||||
|
||||
// fd = ::open ( fname, O_RDONLY | O_NONBLOCK ) ;
|
||||
fd = ::open ( fname, O_RDONLY ) ;
|
||||
|
||||
error = ( fd < 0 ) ;
|
||||
|
||||
if ( error )
|
||||
return ;
|
||||
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
|
||||
/*
|
||||
FIXME: get joystick name for BSD
|
||||
*/
|
||||
|
||||
float axes[_JS_MAX_AXES];
|
||||
int buttons[_JS_MAX_AXES];
|
||||
rawRead ( buttons, axes );
|
||||
error = axes[0] < -1000000000.0f;
|
||||
if ( error )
|
||||
return ;
|
||||
|
||||
sprintf(joyfname,"%s/.joy%drc",::getenv( "HOME" ),id);
|
||||
|
||||
joyfile = fopen(joyfname,"r");
|
||||
error = joyfile == NULL;
|
||||
if ( error )
|
||||
return ;
|
||||
noargs = fscanf(joyfile,"%d%f%f%f%f%f%f",&in_no_axes,
|
||||
&min[0],¢er[0],&max[0],
|
||||
&min[1],¢er[1],&max[1]);
|
||||
error = noargs != 7 || in_no_axes != _JS_MAX_AXES;
|
||||
fclose(joyfile);
|
||||
if ( error )
|
||||
return ;
|
||||
|
||||
for ( int i = 0 ; i < _JS_MAX_AXES ; i++ )
|
||||
{
|
||||
dead_band [ i ] = 0.0f ;
|
||||
saturate [ i ] = 1.0f ;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
/*
|
||||
Set the correct number of axes for the linux driver
|
||||
*/
|
||||
|
||||
# ifdef JS_NEW
|
||||
ioctl ( fd, JSIOCGAXES , & num_axes ) ;
|
||||
ioctl ( fd, JSIOCGBUTTONS, & num_buttons ) ;
|
||||
ioctl ( fd, JSIOCGNAME ( sizeof(name) ), name ) ;
|
||||
fcntl ( fd, F_SETFL, O_NONBLOCK ) ;
|
||||
|
||||
if ( num_axes > _JS_MAX_AXES )
|
||||
num_axes = _JS_MAX_AXES ;
|
||||
# endif
|
||||
|
||||
/*
|
||||
The Linux driver seems to return 512 for all axes
|
||||
when no stick is present - but there is a chance
|
||||
that could happen by accident - so it's gotta happen
|
||||
on both axes for at least 100 attempts.
|
||||
*/
|
||||
|
||||
#ifndef JS_NEW
|
||||
int counter = 0 ;
|
||||
|
||||
do
|
||||
{
|
||||
rawRead ( NULL, center ) ;
|
||||
counter++ ;
|
||||
} while ( ! error &&
|
||||
counter < 100 &&
|
||||
center[0] == 512.0f &&
|
||||
center[1] == 512.0f ) ;
|
||||
|
||||
if ( counter >= 100 )
|
||||
setError() ;
|
||||
#endif
|
||||
|
||||
for ( int i = 0 ; i < _JS_MAX_AXES ; i++ )
|
||||
{
|
||||
#ifdef JS_NEW
|
||||
max [ i ] = 32767.0f ;
|
||||
center [ i ] = 0.0f ;
|
||||
min [ i ] = -32767.0f ;
|
||||
#else
|
||||
max [ i ] = center [ i ] * 2.0f ;
|
||||
min [ i ] = 0.0f ;
|
||||
#endif
|
||||
dead_band [ i ] = 0.0f ;
|
||||
saturate [ i ] = 1.0f ;
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void close ()
|
||||
{
|
||||
#if !defined( WIN32 ) && !defined( macintosh )
|
||||
if ( ! error )
|
||||
::close ( fd ) ;
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
|
||||
ISpSuspend ();
|
||||
ISpStop ();
|
||||
ISpShutdown ();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
float fudge_axis ( float value, int axis ) const
|
||||
{
|
||||
if ( value < center[axis] )
|
||||
{
|
||||
float xx = ( value - center[ axis ] ) /
|
||||
( center [ axis ] - min [ axis ] ) ;
|
||||
|
||||
if ( xx < -saturate [ axis ] )
|
||||
return -1.0f ;
|
||||
|
||||
if ( xx > -dead_band [ axis ] )
|
||||
return 0.0f ;
|
||||
|
||||
xx = ( xx + dead_band [ axis ] ) /
|
||||
( saturate [ axis ] - dead_band [ axis ] ) ;
|
||||
|
||||
return ( xx < -1.0f ) ? -1.0f : xx ;
|
||||
}
|
||||
else
|
||||
{
|
||||
float xx = ( value - center [ axis ] ) /
|
||||
( max [ axis ] - center [ axis ] ) ;
|
||||
|
||||
if ( xx > saturate [ axis ] )
|
||||
return 1.0f ;
|
||||
|
||||
if ( xx < dead_band [ axis ] )
|
||||
return 0.0f ;
|
||||
|
||||
xx = ( xx - dead_band [ axis ] ) /
|
||||
( saturate [ axis ] - dead_band [ axis ] ) ;
|
||||
|
||||
return ( xx > 1.0f ) ? 1.0f : xx ;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
jsJoystick ( int ident = 0 )
|
||||
{
|
||||
#ifdef WIN32
|
||||
switch ( ident )
|
||||
{
|
||||
case 0 : js_id = JOYSTICKID1 ; open () ; break ;
|
||||
case 1 : js_id = JOYSTICKID2 ; open () ; break;
|
||||
default : num_axes = 0 ; setError () ; break ;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
//id = ident;
|
||||
sprintf ( fname, "/dev/joy%d", ident ) ;
|
||||
# elif defined(__linux__)
|
||||
sprintf ( fname, "/dev/input/js%d", ident ) ;
|
||||
if ( access ( fname, F_OK ) != 0 )
|
||||
sprintf ( fname, "/dev/js%d", ident ) ;
|
||||
# else
|
||||
sprintf ( fname, "/dev/js%d", ident ) ; /* FIXME */
|
||||
# endif
|
||||
open () ;
|
||||
#endif
|
||||
}
|
||||
|
||||
~jsJoystick ()
|
||||
{
|
||||
close () ;
|
||||
}
|
||||
|
||||
const char* getName () const { return name ; }
|
||||
int getNumAxes () const { return num_axes ; }
|
||||
int notWorking () const { return error ; }
|
||||
void setError () { error = JS_TRUE ; }
|
||||
|
||||
float getDeadBand ( int axis ) const { return dead_band [ axis ] ; }
|
||||
void setDeadBand ( int axis, float db ) { dead_band [ axis ] = db ; }
|
||||
|
||||
float getSaturation ( int axis ) const { return saturate [ axis ] ; }
|
||||
void setSaturation ( int axis, float st ) { saturate [ axis ] = st ; }
|
||||
|
||||
void setMinRange ( float *axes ) { memcpy ( min , axes, num_axes * sizeof(float) ) ; }
|
||||
void setMaxRange ( float *axes ) { memcpy ( max , axes, num_axes * sizeof(float) ) ; }
|
||||
void setCenter ( float *axes ) { memcpy ( center, axes, num_axes * sizeof(float) ) ; }
|
||||
|
||||
void getMinRange ( float *axes ) const { memcpy ( axes, min , num_axes * sizeof(float) ) ; }
|
||||
void getMaxRange ( float *axes ) const { memcpy ( axes, max , num_axes * sizeof(float) ) ; }
|
||||
void getCenter ( float *axes ) const { memcpy ( axes, center, num_axes * sizeof(float) ) ; }
|
||||
|
||||
void read ( int *buttons, float *axes )
|
||||
{
|
||||
if ( error )
|
||||
{
|
||||
if ( buttons )
|
||||
*buttons = 0 ;
|
||||
|
||||
if ( axes )
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
axes[i] = 0.0f ;
|
||||
}
|
||||
|
||||
float raw_axes [ _JS_MAX_AXES ] ;
|
||||
|
||||
rawRead ( buttons, raw_axes ) ;
|
||||
|
||||
if ( axes )
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
axes[i] = fudge_axis ( raw_axes[i], i ) ;
|
||||
}
|
||||
|
||||
void rawRead ( int *buttons, float *axes )
|
||||
{
|
||||
if ( error )
|
||||
{
|
||||
if ( buttons )
|
||||
*buttons = 0 ;
|
||||
|
||||
if ( axes )
|
||||
for ( int i = 0 ; i < num_axes ; i++ )
|
||||
axes[i] = 1500.0f ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
#ifdef macintosh
|
||||
|
||||
int i;
|
||||
int err;
|
||||
UInt32 state;
|
||||
|
||||
if (buttons) {
|
||||
|
||||
*buttons = 0;
|
||||
|
||||
for (i = 0; i < num_buttons; i++) {
|
||||
|
||||
err = ISpElement_GetSimpleState (isp_elem[i + isp_num_axis ], &state);
|
||||
ISP_CHECK_ERR (err)
|
||||
|
||||
*buttons |= state << i;
|
||||
}
|
||||
}
|
||||
|
||||
if (axes) {
|
||||
|
||||
for (i = 0; i < num_axes; i++) {
|
||||
|
||||
err = ISpElement_GetSimpleState (isp_elem[ i ], &state);
|
||||
ISP_CHECK_ERR (err);
|
||||
|
||||
axes [i] = (float) state;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined ( WIN32 )
|
||||
MMRESULT status = joyGetPosEx ( js_id, &js ) ;
|
||||
|
||||
if ( status != JOYERR_NOERROR )
|
||||
{
|
||||
setError() ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
{
|
||||
*buttons = (int) js . dwButtons ;
|
||||
}
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
/* WARNING - Fall through case clauses!! */
|
||||
//lint -save -e616
|
||||
|
||||
switch ( num_axes )
|
||||
{
|
||||
case 8:
|
||||
// Generate two POV axes from the POV hat angle.
|
||||
// Low 16 bits of js.dwPOV gives heading (clockwise from ahead) in
|
||||
// hundredths of a degree, or 0xFFFF when idle.
|
||||
if ( (js.dwPOV & 0xFFFF) == 0xFFFF ) {
|
||||
axes[6] = 0.0;
|
||||
axes[7] = 0.0;
|
||||
} else {
|
||||
// This is the contentious bit: how to convert angle to X/Y.
|
||||
// wk: I know of no define for PI that we could use here:
|
||||
// SG_PI would pull in sg, M_PI is undefined for MSVC
|
||||
// But the accuracy of the value of PI is very unimportant at this point.
|
||||
float s = (float)sin((js.dwPOV & 0xFFFF) * (0.01 * 3.1415926535f / 180));
|
||||
float c = (float)cos((js.dwPOV & 0xFFFF) * (0.01 * 3.1415926535f / 180));
|
||||
// Convert to coordinates on a square so that North-East
|
||||
// is (1,1) not (.7,.7), etc.
|
||||
// s and c cannot both be zero so we won't divide by zero.
|
||||
if (fabs(s) < fabs(c)) {
|
||||
axes[6] = (c < 0.0) ? -s/c : s/c;
|
||||
axes[7] = (c < 0.0) ? -1.0f : 1.0f;
|
||||
} else {
|
||||
axes[6] = (s < 0.0) ? -1.0f : 1.0f;
|
||||
axes[7] = (s < 0.0) ? -c/s : c/s;
|
||||
}
|
||||
}
|
||||
case 6: axes[5] = (float) js . dwVpos ;
|
||||
case 5: axes[4] = (float) js . dwUpos ;
|
||||
case 4: axes[3] = (float) js . dwRpos ;
|
||||
case 3: axes[2] = (float) js . dwZpos ;
|
||||
case 2: axes[1] = (float) js . dwYpos ;
|
||||
case 1: axes[0] = (float) js . dwXpos ;
|
||||
break;
|
||||
default:
|
||||
ulSetError ( UL_WARNING, "PLIB_JS: Wrong num_axes. Joystick input is now invalid" ) ;
|
||||
|
||||
}
|
||||
//lint -restore
|
||||
}
|
||||
#else
|
||||
|
||||
# ifdef JS_NEW
|
||||
|
||||
while (1)
|
||||
{
|
||||
int status = ::read ( fd, &js, sizeof(js_event) ) ;
|
||||
|
||||
if ( status != sizeof(js_event) )
|
||||
{
|
||||
/* use the old values */
|
||||
|
||||
if ( buttons ) *buttons = tmp_buttons ;
|
||||
if ( axes ) memcpy ( axes, tmp_axes, sizeof(float) * num_axes ) ;
|
||||
|
||||
if ( errno == EAGAIN )
|
||||
return ;
|
||||
|
||||
perror( fname ) ;
|
||||
setError () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
switch ( js.type & ~JS_EVENT_INIT )
|
||||
{
|
||||
case JS_EVENT_BUTTON :
|
||||
if ( js.value == 0 ) /* clear the flag */
|
||||
tmp_buttons &= ~(1 << js.number) ;
|
||||
else
|
||||
tmp_buttons |= (1 << js.number) ;
|
||||
break ;
|
||||
|
||||
case JS_EVENT_AXIS:
|
||||
if ( js.number < num_axes )
|
||||
{
|
||||
tmp_axes [ js.number ] = (float) js.value ;
|
||||
|
||||
if ( axes )
|
||||
memcpy ( axes, tmp_axes, sizeof(float) * num_axes ) ;
|
||||
}
|
||||
break ;
|
||||
|
||||
default:
|
||||
ulSetError ( UL_WARNING, "PLIB_JS: Unrecognised /dev/js return!?!" ) ;
|
||||
|
||||
/* use the old values */
|
||||
|
||||
if ( buttons ) *buttons = tmp_buttons ;
|
||||
if ( axes ) memcpy ( axes, tmp_axes, sizeof(float) * num_axes ) ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
*buttons = tmp_buttons ;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
int status = ::read ( fd, &js, JS_RETURN ) ;
|
||||
|
||||
if ( status != JS_RETURN )
|
||||
{
|
||||
perror ( fname ) ;
|
||||
setError () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
*buttons = ( js.b1 ? 1 : 0 ) | ( js.b2 ? 2 : 0 ) ;
|
||||
# else
|
||||
*buttons = js.buttons ;
|
||||
# endif
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
axes[0] = (float) js.x ;
|
||||
axes[1] = (float) js.y ;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
} ;
|
||||
|
||||
extern void jsInit () ;
|
||||
|
||||
//lint -restore
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="js"
|
||||
SccProjectName="js"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\util"
|
||||
PreprocessorDefinitions="WIN32,_DEBUG,_LIB"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="2"
|
||||
PrecompiledHeaderFile=".\Debug/js.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="Debug\js_d.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Copy Library to plib directory"
|
||||
CommandLine="copy debug\*.lib ..\..\*.*
|
||||
copy js.h ..\..\js.h
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\util"
|
||||
PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Release/js.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Release\js.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Copy Library to plib directory"
|
||||
CommandLine="copy release\*.lib ..\..\*.*
|
||||
copy js.h ..\..\js.h
|
||||
"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\js.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\js.h">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,16 +0,0 @@
|
||||
if BUILD_NET
|
||||
|
||||
lib_LIBRARIES = libplibnet.a
|
||||
|
||||
include_HEADERS = netBuffer.h netChannel.h netChat.h netMessage.h \
|
||||
netMonitor.h netSocket.h
|
||||
|
||||
libplibnet_a_SOURCES = netBuffer.cxx netChannel.cxx netChat.cxx \
|
||||
netMessage.cxx netMonitor.cxx netSocket.cxx
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/util
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = net.dsp
|
||||
|
||||
@@ -1,327 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
|
||||
@BUILD_NET_TRUE@lib_LIBRARIES = libplibnet.a
|
||||
|
||||
@BUILD_NET_TRUE@include_HEADERS = netBuffer.h netChannel.h netChat.h netMessage.h netMonitor.h netSocket.h
|
||||
|
||||
@BUILD_NET_TRUE@libplibnet_a_SOURCES = netBuffer.cxx netChannel.cxx netChat.cxx netMessage.cxx netMonitor.cxx netSocket.cxx
|
||||
|
||||
@BUILD_NET_TRUE@INCLUDES = -I$(top_srcdir)/src/util
|
||||
|
||||
EXTRA_DIST = net.dsp
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(lib_LIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
libplibnet_a_LIBADD =
|
||||
@BUILD_NET_TRUE@libplibnet_a_OBJECTS = netBuffer.o netChannel.o \
|
||||
@BUILD_NET_TRUE@netChat.o netMessage.o netMonitor.o netSocket.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
HEADERS = $(include_HEADERS)
|
||||
|
||||
DIST_COMMON = README Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(libplibnet_a_SOURCES)
|
||||
OBJECTS = $(libplibnet_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .cxx .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/net/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-libLIBRARIES:
|
||||
|
||||
clean-libLIBRARIES:
|
||||
-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
|
||||
|
||||
distclean-libLIBRARIES:
|
||||
|
||||
maintainer-clean-libLIBRARIES:
|
||||
|
||||
install-libLIBRARIES: $(lib_LIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
@$(POST_INSTALL)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||
done
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
libplibnet.a: $(libplibnet_a_OBJECTS) $(libplibnet_a_DEPENDENCIES)
|
||||
-rm -f libplibnet.a
|
||||
$(AR) cru libplibnet.a $(libplibnet_a_OBJECTS) $(libplibnet_a_LIBADD)
|
||||
$(RANLIB) libplibnet.a
|
||||
.cxx.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
install-includeHEADERS: $(include_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(includedir)
|
||||
@list='$(include_HEADERS)'; for p in $$list; do \
|
||||
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
|
||||
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
|
||||
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
uninstall-includeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(include_HEADERS)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = src/net
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
netBuffer.o: netBuffer.cxx netBuffer.h netChannel.h netSocket.h \
|
||||
../../src/util/ul.h
|
||||
netChannel.o: netChannel.cxx netChannel.h netSocket.h \
|
||||
../../src/util/ul.h
|
||||
netChat.o: netChat.cxx netChat.h netBuffer.h netChannel.h netSocket.h \
|
||||
../../src/util/ul.h
|
||||
netMessage.o: netMessage.cxx netMessage.h netBuffer.h netChannel.h \
|
||||
netSocket.h ../../src/util/ul.h
|
||||
netMonitor.o: netMonitor.cxx netMonitor.h netChat.h netBuffer.h \
|
||||
netChannel.h netSocket.h ../../src/util/ul.h
|
||||
netSocket.o: netSocket.cxx netSocket.h ../../src/util/ul.h
|
||||
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am: install-libLIBRARIES
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am: install-includeHEADERS
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am: uninstall-libLIBRARIES uninstall-includeHEADERS
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES) $(HEADERS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-libLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-libLIBRARIES clean-compile clean-tags clean-generic \
|
||||
mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-libLIBRARIES distclean-compile distclean-tags \
|
||||
distclean-generic clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-libLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-libLIBRARIES distclean-libLIBRARIES \
|
||||
clean-libLIBRARIES maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
|
||||
install-libLIBRARIES mostlyclean-compile distclean-compile \
|
||||
clean-compile maintainer-clean-compile uninstall-includeHEADERS \
|
||||
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
|
||||
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,47 +0,0 @@
|
||||
PLIB Network Library
|
||||
-------------------
|
||||
|
||||
DESCRIPTION:
|
||||
|
||||
This is a C++ library for making networked games.
|
||||
It includes event-driven channels, support for
|
||||
buffering and pipelining, a monitor server for remote
|
||||
telnet admin, and binary messages.
|
||||
|
||||
HISTORY
|
||||
|
||||
Initial work by Dave McClurg <dpm@efn.org>
|
||||
This library is based on from a high-performance
|
||||
internet server architecture for Python called Medusa.
|
||||
http://www.nightmare.com/medusa/medusa.html
|
||||
Added binary messages and PLIB naming conventions
|
||||
|
||||
LICENSING:
|
||||
|
||||
This library is distributed with PLIB under the GNU LGPL.
|
||||
|
||||
|
||||
MEDUSA COPYRIGHT:
|
||||
|
||||
---
|
||||
Copyright 1996 by Sam Rushing
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and
|
||||
its documentation for any purpose and without fee is hereby
|
||||
granted, provided that the above copyright notice appear in all
|
||||
copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the name of Sam
|
||||
Rushing not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
---
|
||||
@@ -1,207 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="net" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=net - 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 "net.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 "net.mak" CFG="net - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "net - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "net - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "net"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "net - 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 Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\util" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
# Begin Custom Build - 'net' gets installed
|
||||
ProjDir=.
|
||||
InputPath=.\Release\net.lib
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
BuildCmds= \
|
||||
copy $(ProjDir)\netBuffer.h $(ProjDir)\..\..\netBuffer.h \
|
||||
copy $(ProjDir)\netChannel.h $(ProjDir)\..\..\netChannel.h \
|
||||
copy $(ProjDir)\netChat.h $(ProjDir)\..\..\netChat.h \
|
||||
copy $(ProjDir)\netMessage.h $(ProjDir)\..\..\netMessage.h \
|
||||
copy $(ProjDir)\netMonitor.h $(ProjDir)\..\..\netMonitor.h \
|
||||
copy $(ProjDir)\netSocket.h $(ProjDir)\..\..\netSocket.h \
|
||||
|
||||
|
||||
"$(ProjDir)\..\..\netBuffer.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netChannel.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netChat.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netMessage.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netMonitor.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netSocket.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=Copy Library to plib directory
|
||||
PostBuild_Cmds=copy release\*.lib ..\..\*.*
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "net - 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 Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /Zi /Od /I "..\util" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"Debug\net_d.lib"
|
||||
# Begin Custom Build - 'net' gets installed
|
||||
ProjDir=.
|
||||
InputPath=.\Debug\net_d.lib
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
BuildCmds= \
|
||||
copy $(ProjDir)\netBuffer.h $(ProjDir)\..\..\netBuffer.h \
|
||||
copy $(ProjDir)\netChannel.h $(ProjDir)\..\..\netChannel.h \
|
||||
copy $(ProjDir)\netChat.h $(ProjDir)\..\..\netChat.h \
|
||||
copy $(ProjDir)\netMessage.h $(ProjDir)\..\..\netMessage.h \
|
||||
copy $(ProjDir)\netMonitor.h $(ProjDir)\..\..\netMonitor.h \
|
||||
copy $(ProjDir)\netSocket.h $(ProjDir)\..\..\netSocket.h \
|
||||
|
||||
|
||||
"$(ProjDir)\..\..\netBuffer.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netChannel.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netChat.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netMessage.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netMonitor.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(ProjDir)\..\..\netSocket.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
# Begin Special Build Tool
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Desc=Copy Library to plib directory
|
||||
PostBuild_Cmds=copy debug\*.lib ..\..\*.*
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "net - Win32 Release"
|
||||
# Name "net - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netBuffer.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netChannel.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netChannel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netChat.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netChat.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netMessage.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netMessage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netMonitor.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netMonitor.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netSocket.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\netSocket.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,164 +0,0 @@
|
||||
<?xml version="1.0" encoding = "Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.00"
|
||||
Name="net"
|
||||
SccProjectName="net"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\util"
|
||||
PreprocessorDefinitions="WIN32,_DEBUG,_LIB"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="2"
|
||||
PrecompiledHeaderFile=".\Debug/net.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="'net' gets installed"
|
||||
CommandLine="copy $(ProjectDir)netBuffer.h $(ProjectDir)..\..\netBuffer.h
|
||||
copy $(ProjectDir)netChannel.h $(ProjectDir)..\..\netChannel.h
|
||||
copy $(ProjectDir)netChat.h $(ProjectDir)..\..\netChat.h
|
||||
copy $(ProjectDir)netMessage.h $(ProjectDir)..\..\netMessage.h
|
||||
copy $(ProjectDir)netMonitor.h $(ProjectDir)..\..\netMonitor.h
|
||||
copy $(ProjectDir)netSocket.h $(ProjectDir)..\..\netSocket.h
|
||||
"
|
||||
Outputs="$(ProjectDir)..\..\netBuffer.h;$(ProjectDir)..\..\netChannel.h;$(ProjectDir)..\..\netChat.h;$(ProjectDir)..\..\netMessage.h;$(ProjectDir)..\..\netMonitor.h;$(ProjectDir)..\..\netSocket.h"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="Debug\net_d.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Copy Library to plib directory"
|
||||
CommandLine="copy debug\*.lib ..\..\*.*"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\util"
|
||||
PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\Release/net.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="'net' gets installed"
|
||||
CommandLine="copy $(ProjectDir)netBuffer.h $(ProjectDir)..\..\netBuffer.h
|
||||
copy $(ProjectDir)netChannel.h $(ProjectDir)..\..\netChannel.h
|
||||
copy $(ProjectDir)netChat.h $(ProjectDir)..\..\netChat.h
|
||||
copy $(ProjectDir)netMessage.h $(ProjectDir)..\..\netMessage.h
|
||||
copy $(ProjectDir)netMonitor.h $(ProjectDir)..\..\netMonitor.h
|
||||
copy $(ProjectDir)netSocket.h $(ProjectDir)..\..\netSocket.h
|
||||
"
|
||||
Outputs="$(ProjectDir)..\..\netBuffer.h;$(ProjectDir)..\..\netChannel.h;$(ProjectDir)..\..\netChat.h;$(ProjectDir)..\..\netMessage.h;$(ProjectDir)..\..\netMonitor.h;$(ProjectDir)..\..\netSocket.h"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Release\net.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Copy Library to plib directory"
|
||||
CommandLine="copy release\*.lib ..\..\*.*"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\netBuffer.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netBuffer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netChannel.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netChannel.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netChat.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netChat.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netMessage.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netMessage.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netMonitor.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netMonitor.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netSocket.cxx">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\netSocket.h">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "netBuffer.h"
|
||||
|
||||
void
|
||||
netBufferChannel::handleRead (void)
|
||||
{
|
||||
int max_read = in_buffer.getMaxLength() - in_buffer.getLength() ;
|
||||
if (max_read)
|
||||
{
|
||||
char* data = in_buffer.getData() + in_buffer.getLength() ;
|
||||
int num_read = recv (data, max_read) ;
|
||||
if (num_read > 0)
|
||||
{
|
||||
in_buffer.append (num_read) ;
|
||||
//ulSetError ( UL_DEBUG, "netBufferChannel: %d read", num_read ) ;
|
||||
}
|
||||
}
|
||||
if (in_buffer.getLength())
|
||||
{
|
||||
handleBufferRead (in_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
netBufferChannel::handleWrite (void)
|
||||
{
|
||||
if (out_buffer.getLength())
|
||||
{
|
||||
if (isConnected())
|
||||
{
|
||||
int length = out_buffer.getLength() ;
|
||||
if (length>512)
|
||||
length=512;
|
||||
int num_sent = netChannel::send (
|
||||
out_buffer.getData(), length);
|
||||
if (num_sent > 0)
|
||||
{
|
||||
out_buffer.remove (0, num_sent);
|
||||
//ulSetError ( UL_DEBUG, "netBufferChannel: %d sent", num_sent ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (should_close)
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
@@ -1,235 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* netBuffer - network buffer class
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Clients and servers built on top of netBufferChannel
|
||||
* automatically support pipelining.
|
||||
*
|
||||
* Pipelining refers to a protocol capability. Normally,
|
||||
* a conversation with a server has a back-and-forth
|
||||
* quality to it. The client sends a command, and
|
||||
* waits for the response. If a client needs to send
|
||||
* many commands over a high-latency connection,
|
||||
* waiting for each response can take a long time.
|
||||
*
|
||||
* For example, when sending a mail message to many recipients
|
||||
* with SMTP, the client will send a series of RCPT commands, one
|
||||
* for each recipient. For each of these commands, the server will
|
||||
* send back a reply indicating whether the mailbox specified is
|
||||
* valid. If you want to send a message to several hundred recipients,
|
||||
* this can be rather tedious if the round-trip time for each command
|
||||
* is long. You'd like to be able to send a bunch of RCPT commands
|
||||
* in one batch, and then count off the responses to them as they come.
|
||||
*
|
||||
* I have a favorite visual when explaining the advantages of
|
||||
* pipelining. Imagine each request to the server is a boxcar on a train.
|
||||
* The client is in Los Angeles, and the server is in New York.
|
||||
* Pipelining lets you hook all your cars in one long chain; send
|
||||
* them to New York, where they are filled and sent back to you.
|
||||
* Without pipelining you have to send one car at a time.
|
||||
*
|
||||
* Not all protocols allow pipelining. Not all servers support it;
|
||||
* Sendmail, for example, does not support pipelining because it tends
|
||||
* to fork unpredictably, leaving buffered data in a questionable state.
|
||||
* A recent extension to the SMTP protocol allows a server to specify
|
||||
* whether it supports pipelining. HTTP/1.1 explicitly requires that
|
||||
* a server support pipelining.
|
||||
*
|
||||
* NOTES
|
||||
* When a user passes in a buffer object, it belongs to
|
||||
* the user. When the library gives a buffer to the user,
|
||||
* the user should copy it.
|
||||
*
|
||||
* AUTHORS
|
||||
* Sam Rushing <rushing@nightmare.com> - original version for Medusa
|
||||
* Dave McClurg <dpm@efn.org> - modified for use in PLIB
|
||||
*
|
||||
* CREATION DATE
|
||||
* Dec-2000
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NET_BUFFER_H
|
||||
#define NET_BUFFER_H
|
||||
|
||||
#include "netChannel.h"
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
// netName
|
||||
// ===========================================================================
|
||||
|
||||
enum { NET_MAX_NAME = 31 } ;
|
||||
//eg. char name [ NET_MAX_NAME+1 ] ;
|
||||
|
||||
|
||||
inline char* netCopyName ( char* dst, cchar* src )
|
||||
{
|
||||
if ( src != NULL )
|
||||
{
|
||||
strncpy ( dst, src, NET_MAX_NAME ) ;
|
||||
dst [ NET_MAX_NAME ] = 0 ;
|
||||
}
|
||||
else
|
||||
*dst = 0 ;
|
||||
return dst ;
|
||||
}
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
// netBuffer
|
||||
// ===========================================================================
|
||||
|
||||
class netBuffer
|
||||
{
|
||||
protected:
|
||||
int length ;
|
||||
int max_length ;
|
||||
char* data ;
|
||||
|
||||
public:
|
||||
netBuffer ( int _max_length )
|
||||
{
|
||||
length = 0 ;
|
||||
max_length = _max_length ;
|
||||
data = new char [ max_length+1 ] ; //for null terminator
|
||||
}
|
||||
|
||||
~netBuffer ()
|
||||
{
|
||||
delete[] data ;
|
||||
}
|
||||
|
||||
int getLength() const { return length ; }
|
||||
int getMaxLength() const { return max_length ; }
|
||||
|
||||
/*
|
||||
** getData() returns a pointer to the data
|
||||
** Note: a zero (0) byte is appended for convenience
|
||||
** but the data may have internal zero (0) bytes already
|
||||
*/
|
||||
char* getData() { data [length] = 0 ; return data ; }
|
||||
const char* getData() const { ((char*)data) [length] = 0 ; return data ; }
|
||||
|
||||
void remove ()
|
||||
{
|
||||
length = 0 ;
|
||||
}
|
||||
|
||||
void remove (int pos, int n)
|
||||
{
|
||||
assert (pos>=0 && pos<length && (pos+n)<=length) ;
|
||||
//if (pos>=0 && pos<length && (pos+n)<=length)
|
||||
{
|
||||
memmove(&data[pos],&data[pos+n],length-(pos+n)) ;
|
||||
length -= n ;
|
||||
}
|
||||
}
|
||||
|
||||
bool append (const char* s, int n)
|
||||
{
|
||||
if ((length+n)<=max_length)
|
||||
{
|
||||
memcpy(&data[length],s,n) ;
|
||||
length += n ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool append (int n)
|
||||
{
|
||||
if ((length+n)<=max_length)
|
||||
{
|
||||
length += n ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// ===========================================================================
|
||||
// netBufferChannel
|
||||
// ===========================================================================
|
||||
|
||||
class netBufferChannel : public netChannel
|
||||
{
|
||||
netBuffer in_buffer;
|
||||
netBuffer out_buffer;
|
||||
int should_close ;
|
||||
|
||||
virtual bool readable (void)
|
||||
{
|
||||
return (netChannel::readable() &&
|
||||
(in_buffer.getLength() < in_buffer.getMaxLength()));
|
||||
}
|
||||
|
||||
virtual void handleRead (void) ;
|
||||
|
||||
virtual bool writable (void)
|
||||
{
|
||||
return (out_buffer.getLength() || should_close);
|
||||
}
|
||||
|
||||
virtual void handleWrite (void) ;
|
||||
|
||||
public:
|
||||
|
||||
// constructor
|
||||
netBufferChannel (int in_buffer_size = 4096, int out_buffer_size = 16384) :
|
||||
in_buffer (in_buffer_size),
|
||||
out_buffer (out_buffer_size),
|
||||
should_close (0)
|
||||
{ /* empty */
|
||||
}
|
||||
|
||||
virtual void handleClose ( void )
|
||||
{
|
||||
in_buffer.remove () ;
|
||||
out_buffer.remove () ;
|
||||
should_close = 0 ;
|
||||
netChannel::handleClose () ;
|
||||
}
|
||||
|
||||
void closeWhenDone (void) { should_close = 1 ; }
|
||||
|
||||
virtual bool bufferSend (const char* msg, int msg_len)
|
||||
{
|
||||
if ( out_buffer.append(msg,msg_len) )
|
||||
return true ;
|
||||
ulSetError ( UL_WARNING, "netBufferChannel: output buffer overflow!" ) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
virtual void handleBufferRead (netBuffer& buffer)
|
||||
{
|
||||
/* do something here */
|
||||
buffer.remove();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // NET_BUFFER_H
|
||||
@@ -1,277 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
// TODO:
|
||||
// have all socket-related functions assert that the socket has not
|
||||
// been closed. [a read event may close it, and a write event may try
|
||||
// to write or something...]
|
||||
// Maybe assert valid handle, too?
|
||||
|
||||
#include "netChannel.h"
|
||||
|
||||
static netChannel* channels = 0 ;
|
||||
|
||||
netChannel::netChannel ()
|
||||
{
|
||||
closed = true ;
|
||||
connected = false ;
|
||||
accepting = false ;
|
||||
write_blocked = false ;
|
||||
should_delete = false ;
|
||||
|
||||
next_channel = channels ;
|
||||
channels = this ;
|
||||
}
|
||||
|
||||
netChannel::~netChannel ()
|
||||
{
|
||||
close();
|
||||
|
||||
netChannel* prev = NULL ;
|
||||
for ( netChannel* ch = channels; ch != NULL;
|
||||
ch = ch -> next_channel )
|
||||
{
|
||||
if (ch == this)
|
||||
{
|
||||
ch = ch -> next_channel ;
|
||||
if ( prev != NULL )
|
||||
prev -> next_channel = ch ;
|
||||
else
|
||||
channels = ch ;
|
||||
next_channel = 0 ;
|
||||
break;
|
||||
}
|
||||
prev = ch ;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
netChannel::setHandle (int handle, bool is_connected)
|
||||
{
|
||||
close () ;
|
||||
netSocket::setHandle ( handle ) ;
|
||||
connected = is_connected ;
|
||||
//if ( connected ) this->handleConnect();
|
||||
closed = false ;
|
||||
}
|
||||
|
||||
bool
|
||||
netChannel::open (void)
|
||||
{
|
||||
close();
|
||||
if (netSocket::open(true)) {
|
||||
closed = false ;
|
||||
setBlocking ( false ) ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
int
|
||||
netChannel::listen ( int backlog )
|
||||
{
|
||||
accepting = true ;
|
||||
return netSocket::listen ( backlog ) ;
|
||||
}
|
||||
|
||||
int
|
||||
netChannel::connect ( cchar* host, int port )
|
||||
{
|
||||
int result = netSocket::connect ( host, port ) ;
|
||||
if (result == 0) {
|
||||
connected = true ;
|
||||
//this->handleConnect();
|
||||
return 0;
|
||||
} else if (isNonBlockingError ()) {
|
||||
return 0;
|
||||
} else {
|
||||
// some other error condition
|
||||
this->handleError (result);
|
||||
close();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
netChannel::send (const void * buffer, int size, int flags)
|
||||
{
|
||||
int result = netSocket::send (buffer, size, flags);
|
||||
|
||||
if (result == (int)size) {
|
||||
// everything was sent
|
||||
write_blocked = false ;
|
||||
return result;
|
||||
} else if (result >= 0) {
|
||||
// not all of it was sent, but no error
|
||||
write_blocked = true ;
|
||||
return result;
|
||||
} else if (isNonBlockingError ()) {
|
||||
write_blocked = true ;
|
||||
return 0;
|
||||
} else {
|
||||
this->handleError (result);
|
||||
close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
netChannel::recv (void * buffer, int size, int flags)
|
||||
{
|
||||
int result = netSocket::recv (buffer, size, flags);
|
||||
|
||||
if (result > 0) {
|
||||
return result;
|
||||
} else if (result == 0) {
|
||||
close();
|
||||
return 0;
|
||||
} else if (isNonBlockingError ()) {
|
||||
return 0;
|
||||
} else {
|
||||
this->handleError (result);
|
||||
close();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
netChannel::close (void)
|
||||
{
|
||||
if ( !closed )
|
||||
{
|
||||
this->handleClose();
|
||||
|
||||
closed = true ;
|
||||
connected = false ;
|
||||
accepting = false ;
|
||||
write_blocked = false ;
|
||||
}
|
||||
|
||||
netSocket::close () ;
|
||||
}
|
||||
|
||||
void
|
||||
netChannel::handleReadEvent (void)
|
||||
{
|
||||
if (accepting) {
|
||||
if (!connected) {
|
||||
connected = true ;
|
||||
//this->handleConnect();
|
||||
}
|
||||
this->handleAccept();
|
||||
} else if (!connected) {
|
||||
connected = true ;
|
||||
//this->handleConnect();
|
||||
this->handleRead();
|
||||
} else {
|
||||
this->handleRead();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
netChannel::handleWriteEvent (void)
|
||||
{
|
||||
if (!connected) {
|
||||
connected = true ;
|
||||
//this->handleConnect();
|
||||
}
|
||||
write_blocked = false ;
|
||||
this->handleWrite();
|
||||
}
|
||||
|
||||
bool
|
||||
netChannel::poll (u32 timeout)
|
||||
{
|
||||
if (!channels)
|
||||
return false ;
|
||||
|
||||
enum { MAX_SOCKETS = 256 } ;
|
||||
netSocket* reads [ MAX_SOCKETS+1 ] ;
|
||||
netSocket* writes [ MAX_SOCKETS+1 ] ;
|
||||
netSocket* deletes [ MAX_SOCKETS+1 ] ;
|
||||
int nreads = 0 ;
|
||||
int nwrites = 0 ;
|
||||
int ndeletes = 0 ;
|
||||
int nopen = 0 ;
|
||||
netChannel* ch;
|
||||
for ( ch = channels; ch != NULL; ch = ch -> next_channel )
|
||||
{
|
||||
if ( ch -> should_delete )
|
||||
{
|
||||
assert(ndeletes<MAX_SOCKETS);
|
||||
deletes[ndeletes++] = ch ;
|
||||
}
|
||||
else if ( ! ch -> closed )
|
||||
{
|
||||
nopen++ ;
|
||||
if (ch -> readable()) {
|
||||
assert(nreads<MAX_SOCKETS);
|
||||
reads[nreads++] = ch ;
|
||||
}
|
||||
if (ch -> writable()) {
|
||||
assert(nwrites<MAX_SOCKETS);
|
||||
writes[nwrites++] = ch ;
|
||||
}
|
||||
}
|
||||
}
|
||||
reads[nreads] = NULL ;
|
||||
writes[nwrites] = NULL ;
|
||||
deletes[ndeletes] = NULL ;
|
||||
|
||||
int i ;
|
||||
for ( i=0; deletes[i]; i++ )
|
||||
{
|
||||
ch = (netChannel*)deletes[i];
|
||||
delete ch ;
|
||||
}
|
||||
|
||||
if (!nopen)
|
||||
return false ;
|
||||
if (!nreads && !nwrites)
|
||||
return true ; //hmmm- should we shutdown?
|
||||
|
||||
netSocket::select (reads, writes, timeout) ;
|
||||
|
||||
for ( i=0; reads[i]; i++ )
|
||||
{
|
||||
ch = (netChannel*)reads[i];
|
||||
if ( ! ch -> closed )
|
||||
ch -> handleReadEvent();
|
||||
}
|
||||
|
||||
for ( i=0; writes[i]; i++ )
|
||||
{
|
||||
ch = (netChannel*)writes[i];
|
||||
if ( ! ch -> closed )
|
||||
ch -> handleWriteEvent();
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void
|
||||
netChannel::loop (u32 timeout)
|
||||
{
|
||||
while ( poll (timeout) ) ;
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* netChannel - network channel class
|
||||
*
|
||||
* DESCRIPTION
|
||||
* netChannel is adds event-handling to the low-level
|
||||
* netSocket class. Otherwise, it can be treated as
|
||||
* a normal non-blocking socket object.
|
||||
*
|
||||
* The direct interface between the netPoll() loop and
|
||||
* the channel object are the handleReadEvent and
|
||||
* handleWriteEvent methods. These are called
|
||||
* whenever a channel object 'fires' that event.
|
||||
*
|
||||
* The firing of these low-level events can tell us whether
|
||||
* certain higher-level events have taken place, depending on
|
||||
* the timing and state of the connection.
|
||||
*
|
||||
* AUTHORS
|
||||
* Sam Rushing <rushing@nightmare.com> - original version for Medusa
|
||||
* Dave McClurg <dpm@efn.org> - modified for use in PLIB
|
||||
*
|
||||
* CREATION DATE
|
||||
* Dec-2000
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NET_CHANNEL_H
|
||||
#define NET_CHANNEL_H
|
||||
|
||||
#include "netSocket.h"
|
||||
|
||||
class netChannel : public netSocket
|
||||
{
|
||||
bool closed, connected, accepting, write_blocked, should_delete ;
|
||||
netChannel* next_channel ;
|
||||
|
||||
friend bool netPoll (u32 timeout);
|
||||
|
||||
public:
|
||||
|
||||
netChannel () ;
|
||||
virtual ~netChannel () ;
|
||||
|
||||
void setHandle (int s, bool is_connected = true);
|
||||
bool isConnected () const { return connected; }
|
||||
bool isClosed () const { return closed; }
|
||||
void shouldDelete () { should_delete = true ; }
|
||||
|
||||
// --------------------------------------------------
|
||||
// socket methods
|
||||
// --------------------------------------------------
|
||||
|
||||
bool open ( void ) ;
|
||||
void close ( void ) ;
|
||||
int listen ( int backlog ) ;
|
||||
int connect ( cchar* host, int port ) ;
|
||||
int send ( const void * buf, int size, int flags = 0 ) ;
|
||||
int recv ( void * buf, int size, int flags = 0 ) ;
|
||||
|
||||
// poll() eligibility predicates
|
||||
virtual bool readable (void) { return (connected || accepting); }
|
||||
virtual bool writable (void) { return (!connected || write_blocked); }
|
||||
|
||||
// --------------------------------------------------
|
||||
// event handlers
|
||||
// --------------------------------------------------
|
||||
|
||||
void handleReadEvent (void);
|
||||
void handleWriteEvent (void);
|
||||
|
||||
// These are meant to be overridden.
|
||||
virtual void handleClose (void) {
|
||||
//ulSetError(UL_WARNING,"Network: %d: unhandled close",getHandle());
|
||||
}
|
||||
virtual void handleRead (void) {
|
||||
ulSetError(UL_WARNING,"Network: %d: unhandled read",getHandle());
|
||||
}
|
||||
virtual void handleWrite (void) {
|
||||
ulSetError(UL_WARNING,"Network: %d: unhandled write",getHandle());
|
||||
}
|
||||
virtual void handleAccept (void) {
|
||||
ulSetError(UL_WARNING,"Network: %d: unhandled accept",getHandle());
|
||||
}
|
||||
virtual void handleError (int error) {
|
||||
ulSetError(UL_WARNING,"Network: %d: errno: %s(%d)",getHandle(),strerror(errno),errno);
|
||||
}
|
||||
|
||||
static bool poll (u32 timeout = 0 ) ;
|
||||
static void loop (u32 timeout = 0 ) ;
|
||||
};
|
||||
|
||||
#endif // NET_CHANNEL_H
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "netChat.h"
|
||||
|
||||
void
|
||||
netChat::setTerminator (const char* t)
|
||||
{
|
||||
if (terminator) delete[] terminator;
|
||||
terminator = ulStrDup(t);
|
||||
}
|
||||
|
||||
const char*
|
||||
netChat::getTerminator (void)
|
||||
{
|
||||
return terminator;
|
||||
}
|
||||
|
||||
// return the size of the largest prefix of needle at the end
|
||||
// of haystack
|
||||
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
static int
|
||||
find_prefix_at_end (const netBuffer& haystack, const char* needle)
|
||||
{
|
||||
const char* hd = haystack.getData();
|
||||
int hl = haystack.getLength();
|
||||
int nl = strlen(needle);
|
||||
|
||||
for (int i = MAX (nl-hl, 0); i < nl; i++) {
|
||||
//if (haystack.compare (needle, hl-(nl-i), nl-i) == 0) {
|
||||
if (memcmp(needle, &hd[hl-(nl-i)], nl-i) == 0) {
|
||||
return (nl-i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find_terminator (const netBuffer& haystack, const char* needle)
|
||||
{
|
||||
if (needle && *needle)
|
||||
{
|
||||
const char* data = haystack.getData();
|
||||
char* ptr = strstr(data,needle);
|
||||
if (ptr != NULL)
|
||||
return(ptr-data);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
netChat::handleBufferRead (netBuffer& in_buffer)
|
||||
{
|
||||
// Continue to search for terminator in in_buffer,
|
||||
// while calling collect_incoming_data. The while loop is
|
||||
// necessary because we might read several data+terminator combos
|
||||
// with a single recv().
|
||||
|
||||
while (in_buffer.getLength()) {
|
||||
|
||||
// special case where we're not using a terminator
|
||||
if (terminator == 0 || *terminator == 0) {
|
||||
collectIncomingData (in_buffer.getData(),in_buffer.getLength());
|
||||
in_buffer.remove ();
|
||||
return;
|
||||
}
|
||||
|
||||
int terminator_len = strlen(terminator);
|
||||
|
||||
int index = find_terminator ( in_buffer, terminator ) ;
|
||||
|
||||
// 3 cases:
|
||||
// 1) end of buffer matches terminator exactly:
|
||||
// collect data, transition
|
||||
// 2) end of buffer matches some prefix:
|
||||
// collect data to the prefix
|
||||
// 3) end of buffer does not match any prefix:
|
||||
// collect data
|
||||
|
||||
if (index != -1) {
|
||||
// we found the terminator
|
||||
collectIncomingData ( in_buffer.getData(), index ) ;
|
||||
in_buffer.remove (0, index + terminator_len);
|
||||
foundTerminator();
|
||||
} else {
|
||||
// check for a prefix of the terminator
|
||||
int num = find_prefix_at_end (in_buffer, terminator);
|
||||
if (num) {
|
||||
int bl = in_buffer.getLength();
|
||||
// we found a prefix, collect up to the prefix
|
||||
collectIncomingData ( in_buffer.getData(), bl - num ) ;
|
||||
in_buffer.remove (0, bl - num);
|
||||
break;
|
||||
} else {
|
||||
// no prefix, collect it all
|
||||
collectIncomingData (in_buffer.getData(), in_buffer.getLength());
|
||||
in_buffer.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* netChat - network chat class
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This class adds support for 'chat' style protocols -
|
||||
* where one side sends a 'command', and the other sends
|
||||
* a response (examples would be the common internet
|
||||
* protocols - smtp, nntp, ftp, etc..).
|
||||
*
|
||||
* The handle_buffer_read() method looks at the input
|
||||
* stream for the current 'terminator' (usually '\r\n'
|
||||
* for single-line responses, '\r\n.\r\n' for multi-line
|
||||
* output), calling found_terminator() on its receipt.
|
||||
*
|
||||
* EXAMPLE
|
||||
* Say you build an nntp client using this class.
|
||||
* At the start of the connection, you'll have
|
||||
* terminator set to '\r\n', in order to process
|
||||
* the single-line greeting. Just before issuing a
|
||||
* 'LIST' command you'll set it to '\r\n.\r\n'.
|
||||
* The output of the LIST command will be accumulated
|
||||
* (using your own 'collect_incoming_data' method)
|
||||
* up to the terminator, and then control will be
|
||||
* returned to you - by calling your found_terminator()
|
||||
*
|
||||
* AUTHORS
|
||||
* Sam Rushing <rushing@nightmare.com> - original version for Medusa
|
||||
* Dave McClurg <dpm@efn.org> - modified for use in PLIB
|
||||
*
|
||||
* CREATION DATE
|
||||
* Dec-2000
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NET_CHAT_H
|
||||
#define NET_CHAT_H
|
||||
|
||||
#include "netBuffer.h"
|
||||
|
||||
class netChat : public netBufferChannel
|
||||
{
|
||||
char* terminator;
|
||||
|
||||
virtual void handleBufferRead (netBuffer& buffer) ;
|
||||
|
||||
public:
|
||||
|
||||
netChat () : terminator (0) {}
|
||||
|
||||
void setTerminator (const char* t);
|
||||
const char* getTerminator (void);
|
||||
|
||||
bool push (const char* s)
|
||||
{
|
||||
return bufferSend ( s, strlen(s) ) ;
|
||||
}
|
||||
|
||||
virtual void collectIncomingData (const char* s, int n) {}
|
||||
virtual void foundTerminator (void) {}
|
||||
};
|
||||
|
||||
#endif // NET_CHAT_H
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "netMessage.h"
|
||||
|
||||
|
||||
void
|
||||
netMessageChannel::handleBufferRead (netBuffer& in_buffer)
|
||||
{
|
||||
int n = in_buffer.getLength () ;
|
||||
while ( n >= 2 )
|
||||
{
|
||||
u16 msg_len = *( (u16*)in_buffer.getData() ) ;
|
||||
if ( n >= msg_len )
|
||||
{
|
||||
//we have a complete message; handle it
|
||||
netMessage msg(in_buffer.getData(),msg_len);
|
||||
in_buffer.remove(0,msg_len);
|
||||
handleMessage ( msg );
|
||||
|
||||
//ulSetError ( UL_DEBUG, "netMessageChannel: %d read", msg_len ) ;
|
||||
n -= msg_len ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ulSetError ( UL_DEBUG, "netMessageChannel: %d waiting", n ) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* netMessage - message buffer and channel classes
|
||||
*
|
||||
* DESCRIPTION
|
||||
* messages are a binary format for sending buffers over a channel.
|
||||
* message headers contain a type field and length.
|
||||
*
|
||||
* AUTHOR
|
||||
* Dave McClurg <dpm@efn.org>
|
||||
*
|
||||
* CREATION DATE
|
||||
* Dec-2000
|
||||
****/
|
||||
|
||||
#ifndef __NET_MESSAGE__
|
||||
#define __NET_MESSAGE__
|
||||
|
||||
|
||||
#include "netBuffer.h"
|
||||
|
||||
#if defined(__CYGWIN__) || !defined (WIN32)
|
||||
#include <netinet/in.h> // ntohs() etc prototypes
|
||||
#endif
|
||||
|
||||
|
||||
class netGuid //Globally Unique IDentifier
|
||||
{
|
||||
public:
|
||||
u8 data [ 16 ] ;
|
||||
|
||||
netGuid () {}
|
||||
|
||||
netGuid ( u32 l, u16 w1, u16 w2,
|
||||
u8 b1, u8 b2, u8 b3, u8 b4, u8 b5, u8 b6, u8 b7, u8 b8 )
|
||||
{
|
||||
//store in network format (big-endian)
|
||||
data[0] = u8(l>>24);
|
||||
data[1] = u8(l>>16);
|
||||
data[2] = u8(l>>8);
|
||||
data[3] = u8(l);
|
||||
data[4] = u8(w1>>8);
|
||||
data[5] = u8(w1);
|
||||
data[6] = u8(w2>>8);
|
||||
data[7] = u8(w2);
|
||||
data[8] = b1;
|
||||
data[9] = b2;
|
||||
data[10] = b3;
|
||||
data[11] = b4;
|
||||
data[12] = b5;
|
||||
data[13] = b6;
|
||||
data[14] = b7;
|
||||
data[15] = b8;
|
||||
}
|
||||
|
||||
bool operator ==( const netGuid& guid ) const
|
||||
{
|
||||
return memcmp ( data, guid.data, sizeof(data) ) == 0 ;
|
||||
}
|
||||
bool operator !=( const netGuid& guid ) const
|
||||
{
|
||||
return memcmp ( data, guid.data, sizeof(data) ) != 0 ;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
class netMessage : public netBuffer
|
||||
{
|
||||
int pos ;
|
||||
|
||||
void seek ( int new_pos ) const
|
||||
{
|
||||
if ( new_pos < 0 )
|
||||
new_pos = 0 ;
|
||||
else if ( new_pos > length )
|
||||
new_pos = length ;
|
||||
|
||||
//logical const-ness
|
||||
((netMessage*)this) -> pos = new_pos ;
|
||||
}
|
||||
void skip ( int off ) const
|
||||
{
|
||||
seek(pos+off);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// incoming message; header is already there
|
||||
netMessage ( const char* s, int n ) : netBuffer(n)
|
||||
{
|
||||
assert ( n >= 5 ) ;
|
||||
append(s,n);
|
||||
pos = 5 ; // seek past header
|
||||
}
|
||||
|
||||
// outgoing message
|
||||
netMessage ( int type, int to_id, int from_id=0, int n=256 ) : netBuffer(n)
|
||||
{
|
||||
// output header
|
||||
putw ( 0 ) ; //msg_len
|
||||
putbyte ( type ) ;
|
||||
putbyte ( to_id ) ;
|
||||
putbyte ( from_id ) ;
|
||||
}
|
||||
|
||||
int getType () const { return ( (u8*)data )[ 2 ] ; }
|
||||
int getToID () const { return ( (u8*)data )[ 3 ] ; }
|
||||
int getFromID () const { return ( (u8*)data )[ 4 ] ; }
|
||||
void setFromID ( int from_id ) { ( (u8*)data )[ 4 ] = (u8)from_id; }
|
||||
|
||||
void geta ( void* a, int n ) const
|
||||
{
|
||||
assert (pos>=0 && pos<length && (pos+n)<=length) ;
|
||||
//if (pos>=0 && pos<length && (pos+n)<=length)
|
||||
{
|
||||
memcpy(a,&data[pos],n) ;
|
||||
seek(pos+n);
|
||||
}
|
||||
}
|
||||
void puta ( const void* a, int n )
|
||||
{
|
||||
append((const char*)a,n);
|
||||
pos = length;
|
||||
*((u16*)data) = u16(length); //update msg_len
|
||||
}
|
||||
|
||||
int getbyte () const
|
||||
{
|
||||
u8 temp ;
|
||||
geta(&temp,sizeof(temp)) ;
|
||||
return temp ;
|
||||
}
|
||||
void putbyte ( int c )
|
||||
{
|
||||
u8 temp = c ;
|
||||
puta(&temp,sizeof(temp)) ;
|
||||
}
|
||||
|
||||
bool getb () const
|
||||
{
|
||||
u8 temp ;
|
||||
geta(&temp,sizeof(temp)) ;
|
||||
return temp != 0 ;
|
||||
}
|
||||
void putb ( bool b )
|
||||
{
|
||||
u8 temp = b? 1: 0 ;
|
||||
puta(&temp,sizeof(temp)) ;
|
||||
}
|
||||
|
||||
int getw () const
|
||||
{
|
||||
u16 temp ;
|
||||
geta ( &temp, sizeof(temp) ) ;
|
||||
return int ( ntohs ( temp ) ) ;
|
||||
}
|
||||
void putw ( int i )
|
||||
{
|
||||
u16 temp = htons ( u16(i) ) ;
|
||||
puta ( &temp, sizeof(temp) ) ;
|
||||
}
|
||||
|
||||
int geti () const
|
||||
{
|
||||
u32 temp ;
|
||||
geta ( &temp, sizeof(temp) ) ;
|
||||
return int ( ntohl ( temp ) ) ;
|
||||
}
|
||||
void puti ( int i )
|
||||
{
|
||||
u32 temp = htonl ( u32(i) ) ;
|
||||
puta ( &temp, sizeof(temp) ) ;
|
||||
}
|
||||
|
||||
void getfv ( f32* fv, int n ) const
|
||||
{
|
||||
u32* v = (u32*)fv;
|
||||
geta ( v, (n<<2) ) ;
|
||||
for ( int i=0; i<n; i++ )
|
||||
v[i] = ntohl ( v[i] ) ;
|
||||
}
|
||||
void putfv ( const f32* fv, int n )
|
||||
{
|
||||
const u32* v = (const u32*)fv;
|
||||
for ( int i=0; i<n; i++ )
|
||||
{
|
||||
u32 temp = htonl ( v[i] ) ;
|
||||
puta ( &temp, sizeof(temp) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
f32 getf () const
|
||||
{
|
||||
u32 temp ;
|
||||
geta ( &temp, sizeof(temp) ) ;
|
||||
temp = ntohl ( temp ) ;
|
||||
return *((f32*)&temp) ;
|
||||
}
|
||||
void putf ( f32 f )
|
||||
{
|
||||
u32 temp = *((u32*)&f) ;
|
||||
temp = htonl ( temp ) ;
|
||||
puta ( &temp, sizeof(temp) ) ;
|
||||
}
|
||||
|
||||
void gets ( char* s, int n ) const
|
||||
{
|
||||
char* src = &data[pos];
|
||||
char* dst = s;
|
||||
while (pos<length)
|
||||
{
|
||||
char ch = *src++;
|
||||
if ((dst-s)<(n-1))
|
||||
*dst++ = ch ;
|
||||
((netMessage*)this)->pos++;
|
||||
if (ch==0)
|
||||
break;
|
||||
}
|
||||
*dst = 0 ;
|
||||
}
|
||||
void puts ( const char* s )
|
||||
{
|
||||
puta(s,strlen(s)+1);
|
||||
}
|
||||
|
||||
void print ( FILE *fd = stderr ) const
|
||||
{
|
||||
fprintf ( fd, "netMessage: %p, length=%d\n", this, length ) ;
|
||||
fprintf ( fd, " header (type,to,from) = (%d,%d,%d)\n",
|
||||
getType(), getToID(), getFromID() ) ;
|
||||
fprintf ( fd, " data = " ) ;
|
||||
for ( int i=0; i<length; i++ )
|
||||
fprintf ( fd, "%02x ", data[i] ) ;
|
||||
fprintf ( fd, "\n" ) ;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class netMessageChannel : public netBufferChannel
|
||||
{
|
||||
virtual void handleBufferRead (netBuffer& buffer) ;
|
||||
|
||||
public:
|
||||
|
||||
bool sendMessage ( const netMessage& msg )
|
||||
{
|
||||
return bufferSend ( msg.getData(), msg.getLength() ) ;
|
||||
}
|
||||
|
||||
virtual void handleMessage ( const netMessage& msg ) {}
|
||||
};
|
||||
|
||||
|
||||
#endif //__NET_MESSAGE__
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "netMonitor.h"
|
||||
|
||||
|
||||
class netMonitorChannel : public netChat
|
||||
{
|
||||
netMonitorServer* server ;
|
||||
bool authorized ;
|
||||
netBuffer buffer;
|
||||
|
||||
void prompt () ;
|
||||
|
||||
virtual void collectIncomingData (const char* s, int n) ;
|
||||
virtual void foundTerminator (void) ;
|
||||
|
||||
public:
|
||||
|
||||
netMonitorChannel ( netMonitorServer* server ) ;
|
||||
|
||||
virtual void handleClose (void)
|
||||
{
|
||||
ulSetError(UL_DEBUG, "%d: Client disconnected.",getHandle());
|
||||
shouldDelete () ;
|
||||
netChat::handleClose () ;
|
||||
server -> active = 0 ;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
// for now, we ignore any telnet option stuff sent to
|
||||
// us, and we process the backspace key ourselves.
|
||||
// gee, it would be fun to write a full-blown line-editing
|
||||
// environment, etc...
|
||||
|
||||
static void clean_line (char* line)
|
||||
{
|
||||
char* dst = line ;
|
||||
for ( char* src = line ; *src ; src ++ )
|
||||
{
|
||||
char ch = *src ;
|
||||
if (ch==8 || ch==127)
|
||||
{
|
||||
// backspace
|
||||
if (dst != line)
|
||||
dst -- ;
|
||||
}
|
||||
else if (ch<127)
|
||||
{
|
||||
*dst++ = *src ;
|
||||
}
|
||||
}
|
||||
*dst = 0 ;
|
||||
}
|
||||
|
||||
|
||||
netMonitorChannel::netMonitorChannel ( netMonitorServer* _server ) : buffer(512)
|
||||
{
|
||||
server = _server ;
|
||||
setTerminator("\r\n");
|
||||
|
||||
if ( server -> password && server -> password [0] != 0 )
|
||||
{
|
||||
authorized = false ;
|
||||
push ("Enter password: ") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
authorized = true ;
|
||||
push ( netFormat("Connected to \"%s\"... Welcome!\r\n", server -> name ) ) ;
|
||||
prompt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void netMonitorChannel::prompt ()
|
||||
{
|
||||
push ( server -> prompt ) ;
|
||||
}
|
||||
|
||||
|
||||
void netMonitorChannel::collectIncomingData (const char* s, int n)
|
||||
{
|
||||
if ( !buffer.append(s,n) )
|
||||
{
|
||||
// denial of service.
|
||||
push ("BCNU\r\n");
|
||||
closeWhenDone();
|
||||
}
|
||||
}
|
||||
|
||||
void netMonitorChannel::foundTerminator (void)
|
||||
{
|
||||
char* line = buffer.getData();
|
||||
clean_line ( line ) ;
|
||||
|
||||
if (!authorized)
|
||||
{
|
||||
if (strcmp(line,server -> password) == 0)
|
||||
{
|
||||
authorized = true ;
|
||||
push ( netFormat("Connected to \"%s\"... Welcome!\r\n",server -> name) ) ;
|
||||
prompt () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
else if (*line == 0)
|
||||
{
|
||||
prompt();
|
||||
}
|
||||
else if (*line == 4 || strcmp(line,"exit") == 0)
|
||||
{
|
||||
push ("BCNU\r\n"); //Be seein' you
|
||||
closeWhenDone();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( server -> cmdfunc )
|
||||
{
|
||||
server -> cmdfunc ( line ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ulSetError(UL_DEBUG,"echo: %s",line);
|
||||
|
||||
push(line);
|
||||
push(getTerminator());
|
||||
}
|
||||
|
||||
prompt();
|
||||
}
|
||||
buffer.remove();
|
||||
}
|
||||
|
||||
|
||||
void netMonitorServer::handleAccept (void)
|
||||
{
|
||||
if ( !active )
|
||||
{
|
||||
netAddress addr ;
|
||||
int s = accept ( &addr ) ;
|
||||
|
||||
ulSetError(UL_DEBUG, "%d: Client %s:%d connected",s,addr.getHost(),addr.getPort());
|
||||
|
||||
active = new netMonitorChannel ( this ) ;
|
||||
active -> setHandle (s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool netMonitorServer::push (const char* s)
|
||||
{
|
||||
if ( active )
|
||||
return active -> push ( s ) ;
|
||||
return false ;
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* netMonitor - network monitor server
|
||||
*
|
||||
* DESCRIPTION
|
||||
* netMonitor is a telnet command port with
|
||||
* password authorization. It can be paired
|
||||
* with and used to remotely admin another server.
|
||||
*
|
||||
* AUTHORS
|
||||
* Sam Rushing <rushing@nightmare.com> - original version for Medusa
|
||||
* Dave McClurg <dpm@efn.org> - modified for use in PLIB
|
||||
*
|
||||
* CREATION DATE
|
||||
* Dec-2000
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NET_MONITOR_H
|
||||
#define NET_MONITOR_H
|
||||
|
||||
#include "netChat.h"
|
||||
|
||||
|
||||
class netMonitorServer : private netChannel
|
||||
{
|
||||
char* name ;
|
||||
char* password ;
|
||||
char* prompt ;
|
||||
void (*cmdfunc)(cchar*) ;
|
||||
class netMonitorChannel* active ;
|
||||
|
||||
friend class netMonitorChannel ;
|
||||
|
||||
virtual bool writable (void) { return false ; }
|
||||
virtual void handleAccept (void) ;
|
||||
|
||||
public:
|
||||
|
||||
netMonitorServer( cchar* _name, int port )
|
||||
{
|
||||
name = ulStrDup(_name);
|
||||
password = ulStrDup("") ;
|
||||
prompt = ulStrDup(">>> ");
|
||||
cmdfunc = 0 ;
|
||||
active = 0 ;
|
||||
|
||||
open () ;
|
||||
bind ("", port);
|
||||
listen (1);
|
||||
|
||||
ulSetError(UL_DEBUG, "Monitor \"%s\" started on port %d",name,port);
|
||||
}
|
||||
|
||||
~netMonitorServer()
|
||||
{
|
||||
delete[] name ;
|
||||
delete[] password ;
|
||||
delete[] prompt ;
|
||||
}
|
||||
|
||||
cchar* getPassword () const { return password; }
|
||||
void setPassword ( cchar* string )
|
||||
{
|
||||
delete[] password ;
|
||||
password = ulStrDup ( string?string:"" ) ;
|
||||
}
|
||||
|
||||
void setPrompt ( cchar* string )
|
||||
{
|
||||
delete[] prompt ;
|
||||
prompt = ulStrDup ( string?string:"" ) ;
|
||||
}
|
||||
|
||||
void setCommandFunc ( void (*func)(cchar*) )
|
||||
{
|
||||
cmdfunc = func ;
|
||||
}
|
||||
|
||||
bool push (const char* s) ;
|
||||
} ;
|
||||
|
||||
#endif // NET_MONITOR_H
|
||||
@@ -1,446 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "netSocket.h"
|
||||
|
||||
#if defined(__CYGWIN__) || !defined (WIN32)
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h> /* Need both for Mandrake 8.0!! */
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <winsock.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(socklen_t)
|
||||
#define socklen_t int
|
||||
#endif
|
||||
|
||||
/* Paul Wiltsey says we need this for Solaris 2.8 */
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE ((unsigned long)-1)
|
||||
#endif
|
||||
|
||||
netAddress::netAddress ( cchar* host, int port )
|
||||
{
|
||||
set ( host, port ) ;
|
||||
}
|
||||
|
||||
|
||||
void netAddress::set ( cchar* host, int port )
|
||||
{
|
||||
memset(this, 0, sizeof(netAddress));
|
||||
|
||||
sin_family = AF_INET ;
|
||||
sin_port = htons (port);
|
||||
|
||||
/* Convert a string specifying a host name or one of a few symbolic
|
||||
** names to a numeric IP address. This usually calls gethostbyname()
|
||||
** to do the work; the names "" and "<broadcast>" are special.
|
||||
*/
|
||||
|
||||
if (host[0] == '\0') {
|
||||
sin_addr = INADDR_ANY;
|
||||
}
|
||||
if (host[0] == '<' && strcmp(host, "<broadcast>") == 0) {
|
||||
sin_addr = INADDR_BROADCAST;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
int d1, d2, d3, d4;
|
||||
char ch;
|
||||
if (sscanf(host, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 &&
|
||||
0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 &&
|
||||
0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) {
|
||||
sin_addr = htonl(
|
||||
((long) d1 << 24) | ((long) d2 << 16) |
|
||||
((long) d3 << 8) | ((long) d4 << 0));
|
||||
}
|
||||
else //let's try gethostbyname()
|
||||
#else
|
||||
sin_addr = inet_addr(host);
|
||||
if ( sin_addr == INADDR_NONE )
|
||||
#endif
|
||||
{
|
||||
struct hostent *hp = gethostbyname(host);
|
||||
if (hp != NULL)
|
||||
{
|
||||
memcpy((char *) &sin_addr, hp->h_addr, hp->h_length);
|
||||
}
|
||||
else //failure
|
||||
{
|
||||
sin_addr = INADDR_ANY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Create a string object representing an IP address.
|
||||
This is always a string of the form 'dd.dd.dd.dd' (with variable
|
||||
size numbers). */
|
||||
|
||||
cchar* netAddress::getHost () const
|
||||
{
|
||||
#if 0
|
||||
cchar* buf = inet_ntoa ( sin_addr ) ;
|
||||
#else
|
||||
static char buf [32];
|
||||
long x = ntohl(sin_addr);
|
||||
sprintf(buf, "%d.%d.%d.%d",
|
||||
(int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
|
||||
(int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff );
|
||||
#endif
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
int netAddress::getPort() const
|
||||
{
|
||||
return ntohs(sin_port);
|
||||
}
|
||||
|
||||
cchar* netAddress::getLocalHost ()
|
||||
{
|
||||
//gethostbyname(gethostname())
|
||||
|
||||
char buf[256];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
gethostname(buf, sizeof(buf)-1);
|
||||
const hostent *hp = gethostbyname(buf);
|
||||
if (hp && *hp->h_addr_list)
|
||||
{
|
||||
in_addr addr = *((in_addr*)*hp->h_addr_list);
|
||||
cchar* host = inet_ntoa(addr);
|
||||
if ( host )
|
||||
return host ;
|
||||
}
|
||||
return "127.0.0.1" ;
|
||||
}
|
||||
|
||||
bool netAddress::getBroadcast () const {
|
||||
return sin_addr == INADDR_BROADCAST;
|
||||
}
|
||||
|
||||
netSocket::netSocket ()
|
||||
{
|
||||
handle = -1 ;
|
||||
}
|
||||
|
||||
netSocket::~netSocket ()
|
||||
{
|
||||
close () ;
|
||||
}
|
||||
|
||||
void netSocket::setHandle (int _handle)
|
||||
{
|
||||
close () ;
|
||||
handle = _handle ;
|
||||
}
|
||||
|
||||
bool
|
||||
netSocket::open ( bool stream )
|
||||
{
|
||||
close () ;
|
||||
handle = ::socket ( AF_INET, (stream? SOCK_STREAM: SOCK_DGRAM), 0 ) ;
|
||||
return (handle != -1);
|
||||
}
|
||||
|
||||
void
|
||||
netSocket::setBlocking ( bool blocking )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
|
||||
#if defined(__CYGWIN__) || !defined (WIN32)
|
||||
|
||||
int delay_flag = ::fcntl (handle, F_GETFL, 0);
|
||||
if (blocking)
|
||||
delay_flag &= (~O_NDELAY);
|
||||
else
|
||||
delay_flag |= O_NDELAY;
|
||||
::fcntl (handle, F_SETFL, delay_flag);
|
||||
|
||||
#else
|
||||
|
||||
u_long nblocking = blocking? 0: 1;
|
||||
::ioctlsocket(handle, FIONBIO, &nblocking);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
netSocket::setBroadcast ( bool broadcast )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
int result;
|
||||
if ( broadcast ) {
|
||||
int one = 1;
|
||||
#ifdef WIN32
|
||||
result = ::setsockopt( handle, SOL_SOCKET, SO_BROADCAST, (char*)&one, sizeof(one) );
|
||||
#else
|
||||
result = ::setsockopt( handle, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one) );
|
||||
#endif
|
||||
} else {
|
||||
result = ::setsockopt( handle, SOL_SOCKET, SO_BROADCAST, NULL, 0 );
|
||||
}
|
||||
if ( result < 0 ) {
|
||||
perror("set broadcast:");
|
||||
}
|
||||
assert ( result != -1 );
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::bind ( cchar* host, int port )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
netAddress addr ( host, port ) ;
|
||||
return ::bind(handle,(const sockaddr*)&addr,sizeof(netAddress));
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::listen ( int backlog )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
return ::listen(handle,backlog);
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::accept ( netAddress* addr )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
socklen_t addr_len = (socklen_t) sizeof(netAddress) ;
|
||||
return ::accept(handle,(sockaddr*)addr,&addr_len);
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::connect ( cchar* host, int port )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
netAddress addr ( host, port ) ;
|
||||
if ( addr.getBroadcast() ) {
|
||||
setBroadcast( true );
|
||||
}
|
||||
return ::connect(handle,(const sockaddr*)&addr,sizeof(netAddress));
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::send (const void * buffer, int size, int flags)
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
return ::send (handle, (cchar*)buffer, size, flags);
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::sendto ( const void * buffer, int size, int flags, const netAddress* to )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
return ::sendto(handle,(cchar*)buffer,size,flags,(const sockaddr*)to,sizeof(netAddress));
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::recv (void * buffer, int size, int flags)
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
return ::recv (handle, (char*)buffer, size, flags);
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::recvfrom ( void * buffer, int size, int flags, netAddress* from )
|
||||
{
|
||||
assert ( handle != -1 ) ;
|
||||
socklen_t fromlen = (socklen_t) sizeof(netAddress) ;
|
||||
return ::recvfrom(handle,(char*)buffer,size,flags,(sockaddr*)from,&fromlen);
|
||||
}
|
||||
|
||||
void
|
||||
netSocket::close (void)
|
||||
{
|
||||
if ( handle != -1 )
|
||||
{
|
||||
#if defined(__CYGWIN__) || !defined (WIN32)
|
||||
::close( handle );
|
||||
#else
|
||||
::closesocket( handle );
|
||||
#endif
|
||||
handle = -1 ;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
netSocket::isNonBlockingError ()
|
||||
{
|
||||
#if defined(__CYGWIN__) || !defined (WIN32)
|
||||
switch (errno) {
|
||||
case EWOULDBLOCK: // always == NET_EAGAIN?
|
||||
case EALREADY:
|
||||
case EINPROGRESS:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
int wsa_errno = WSAGetLastError();
|
||||
if ( wsa_errno != 0 )
|
||||
{
|
||||
WSASetLastError(0);
|
||||
ulSetError(UL_WARNING,"WSAGetLastError() => %d",wsa_errno);
|
||||
switch (wsa_errno) {
|
||||
case WSAEWOULDBLOCK: // always == NET_EAGAIN?
|
||||
case WSAEALREADY:
|
||||
case WSAEINPROGRESS:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
netSocket::select ( netSocket** reads, netSocket** writes, int timeout )
|
||||
{
|
||||
fd_set r,w;
|
||||
|
||||
FD_ZERO (&r);
|
||||
FD_ZERO (&w);
|
||||
|
||||
int i, k ;
|
||||
int num = 0 ;
|
||||
|
||||
for ( i=0; reads[i]; i++ )
|
||||
{
|
||||
int fd = reads[i]->getHandle();
|
||||
FD_SET (fd, &r);
|
||||
num++;
|
||||
}
|
||||
|
||||
for ( i=0; writes[i]; i++ )
|
||||
{
|
||||
int fd = writes[i]->getHandle();
|
||||
FD_SET (fd, &w);
|
||||
num++;
|
||||
}
|
||||
|
||||
if (!num)
|
||||
return num ;
|
||||
|
||||
/* Set up the timeout */
|
||||
struct timeval tv ;
|
||||
tv.tv_sec = timeout/1000;
|
||||
tv.tv_usec = (timeout%1000)*1000;
|
||||
|
||||
// It bothers me that select()'s first argument does not appear to
|
||||
// work as advertised... [it hangs like this if called with
|
||||
// anything less than FD_SETSIZE, which seems wasteful?]
|
||||
|
||||
// Note: we ignore the 'exception' fd_set - I have never had a
|
||||
// need to use it. The name is somewhat misleading - the only
|
||||
// thing I have ever seen it used for is to detect urgent data -
|
||||
// which is an unportable feature anyway.
|
||||
|
||||
::select (FD_SETSIZE, &r, &w, 0, &tv);
|
||||
|
||||
//remove sockets that had no activity
|
||||
|
||||
num = 0 ;
|
||||
|
||||
for ( k=i=0; reads[i]; i++ )
|
||||
{
|
||||
int fd = reads[i]->getHandle();
|
||||
if (FD_ISSET (fd, &r)) {
|
||||
reads[k++] = reads[i];
|
||||
num++;
|
||||
}
|
||||
}
|
||||
reads[k] = NULL ;
|
||||
|
||||
for ( k=i=0; writes[i]; i++ )
|
||||
{
|
||||
int fd = writes[i]->getHandle();
|
||||
if (FD_ISSET (fd, &w)) {
|
||||
writes[k++] = writes[i];
|
||||
num++;
|
||||
}
|
||||
}
|
||||
writes[k] = NULL ;
|
||||
|
||||
return num ;
|
||||
}
|
||||
|
||||
/* Init/Exit functions */
|
||||
static void netExit ( void )
|
||||
{
|
||||
#if defined(__CYGWIN__) || !defined (WIN32)
|
||||
#else
|
||||
/* Clean up windows networking */
|
||||
if ( WSACleanup() == SOCKET_ERROR ) {
|
||||
if ( WSAGetLastError() == WSAEINPROGRESS ) {
|
||||
WSACancelBlockingCall();
|
||||
WSACleanup();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int netInit ( int* argc, char** argv )
|
||||
{
|
||||
assert ( sizeof(sockaddr_in) == sizeof(netAddress) ) ;
|
||||
|
||||
#if defined(__CYGWIN__) || !defined (WIN32)
|
||||
#else
|
||||
/* Start up the windows networking */
|
||||
WORD version_wanted = MAKEWORD(1,1);
|
||||
WSADATA wsaData;
|
||||
|
||||
if ( WSAStartup(version_wanted, &wsaData) != 0 ) {
|
||||
ulSetError(UL_WARNING,"Couldn't initialize Winsock 1.1");
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
atexit( netExit ) ;
|
||||
return(0);
|
||||
}
|
||||
|
||||
cchar* netFormat ( cchar* format, ... )
|
||||
{
|
||||
static char buffer[ 256 ];
|
||||
va_list argptr;
|
||||
va_start(argptr, format);
|
||||
vsprintf( buffer, format, argptr );
|
||||
va_end(argptr);
|
||||
return( buffer );
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* netSocket - network sockets
|
||||
*
|
||||
* DESCRIPTION
|
||||
* netSocket is a thin C++ wrapper over bsd sockets to
|
||||
* facilitate porting to other platforms
|
||||
*
|
||||
* AUTHOR
|
||||
* Dave McClurg <dpm@efn.org>
|
||||
*
|
||||
* CREATION DATE
|
||||
* Dec-2000
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef NET_SOCKET_H
|
||||
#define NET_SOCKET_H
|
||||
|
||||
|
||||
#include "ul.h"
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/*
|
||||
* Define Basic types
|
||||
*/
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed int s32;
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
|
||||
typedef const char cchar;
|
||||
typedef const void cvoid;
|
||||
|
||||
|
||||
/*
|
||||
* Socket address, internet style.
|
||||
*/
|
||||
class netAddress
|
||||
{
|
||||
s16 sin_family;
|
||||
u16 sin_port;
|
||||
u32 sin_addr;
|
||||
char sin_zero[8];
|
||||
|
||||
public:
|
||||
netAddress () {}
|
||||
netAddress ( cchar* host, int port ) ;
|
||||
|
||||
void set ( cchar* host, int port ) ;
|
||||
cchar* getHost () const ;
|
||||
int getPort() const ;
|
||||
|
||||
static cchar* getLocalHost () ;
|
||||
|
||||
bool getBroadcast () const ;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Socket type
|
||||
*/
|
||||
class netSocket
|
||||
{
|
||||
int handle ;
|
||||
|
||||
public:
|
||||
|
||||
netSocket () ;
|
||||
virtual ~netSocket () ;
|
||||
|
||||
int getHandle () const { return handle; }
|
||||
void setHandle (int handle) ;
|
||||
|
||||
bool open ( bool stream=true ) ;
|
||||
void close ( void ) ;
|
||||
int bind ( cchar* host, int port ) ;
|
||||
int listen ( int backlog ) ;
|
||||
int accept ( netAddress* addr ) ;
|
||||
int connect ( cchar* host, int port ) ;
|
||||
int send ( const void * buffer, int size, int flags = 0 ) ;
|
||||
int sendto ( const void * buffer, int size, int flags, const netAddress* to ) ;
|
||||
int recv ( void * buffer, int size, int flags = 0 ) ;
|
||||
int recvfrom ( void * buffer, int size, int flags, netAddress* from ) ;
|
||||
|
||||
void setBlocking ( bool blocking ) ;
|
||||
void setBroadcast ( bool broadcast ) ;
|
||||
|
||||
static bool isNonBlockingError () ;
|
||||
static int select ( netSocket** reads, netSocket** writes, int timeout ) ;
|
||||
} ;
|
||||
|
||||
|
||||
int netInit ( int* argc = NULL, char** argv = NULL ) ;
|
||||
cchar* netFormat ( cchar* fmt, ... ) ;
|
||||
|
||||
|
||||
#endif // NET_SOCKET_H
|
||||
@@ -1,25 +0,0 @@
|
||||
if BUILD_PUI
|
||||
|
||||
lib_LIBRARIES = libplibpu.a
|
||||
|
||||
include_HEADERS = pu.h
|
||||
|
||||
libplibpu_a_SOURCES = \
|
||||
pu.cxx puBox.cxx puButton.cxx puButtonBox.cxx \
|
||||
puArrowButton.cxx puDialogBox.cxx puFrame.cxx puGroup.cxx \
|
||||
puInput.cxx puInterface.cxx puLocal.h puMenuBar.cxx \
|
||||
puObject.cxx puOneShot.cxx puPopup.cxx puPopupMenu.cxx \
|
||||
puFilePicker.cxx puListBox.cxx puSlider.cxx puText.cxx \
|
||||
puValue.cxx puFont.cxx puBiSlider.cxx puTriSlider.cxx \
|
||||
puDial.cxx puVerticalMenu.cxx puLargeInput.cxx \
|
||||
puFileSelector.cxx puComboBox.cxx puSelectBox.cxx puRange.cxx \
|
||||
puSpinBox.cxx puScrollBar.cxx
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/sg -I$(top_srcdir)/src/fnt
|
||||
INCLUDES += -I$(top_srcdir)/src/util
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = pui.dsp
|
||||
|
||||
|
||||
@@ -1,390 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
VERSION = @VERSION@
|
||||
|
||||
@BUILD_PUI_TRUE@lib_LIBRARIES = libplibpu.a
|
||||
|
||||
@BUILD_PUI_TRUE@include_HEADERS = pu.h
|
||||
|
||||
@BUILD_PUI_TRUE@libplibpu_a_SOURCES = pu.cxx puBox.cxx puButton.cxx puButtonBox.cxx puArrowButton.cxx puDialogBox.cxx puFrame.cxx puGroup.cxx puInput.cxx puInterface.cxx puLocal.h puMenuBar.cxx puObject.cxx puOneShot.cxx puPopup.cxx puPopupMenu.cxx puFilePicker.cxx puListBox.cxx puSlider.cxx puText.cxx puValue.cxx puFont.cxx puBiSlider.cxx puTriSlider.cxx puDial.cxx puVerticalMenu.cxx puLargeInput.cxx puFileSelector.cxx puComboBox.cxx puSelectBox.cxx puRange.cxx puSpinBox.cxx puScrollBar.cxx
|
||||
@BUILD_PUI_TRUE@INCLUDES = -I$(top_srcdir)/src/sg -I$(top_srcdir)/src/fnt -I$(top_srcdir)/src/util
|
||||
|
||||
EXTRA_DIST = pui.dsp
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(lib_LIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
X_CFLAGS = @X_CFLAGS@
|
||||
X_LIBS = @X_LIBS@
|
||||
X_EXTRA_LIBS = @X_EXTRA_LIBS@
|
||||
X_PRE_LIBS = @X_PRE_LIBS@
|
||||
libplibpu_a_LIBADD =
|
||||
@BUILD_PUI_TRUE@libplibpu_a_OBJECTS = pu.o puBox.o puButton.o \
|
||||
@BUILD_PUI_TRUE@puButtonBox.o puArrowButton.o puDialogBox.o puFrame.o \
|
||||
@BUILD_PUI_TRUE@puGroup.o puInput.o puInterface.o puMenuBar.o \
|
||||
@BUILD_PUI_TRUE@puObject.o puOneShot.o puPopup.o puPopupMenu.o \
|
||||
@BUILD_PUI_TRUE@puFilePicker.o puListBox.o puSlider.o puText.o \
|
||||
@BUILD_PUI_TRUE@puValue.o puFont.o puBiSlider.o puTriSlider.o puDial.o \
|
||||
@BUILD_PUI_TRUE@puVerticalMenu.o puLargeInput.o puFileSelector.o \
|
||||
@BUILD_PUI_TRUE@puComboBox.o puSelectBox.o puRange.o puSpinBox.o \
|
||||
@BUILD_PUI_TRUE@puScrollBar.o
|
||||
AR = ar
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
HEADERS = $(include_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(libplibpu_a_SOURCES)
|
||||
OBJECTS = $(libplibpu_a_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .cxx .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/pui/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-libLIBRARIES:
|
||||
|
||||
clean-libLIBRARIES:
|
||||
-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
|
||||
|
||||
distclean-libLIBRARIES:
|
||||
|
||||
maintainer-clean-libLIBRARIES:
|
||||
|
||||
install-libLIBRARIES: $(lib_LIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
@$(POST_INSTALL)
|
||||
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||
done
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
libplibpu.a: $(libplibpu_a_OBJECTS) $(libplibpu_a_DEPENDENCIES)
|
||||
-rm -f libplibpu.a
|
||||
$(AR) cru libplibpu.a $(libplibpu_a_OBJECTS) $(libplibpu_a_LIBADD)
|
||||
$(RANLIB) libplibpu.a
|
||||
.cxx.o:
|
||||
$(CXXCOMPILE) -c $<
|
||||
|
||||
install-includeHEADERS: $(include_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(includedir)
|
||||
@list='$(include_HEADERS)'; for p in $$list; do \
|
||||
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
|
||||
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
|
||||
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
uninstall-includeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(include_HEADERS)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$p; \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = src/pui
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
pu.o: pu.cxx puLocal.h pu.h ../../src/fnt/fnt.h ../../src/sg/sg.h \
|
||||
../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puArrowButton.o: puArrowButton.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puBiSlider.o: puBiSlider.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puBox.o: puBox.cxx puLocal.h pu.h ../../src/fnt/fnt.h ../../src/sg/sg.h \
|
||||
../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puButton.o: puButton.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puButtonBox.o: puButtonBox.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puComboBox.o: puComboBox.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puDial.o: puDial.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puDialogBox.o: puDialogBox.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puFilePicker.o: puFilePicker.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puFileSelector.o: puFileSelector.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puFont.o: puFont.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puFrame.o: puFrame.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puGroup.o: puGroup.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puInput.o: puInput.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puInterface.o: puInterface.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puLargeInput.o: puLargeInput.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puListBox.o: puListBox.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puMenuBar.o: puMenuBar.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puObject.o: puObject.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puOneShot.o: puOneShot.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puPopup.o: puPopup.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puPopupMenu.o: puPopupMenu.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puRange.o: puRange.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puScrollBar.o: puScrollBar.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puSelectBox.o: puSelectBox.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puSlider.o: puSlider.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puSpinBox.o: puSpinBox.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puText.o: puText.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puTriSlider.o: puTriSlider.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puValue.o: puValue.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
puVerticalMenu.o: puVerticalMenu.cxx puLocal.h pu.h ../../src/fnt/fnt.h \
|
||||
../../src/sg/sg.h ../../src/util/ul.h ../../src/util/ulRTTI.h
|
||||
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am: install-libLIBRARIES
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am: install-includeHEADERS
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am: uninstall-libLIBRARIES uninstall-includeHEADERS
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LIBRARIES) $(HEADERS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-libLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-libLIBRARIES clean-compile clean-tags clean-generic \
|
||||
mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-libLIBRARIES distclean-compile distclean-tags \
|
||||
distclean-generic clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-libLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-libLIBRARIES distclean-libLIBRARIES \
|
||||
clean-libLIBRARIES maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
|
||||
install-libLIBRARIES mostlyclean-compile distclean-compile \
|
||||
clean-compile maintainer-clean-compile uninstall-includeHEADERS \
|
||||
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
|
||||
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,489 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
#ifndef WIN32
|
||||
# if defined(macintosh)
|
||||
# include <agl.h>
|
||||
# elif defined(__APPLE__)
|
||||
# include <OpenGL/CGLCurrent.h>
|
||||
# else
|
||||
# include <GL/glx.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int puRefresh = TRUE ;
|
||||
|
||||
static int puWindowWidth = 400 ;
|
||||
static int puWindowHeight = 400 ;
|
||||
|
||||
static int openGLSize = 0 ;
|
||||
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
|
||||
int puGetWindow ( void ) { return 0 ; }
|
||||
void puSetWindow ( int w ) {}
|
||||
int puGetWindowHeight ( void ) { return puWindowHeight ; }
|
||||
int puGetWindowWidth ( void ) { return puWindowWidth ; }
|
||||
|
||||
void puSetWindowSize ( int width, int height )
|
||||
{
|
||||
puWindowWidth = width ;
|
||||
puWindowHeight = height ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
void puSetResizeMode ( int mode ) {
|
||||
openGLSize = mode ;
|
||||
}
|
||||
|
||||
|
||||
int puGetWindow ( void )
|
||||
{
|
||||
return glutGetWindow () ;
|
||||
}
|
||||
|
||||
|
||||
void puSetWindow ( int w ) { glutSetWindow ( w ) ; }
|
||||
|
||||
int puGetWindowHeight ( void )
|
||||
{
|
||||
if ( ! openGLSize )
|
||||
return glutGet ( (GLenum) GLUT_WINDOW_HEIGHT ) ;
|
||||
else
|
||||
return puWindowHeight ;
|
||||
}
|
||||
|
||||
|
||||
int puGetWindowWidth ( void )
|
||||
{
|
||||
if ( ! openGLSize )
|
||||
return glutGet ( (GLenum) GLUT_WINDOW_WIDTH ) ;
|
||||
else
|
||||
return puWindowWidth ;
|
||||
}
|
||||
|
||||
|
||||
void puSetWindowSize ( int width, int height )
|
||||
{
|
||||
if ( ! openGLSize )
|
||||
ulSetError ( UL_WARNING, "PUI: puSetWindowSize shouldn't be used with GLUT." ) ;
|
||||
else
|
||||
{
|
||||
glutReshapeWindow ( width, height ) ;
|
||||
puWindowWidth = width ;
|
||||
puWindowHeight = height ;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
puColour _puDefaultColourTable[] =
|
||||
{
|
||||
{ 0.5f, 0.5f, 0.5f, 1.0f }, /* PUCOL_FOREGROUND */
|
||||
{ 0.3f, 0.3f, 0.3f, 1.0f }, /* PUCOL_BACKGROUND */
|
||||
{ 0.7f, 0.7f, 0.7f, 1.0f }, /* PUCOL_HIGHLIGHT */
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f }, /* PUCOL_LABEL */
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f }, /* PUCOL_LEGEND */
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f } /* PUCOL_MISC */
|
||||
} ;
|
||||
|
||||
|
||||
static bool glIsValidContext ( void )
|
||||
{
|
||||
#if defined(CONSOLE)
|
||||
return true ;
|
||||
#elif defined(WIN32)
|
||||
return ( wglGetCurrentContext () != NULL ) ;
|
||||
#elif defined(macintosh)
|
||||
return ( aglGetCurrentContext () != NULL ) ;
|
||||
#elif defined(__APPLE__)
|
||||
return ( CGLGetCurrentContext () != NULL ) ;
|
||||
#else
|
||||
return ( glXGetCurrentContext () != NULL ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int _puCursor_enable = FALSE ;
|
||||
static int _puCursor_x = 0 ;
|
||||
static int _puCursor_y = 0 ;
|
||||
static float _puCursor_bgcolour [4] = { 1.0f, 1.0f, 1.0f, 1.0f } ;
|
||||
static float _puCursor_fgcolour [4] = { 0.0f, 0.0f, 0.0f, 1.0f } ;
|
||||
|
||||
void puHideCursor ( void ) { _puCursor_enable = FALSE ; }
|
||||
void puShowCursor ( void ) { _puCursor_enable = TRUE ; }
|
||||
int puCursorIsHidden ( void ) { return ! _puCursor_enable ; }
|
||||
|
||||
void puCursor ( int x, int y )
|
||||
{
|
||||
_puCursor_x = x ;
|
||||
_puCursor_y = y ;
|
||||
}
|
||||
|
||||
|
||||
static void puDrawCursor ( int x, int y )
|
||||
{
|
||||
glColor4fv ( _puCursor_bgcolour ) ;
|
||||
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( x, y ) ;
|
||||
glVertex2i ( x + 13, y - 4 ) ;
|
||||
glVertex2i ( x + 4, y - 13 ) ;
|
||||
|
||||
glVertex2i ( x + 8, y - 3 ) ;
|
||||
glVertex2i ( x + 17, y - 12 ) ;
|
||||
glVertex2i ( x + 12, y - 17 ) ;
|
||||
|
||||
glVertex2i ( x + 12, y - 17 ) ;
|
||||
glVertex2i ( x + 3, y - 8 ) ;
|
||||
glVertex2i ( x + 8, y - 3 ) ;
|
||||
glEnd () ;
|
||||
|
||||
glColor4fv ( _puCursor_fgcolour ) ;
|
||||
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( x+1, y-1 ) ;
|
||||
glVertex2i ( x + 11, y - 4 ) ;
|
||||
glVertex2i ( x + 4, y - 11 ) ;
|
||||
|
||||
glVertex2i ( x + 8, y - 5 ) ;
|
||||
glVertex2i ( x + 15, y - 12 ) ;
|
||||
glVertex2i ( x + 12, y - 15 ) ;
|
||||
|
||||
glVertex2i ( x + 12, y - 15 ) ;
|
||||
glVertex2i ( x + 5, y - 8 ) ;
|
||||
glVertex2i ( x + 8, y - 5 ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
|
||||
// Pointer to linked list of objects to delete
|
||||
// as a result of keyboarding or mouse clicking
|
||||
|
||||
static puObject *objects_to_delete = NULL;
|
||||
|
||||
|
||||
void puDeleteObject ( puObject *ob )
|
||||
{
|
||||
if ( ob == NULL )
|
||||
return ;
|
||||
|
||||
puGroup *parent = ob->getParent () ;
|
||||
|
||||
if ( !ob->IsItSubWidget() )
|
||||
{
|
||||
/* Add object to linked list to be deleted */
|
||||
if ( objects_to_delete == NULL )
|
||||
objects_to_delete = ob ;
|
||||
else
|
||||
{
|
||||
/* Ensure that objects are deleted in the order of puDeleteObject calls */
|
||||
|
||||
puObject *last ;
|
||||
|
||||
for ( last = objects_to_delete ;
|
||||
last -> getNextObject() != NULL ;
|
||||
last = last -> getNextObject() )
|
||||
/* Find last object. */ ;
|
||||
|
||||
last -> setNextObject ( ob ) ;
|
||||
}
|
||||
/* Remove from parent interface */
|
||||
|
||||
if ( parent != ob && parent != NULL )
|
||||
parent -> remove ( ob ) ; /* Sets object's next and previous pointers to null as well */
|
||||
|
||||
/* If it is a group, then delete all child objects as well */
|
||||
if ( ob->getType () & PUCLASS_GROUP )
|
||||
{
|
||||
puObject *child = ((puGroup *)ob)->getFirstChild () ;
|
||||
while ( child )
|
||||
{
|
||||
puObject *next = child->getNextObject () ;
|
||||
puDeleteObject ( child ) ;
|
||||
child = next ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void puCleanUpJunk ( void )
|
||||
{
|
||||
puObject * local_objects_to_delete = objects_to_delete ;
|
||||
objects_to_delete = NULL ;
|
||||
/* Step through the linked list of objects to delete, removing them. */
|
||||
while ( local_objects_to_delete != NULL )
|
||||
{
|
||||
puObject *next_ob = local_objects_to_delete -> getNextObject() ;
|
||||
delete local_objects_to_delete ;
|
||||
local_objects_to_delete = next_ob ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static puObject *active_widget ; /* Widget which is currently receiving user input */
|
||||
static char *input_paste_buffer ; /* Cut/Copy/Paste buffer for input widgets */
|
||||
|
||||
void puInit ( void )
|
||||
{
|
||||
static int firsttime = TRUE ;
|
||||
|
||||
if ( firsttime )
|
||||
{
|
||||
if ( ! glIsValidContext () )
|
||||
{
|
||||
ulSetError ( UL_FATAL,
|
||||
"puInit called without a valid OpenGL context.");
|
||||
}
|
||||
|
||||
new puInterface ( 0, 0 ) ;
|
||||
|
||||
active_widget = NULL ;
|
||||
input_paste_buffer = NULL ;
|
||||
|
||||
firsttime = FALSE ;
|
||||
#ifdef PU_NOT_USING_GLUT
|
||||
|
||||
// No GLUT fonts, try some corresponding textured fonts
|
||||
|
||||
if ( ( PUFONT_TXF_TYPEWRITER.load ( "Courier.txf" ) == FALSE ) |
|
||||
( PUFONT_TXF_TIMES.load ( "Times-Roman.txf" ) == FALSE ) |
|
||||
( PUFONT_TXF_HELVETICA.load ( "Helvetica.txf" ) == FALSE ) )
|
||||
{
|
||||
// Exit
|
||||
ulSetError ( UL_FATAL, "PUI: Could not load default fonts." ) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void puSetOpenGLState ( void )
|
||||
{
|
||||
int w = puGetWindowWidth () ;
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
if ( ! openGLSize )
|
||||
glPushAttrib ( GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
|
||||
else
|
||||
glPushAttrib ( GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
|
||||
|
||||
glDisable ( GL_LIGHTING ) ;
|
||||
glDisable ( GL_FOG ) ;
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
glDisable ( GL_DEPTH_TEST ) ;
|
||||
glDisable ( GL_CULL_FACE ) ;
|
||||
|
||||
if ( ! openGLSize )
|
||||
glViewport ( 0, 0, w, h ) ;
|
||||
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
glOrtho ( 0, w, 0, h, -1, 1 ) ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPushMatrix () ;
|
||||
glLoadIdentity () ;
|
||||
}
|
||||
|
||||
static void puRestoreOpenGLState ( void )
|
||||
{
|
||||
glMatrixMode ( GL_PROJECTION ) ;
|
||||
glPopMatrix () ;
|
||||
glMatrixMode ( GL_MODELVIEW ) ;
|
||||
glPopMatrix () ;
|
||||
glPopAttrib () ;
|
||||
}
|
||||
|
||||
|
||||
void puDisplay ( void )
|
||||
{
|
||||
puCleanUpJunk () ;
|
||||
|
||||
puSetOpenGLState () ;
|
||||
puGetUltimateLiveInterface () -> draw ( 0, 0 ) ;
|
||||
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
if ( _puCursor_enable )
|
||||
puDrawCursor ( _puCursor_x,
|
||||
h - _puCursor_y ) ;
|
||||
|
||||
puRestoreOpenGLState () ;
|
||||
|
||||
puRefresh = FALSE ;
|
||||
}
|
||||
|
||||
|
||||
void puDisplay ( int window_number ) /* Deprecated */
|
||||
{
|
||||
if ( window_number == puGetWindow () )
|
||||
puDisplay () ;
|
||||
}
|
||||
|
||||
|
||||
int puKeyboard ( int key, int updown )
|
||||
{
|
||||
int return_value = puGetBaseLiveInterface () -> checkKey ( key, updown ) ;
|
||||
|
||||
puCleanUpJunk () ;
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
|
||||
static int last_buttons = 0 ;
|
||||
static int pu_mouse_x = 0 ;
|
||||
static int pu_mouse_y = 0 ;
|
||||
static int pu_mouse_offset_x = 0 ;
|
||||
static int pu_mouse_offset_y = 0 ;
|
||||
|
||||
int puGetPressedButton ()
|
||||
{
|
||||
return last_buttons ;
|
||||
}
|
||||
|
||||
int puMouse ( int button, int updown, int x, int y )
|
||||
{
|
||||
puCursor ( x, y ) ;
|
||||
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
if ( updown == PU_DOWN )
|
||||
last_buttons |= ( 1 << button ) ;
|
||||
else
|
||||
last_buttons &= ~( 1 << button ) ;
|
||||
|
||||
pu_mouse_x = x ;
|
||||
pu_mouse_y = h - y ;
|
||||
int return_value = puGetBaseLiveInterface () -> checkHit ( button,
|
||||
updown, pu_mouse_x, pu_mouse_y ) ;
|
||||
|
||||
puCleanUpJunk () ;
|
||||
|
||||
puObject *active = puActiveWidget () ;
|
||||
|
||||
if ( ( last_buttons == 0 ) && ( active != NULL ) )
|
||||
{
|
||||
int x_offset, y_offset ;
|
||||
active -> getAbsolutePosition ( &x_offset, &y_offset ) ;
|
||||
|
||||
x_offset -= active -> getABox () -> min [0] ;
|
||||
y_offset -= active -> getABox () -> min [1] ;
|
||||
|
||||
if ( ! active -> isHit ( pu_mouse_x - x_offset, pu_mouse_y - y_offset ) )
|
||||
{
|
||||
active -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
|
||||
int puMouse ( int x, int y )
|
||||
{
|
||||
puCursor ( x, y ) ;
|
||||
|
||||
int button =
|
||||
(last_buttons & (1<<PU_LEFT_BUTTON )) ? PU_LEFT_BUTTON :
|
||||
(last_buttons & (1<<PU_MIDDLE_BUTTON)) ? PU_MIDDLE_BUTTON :
|
||||
(last_buttons & (1<<PU_RIGHT_BUTTON )) ? PU_RIGHT_BUTTON : PU_NOBUTTON ;
|
||||
|
||||
int h = puGetWindowHeight () ;
|
||||
|
||||
pu_mouse_x = x ;
|
||||
pu_mouse_y = h - y ;
|
||||
|
||||
/*
|
||||
When you drag over an ACTIVE widget, you don't
|
||||
affect any other widgets until you release the
|
||||
mouse button.
|
||||
*/
|
||||
if ( puActiveWidget () )
|
||||
{
|
||||
puActiveWidget()->doHit(button, PU_DRAG, pu_mouse_x - pu_mouse_offset_x,
|
||||
pu_mouse_y - pu_mouse_offset_y) ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
int return_value = puGetBaseLiveInterface () -> checkHit ( button,
|
||||
PU_DRAG, pu_mouse_x, pu_mouse_y ) ;
|
||||
|
||||
puCleanUpJunk () ;
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
void puMoveToLast (puObject *ob)
|
||||
{
|
||||
puGroup *parent = ob -> getParent () ;
|
||||
|
||||
/* If no parent interface, return. */
|
||||
|
||||
if ( ! parent ) return;
|
||||
|
||||
/* Remove "ob" from present place in the "dlist" list */
|
||||
|
||||
parent -> remove (ob) ;
|
||||
|
||||
/* Place at the end of the list */
|
||||
|
||||
parent -> add (ob) ;
|
||||
|
||||
/*
|
||||
Now repeat the process for the parent interface so that the interface will
|
||||
be drawn last of all interfaces.
|
||||
*/
|
||||
|
||||
puMoveToLast ( parent );
|
||||
}
|
||||
|
||||
void puDeactivateWidget ( void ) { active_widget = NULL ; }
|
||||
void puSetActiveWidget ( puObject *w, int x, int y )
|
||||
{
|
||||
active_widget = w ;
|
||||
pu_mouse_offset_x = pu_mouse_x - x ;
|
||||
pu_mouse_offset_y = pu_mouse_y - y ;
|
||||
}
|
||||
|
||||
puObject *puActiveWidget ( void ) { return active_widget ; }
|
||||
|
||||
void puSetPasteBuffer ( char *ch )
|
||||
{
|
||||
delete [] input_paste_buffer ;
|
||||
input_paste_buffer = new char [ strlen(ch) + 1 ] ;
|
||||
strcpy ( input_paste_buffer, ch ) ;
|
||||
}
|
||||
|
||||
char *puGetPasteBuffer ( void ) { return input_paste_buffer ; }
|
||||
|
||||
int puNeedRefresh ( void ) { return puRefresh ; }
|
||||
void puPostRefresh ( void ) { puRefresh = TRUE ; }
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puArrowButton,puButton)
|
||||
|
||||
|
||||
void puDrawArrowButtonTriangle ( int pos_x, int pos_y, int size_x, int size_y,
|
||||
puColour colour, int arrow_type, int active )
|
||||
{
|
||||
/*
|
||||
If greyed out then halve the opacity when drawing
|
||||
the widget
|
||||
*/
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour ) ;
|
||||
else
|
||||
glColor4f ( colour [0],
|
||||
colour [1],
|
||||
colour [2],
|
||||
colour [3] / 2.0f ) ; // 50% more transparent
|
||||
|
||||
switch ( arrow_type )
|
||||
{
|
||||
case PUARROW_UP :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x , pos_y + size_y/4 ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y - size_y/4 ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
case PUARROW_DOWN :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y + size_y/4 ) ;
|
||||
glVertex2i ( pos_x , pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y + size_y/4 ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
case PUARROW_FASTUP :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x , pos_y ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y - size_y/4 ) ;
|
||||
|
||||
glVertex2i ( pos_x - size_x/4, pos_y ) ;
|
||||
glVertex2i ( pos_x , pos_y + size_y/4 ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
case PUARROW_FASTDOWN :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y + size_y/4 ) ;
|
||||
glVertex2i ( pos_x , pos_y ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y + size_y/4 ) ;
|
||||
|
||||
glVertex2i ( pos_x - size_x/4, pos_y ) ;
|
||||
glVertex2i ( pos_x , pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
case PUARROW_LEFT :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y + size_y/4 ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
case PUARROW_RIGHT :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y + size_y/4 ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
case PUARROW_FASTLEFT :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x , pos_y ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y + size_y/4 ) ;
|
||||
|
||||
glVertex2i ( pos_x , pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y ) ;
|
||||
glVertex2i ( pos_x , pos_y + size_y/4 ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
case PUARROW_FASTRIGHT :
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x , pos_y ) ;
|
||||
glVertex2i ( pos_x - size_x/4, pos_y + size_y/4 ) ;
|
||||
|
||||
glVertex2i ( pos_x , pos_y - size_y/4 ) ;
|
||||
glVertex2i ( pos_x + size_x/4, pos_y ) ;
|
||||
glVertex2i ( pos_x , pos_y + size_y/4 ) ;
|
||||
glEnd () ;
|
||||
break;
|
||||
|
||||
default :
|
||||
ulSetError ( UL_WARNING, "PUI: Unrecognised 'arrow_type' %d", arrow_type ) ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void puArrowButton::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
/*
|
||||
If arrow button is pushed or highlighted -
|
||||
use inverse style for button itself
|
||||
*/
|
||||
|
||||
if ( getIntegerValue() ^ highlighted )
|
||||
{
|
||||
if ( parent && ( ( parent->getType() & PUCLASS_POPUPMENU ) ||
|
||||
( parent->getType() & PUCLASS_MENUBAR ) ) )
|
||||
abox.draw ( dx, dy, PUSTYLE_SMALL_SHADED, colour, isReturnDefault(), 2 ) ;
|
||||
else
|
||||
abox.draw ( dx, dy, -style, colour, isReturnDefault(), border_thickness ) ;
|
||||
}
|
||||
else
|
||||
abox.draw ( dx, dy, style, colour, isReturnDefault(), border_thickness ) ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
int size_x = abox.max[0] - abox.min[0] ;
|
||||
int size_y = abox.max[1] - abox.min[1] ;
|
||||
|
||||
int pos_x = dx + ( abox.max[0] + abox.min[0] ) / 2 ;
|
||||
int pos_y = dy + ( abox.max[1] + abox.min[1] ) / 2 ;
|
||||
|
||||
puDrawArrowButtonTriangle ( pos_x, pos_y, size_x, size_y, colour [ PUCOL_MISC ], arrow_type, active ) ;
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puBiSlider,puSlider)
|
||||
|
||||
|
||||
void puBiSlider::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
// Draw the slider box itself
|
||||
|
||||
if ( ( style == PUSTYLE_BEVELLED ) ||
|
||||
( style == PUSTYLE_SHADED ) )
|
||||
abox.draw ( dx, dy, -PUSTYLE_BOXED, colour, FALSE, 2 ) ;
|
||||
else
|
||||
abox.draw ( dx, dy, -style, colour, FALSE, border_thickness ) ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
// Draw the current_max slider and label it
|
||||
|
||||
float val ;
|
||||
|
||||
if ( getMaxValue() > getMinValue() )
|
||||
val = (float)(getCurrentMax() - getMinValue()) / (float)(getMaxValue() - getMinValue()) ;
|
||||
else
|
||||
val = 1.0f ;
|
||||
|
||||
char str_value[10] ;
|
||||
sprintf (str_value, "%g", getCurrentMax() ) ;
|
||||
|
||||
draw_slider_box ( dx, dy, abox, val, str_value ) ;
|
||||
|
||||
// Draw the current_min slider and label it
|
||||
|
||||
if ( getMaxValue() > getMinValue() )
|
||||
val = (float)(getCurrentMin() - getMinValue()) / (float)(getMaxValue() - getMinValue()) ;
|
||||
else
|
||||
val = 0.0f ;
|
||||
|
||||
sprintf (str_value, "%g", getCurrentMin() ) ;
|
||||
|
||||
draw_slider_box ( dx, dy, abox, val, str_value ) ;
|
||||
|
||||
draw_legend ( dx, dy ) ;
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puBiSlider::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
puMoveToLast ( this );
|
||||
|
||||
if ( button == PU_LEFT_BUTTON && updown == PU_UP )
|
||||
{
|
||||
setActiveButton ( 0 ) ;
|
||||
puDeactivateWidget () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
int sd = isVertical() ;
|
||||
int sz = abox.max [sd] - abox.min [sd] ;
|
||||
int coord = isVertical() ? y : x ;
|
||||
|
||||
float next_value ;
|
||||
|
||||
if ( sz == 0 )
|
||||
next_value = 0.5f ;
|
||||
else
|
||||
{
|
||||
next_value = ( (float)coord - (float)abox.min[sd] - (float)sz * slider_fraction / 2.0f ) /
|
||||
( (float) sz * (1.0f - slider_fraction) ) ;
|
||||
}
|
||||
|
||||
next_value = (next_value < 0.0f) ? 0.0f : (next_value > 1.0) ? 1.0f : next_value ;
|
||||
|
||||
float new_value = getMinValue() + next_value * ( getMaxValue() - getMinValue() ) ;
|
||||
|
||||
if ( ( getActiveButton() == 0 ) || ( updown == PU_DOWN ) ) // No currently-active slider, set whichever is closest
|
||||
{
|
||||
if ( (new_value-getCurrentMin()) < (getCurrentMax()-new_value) ) // Closest to current_min
|
||||
{
|
||||
setCurrentMin ( checkStep(new_value) ) ;
|
||||
setActiveButton ( 1 ) ;
|
||||
}
|
||||
else // Closest to current_max
|
||||
{
|
||||
setCurrentMax ( checkStep(new_value) ) ;
|
||||
setActiveButton ( 2 ) ;
|
||||
}
|
||||
}
|
||||
else if ( getActiveButton() == 1 ) // Currently moving current_min
|
||||
{
|
||||
setCurrentMin ( checkStep(new_value) ) ;
|
||||
if ( getCurrentMax() < getCurrentMin() ) setCurrentMax ( getCurrentMin() ) ;
|
||||
}
|
||||
else if ( getActiveButton() == 2 ) // Currently moving current_max
|
||||
{
|
||||
setCurrentMax ( checkStep(new_value) ) ;
|
||||
if ( getCurrentMax() < getCurrentMin() ) setCurrentMin ( getCurrentMax() ) ;
|
||||
}
|
||||
|
||||
|
||||
switch ( cb_mode )
|
||||
{
|
||||
case PUSLIDER_CLICK :
|
||||
if ( updown == active_mouse_edge )
|
||||
{
|
||||
last_cb_value = next_value ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_DELTA :/* Deprecated! */
|
||||
if ( fabs ( last_cb_value - next_value ) >= cb_delta )
|
||||
{
|
||||
last_cb_value = next_value ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_ALWAYS :
|
||||
default :
|
||||
last_cb_value = next_value ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
#define PU_DFLT_OFFSET 8
|
||||
|
||||
void puBox::extend ( puBox *bx )
|
||||
{
|
||||
if ( bx -> isEmpty () ) return ;
|
||||
|
||||
if ( min[0]>bx->min[0] ) min[0] = bx->min[0] ;
|
||||
if ( min[1]>bx->min[1] ) min[1] = bx->min[1] ;
|
||||
if ( max[0]<bx->max[0] ) max[0] = bx->max[0] ;
|
||||
if ( max[1]<bx->max[1] ) max[1] = bx->max[1] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void puBox::draw ( int dx, int dy, int style, puColour colour[], int am_default, int border )
|
||||
{
|
||||
int mid = PUCOL_FOREGROUND ;
|
||||
int hi = PUCOL_HIGHLIGHT ;
|
||||
int lo = PUCOL_BACKGROUND ;
|
||||
|
||||
/* Colour assignments */
|
||||
|
||||
switch ( style )
|
||||
{
|
||||
case PUSTYLE_NONE :
|
||||
return ;
|
||||
|
||||
case PUSTYLE_PLAIN :
|
||||
case PUSTYLE_DROPSHADOW :
|
||||
mid = PUCOL_FOREGROUND ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_SMALL_SHADED :
|
||||
case PUSTYLE_SHADED :
|
||||
case PUSTYLE_SMALL_BEVELLED :
|
||||
case PUSTYLE_BEVELLED :
|
||||
case PUSTYLE_BOXED :
|
||||
case PUSTYLE_SPECIAL_UNDERLINED :
|
||||
mid = PUCOL_FOREGROUND ;
|
||||
hi = PUCOL_HIGHLIGHT ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_RADIO :
|
||||
hi = PUCOL_HIGHLIGHT ;
|
||||
lo = PUCOL_LEGEND ;
|
||||
break ;
|
||||
|
||||
case -PUSTYLE_RADIO :
|
||||
hi = PUCOL_HIGHLIGHT ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case -PUSTYLE_PLAIN :
|
||||
case -PUSTYLE_DROPSHADOW :
|
||||
mid = PUCOL_HIGHLIGHT ;
|
||||
lo = PUCOL_BACKGROUND ;
|
||||
break ;
|
||||
|
||||
case -PUSTYLE_SMALL_BEVELLED :
|
||||
case -PUSTYLE_BEVELLED :
|
||||
case -PUSTYLE_SMALL_SHADED :
|
||||
case -PUSTYLE_SHADED :
|
||||
case -PUSTYLE_BOXED :
|
||||
case -PUSTYLE_SPECIAL_UNDERLINED :
|
||||
mid = PUCOL_FOREGROUND ;
|
||||
hi = PUCOL_BACKGROUND ;
|
||||
lo = PUCOL_HIGHLIGHT ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
ulSetError ( UL_WARNING, "PUI: Unrecognised 'style' %d", style ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
switch ( abs(style) )
|
||||
{
|
||||
case PUSTYLE_PLAIN :
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_SMALL_BEVELLED :
|
||||
case PUSTYLE_SMALL_SHADED :
|
||||
case PUSTYLE_BEVELLED :
|
||||
case PUSTYLE_SHADED :
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + border, dy + min[1] + border ) ;
|
||||
glVertex2i ( dx + min[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + border, dy + max[1] - border ) ;
|
||||
glVertex2i ( dx + min[0], dy + max[1] ) ;
|
||||
glVertex2i ( dx + max[0] - border, dy + max[1] - border ) ;
|
||||
glVertex2i ( dx + max[0], dy + max[1] ) ;
|
||||
glEnd () ;
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + border, dy + min[1] + border ) ;
|
||||
glVertex2i ( dx + max[0], dy + min[1] ) ;
|
||||
glVertex2i ( dx + max[0] - border, dy + min[1] + border ) ;
|
||||
glVertex2i ( dx + max[0], dy + max[1] ) ;
|
||||
glVertex2i ( dx + max[0] - border, dy + max[1] - border ) ;
|
||||
glEnd () ;
|
||||
|
||||
if ( ( abs(style) == PUSTYLE_SMALL_BEVELLED ) ||
|
||||
( abs(style) == PUSTYLE_BEVELLED ) )
|
||||
{
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0] + border, dy + min[1] + border,
|
||||
dx + max[0] - border, dy + max[1] - border ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
glShadeModel ( GL_SMOOTH ) ;
|
||||
glBegin ( GL_POLYGON ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glVertex2i ( dx + min[0] + border, dy + min[1] + border ) ;
|
||||
if ( ( style == PUSTYLE_SMALL_SHADED ) ||
|
||||
( style == PUSTYLE_SHADED ) )
|
||||
glColor4f ( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
|
||||
colour [lo][3] ) ;
|
||||
else
|
||||
glColor4f ( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
|
||||
colour [hi][3] ) ;
|
||||
glVertex2i ( dx + min[0] + border, dy + max[1] - border ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glVertex2i ( dx + max[0] - border, dy + max[1] - border ) ;
|
||||
if ( ( style == -PUSTYLE_SMALL_SHADED ) ||
|
||||
( style == -PUSTYLE_SHADED ) )
|
||||
glColor4f ( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
|
||||
colour [lo][3] ) ;
|
||||
else
|
||||
glColor4f ( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
|
||||
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
|
||||
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
|
||||
colour [hi][3] ) ;
|
||||
glVertex2i ( dx + max[0] - border, dy + min[1] + border ) ;
|
||||
glEnd () ;
|
||||
glShadeModel (GL_FLAT) ;
|
||||
|
||||
if ( ( style == -PUSTYLE_SMALL_SHADED ) ||
|
||||
( style == -PUSTYLE_SHADED ) )
|
||||
{
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + border , dy + min[1] + border ) ;
|
||||
glVertex2i ( dx + min[0] + border/2 , dy + min[1] + border/2 ) ;
|
||||
glVertex2i ( dx + min[0] + border , dy + max[1] - border ) ;
|
||||
glVertex2i ( dx + min[0] + border/2 , dy + max[1] - border/2 ) ;
|
||||
glVertex2i ( dx + max[0] - border , dy + max[1] - border ) ;
|
||||
glVertex2i ( dx + max[0] - border/2 , dy + max[1] - border/2 ) ;
|
||||
glEnd () ;
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUAD_STRIP ) ;
|
||||
glVertex2i ( dx + min[0] + border/2 , dy + min[1] + border/2 ) ;
|
||||
glVertex2i ( dx + min[0] + border , dy + min[1] + border ) ;
|
||||
glVertex2i ( dx + max[0] - border/2 , dy + min[1] + border/2 ) ;
|
||||
glVertex2i ( dx + max[0] - border , dy + min[1] + border ) ;
|
||||
glVertex2i ( dx + max[0] - border/2 , dy + max[1] - border/2 ) ;
|
||||
glVertex2i ( dx + max[0] - border , dy + max[1] - border ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSTYLE_BOXED :
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0]+border, dy + min[1]+border,
|
||||
dx + max[0]-border, dy + max[1]-border ) ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_RADIO :
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glBegin ( GL_LINE_LOOP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE , dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] + PU_RADIO_BUTTON_SIZE ) ;
|
||||
glVertex2i ( dx + min[0] , dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glEnd () ;
|
||||
|
||||
if ( style < 0 )
|
||||
{
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glBegin ( GL_QUADS ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] + 2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE-2, dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glVertex2i ( dx + min[0] + PU_RADIO_BUTTON_SIZE/2, dy + min[1] + PU_RADIO_BUTTON_SIZE-2 ) ;
|
||||
glVertex2i ( dx + min[0] + 2 , dy + min[1] + PU_RADIO_BUTTON_SIZE/2 ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSTYLE_SPECIAL_UNDERLINED :
|
||||
glColor4fv ( colour [ hi ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + min[1]+border ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1]+border,
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_DROPSHADOW :
|
||||
glColor4fv ( colour [ lo ] ) ;
|
||||
glRecti ( dx + min[0] + border, dy + min[1] - border,
|
||||
dx + max[0] + border, dy + max[1] - border ) ;
|
||||
glColor4fv ( colour [ mid ] ) ;
|
||||
glRecti ( dx + min[0], dy + min[1],
|
||||
dx + max[0], dy + max[1] ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( am_default )
|
||||
{
|
||||
glColor4fv ( colour [ PUCOL_BACKGROUND ] ) ;
|
||||
glLineStipple ( 1, 0xF0F0 ) ;
|
||||
glEnable ( GL_LINE_STIPPLE ) ;
|
||||
glBegin ( GL_LINE_LOOP ) ;
|
||||
glVertex2i ( dx + min[0] + PU_DFLT_OFFSET, dy + min[1] + PU_DFLT_OFFSET ) ;
|
||||
glVertex2i ( dx + min[0] + PU_DFLT_OFFSET, dy + max[1] - PU_DFLT_OFFSET ) ;
|
||||
glVertex2i ( dx + max[0] - PU_DFLT_OFFSET, dy + max[1] - PU_DFLT_OFFSET ) ;
|
||||
glVertex2i ( dx + max[0] - PU_DFLT_OFFSET, dy + min[1] + PU_DFLT_OFFSET ) ;
|
||||
glEnd () ;
|
||||
glDisable ( GL_LINE_STIPPLE ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puButton,puObject)
|
||||
|
||||
|
||||
void puButton::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
if ( button_type == PUBUTTON_NORMAL )
|
||||
{
|
||||
/* If button is pushed or highlighted - use inverse style */
|
||||
|
||||
if ( getIntegerValue() ^ highlighted )
|
||||
{
|
||||
if ( parent && ( ( parent->getType() & PUCLASS_POPUPMENU ) ||
|
||||
( parent->getType() & PUCLASS_MENUBAR ) ) )
|
||||
abox.draw ( dx, dy, PUSTYLE_SMALL_SHADED, colour, isReturnDefault(), 2 ) ;
|
||||
else
|
||||
abox.draw ( dx, dy, -style, colour, isReturnDefault(), border_thickness ) ;
|
||||
}
|
||||
else
|
||||
abox.draw ( dx, dy, style, colour, isReturnDefault(), border_thickness ) ;
|
||||
}
|
||||
else if ( ( button_type == PUBUTTON_VCHECK ) ||
|
||||
( button_type == PUBUTTON_XCHECK ) )
|
||||
abox.draw ( dx, dy, PUSTYLE_BOXED, colour, isReturnDefault(), 1 ) ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
switch ( button_type )
|
||||
{
|
||||
case PUBUTTON_NORMAL :
|
||||
draw_legend ( dx, dy ) ;
|
||||
break ;
|
||||
|
||||
case PUBUTTON_RADIO :
|
||||
{
|
||||
int btn_width = abox.max[0] - abox.min[0],
|
||||
btn_height = abox.max[1] - abox.min[1] ;
|
||||
|
||||
glColor4fv ( ( getIntegerValue () ^ highlighted ) ?
|
||||
colour [ PUCOL_BACKGROUND ] : colour [ PUCOL_LEGEND ] ) ;
|
||||
|
||||
glBegin ( GL_LINE_LOOP ) ;
|
||||
glVertex2i ( dx+abox.min[0] + btn_width/2, dy+abox.min[1] ) ;
|
||||
glVertex2i ( dx+abox.min[0] + btn_width, dy+abox.min[1] + btn_height/2 ) ;
|
||||
glVertex2i ( dx+abox.min[0] + btn_width/2, dy+abox.min[1] + btn_height ) ;
|
||||
glVertex2i ( dx+abox.min[0], dy+abox.min[1] + btn_height/2 ) ;
|
||||
glEnd () ;
|
||||
|
||||
if ( getIntegerValue () ^ highlighted )
|
||||
{
|
||||
/* If greyed out then halve the opacity when drawing the widget */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_HIGHLIGHT ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_HIGHLIGHT ][0],
|
||||
colour [ PUCOL_HIGHLIGHT ][1],
|
||||
colour [ PUCOL_HIGHLIGHT ][2],
|
||||
colour [ PUCOL_HIGHLIGHT ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
glBegin ( GL_QUADS ) ;
|
||||
glVertex2i ( dx+abox.min[0] + btn_width/2,
|
||||
dy+abox.min[1] + 2 ) ;
|
||||
glVertex2i ( dx+abox.min[0] + btn_width - 2,
|
||||
dy+abox.min[1] + btn_height/2 ) ;
|
||||
glVertex2i ( dx+abox.min[0] + btn_width/2,
|
||||
dy+abox.min[1] + btn_height - 2 ) ;
|
||||
glVertex2i ( dx+abox.min[0] + 2,
|
||||
dy+abox.min[1] + btn_height/2 ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
break ;
|
||||
}
|
||||
|
||||
case PUBUTTON_CIRCLE :
|
||||
{
|
||||
float rad = ( (abox.max[0]-abox.min[0]) < (abox.max[1]-abox.min[1]) ) ?
|
||||
(abox.max[0]-abox.min[0])/2.0f : (abox.max[1]-abox.min[1])/2.0f ;
|
||||
float dtheta = 2.0f / rad ;
|
||||
float theta ;
|
||||
|
||||
/* Draw the outer circle */
|
||||
|
||||
glColor4fv ( colour [ PUCOL_FOREGROUND ] ) ;
|
||||
|
||||
glBegin ( GL_POLYGON ) ;
|
||||
for ( theta = -SG_PI ; theta <= SG_PI ; theta += dtheta )
|
||||
glVertex2f ( dx + abox.min[0] + rad + (rad * cos ( theta )),
|
||||
dy + abox.min[1] + rad + (rad * sin ( theta )) ) ;
|
||||
glEnd () ;
|
||||
|
||||
if ( getIntegerValue () ^ highlighted )
|
||||
/* If clicked, draw the inner circle with half the radius */
|
||||
{
|
||||
rad /= 2 ;
|
||||
dtheta = 2.0f / rad ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the widget */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_MISC ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_MISC ][0],
|
||||
colour [ PUCOL_MISC ][1],
|
||||
colour [ PUCOL_MISC ][2],
|
||||
colour [ PUCOL_MISC ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
glBegin ( GL_POLYGON ) ;
|
||||
for ( theta = -SG_PI ; theta <= SG_PI ; theta += dtheta )
|
||||
glVertex2f ( dx + abox.min[0] + rad*2 + (rad * cos ( theta )),
|
||||
dy + abox.min[1] + rad*2 + (rad * sin ( theta )) ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
break ;
|
||||
}
|
||||
|
||||
case PUBUTTON_VCHECK :
|
||||
case PUBUTTON_XCHECK :
|
||||
if ( getIntegerValue () ^ highlighted )
|
||||
{
|
||||
/* If greyed out then halve the opacity when drawing the widget */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_MISC ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_MISC ][0],
|
||||
colour [ PUCOL_MISC ][1],
|
||||
colour [ PUCOL_MISC ][2],
|
||||
colour [ PUCOL_MISC ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
glPushAttrib ( GL_LINE_BIT ) ;
|
||||
|
||||
glLineWidth ( 2.0f ) ;
|
||||
|
||||
if ( button_type == PUBUTTON_VCHECK )
|
||||
{
|
||||
glBegin ( GL_LINE_STRIP ) ;
|
||||
glVertex2i ( dx + abox.min[0],
|
||||
dy + abox.min[1] + (abox.max[1] - abox.min[1])/2 ) ;
|
||||
glVertex2i ( dx + abox.min[0] + (abox.max[0] - abox.min[0])/3,
|
||||
dy + abox.min[1] ) ;
|
||||
glVertex2i ( dx + abox.max[0],
|
||||
dy + abox.max[1] ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
else if ( button_type == PUBUTTON_XCHECK )
|
||||
{
|
||||
glBegin ( GL_LINES ) ;
|
||||
glVertex2i ( dx + abox.min[0] + 1, dy + abox.min[1] + 1 ) ;
|
||||
glVertex2i ( dx + abox.max[0] - 1, dy + abox.max[1] - 1 ) ;
|
||||
glVertex2i ( dx + abox.max[0] - 1, dy + abox.min[1] + 1 ) ;
|
||||
glVertex2i ( dx + abox.min[0] + 1, dy + abox.max[1] - 1 ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
|
||||
glPopAttrib () ;
|
||||
}
|
||||
|
||||
break ;
|
||||
|
||||
default :
|
||||
ulSetError ( UL_WARNING, "PUI: Unrecognised 'button_type' %d", button_type ) ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puButton::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
puMoveToLast ( this );
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
|
||||
{
|
||||
lowlight () ;
|
||||
setValue ( (int) ! getIntegerValue () ) ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
else
|
||||
highlight () ;
|
||||
}
|
||||
else
|
||||
lowlight () ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puButtonBox,puObject)
|
||||
|
||||
|
||||
puButtonBox::puButtonBox ( int minx, int miny, int maxx, int maxy,
|
||||
char **labels, int one_button ) :
|
||||
puObject ( minx, miny, maxx, maxy )
|
||||
{
|
||||
type |= PUCLASS_BUTTONBOX ;
|
||||
one_only = one_button ;
|
||||
|
||||
button_labels = labels ;
|
||||
|
||||
newList ( labels ) ;
|
||||
}
|
||||
|
||||
|
||||
void puButtonBox::newList ( char ** _list )
|
||||
{
|
||||
button_labels = _list ;
|
||||
|
||||
if ( button_labels == NULL )
|
||||
num_kids = 0 ;
|
||||
else
|
||||
for ( num_kids = 0 ; button_labels [ num_kids ] != NULL ; num_kids++ )
|
||||
/* Count number of items */ ;
|
||||
|
||||
puPostRefresh() ;
|
||||
}
|
||||
|
||||
|
||||
int puButtonBox::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( updown == PU_UP ||
|
||||
! isReturnDefault() ||
|
||||
( key != '\r' && key != '\n' ) || ( window != puGetWindow () ) )
|
||||
return FALSE ;
|
||||
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
int v = getIntegerValue () ;
|
||||
|
||||
if ( ! one_only )
|
||||
v = ~v ;
|
||||
else
|
||||
if ( ++v > num_kids )
|
||||
v = 0 ;
|
||||
|
||||
setValue ( v ) ;
|
||||
// puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
int puButtonBox::checkHit ( int /*button*/, int updown, int x, int y )
|
||||
{
|
||||
if ( ! isHit ( x, y ) ||
|
||||
( updown != active_mouse_edge &&
|
||||
active_mouse_edge != PU_UP_AND_DOWN ) )
|
||||
return FALSE ;
|
||||
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
puMoveToLast ( this );
|
||||
|
||||
int i = num_kids - 1 - (( y - abox.min[1] - PUSTR_BGAP ) * num_kids ) /
|
||||
( abox.max[1] - abox.min[1] - PUSTR_BGAP - PUSTR_TGAP ) ;
|
||||
|
||||
if ( i < 0 ) i = 0 ;
|
||||
if ( i >= num_kids ) i = num_kids - 1 ;
|
||||
|
||||
if ( one_only )
|
||||
setValue ( i ) ;
|
||||
else
|
||||
setValue ( getIntegerValue () ^ ( 1 << i ) ) ;
|
||||
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
void puButtonBox::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
abox.draw ( dx, dy, style, colour, isReturnDefault(), border_thickness ) ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
for ( int i = 0 ; i < num_kids ; i++ )
|
||||
{
|
||||
puBox tbox ;
|
||||
|
||||
tbox.min [ 0 ] = abox.min [ 0 ] + PUSTR_LGAP + PUSTR_LGAP ;
|
||||
tbox.min [ 1 ] = abox.min [ 1 ] + ((abox.max[1]-abox.min[1]-PUSTR_TGAP-PUSTR_BGAP)/num_kids) * (num_kids-1-i) ;
|
||||
tbox.max [ 0 ] = tbox.min [ 0 ] ;
|
||||
tbox.max [ 1 ] = tbox.min [ 1 ] ;
|
||||
|
||||
if (( one_only && i == getIntegerValue() ) ||
|
||||
( !one_only && ((1<<i) & getIntegerValue() ) != 0 ) )
|
||||
tbox.draw ( dx, dy + PUSTR_BGAP + PUSTR_BGAP, -PUSTYLE_RADIO, colour, FALSE, border_thickness ) ;
|
||||
else
|
||||
tbox.draw ( dx, dy + PUSTR_BGAP + PUSTR_BGAP, PUSTYLE_RADIO, colour, FALSE, border_thickness ) ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the label and legend */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
legendFont.drawString ( button_labels[i],
|
||||
dx + tbox.min[0] + PU_RADIO_BUTTON_SIZE + PUSTR_LGAP,
|
||||
dy + tbox.min[1] + legendFont.getStringDescender() + PUSTR_BGAP + PUSTR_BGAP) ;
|
||||
}
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,270 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puComboBox,puGroup)
|
||||
|
||||
|
||||
void puComboBox::input_down_cb ( puObject *inp )
|
||||
{
|
||||
puComboBox *cbox = (puComboBox *) inp -> getUserData () ;
|
||||
|
||||
cbox -> invokeCallback () ;
|
||||
}
|
||||
|
||||
void puComboBox::handle_arrow ( puObject *arrow )
|
||||
{
|
||||
puComboBox *cbox = (puComboBox *) arrow -> getUserData () ;
|
||||
|
||||
if ( ! cbox -> __getPopupMenu () -> isVisible () )
|
||||
cbox -> __getPopupMenu () -> reveal () ;
|
||||
else
|
||||
cbox -> __getPopupMenu () -> hide () ;
|
||||
|
||||
/* arrow -> setStyle ( - arrow -> getStyle () ) ; */
|
||||
}
|
||||
|
||||
void puComboBox::handle_popup ( puObject *popupm )
|
||||
{
|
||||
puComboBox *cbox = (puComboBox *) popupm -> getUserData () ;
|
||||
|
||||
cbox -> setCurrentItem ( popupm -> getLegend () ) ;
|
||||
}
|
||||
|
||||
|
||||
void puComboBox::update_widgets ( void )
|
||||
{
|
||||
if ( curr_item >= 0 )
|
||||
/* There are some items */
|
||||
{
|
||||
setValue ( list[curr_item] ) ;
|
||||
|
||||
arrow_btn -> activate () ;
|
||||
}
|
||||
else
|
||||
/* There aren't any items */
|
||||
{
|
||||
setValue ( "" ) ;
|
||||
|
||||
arrow_btn -> greyOut () ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void puComboBox::newList ( char ** _list )
|
||||
{
|
||||
list = _list ;
|
||||
|
||||
popup_menu -> empty () ;
|
||||
|
||||
if ( list == NULL )
|
||||
num_items = 0 ;
|
||||
else
|
||||
{
|
||||
for ( num_items = 0 ; list[num_items] != NULL ; num_items++ )
|
||||
/* Count number of items */ ;
|
||||
|
||||
if ( num_items > 0 )
|
||||
{
|
||||
int dummy, h ;
|
||||
int old_height = abox.max[1] - abox.min[1] ;
|
||||
int i ;
|
||||
|
||||
puPushGroup ( popup_menu ) ;
|
||||
|
||||
for ( i = (num_items - 1) ; i >= 0 ; i-- )
|
||||
{
|
||||
puObject *menu_item = popup_menu -> add_item ( list[i], handle_popup ) ;
|
||||
|
||||
menu_item -> setUserData ( this ) ;
|
||||
menu_item -> getSize ( &dummy, &h ) ;
|
||||
menu_item -> setSize ( abox.max[0] - abox.min[0], h ) ;
|
||||
}
|
||||
|
||||
popup_menu -> close() ;
|
||||
|
||||
/* Position popup menu correctly */
|
||||
|
||||
popup_menu -> getSize ( &dummy, &h ) ;
|
||||
|
||||
if ( (abox.min[1] - h) >= 0 )
|
||||
{
|
||||
popup_menu -> setPosition ( 0, 0 - h ) ;
|
||||
|
||||
arrow_btn -> setArrowType ( PUARROW_DOWN ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
popup_menu -> setPosition ( 0, old_height ) ;
|
||||
|
||||
arrow_btn -> setArrowType ( PUARROW_UP ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
curr_item = ( num_items > 0 ? 0 : - 1 ) ;
|
||||
update_widgets () ;
|
||||
}
|
||||
|
||||
int puComboBox::getCurrentItem ( void )
|
||||
{
|
||||
if ( num_items > 0 )
|
||||
{
|
||||
if ( strcmp ( list[curr_item], getStringValue() ) )
|
||||
/* The user typed in an arbitrary string.
|
||||
Let's see if it is one of our entries ... */
|
||||
{
|
||||
int i ;
|
||||
|
||||
for ( i = 0 ; i < num_items ; i++ )
|
||||
{
|
||||
if ( !strcmp ( list[i], getStringValue() ) )
|
||||
/* ... yes, it its ! */
|
||||
return i ;
|
||||
}
|
||||
|
||||
/* ... no, it isn't. */
|
||||
return -1 ;
|
||||
}
|
||||
}
|
||||
|
||||
return curr_item ;
|
||||
}
|
||||
|
||||
void puComboBox::setCurrentItem ( const char *item_ptr )
|
||||
{
|
||||
int i ;
|
||||
|
||||
for ( i = 0 ; i < num_items ; i++ )
|
||||
{
|
||||
if ( list[i] == item_ptr )
|
||||
{
|
||||
setCurrentItem ( i ) ;
|
||||
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void puComboBox::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
|
||||
puGroup::draw ( dx, dy ) ;
|
||||
}
|
||||
|
||||
int puComboBox::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( input -> checkHit ( button, updown, x-abox.min[0], y-abox.min[1] ) )
|
||||
{
|
||||
popup_menu -> hide () ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
else
|
||||
return puGroup::checkHit ( button, updown, x, y ) ;
|
||||
}
|
||||
|
||||
int puComboBox::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( ! input -> isAcceptingInput () || ! isVisible () || ! isActive () || ( window != puGetWindow () ) )
|
||||
return FALSE ;
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case PU_KEY_HOME :
|
||||
setCurrentItem ( 0 ) ;
|
||||
break ;
|
||||
|
||||
case PU_KEY_END :
|
||||
setCurrentItem ( num_items - 1 ) ;
|
||||
break ;
|
||||
|
||||
case PU_KEY_UP :
|
||||
setCurrentItem ( getCurrentItem () + 1 ) ;
|
||||
break ;
|
||||
|
||||
case PU_KEY_DOWN :
|
||||
setCurrentItem ( getCurrentItem () - 1 ) ;
|
||||
break ;
|
||||
|
||||
case PU_KEY_PAGE_UP :
|
||||
case PU_KEY_PAGE_DOWN :
|
||||
if ( ! popup_menu -> isVisible () )
|
||||
popup_menu -> reveal () ;
|
||||
else
|
||||
popup_menu -> hide () ;
|
||||
|
||||
break ;
|
||||
|
||||
default :
|
||||
return input -> checkKey ( key, updown ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
puComboBox::puComboBox ( int minx, int miny, int maxx, int maxy,
|
||||
char **entries, int editable ) :
|
||||
puGroup( minx, miny )
|
||||
{
|
||||
type |= PUCLASS_COMBOBOX ;
|
||||
|
||||
char *stringval ;
|
||||
int arrow_width = (int) ( (maxy-miny) / 1.5 ) ;
|
||||
|
||||
input = new puInput ( 0, 0, maxx-minx - arrow_width, maxy-miny ) ;
|
||||
input -> setUserData ( this ) ;
|
||||
input -> setDownCallback ( input_down_cb ) ;
|
||||
|
||||
input -> setStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
|
||||
if ( ! editable )
|
||||
input -> disableInput () ;
|
||||
|
||||
/* Share 'string' value with input box */
|
||||
input -> getValue ( &stringval ) ;
|
||||
setValuator ( stringval ) ;
|
||||
|
||||
arrow_btn = new puArrowButton ( maxx-minx - arrow_width, 0,
|
||||
maxx-minx, maxy-miny,
|
||||
PUARROW_DOWN ) ;
|
||||
arrow_btn -> setStyle ( PUSTYLE_SMALL_SHADED ) ;
|
||||
arrow_btn -> setUserData ( this ) ;
|
||||
arrow_btn -> setCallback ( handle_arrow ) ;
|
||||
|
||||
popup_menu = new puPopupMenu ( 0, 0 ) ;
|
||||
popup_menu -> close () ;
|
||||
|
||||
close () ;
|
||||
|
||||
newList ( entries ) ;
|
||||
}
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puDial,puRange)
|
||||
|
||||
|
||||
void puDial::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
// Draw the active box.
|
||||
|
||||
if ( ( style == PUSTYLE_BEVELLED ) ||
|
||||
( style == PUSTYLE_SHADED ) )
|
||||
abox.draw ( dx, dy, -PUSTYLE_BOXED, colour, FALSE, 2 ) ;
|
||||
else
|
||||
abox.draw ( dx, dy, -style, colour, FALSE, border_thickness ) ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
// If greyed out then halve the opacity when drawing the widget
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_MISC ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_MISC ][0],
|
||||
colour [ PUCOL_MISC ][1],
|
||||
colour [ PUCOL_MISC ][2],
|
||||
colour [ PUCOL_MISC ][3] / 2.0f ) ; // 50% more transparent
|
||||
|
||||
// Draw the surrounding circle.
|
||||
|
||||
float rad = (float)( abox.max [0] - abox.min [0] ) / 2.0f - 3.0f ;
|
||||
int x_cen = dx + ( abox.max [0] + abox.min [0] ) / 2 ;
|
||||
int y_cen = dy + ( abox.max [1] + abox.min [1] ) / 2 ;
|
||||
|
||||
float dtheta = 3.0f / rad ; // three pixels per segment
|
||||
|
||||
glPushAttrib ( GL_LINE_BIT ) ;
|
||||
|
||||
glLineWidth ( 2.0f ) ; // set line width to two pixels
|
||||
|
||||
glBegin ( GL_LINE_STRIP ) ;
|
||||
|
||||
float theta ;
|
||||
for ( theta = -SG_PI; theta < SG_PI+dtheta; theta+= dtheta )
|
||||
{
|
||||
float x = (float)x_cen + rad * (float)cos ( (double)theta ) ;
|
||||
float y = (float)y_cen + rad * (float)sin ( (double)theta ) ;
|
||||
|
||||
glVertex2f ( x, y ) ;
|
||||
}
|
||||
|
||||
glEnd () ;
|
||||
|
||||
// Draw the line from the center.
|
||||
|
||||
glLineWidth ( 4.0f ) ; // four pixels wide
|
||||
|
||||
float val ;
|
||||
getValue ( &val ) ;
|
||||
val = ( val - minimum_value) / (maximum_value - minimum_value) ;
|
||||
|
||||
if ( val < 0.0 ) val = 0.0 ;
|
||||
if ( val > 1.0 ) val = 1.0 ;
|
||||
|
||||
val = ( 2.0f * val - 1.0f ) * SG_PI ;
|
||||
|
||||
glBegin ( GL_LINES ) ;
|
||||
|
||||
glVertex2f ( (float)x_cen, (float)y_cen ) ;
|
||||
glVertex2f ( (float)x_cen + rad * (float)sin ( (double)val ), (float)y_cen + rad * (float)cos ( (double)val ) ) ;
|
||||
|
||||
glEnd () ;
|
||||
|
||||
glPopAttrib () ;
|
||||
|
||||
draw_legend ( dx, dy ) ;
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puDial::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
puMoveToLast ( this );
|
||||
|
||||
if ( button == PU_LEFT_BUTTON && updown == PU_UP )
|
||||
{
|
||||
puDeactivateWidget () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
int x_cen = ( abox.max [0] + abox.min [0] ) / 2 ;
|
||||
int y_cen = ( abox.max [1] + abox.min [1] ) / 2 ;
|
||||
float angle = (float)atan2 ( (double)(x-x_cen), (double)(y-y_cen) ) / SG_PI ;
|
||||
|
||||
// Move to within the (0,1) interval
|
||||
|
||||
if ( angle < -1.0f )
|
||||
angle += 2.0 ;
|
||||
else if (angle > 1.0f )
|
||||
angle -= 2.0 ;
|
||||
|
||||
angle = ( angle + 1.0f ) / 2.0f ;
|
||||
|
||||
// Check for hitting the limits (user has dragged the mouse around the bottom
|
||||
// of the widget)
|
||||
if ( !wrap )
|
||||
{
|
||||
if ( ( angle > 0.75 ) && ( getFloatValue () < 0.25 ) )
|
||||
angle = 0.0 ;
|
||||
else if ( ( angle < 0.25 ) && ( getFloatValue () > 0.75 ) )
|
||||
angle = 1.0 ;
|
||||
}
|
||||
|
||||
angle = angle * (maximum_value - minimum_value) + minimum_value ;
|
||||
setValue( checkStep(angle) ) ;
|
||||
|
||||
switch ( cb_mode )
|
||||
{
|
||||
case PUSLIDER_CLICK :
|
||||
if ( updown == active_mouse_edge )
|
||||
{
|
||||
last_cb_value = angle ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_DELTA :/* Deprecated! */
|
||||
if ( fabs ( last_cb_value - angle ) >= cb_delta )
|
||||
{
|
||||
last_cb_value = angle ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_ALWAYS :
|
||||
default :
|
||||
last_cb_value = angle ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puDialogBox,puPopup)
|
||||
|
||||
@@ -1,543 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* puFilePicker
|
||||
*
|
||||
* DESCRIPTION
|
||||
* PUI dialog for picking files
|
||||
*
|
||||
* AUTHOR
|
||||
* Dave McClurg <dpm@efn.org>
|
||||
*
|
||||
* CREATION DATE
|
||||
* August 2000
|
||||
*
|
||||
* MODIFICATION HISTORY
|
||||
* John Fay - many improvements
|
||||
* Steve Baker - Added functionality to allow directory tree traversal
|
||||
****/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puFilePicker,puDialogBox)
|
||||
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
#define DOTDOTSLASH "..\\"
|
||||
#define SLASH "\\"
|
||||
#else
|
||||
#define DOTDOTSLASH "../"
|
||||
#define SLASH "/"
|
||||
#endif
|
||||
|
||||
static void puFilePickerHandleSlider ( puObject * slider )
|
||||
{
|
||||
float val ;
|
||||
slider -> getValue ( &val ) ;
|
||||
val = 1.0f - val ;
|
||||
|
||||
puListBox* list_box = (puListBox*) slider -> getUserData () ;
|
||||
int idx = int ( list_box -> getNumItems () * val ) ;
|
||||
list_box -> setTopItem ( idx ) ;
|
||||
}
|
||||
|
||||
static void puFilePickerHandleArrow ( puObject *arrow )
|
||||
{
|
||||
puSlider *slider = (puSlider *) arrow->getUserData () ;
|
||||
puListBox* list_box = (puListBox*) slider -> getUserData () ;
|
||||
|
||||
int type = ((puArrowButton *)arrow)->getArrowType() ;
|
||||
int inc = ( type == PUARROW_DOWN ) ? 1 :
|
||||
( type == PUARROW_UP ) ? -1 :
|
||||
( type == PUARROW_FASTDOWN ) ? 10 :
|
||||
( type == PUARROW_FASTUP ) ? -10 : 0 ;
|
||||
|
||||
float val ;
|
||||
slider -> getValue ( &val ) ;
|
||||
val = 1.0f - val ;
|
||||
int num_items = list_box->getNumItems () - 1 ;
|
||||
if ( num_items > 0 )
|
||||
{
|
||||
int idx = int ( num_items * val + 0.5 ) + inc ;
|
||||
if ( idx > num_items ) idx = num_items ;
|
||||
if ( idx < 0 ) idx = 0 ;
|
||||
|
||||
slider -> setValue ( 1.0f - (float)idx / num_items ) ;
|
||||
list_box -> setTopItem ( idx ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void chop_file ( char *fname )
|
||||
{
|
||||
/* removes everything back to the last '/' */
|
||||
|
||||
for ( int i = strlen(fname)-1 ; fname[i] != SLASH[0] && i >= 0 ; i-- )
|
||||
fname[i] = '\0' ;
|
||||
}
|
||||
|
||||
|
||||
static void go_up_one_directory ( char *fname )
|
||||
{
|
||||
/* removes everything back to the last but one '/' */
|
||||
|
||||
chop_file ( fname ) ;
|
||||
|
||||
if ( fname [ 0 ] == '\0' )
|
||||
{
|
||||
/* Empty string! The only way to go up is to append a "../" */
|
||||
|
||||
strcpy ( fname, DOTDOTSLASH ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* If the last path element is a "../" then we'll have to add another "../" */
|
||||
|
||||
if ( strcmp ( & fname [ strlen(fname)-3 ], DOTDOTSLASH ) == 0 )
|
||||
{
|
||||
if ( strlen ( fname ) + 4 >= PUSTRING_MAX )
|
||||
{
|
||||
ulSetError ( UL_WARNING, "PUI: puFilePicker - path is too long, max is %d.",
|
||||
PUSTRING_MAX ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
strcat ( fname, DOTDOTSLASH ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* Otherwise, just delete the last element of the path. */
|
||||
|
||||
/* Remove the trailing slash - then remove the rest as if it was a file name */
|
||||
|
||||
fname [ strlen(fname)-1 ] = '\0' ;
|
||||
chop_file ( fname ) ;
|
||||
}
|
||||
|
||||
|
||||
void puFilePicker::handle_select ( puObject* l_box )
|
||||
{
|
||||
puFilePicker* file_picker = (puFilePicker*) l_box -> getUserData () ;
|
||||
|
||||
int selected ;
|
||||
l_box -> getValue ( &selected ) ;
|
||||
|
||||
if ( selected >= 0 && selected < file_picker -> num_files )
|
||||
{
|
||||
char *dst = file_picker -> getStringValue () ;
|
||||
char *src = file_picker -> files [ selected ] ;
|
||||
|
||||
chop_file ( dst ) ;
|
||||
|
||||
if ( strcmp ( src, "[.]" ) == 0 )
|
||||
{
|
||||
/* Do nothing - but better refresh anyway. */
|
||||
|
||||
file_picker -> find_files () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( strcmp ( src, "[..]" ) == 0 )
|
||||
{
|
||||
/* Do back up one level - so refresh. */
|
||||
|
||||
go_up_one_directory ( dst ) ;
|
||||
file_picker -> find_files () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( file_picker -> dflag [ selected ] )
|
||||
{
|
||||
/* If this is a directory - then descend into it and refresh */
|
||||
|
||||
if ( strlen ( dst ) + strlen ( src ) + 2 >= PUSTRING_MAX )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI: puFilePicker - path is too long, max is %d.", PUSTRING_MAX ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
strcat ( dst, &src[1] ) ; /* Remove leading '[' */
|
||||
dst [ strlen ( dst ) - 1 ] = SLASH[0] ; /* Replace trailing ']' with slash */
|
||||
file_picker -> find_files () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* If this is a regular file - then just append it to the string */
|
||||
|
||||
if ( strlen ( dst ) + strlen ( src ) + 2 >= PUSTRING_MAX )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI: puFilePicker - path is too long, max is %d.", PUSTRING_MAX ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
strcat ( dst, src ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
The user clicked on blank screen - maybe we should
|
||||
refresh just in case some other process created the
|
||||
file.
|
||||
*/
|
||||
|
||||
file_picker -> find_files () ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void puFilePickerHandleCancel ( puObject* b )
|
||||
{
|
||||
puFilePicker* file_picker = (puFilePicker*) b -> getUserData () ;
|
||||
file_picker -> setValue ( "" ) ;
|
||||
file_picker -> invokeCallback () ;
|
||||
}
|
||||
|
||||
static void puFilePickerHandleOk ( puObject* b )
|
||||
{
|
||||
puFilePicker* file_picker = (puFilePicker*) b -> getUserData () ;
|
||||
|
||||
file_picker -> invokeCallback () ;
|
||||
}
|
||||
|
||||
void puFilePicker::setSize ( int w, int h )
|
||||
{
|
||||
// Resize the frame widget
|
||||
frame->setSize ( w, h ) ;
|
||||
|
||||
// Resize and position the slider
|
||||
slider->setPosition ( w-30, 40+20*arrow_count ) ;
|
||||
slider->setSize ( 20, h-70-40*arrow_count ) ;
|
||||
|
||||
// Position the arrow buttons
|
||||
if ( up_arrow )
|
||||
{
|
||||
up_arrow->setPosition ( w-30, h-30-20*arrow_count ) ;
|
||||
down_arrow->setPosition ( w-30, 20+20*arrow_count ) ;
|
||||
}
|
||||
|
||||
if ( fastup_arrow )
|
||||
{
|
||||
fastup_arrow->setPosition ( w-30, h-50 ) ;
|
||||
fastdown_arrow->setPosition ( w-30, 40 ) ;
|
||||
}
|
||||
|
||||
// Resize the list box
|
||||
list_box->setSize ( w-40, h-70 ) ;
|
||||
|
||||
// Resoze and position the buttons
|
||||
cancel_button->setSize ( (w<170)?(w/2-15):70, 20 ) ;
|
||||
ok_button->setSize ( (w<170)?(w/2-15):70, 20 ) ;
|
||||
ok_button->setPosition ( (w<170)?(w/2+5):90, 10 ) ;
|
||||
}
|
||||
|
||||
puFilePicker::~puFilePicker ()
|
||||
{
|
||||
if ( files )
|
||||
{
|
||||
for ( int i=0; i<num_files; i++ )
|
||||
delete [] files[i];
|
||||
|
||||
delete[] files;
|
||||
delete[] dflag;
|
||||
}
|
||||
}
|
||||
|
||||
void puFilePicker::puFilePickerInit ( int x, int y, int w, int h, int arrows,
|
||||
const char *dir, const char *title )
|
||||
{
|
||||
type |= PUCLASS_FILEPICKER ;
|
||||
|
||||
files = NULL ;
|
||||
dflag = NULL ;
|
||||
num_files = 0 ;
|
||||
|
||||
strcpy ( startDir, dir ) ;
|
||||
|
||||
if ( arrows > 2 ) arrows = 2 ;
|
||||
if ( arrows < 0 ) arrows = 0 ;
|
||||
arrow_count = arrows ;
|
||||
|
||||
frame = new puFrame ( 0, 0, w, h );
|
||||
|
||||
slider = new puSlider (w-30,40+20*arrows,h-70-40*arrows,TRUE,20);
|
||||
slider->setDelta(0.1f);
|
||||
slider->setValue(1.0f);
|
||||
slider->setSliderFraction (0.2f) ;
|
||||
slider->setCBMode( PUSLIDER_DELTA );
|
||||
|
||||
list_box = new puListBox ( 10, 40, w-40, h-30 ) ;
|
||||
list_box -> setLabel ( title );
|
||||
list_box -> setLabelPlace ( PUPLACE_TOP_LEFT ) ;
|
||||
list_box -> setStyle ( -PUSTYLE_SMALL_SHADED ) ;
|
||||
list_box -> setUserData ( this ) ;
|
||||
list_box -> setCallback ( handle_select ) ;
|
||||
list_box -> setValue ( 0 ) ;
|
||||
|
||||
find_files () ;
|
||||
|
||||
handle_select ( list_box ) ;
|
||||
|
||||
slider -> setUserData ( list_box ) ;
|
||||
slider -> setCallback ( puFilePickerHandleSlider ) ;
|
||||
|
||||
cancel_button = new puOneShot ( 10, 10, (w<170)?(w/2-5):80, 30 ) ;
|
||||
cancel_button -> setLegend ( "Cancel" ) ;
|
||||
cancel_button -> setUserData ( this ) ;
|
||||
cancel_button -> setCallback ( puFilePickerHandleCancel ) ;
|
||||
|
||||
ok_button = new puOneShot ( (w<170)?(w/2+5):90, 10, (w<170)?(w-10):160, 30 ) ;
|
||||
ok_button -> setLegend ( "Ok" ) ;
|
||||
ok_button -> setUserData ( this ) ;
|
||||
ok_button -> setCallback ( puFilePickerHandleOk ) ;
|
||||
// ok_button->makeReturnDefault ( TRUE ) ;
|
||||
|
||||
up_arrow = (puArrowButton *)NULL ; down_arrow = (puArrowButton *)NULL ;
|
||||
fastup_arrow = (puArrowButton *)NULL ; fastdown_arrow = (puArrowButton *)NULL ;
|
||||
|
||||
if ( arrows > 0 )
|
||||
{
|
||||
down_arrow = new puArrowButton ( w-30, 20+20*arrows, w-10, 40+20*arrows, PUARROW_DOWN ) ;
|
||||
down_arrow->setUserData ( slider ) ;
|
||||
down_arrow->setCallback ( puFilePickerHandleArrow ) ;
|
||||
|
||||
up_arrow = new puArrowButton ( w-30, h-30-20*arrows, w-10, h-10-20*arrows, PUARROW_UP ) ;
|
||||
up_arrow->setUserData ( slider ) ;
|
||||
up_arrow->setCallback ( puFilePickerHandleArrow ) ;
|
||||
}
|
||||
|
||||
if ( arrows == 2 )
|
||||
{
|
||||
fastdown_arrow = new puArrowButton ( w-30, 40, w-10, 60, PUARROW_FASTDOWN ) ;
|
||||
fastdown_arrow->setUserData ( slider ) ;
|
||||
fastdown_arrow->setCallback ( puFilePickerHandleArrow ) ;
|
||||
|
||||
fastup_arrow = new puArrowButton ( w-30, h-50, w-10, h-30, PUARROW_FASTUP ) ;
|
||||
fastup_arrow->setUserData ( slider ) ;
|
||||
fastup_arrow->setCallback ( puFilePickerHandleArrow ) ;
|
||||
}
|
||||
|
||||
close () ;
|
||||
reveal () ;
|
||||
}
|
||||
|
||||
static int puFilePickerStringCompare ( const char *s1, const char *s2,
|
||||
const char f1, const char f2 )
|
||||
{
|
||||
if ( f1 > f2 ) /* Directories before regular files. */
|
||||
return -1 ;
|
||||
|
||||
if ( f1 < f2 )
|
||||
return 1 ;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
char c1 = s1? (*s1++): 0 ;
|
||||
char c2 = s2? (*s2++): 0 ;
|
||||
|
||||
//end of string?
|
||||
if ( !c1 || !c2 )
|
||||
{
|
||||
if ( c1 )
|
||||
return 1 ; //s1 is longer
|
||||
if ( c2 )
|
||||
return -1 ; //s1 is shorter
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
if ( c1 == c2 )
|
||||
continue ;
|
||||
|
||||
/*
|
||||
Windoze users are case-insensitive - so they presumably
|
||||
want case ignored in the sorting.
|
||||
|
||||
UNIX users, however, do things like calling their makefiles
|
||||
'Makefile' so as to force them to the start of the directory
|
||||
listing.
|
||||
*/
|
||||
|
||||
#if defined(WIN32)
|
||||
if ( c1 >= 'a' && c1 <= 'z' )
|
||||
c1 = c1 - ('a'-'A') ;
|
||||
|
||||
if ( c2 >= 'a' && c2 <= 'z' )
|
||||
c2 = c2 - ('a'-'A') ;
|
||||
#endif
|
||||
|
||||
if ( c1 != c2 )
|
||||
{
|
||||
if ( c1 < c2 )
|
||||
return -1 ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
static void puFilePickerSort ( char** list, char *flags, int size )
|
||||
//
|
||||
// comb sort - a modified bubble sort
|
||||
// taken from BYTE, April 1991, ppg 315-320
|
||||
//
|
||||
{
|
||||
int switches ;
|
||||
int gap = size ;
|
||||
|
||||
do
|
||||
{
|
||||
gap = ((gap * 197) >> 8); // gap /= 1.3;
|
||||
|
||||
switch (gap)
|
||||
{
|
||||
case 0: // the smallest gap is 1 -- bubble sort
|
||||
gap = 1;
|
||||
break;
|
||||
|
||||
case 9: // this is what makes this Combsort11
|
||||
case 10:
|
||||
gap = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
switches = 0 ; // dirty pass flag
|
||||
|
||||
int top = size - gap;
|
||||
|
||||
for ( int i=0; i<top; ++i )
|
||||
{
|
||||
int j=i+gap;
|
||||
|
||||
if ( puFilePickerStringCompare ( list [i], list [j],
|
||||
flags[i], flags[j] ) > 0 )
|
||||
{
|
||||
char* temp = list[i] ;
|
||||
list[i] = list[j] ;
|
||||
list[j] = temp ;
|
||||
|
||||
char tmp2 = flags[i] ;
|
||||
flags[i] = flags[j] ;
|
||||
flags[j] = tmp2 ;
|
||||
|
||||
++switches;
|
||||
}
|
||||
}
|
||||
} while ( switches || gap > 1 ) ;
|
||||
}
|
||||
|
||||
|
||||
void puFilePicker::find_files ( void )
|
||||
{
|
||||
if ( files != NULL )
|
||||
{
|
||||
for ( int i = 0 ; i < num_files ; i++ )
|
||||
delete [] files[i] ;
|
||||
|
||||
delete [] files ;
|
||||
delete [] dflag ;
|
||||
}
|
||||
|
||||
num_files = 0 ;
|
||||
|
||||
char dir [ PUSTRING_MAX * 2 ] ;
|
||||
|
||||
strcpy ( dir, startDir ) ;
|
||||
strcat ( dir, SLASH ) ;
|
||||
strcat ( dir, getStringValue() ) ;
|
||||
|
||||
if ( dir [ strlen ( dir ) - 1 ] != SLASH[0] ) /* Someone forgot a trailing '/' */
|
||||
strcat ( dir, SLASH ) ;
|
||||
|
||||
int ifile = 0 ;
|
||||
|
||||
ulDir *dirp = ulOpenDir ( dir ) ;
|
||||
ulDirEnt *dp ;
|
||||
|
||||
if ( dirp == NULL )
|
||||
{
|
||||
perror ("puFilePicker") ;
|
||||
ulSetError ( UL_WARNING, "PUI:puFilePicker - can't open directory '%s'", dir ) ;
|
||||
num_files = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
while ( ( dp = ulReadDir(dirp) ) != NULL )
|
||||
ifile++ ;
|
||||
|
||||
ulCloseDir ( dirp ) ;
|
||||
|
||||
num_files = ifile ;
|
||||
|
||||
if ( num_files == 0 )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI:puFilePicker - no entries in directory '%s'?!", dir ) ;
|
||||
num_files = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
files = new char* [ num_files+1 ] ;
|
||||
dflag = new char [ num_files+1 ] ;
|
||||
|
||||
dirp = ulOpenDir ( dir ) ;
|
||||
|
||||
if ( dirp == NULL )
|
||||
{
|
||||
perror ("puFilePicker") ;
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI:puFilePicker - can't re-open directory '%s'", dir ) ;
|
||||
num_files = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
for ( ifile = 0 ; (dp = ulReadDir(dirp)) != NULL && ifile < num_files ; ifile++ )
|
||||
{
|
||||
dflag[ ifile ] = dp->d_isdir ;
|
||||
|
||||
if ( dflag[ ifile ] )
|
||||
{
|
||||
files[ ifile ] = new char[ strlen(dp->d_name)+4 ] ;
|
||||
strcpy ( files [ ifile ], "[" ) ;
|
||||
strcat ( files [ ifile ], dp->d_name ) ;
|
||||
strcat ( files [ ifile ], "]" ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
files[ ifile ] = new char[ strlen(dp->d_name)+1 ] ;
|
||||
strcpy ( files [ ifile ], dp->d_name ) ;
|
||||
}
|
||||
}
|
||||
|
||||
files [ ifile ] = NULL ;
|
||||
|
||||
ulCloseDir ( dirp ) ;
|
||||
|
||||
puFilePickerSort( files, dflag, num_files ) ;
|
||||
|
||||
list_box -> newList ( files ) ;
|
||||
}
|
||||
|
||||
@@ -1,651 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* puFileSelector
|
||||
*
|
||||
* DESCRIPTION
|
||||
* PUI dialog for selecting files
|
||||
*
|
||||
* AUTHOR
|
||||
* Dave McClurg <dpm@efn.org>
|
||||
*
|
||||
* CREATION DATE
|
||||
* August 2000
|
||||
*
|
||||
* MODIFICATION HISTORY
|
||||
* John Fay - many improvements
|
||||
* Steve Baker - moved from FilePicker to FileSelector due to
|
||||
* key API change.
|
||||
****/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puFileSelector,puDialogBox)
|
||||
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
#define DOTDOTSLASH "..\\"
|
||||
#define SLASH "\\"
|
||||
#else
|
||||
#define DOTDOTSLASH "../"
|
||||
#define SLASH "/"
|
||||
#endif
|
||||
|
||||
static void puFileSelectorHandleSlider ( puObject * slider )
|
||||
{
|
||||
float val ;
|
||||
slider -> getValue ( &val ) ;
|
||||
val = 1.0f - val ;
|
||||
|
||||
puListBox* list_box = (puListBox*) slider -> getUserData () ;
|
||||
int idx = int ( list_box -> getNumItems () * val ) ;
|
||||
list_box -> setTopItem ( idx ) ;
|
||||
}
|
||||
|
||||
static void puFileSelectorHandleArrow ( puObject *arrow )
|
||||
{
|
||||
puSlider *slider = (puSlider *) arrow->getUserData () ;
|
||||
puListBox* list_box = (puListBox*) slider -> getUserData () ;
|
||||
|
||||
int type = ((puArrowButton *)arrow)->getArrowType() ;
|
||||
int inc = ( type == PUARROW_DOWN ) ? 1 :
|
||||
( type == PUARROW_UP ) ? -1 :
|
||||
( type == PUARROW_FASTDOWN ) ? 10 :
|
||||
( type == PUARROW_FASTUP ) ? -10 : 0 ;
|
||||
|
||||
float val ;
|
||||
slider -> getValue ( &val ) ;
|
||||
val = 1.0f - val ;
|
||||
int num_items = list_box->getNumItems () - 1 ;
|
||||
if ( num_items > 0 )
|
||||
{
|
||||
int idx = int ( num_items * val + 0.5 ) + inc ;
|
||||
if ( idx > num_items ) idx = num_items ;
|
||||
if ( idx < 0 ) idx = 0 ;
|
||||
|
||||
slider -> setValue ( 1.0f - (float)idx / num_items ) ;
|
||||
list_box -> setTopItem ( idx ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool is_slash ( char ch )
|
||||
{
|
||||
#if defined(WIN32)
|
||||
/* win32 can use back or forward slash */
|
||||
return ch == '\\' || ch == '/' ;
|
||||
#else
|
||||
return ch == SLASH[0] ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void chop_file ( char *fname )
|
||||
{
|
||||
/* removes everything back to the last '/' */
|
||||
|
||||
for ( int i = strlen(fname)-1 ; ! is_slash ( fname[i] ) && i >= 0 ; i-- )
|
||||
fname[i] = '\0' ;
|
||||
}
|
||||
|
||||
|
||||
static void go_up_one_directory ( char *fname )
|
||||
{
|
||||
/* removes everything back to the last but one '/' */
|
||||
|
||||
chop_file ( fname ) ;
|
||||
|
||||
if ( fname[0] == '\0' )
|
||||
{
|
||||
/* Empty string! We must be at the root. */
|
||||
|
||||
strcpy ( fname, SLASH ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* Otherwise, just delete the last element of the path. */
|
||||
|
||||
/* Remove the trailing slash - then remove the rest as
|
||||
if it was a file name */
|
||||
|
||||
fname [ strlen(fname)-1 ] = '\0' ;
|
||||
chop_file ( fname ) ;
|
||||
}
|
||||
|
||||
|
||||
void puFileSelector::input_entered ( puObject* inp )
|
||||
{
|
||||
puFileSelector* file_selector = (puFileSelector*) (inp -> getUserData ()) ;
|
||||
|
||||
/*
|
||||
If the input selector is empty - do nothing
|
||||
*/
|
||||
|
||||
if ( inp -> getStringValue() [ 0 ] == '\0' )
|
||||
return ;
|
||||
|
||||
if ( ulIsAbsolutePathName ( inp -> getStringValue () ) )
|
||||
file_selector -> setValue ( inp -> getStringValue () ) ;
|
||||
else
|
||||
{
|
||||
char *s = new char [ strlen ( file_selector->__getStartDir() )
|
||||
+ strlen ( SLASH )
|
||||
+ strlen ( inp -> getStringValue () )
|
||||
+ 1 ] ;
|
||||
|
||||
ulMakePath ( s, file_selector -> __getStartDir(),
|
||||
inp -> getStringValue () ) ;
|
||||
file_selector -> setValue ( s ) ;
|
||||
|
||||
delete [] s ;
|
||||
}
|
||||
|
||||
/*
|
||||
If he typed a valid directory name - then
|
||||
refresh the contents of the browser window
|
||||
*/
|
||||
|
||||
ulDir *d = ulOpenDir ( file_selector->getStringValue() ) ;
|
||||
ulCloseDir ( d ) ;
|
||||
|
||||
if ( d != NULL )
|
||||
file_selector -> find_files () ;
|
||||
}
|
||||
|
||||
|
||||
void puFileSelector::handle_select ( puObject* l_box )
|
||||
{
|
||||
puFileSelector* file_selector = (puFileSelector*) l_box -> getUserData () ;
|
||||
|
||||
int selected ;
|
||||
l_box -> getValue ( &selected ) ;
|
||||
|
||||
if ( selected >= 0 && selected < file_selector -> num_files )
|
||||
{
|
||||
char *dst = file_selector -> getStringValue () ;
|
||||
char *src = file_selector -> files [ selected ] ;
|
||||
|
||||
chop_file ( dst ) ;
|
||||
|
||||
if ( strcmp ( src, "[..]" ) == 0 )
|
||||
{
|
||||
/* Do back up one level - so refresh. */
|
||||
|
||||
go_up_one_directory ( dst ) ;
|
||||
file_selector -> find_files () ;
|
||||
file_selector -> __getInput() -> setValue ( dst ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( file_selector -> dflag [ selected ] )
|
||||
{
|
||||
/* If this is a directory - then descend into it and refresh */
|
||||
|
||||
if ( strlen ( dst ) + strlen ( src ) + 2 >= PUSTRING_MAX )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI: puFileSelector - path is too long, max is %d.", PUSTRING_MAX ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
strcat ( dst, &src[1] ) ; /* Remove leading '[' */
|
||||
dst [ strlen ( dst ) - 1 ] = SLASH[0] ; /* Replace trailing ']' with slash */
|
||||
file_selector -> find_files () ;
|
||||
file_selector -> __getInput() -> setValue ( dst ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* If this is a regular file - then just append it to the string */
|
||||
|
||||
if ( strlen ( dst ) + strlen ( src ) + 2 >= PUSTRING_MAX )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI: puFileSelector - path is too long, max is %d.", PUSTRING_MAX ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
strcat ( dst, src ) ;
|
||||
file_selector -> __getInput() -> setValue ( dst ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
The user clicked on blank screen - maybe we should
|
||||
refresh just in case some other process created the
|
||||
file.
|
||||
*/
|
||||
|
||||
file_selector -> find_files () ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void puFileSelectorHandleCancel ( puObject* b )
|
||||
{
|
||||
puFileSelector* file_selector = (puFileSelector*) b -> getUserData () ;
|
||||
file_selector -> setValue ( "" ) ;
|
||||
file_selector -> invokeCallback () ;
|
||||
}
|
||||
|
||||
static void puFileSelectorHandleOk ( puObject* b )
|
||||
{
|
||||
puFileSelector* file_selector = (puFileSelector*) b -> getUserData () ;
|
||||
|
||||
file_selector -> invokeCallback () ;
|
||||
}
|
||||
|
||||
void puFileSelector::setSize ( int w, int h )
|
||||
{
|
||||
// Resize the frame widget
|
||||
frame->setSize ( w, h ) ;
|
||||
|
||||
// Resize and position the slider
|
||||
slider->setPosition ( w-30, 40+20*arrow_count ) ;
|
||||
slider->setSize ( 20, h-70-40*arrow_count ) ;
|
||||
|
||||
// Position the arrow buttons
|
||||
if ( up_arrow )
|
||||
{
|
||||
up_arrow->setPosition ( w-30, h-30-20*arrow_count ) ;
|
||||
down_arrow->setPosition ( w-30, 20+20*arrow_count ) ;
|
||||
}
|
||||
|
||||
if ( fastup_arrow )
|
||||
{
|
||||
fastup_arrow->setPosition ( w-30, h-50 ) ;
|
||||
fastdown_arrow->setPosition ( w-30, 40 ) ;
|
||||
}
|
||||
|
||||
// Resize the list box
|
||||
list_box->setSize ( w-40, h-70 ) ;
|
||||
|
||||
// Resoze and position the buttons
|
||||
cancel_button->setSize ( (w<170)?(w/2-15):70, 20 ) ;
|
||||
ok_button->setSize ( (w<170)?(w/2-15):70, 20 ) ;
|
||||
ok_button->setPosition ( (w<170)?(w/2+5):90, 10 ) ;
|
||||
}
|
||||
|
||||
puFileSelector::~puFileSelector ()
|
||||
{
|
||||
delete [] startDir ;
|
||||
|
||||
if ( files != NULL )
|
||||
{
|
||||
for ( int i=0; i<num_files; i++ )
|
||||
delete [] files[i];
|
||||
|
||||
delete [] files;
|
||||
delete [] dflag;
|
||||
}
|
||||
}
|
||||
|
||||
void puFileSelector::puFileSelectorInit ( int x, int y, int w, int h,
|
||||
int arrows,
|
||||
const char *dir,
|
||||
const char *title )
|
||||
{
|
||||
type |= PUCLASS_FILESELECTOR ;
|
||||
|
||||
files = NULL ;
|
||||
dflag = NULL ;
|
||||
num_files = 0 ;
|
||||
|
||||
if ( ulIsAbsolutePathName ( dir ) )
|
||||
{
|
||||
/* Include space for trailing slash in case it is necessary */
|
||||
startDir = new char [ strlen ( dir ) + strlen ( SLASH ) + 1 ] ;
|
||||
|
||||
strcpy ( startDir, dir ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
startDir = new char [ UL_NAME_MAX + 1 ] ;
|
||||
if ( ulGetCWD ( startDir, UL_NAME_MAX + 1 ) == NULL )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI: puFileSelector - can't find current directory" ) ;
|
||||
setValue ( "" ) ;
|
||||
invokeCallback () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* Include space for slashes in case they are necessary */
|
||||
char *s = new char [ strlen ( startDir )
|
||||
+ 2 * strlen ( SLASH )
|
||||
+ strlen ( dir ) + 1 ] ;
|
||||
|
||||
strcpy ( s, startDir ) ;
|
||||
|
||||
if ( ! is_slash ( startDir[strlen(startDir)-1] ) )
|
||||
strcat ( s, SLASH ) ;
|
||||
|
||||
strcat ( s, dir ) ;
|
||||
|
||||
delete [] startDir ;
|
||||
startDir = s ;
|
||||
}
|
||||
|
||||
if ( ! is_slash ( startDir[strlen(startDir)-1] ) )
|
||||
strcat ( startDir, SLASH ) ;
|
||||
|
||||
setValue ( startDir ) ;
|
||||
|
||||
if ( arrows > 2 ) arrows = 2 ;
|
||||
if ( arrows < 0 ) arrows = 0 ;
|
||||
arrow_count = arrows ;
|
||||
|
||||
frame = new puFrame ( 0, 0, w, h );
|
||||
|
||||
slider = new puSlider (w-30,40+20*arrows,h-70-40*arrows,TRUE,20);
|
||||
slider->setValue(1.0f);
|
||||
slider->setSliderFraction (0.2f) ;
|
||||
slider->setCBMode( PUSLIDER_DELTA );
|
||||
|
||||
list_box = new puListBox ( 10, 60, w-40, h-30 ) ;
|
||||
list_box -> setLabel ( title );
|
||||
list_box -> setLabelPlace ( PUPLACE_TOP_LEFT ) ;
|
||||
list_box -> setStyle ( -PUSTYLE_SMALL_SHADED ) ;
|
||||
list_box -> setUserData ( this ) ;
|
||||
list_box -> setCallback ( handle_select ) ;
|
||||
list_box -> setValue ( 0 ) ;
|
||||
|
||||
find_files () ;
|
||||
|
||||
handle_select ( list_box ) ;
|
||||
|
||||
slider -> setUserData ( list_box ) ;
|
||||
slider -> setCallback ( puFileSelectorHandleSlider ) ;
|
||||
|
||||
input = new puInput ( 10, 40, w-40, 60 ) ;
|
||||
input -> setValue ( startDir ) ;
|
||||
input -> setUserData ( this ) ;
|
||||
input -> setCallback ( input_entered ) ;
|
||||
input -> setDownCallback ( input_entered ) ;
|
||||
|
||||
cancel_button = new puOneShot ( 10, 10, (w<170)?(w/2-5):80, 30 ) ;
|
||||
cancel_button -> setLegend ( "Cancel" ) ;
|
||||
cancel_button -> setUserData ( this ) ;
|
||||
cancel_button -> setCallback ( puFileSelectorHandleCancel ) ;
|
||||
|
||||
ok_button = new puOneShot ( (w<170)?(w/2+5):90, 10, (w<170)?(w-10):160, 30 ) ;
|
||||
ok_button -> setLegend ( "Ok" ) ;
|
||||
ok_button -> setUserData ( this ) ;
|
||||
ok_button -> setCallback ( puFileSelectorHandleOk ) ;
|
||||
|
||||
up_arrow = down_arrow = NULL ;
|
||||
fastup_arrow = fastdown_arrow = NULL ;
|
||||
|
||||
if ( arrows > 0 )
|
||||
{
|
||||
down_arrow = new puArrowButton ( w-30, 20+20*arrows, w-10, 40+20*arrows, PUARROW_DOWN ) ;
|
||||
down_arrow->setUserData ( slider ) ;
|
||||
down_arrow->setCallback ( puFileSelectorHandleArrow ) ;
|
||||
|
||||
up_arrow = new puArrowButton ( w-30, h-30-20*arrows, w-10, h-10-20*arrows, PUARROW_UP ) ;
|
||||
up_arrow->setUserData ( slider ) ;
|
||||
up_arrow->setCallback ( puFileSelectorHandleArrow ) ;
|
||||
}
|
||||
|
||||
if ( arrows == 2 )
|
||||
{
|
||||
fastdown_arrow = new puArrowButton ( w-30, 40, w-10, 60, PUARROW_FASTDOWN ) ;
|
||||
fastdown_arrow->setUserData ( slider ) ;
|
||||
fastdown_arrow->setCallback ( puFileSelectorHandleArrow ) ;
|
||||
|
||||
fastup_arrow = new puArrowButton ( w-30, h-50, w-10, h-30, PUARROW_FASTUP ) ;
|
||||
fastup_arrow->setUserData ( slider ) ;
|
||||
fastup_arrow->setCallback ( puFileSelectorHandleArrow ) ;
|
||||
}
|
||||
|
||||
close () ;
|
||||
reveal () ;
|
||||
}
|
||||
|
||||
static int puFileSelectorStringCompare ( const char *s1, const char *s2,
|
||||
const char f1, const char f2 )
|
||||
{
|
||||
if ( f1 > f2 ) /* Directories before regular files. */
|
||||
return -1 ;
|
||||
|
||||
if ( f1 < f2 )
|
||||
return 1 ;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
char c1 = s1? (*s1++): 0 ;
|
||||
char c2 = s2? (*s2++): 0 ;
|
||||
|
||||
//end of string?
|
||||
if ( !c1 || !c2 )
|
||||
{
|
||||
if ( c1 )
|
||||
return 1 ; //s1 is longer
|
||||
if ( c2 )
|
||||
return -1 ; //s1 is shorter
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
if ( c1 == c2 )
|
||||
continue ;
|
||||
|
||||
/*
|
||||
Windoze users are case-insensitive - so they presumably
|
||||
want case ignored in the sorting.
|
||||
|
||||
UNIX users, however, do things like calling their makefiles
|
||||
'Makefile' so as to force them to the start of the directory
|
||||
listing.
|
||||
*/
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
if ( c1 >= 'a' && c1 <= 'z' )
|
||||
c1 = c1 - ('a'-'A') ;
|
||||
|
||||
if ( c2 >= 'a' && c2 <= 'z' )
|
||||
c2 = c2 - ('a'-'A') ;
|
||||
#endif
|
||||
|
||||
if ( c1 != c2 )
|
||||
{
|
||||
if ( c1 < c2 )
|
||||
return -1 ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
void puFileSelector::setInitialValue ( const char *s )
|
||||
{
|
||||
if ( ulIsAbsolutePathName ( s ) )
|
||||
{
|
||||
input -> setValue ( s ) ;
|
||||
input -> invokeCallback () ;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat ( input -> getStringValue (), s ) ;
|
||||
input -> invokeCallback () ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void puFileSelectorSort ( char** list, char *flags, int size )
|
||||
//
|
||||
// comb sort - a modified bubble sort
|
||||
// taken from BYTE, April 1991, ppg 315-320
|
||||
//
|
||||
{
|
||||
int switches ;
|
||||
int gap = size ;
|
||||
|
||||
do
|
||||
{
|
||||
gap = ((gap * 197) >> 8); // gap /= 1.3;
|
||||
|
||||
switch (gap)
|
||||
{
|
||||
case 0: // the smallest gap is 1 -- bubble sort
|
||||
gap = 1;
|
||||
break;
|
||||
|
||||
case 9: // this is what makes this Combsort11
|
||||
case 10:
|
||||
gap = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
switches = 0 ; // dirty pass flag
|
||||
|
||||
int top = size - gap;
|
||||
|
||||
for ( int i=0; i<top; ++i )
|
||||
{
|
||||
int j=i+gap;
|
||||
|
||||
if ( puFileSelectorStringCompare ( list [i], list [j],
|
||||
flags[i], flags[j] ) > 0 )
|
||||
{
|
||||
char* temp = list[i] ;
|
||||
list[i] = list[j] ;
|
||||
list[j] = temp ;
|
||||
|
||||
char tmp2 = flags[i] ;
|
||||
flags[i] = flags[j] ;
|
||||
flags[j] = tmp2 ;
|
||||
|
||||
++switches;
|
||||
}
|
||||
}
|
||||
} while ( switches || gap > 1 ) ;
|
||||
}
|
||||
|
||||
|
||||
void puFileSelector::find_files ( void )
|
||||
{
|
||||
if ( files != NULL )
|
||||
{
|
||||
for ( int i = 0 ; i < num_files ; i++ )
|
||||
delete [] files[i] ;
|
||||
|
||||
delete [] files ;
|
||||
delete [] dflag ;
|
||||
}
|
||||
|
||||
num_files = 0 ;
|
||||
|
||||
char dir [ PUSTRING_MAX * 2 ] ;
|
||||
|
||||
strcpy ( dir, getStringValue() ) ;
|
||||
|
||||
if ( ! is_slash ( dir [ strlen ( dir ) - 1 ] ) ) /* Someone forgot a trailing '/' */
|
||||
strcat ( dir, SLASH ) ;
|
||||
|
||||
int ifile = 0 ;
|
||||
|
||||
ulDir *dirp = ulOpenDir ( dir ) ;
|
||||
ulDirEnt *dp ;
|
||||
|
||||
if ( dirp == NULL )
|
||||
{
|
||||
perror ("puFileSelector") ;
|
||||
ulSetError ( UL_WARNING, "PUI:puFileSelector - can't open directory '%s'", dir ) ;
|
||||
num_files = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
/* Count the number of files - skipping "." */
|
||||
|
||||
while ( ( dp = ulReadDir(dirp) ) != NULL )
|
||||
if ( strcmp ( dp->d_name, "." ) != 0 )
|
||||
ifile++ ;
|
||||
|
||||
ulCloseDir ( dirp ) ;
|
||||
|
||||
num_files = ifile ;
|
||||
if ( num_files > 5 )
|
||||
slider -> setDelta ( 0.5f / num_files ) ;
|
||||
else
|
||||
slider -> setDelta ( 0.1f ) ;
|
||||
|
||||
if ( num_files == 0 )
|
||||
{
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI:puFileSelector - no entries in directory '%s'?!", dir ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
files = new char* [ num_files+1 ] ;
|
||||
dflag = new char [ num_files+1 ] ;
|
||||
|
||||
dirp = ulOpenDir ( dir ) ;
|
||||
|
||||
if ( dirp == NULL )
|
||||
{
|
||||
perror ("puFileSelector") ;
|
||||
ulSetError ( UL_WARNING,
|
||||
"PUI:puFileSelector - can't re-open directory '%s'", dir ) ;
|
||||
num_files = 0 ;
|
||||
return ;
|
||||
}
|
||||
|
||||
ifile = 0 ;
|
||||
|
||||
while ( (dp = ulReadDir(dirp)) != NULL && ifile < num_files )
|
||||
{
|
||||
/* Skip over the "." entry... */
|
||||
|
||||
if ( strcmp ( dp->d_name, "." ) != 0 )
|
||||
{
|
||||
dflag[ ifile ] = dp->d_isdir ;
|
||||
|
||||
if ( dflag[ ifile ] )
|
||||
{
|
||||
files[ ifile ] = new char[ strlen(dp->d_name)+4 ] ;
|
||||
strcpy ( files [ ifile ], "[" ) ;
|
||||
strcat ( files [ ifile ], dp->d_name ) ;
|
||||
strcat ( files [ ifile ], "]" ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
files[ ifile ] = new char[ strlen(dp->d_name)+1 ] ;
|
||||
strcpy ( files [ ifile ], dp->d_name ) ;
|
||||
}
|
||||
|
||||
ifile++ ;
|
||||
}
|
||||
}
|
||||
|
||||
files [ ifile ] = NULL ;
|
||||
|
||||
ulCloseDir ( dirp ) ;
|
||||
|
||||
puFileSelectorSort( files, dflag, num_files ) ;
|
||||
|
||||
list_box -> newList ( files ) ;
|
||||
}
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
#ifdef _PU_USE_GLUT_FONTS
|
||||
|
||||
/*
|
||||
A set of puFont's to implement the GLUT BitMap set...
|
||||
*/
|
||||
|
||||
puFont PUFONT_8_BY_13 ( GLUT_BITMAP_8_BY_13 ) ;
|
||||
puFont PUFONT_9_BY_15 ( GLUT_BITMAP_9_BY_15 ) ;
|
||||
puFont PUFONT_TIMES_ROMAN_10 ( GLUT_BITMAP_TIMES_ROMAN_10 ) ;
|
||||
puFont PUFONT_TIMES_ROMAN_24 ( GLUT_BITMAP_TIMES_ROMAN_24 ) ;
|
||||
puFont PUFONT_HELVETICA_10 ( GLUT_BITMAP_HELVETICA_10 ) ;
|
||||
puFont PUFONT_HELVETICA_12 ( GLUT_BITMAP_HELVETICA_12 ) ;
|
||||
puFont PUFONT_HELVETICA_18 ( GLUT_BITMAP_HELVETICA_18 ) ;
|
||||
|
||||
#else // No GLUT fonts, try some corresponding textured fonts
|
||||
|
||||
fntTexFont PUFONT_TXF_TYPEWRITER ;
|
||||
fntTexFont PUFONT_TXF_TIMES ;
|
||||
fntTexFont PUFONT_TXF_HELVETICA ;
|
||||
|
||||
puFont PUFONT_8_BY_13 ( &PUFONT_TXF_TYPEWRITER, 13 ) ;
|
||||
puFont PUFONT_9_BY_15 ( &PUFONT_TXF_TYPEWRITER, 15 ) ;
|
||||
puFont PUFONT_TIMES_ROMAN_10 ( &PUFONT_TXF_TIMES, 10 ) ;
|
||||
puFont PUFONT_TIMES_ROMAN_24 ( &PUFONT_TXF_TIMES, 24 ) ;
|
||||
puFont PUFONT_HELVETICA_10 ( &PUFONT_TXF_HELVETICA, 10 ) ;
|
||||
puFont PUFONT_HELVETICA_12 ( &PUFONT_TXF_HELVETICA, 12 ) ;
|
||||
puFont PUFONT_HELVETICA_18 ( &PUFONT_TXF_HELVETICA, 18 ) ;
|
||||
|
||||
#endif // #ifdef _PU_USE_GLUT_FONTS
|
||||
|
||||
|
||||
puFont::puFont ()
|
||||
{
|
||||
#ifdef _PU_USE_GLUT_FONTS
|
||||
glut_font_handle = GLUT_BITMAP_8_BY_13 ;
|
||||
fnt_font_handle = NULL ;
|
||||
#else
|
||||
fnt_font_handle = &PUFONT_TXF_TYPEWRITER ;
|
||||
pointsize = 13 ;
|
||||
slant = 0 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
float puFont::getFloatStringWidth ( const char *str ) const
|
||||
{
|
||||
if ( str == NULL )
|
||||
return 0.0f ;
|
||||
|
||||
#ifdef _PU_USE_GLUT_FONTS
|
||||
if ( glut_font_handle != NULL )
|
||||
{
|
||||
int res = 0 ;
|
||||
int max_res = 0 ;
|
||||
|
||||
while ( *str != '\0' )
|
||||
{
|
||||
if ( *str == '\n' )
|
||||
{
|
||||
if ( res > max_res ) max_res = res ;
|
||||
res = 0 ;
|
||||
}
|
||||
else
|
||||
res += glutBitmapWidth ( glut_font_handle, *str ) ;
|
||||
|
||||
str++ ;
|
||||
}
|
||||
|
||||
if ( res > max_res ) max_res = res;
|
||||
|
||||
return float(max_res) ;
|
||||
}
|
||||
#endif // #ifdef _PU_USE_GLUT_FONTS
|
||||
|
||||
if ( fnt_font_handle != NULL )
|
||||
{
|
||||
float r, l ;
|
||||
fnt_font_handle -> getBBox ( str, pointsize, slant, &l, &r, NULL, NULL ) ;
|
||||
return ( r - l ) ;
|
||||
}
|
||||
|
||||
return 0.0f ;
|
||||
}
|
||||
|
||||
|
||||
static int count_lines ( const char *str )
|
||||
{
|
||||
int k = 0 ;
|
||||
|
||||
if ( str != NULL )
|
||||
{
|
||||
for ( k = 1 ; *str != '\0' ; str++ )
|
||||
if ( *str == '\n' )
|
||||
k++ ;
|
||||
}
|
||||
|
||||
return k ;
|
||||
}
|
||||
|
||||
#ifdef _PU_USE_GLUT_FONTS
|
||||
static int getGLUTStringHeight ( GlutFont glut_font_handle )
|
||||
{
|
||||
if ( glut_font_handle == GLUT_BITMAP_8_BY_13 ) return 9 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_9_BY_15 ) return 10 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_TIMES_ROMAN_10 ) return 7 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_TIMES_ROMAN_24 ) return 17 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_HELVETICA_10 ) return 8 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_HELVETICA_12 ) return 9 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_HELVETICA_18 ) return 14 ;
|
||||
return 0 ;
|
||||
}
|
||||
#endif // #ifdef _PU_USE_GLUT_FONTS
|
||||
|
||||
int puFont::getStringHeight ( const char *s ) const
|
||||
{
|
||||
/* Height *excluding* descender */
|
||||
|
||||
if ( s == NULL )
|
||||
return 0 ;
|
||||
|
||||
#ifdef _PU_USE_GLUT_FONTS
|
||||
if ( glut_font_handle != (GlutFont) 0 )
|
||||
{
|
||||
int i = getGLUTStringHeight ( glut_font_handle ) + getStringDescender () ;
|
||||
|
||||
return ( i * count_lines ( s ) ) - getStringDescender () ;
|
||||
}
|
||||
#endif // #ifdef _PU_USE_GLUT_FONTS
|
||||
|
||||
if ( fnt_font_handle != NULL )
|
||||
return int ( pointsize * ( 1.333f * count_lines ( s ) - 0.333f ) ) ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
int puFont::getStringDescender ( void ) const
|
||||
{
|
||||
#ifdef _PU_USE_GLUT_FONTS
|
||||
if ( glut_font_handle != (GlutFont) 0 )
|
||||
{
|
||||
if ( glut_font_handle == GLUT_BITMAP_8_BY_13 ) return 2 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_9_BY_15 ) return 3 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_TIMES_ROMAN_10 ) return 2 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_TIMES_ROMAN_24 ) return 5 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_HELVETICA_10 ) return 2 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_HELVETICA_12 ) return 3 ;
|
||||
if ( glut_font_handle == GLUT_BITMAP_HELVETICA_18 ) return 4 ;
|
||||
}
|
||||
#endif // #ifdef _PU_USE_GLUT_FONTS
|
||||
|
||||
if ( fnt_font_handle != NULL )
|
||||
{
|
||||
float b ;
|
||||
fnt_font_handle -> getBBox ( "y", pointsize, slant, NULL, NULL, &b, NULL ) ;
|
||||
return (int) -b ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
void puFont::drawString ( const char *str, int x, int y )
|
||||
{
|
||||
if ( str == NULL )
|
||||
return ;
|
||||
|
||||
#ifdef _PU_USE_GLUT_FONTS
|
||||
if ( glut_font_handle != (GlutFont) 0 )
|
||||
{
|
||||
glRasterPos2f( (float)x, (float)y ) ;
|
||||
|
||||
while ( *str != '\0' )
|
||||
{
|
||||
if (*str == '\n')
|
||||
{
|
||||
y -= getStringHeight () + getStringDescender () ;
|
||||
glRasterPos2f( (float)x, (float)y ) ;
|
||||
}
|
||||
else
|
||||
glutBitmapCharacter ( glut_font_handle, *str ) ;
|
||||
|
||||
str++ ;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
#endif // #ifdef _PU_USE_GLUT_FONTS
|
||||
|
||||
if ( fnt_font_handle != NULL )
|
||||
{
|
||||
sgVec3 curpos ;
|
||||
sgSetVec3 ( curpos, (float)x, (float)y, 0.0f ) ;
|
||||
|
||||
glPushAttrib( GL_COLOR_BUFFER_BIT ); // NHV
|
||||
glEnable ( GL_ALPHA_TEST ) ;
|
||||
glEnable ( GL_BLEND ) ;
|
||||
glAlphaFunc ( GL_GREATER, 0.1f ) ;
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
|
||||
fnt_font_handle -> begin () ;
|
||||
fnt_font_handle -> puts ( curpos, pointsize, slant, str ) ;
|
||||
fnt_font_handle -> end () ;
|
||||
|
||||
glPopAttrib () ;
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puFrame,puObject)
|
||||
|
||||
|
||||
void puFrame::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
abox.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
draw_legend ( dx, dy ) ;
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,469 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puGroup,puObject)
|
||||
|
||||
|
||||
#define PUSTACK_MAX 100
|
||||
|
||||
static int currGroup = -1 ;
|
||||
static puGroup *groupStack [ PUSTACK_MAX ] ;
|
||||
|
||||
void puPushGroup ( puGroup *in )
|
||||
{
|
||||
if ( currGroup < PUSTACK_MAX )
|
||||
groupStack [ ++currGroup ] = in ;
|
||||
else
|
||||
ulSetError ( UL_WARNING, "PUI: Too many puGroups open at once!" ) ;
|
||||
}
|
||||
|
||||
|
||||
void puPopGroup ( void )
|
||||
{
|
||||
if ( currGroup > 0 )
|
||||
--currGroup ;
|
||||
else
|
||||
ulSetError ( UL_WARNING, "PUI: puGroup stack is empty!" ) ;
|
||||
}
|
||||
|
||||
int puNoGroup ( void )
|
||||
{
|
||||
return currGroup < 0 ;
|
||||
}
|
||||
|
||||
|
||||
puGroup *puGetCurrGroup ( void )
|
||||
{
|
||||
if ( currGroup < 0 )
|
||||
{
|
||||
ulSetError ( UL_WARNING, "PUI: No Group!" ) ;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
return groupStack [ currGroup ] ;
|
||||
}
|
||||
|
||||
void puGroup::remove ( puObject *obj )
|
||||
{
|
||||
if ( obj -> getParent () != this )
|
||||
return ;
|
||||
|
||||
/* Are we the first object in the list */
|
||||
|
||||
if ( obj -> getPrevObject() == NULL )
|
||||
dlist = obj -> getNextObject() ;
|
||||
else
|
||||
obj -> getPrevObject() -> setNextObject( obj -> getNextObject() ) ;
|
||||
|
||||
/* Are we the last object in the list */
|
||||
|
||||
if ( obj -> getNextObject() != NULL )
|
||||
obj -> getNextObject() -> setPrevObject( obj -> getPrevObject() ) ;
|
||||
|
||||
obj -> setNextObject ( NULL ) ;
|
||||
obj -> setPrevObject ( NULL ) ;
|
||||
obj -> setParent ( NULL ) ;
|
||||
|
||||
num_children-- ;
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
void puGroup::empty ( void )
|
||||
{
|
||||
puObject *obj = getLastChild () ;
|
||||
while ( obj != NULL )
|
||||
{
|
||||
if ( obj->getType () & PUCLASS_GROUP )
|
||||
{
|
||||
puGroup *group = (puGroup *)obj ;
|
||||
group->empty () ;
|
||||
}
|
||||
|
||||
puObject *temp = obj->getPrevObject () ;
|
||||
delete obj ;
|
||||
obj = temp ;
|
||||
}
|
||||
|
||||
dlist = NULL ;
|
||||
}
|
||||
|
||||
void puGroup::add ( puObject *new_obj )
|
||||
{
|
||||
if ( new_obj -> getParent () != NULL )
|
||||
new_obj -> getParent () -> remove ( new_obj ) ;
|
||||
|
||||
new_obj -> setParent ( this ) ;
|
||||
|
||||
if ( dlist == NULL )
|
||||
{
|
||||
dlist = new_obj ;
|
||||
new_obj -> setNextObject ( NULL ) ;
|
||||
new_obj -> setPrevObject ( NULL ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
puObject *last ;
|
||||
|
||||
for ( last = dlist ;
|
||||
last -> getNextObject() != NULL ;
|
||||
last = last -> getNextObject() )
|
||||
/* Search for end of list. */ ;
|
||||
|
||||
last -> setNextObject ( new_obj ) ;
|
||||
new_obj -> setPrevObject ( last ) ;
|
||||
new_obj -> setNextObject ( NULL ) ;
|
||||
}
|
||||
|
||||
num_children++ ;
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
int puGroup::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () )
|
||||
return FALSE ;
|
||||
|
||||
puObject *bo ;
|
||||
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
bo = getLastChild () ;
|
||||
|
||||
for ( ; bo != NULL ; bo = bo -> getPrevObject() )
|
||||
if ( bo -> checkKey ( key, updown ) )
|
||||
return TRUE ;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
int puGroup::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () )
|
||||
return FALSE ;
|
||||
|
||||
/*
|
||||
This might be a bit redundant - but it's too hard to keep
|
||||
track of changing abox sizes when daughter objects are
|
||||
changing sizes.
|
||||
*/
|
||||
|
||||
recalc_bbox () ;
|
||||
|
||||
puObject *bo ;
|
||||
|
||||
x -= abox.min[0] ;
|
||||
y -= abox.min[1] ;
|
||||
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
if ( !mouse_active )
|
||||
{
|
||||
bo = getLastChild () ;
|
||||
|
||||
for ( ; bo != NULL ; bo = bo -> getPrevObject() )
|
||||
{
|
||||
/* If this is a menu bar and the mouse is over the button, highlight the button, if it's in the right window - JCJ 6 Jun 2002 */
|
||||
if ( ( ( getType () & PUCLASS_MENUBAR ) || ( getType () & PUCLASS_VERTMENU ) ) && ( bo->getType () & PUCLASS_ONESHOT ) && ( window == puGetWindow () ) )
|
||||
/*
|
||||
Changing this statement to something like this:
|
||||
if ( bo->getType () & PUCLASS_ONESHOT )
|
||||
Breaks a lot of stuff... like pressing buttons actually working in filepicker. Need
|
||||
to just define everything that can be pressed passively above, and things should
|
||||
be fröhlich.
|
||||
*/
|
||||
{
|
||||
puBox *box = bo->getABox () ;
|
||||
if ( ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
|
||||
( y >= box->min[1] ) && ( y <= box->max[1] ) )
|
||||
bo->highlight () ;
|
||||
else
|
||||
bo->lowlight () ;
|
||||
}
|
||||
|
||||
if ( bo -> checkHit ( button, updown, x, y ) )
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
If right mouse button is pressed, save mouse coordinates for
|
||||
dragging and dropping. Do this only if the "floating" flag is set.
|
||||
*/
|
||||
|
||||
if ( mouse_active || ( isHit ( x+abox.min[0], y+abox.min[1]) &&
|
||||
floating && ( button == PU_RIGHT_BUTTON ) ) )
|
||||
{
|
||||
puMoveToLast ( this );
|
||||
|
||||
/*
|
||||
Return (x, y) to coordinates of parent interface to avoid "jumping" of
|
||||
present interface as mouse drags
|
||||
*/
|
||||
|
||||
x += abox.min[0] ;
|
||||
y += abox.min[1] ;
|
||||
|
||||
if ( updown == PU_DOWN )
|
||||
{
|
||||
mouse_x = x; /* Save mouse coordinates for dragging */
|
||||
mouse_y = y;
|
||||
|
||||
mouse_active = TRUE ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
else if ( updown == PU_DRAG )
|
||||
{
|
||||
int curr_x, curr_y;
|
||||
|
||||
getPosition ( &curr_x, &curr_y );
|
||||
setPosition ( curr_x+x-mouse_x, curr_y+y-mouse_y ); /* Move to new position */
|
||||
|
||||
mouse_x = x; /* Save new coordinates */
|
||||
mouse_y = y;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
else if ( updown == PU_UP )
|
||||
{
|
||||
mouse_active = FALSE ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
void puGroup::draw ( int dx, int dy )
|
||||
{
|
||||
if ( ! isVisible () )
|
||||
return ;
|
||||
|
||||
for ( puObject *bo = dlist ; bo != NULL ; bo = bo -> getNextObject() )
|
||||
{
|
||||
/* June 16th, 98, Shammi :
|
||||
* The next if statement checks if the object is
|
||||
* a menu bar and makes sure it is repositioned
|
||||
* correctly.
|
||||
*/
|
||||
|
||||
int x, y ;
|
||||
int xdraw = dx + abox.min[0] ;
|
||||
int ydraw = dy + abox.min[1] ;
|
||||
bo -> getPosition (&x, &y) ;
|
||||
|
||||
/* Introduced PUCLASS_VERTMENU into the club of widgets being automatically moved */
|
||||
/* to the top-left corner of the screen. This eliminates all Vertmenu-resize and */
|
||||
/* window-jumping problems. - JCJ 31 May 2002 */
|
||||
|
||||
/* If the object is a menubar or a vertmenu and supposed to be locked to the top, */
|
||||
/* then move it there. - JCJ 6 June 2002 */
|
||||
if ( ( ( bo -> getType () & PUCLASS_MENUBAR ) ||
|
||||
( ( bo -> getType () & PUCLASS_VERTMENU ) &&
|
||||
( bo -> getVStatus () == 1 ) ) ) &&
|
||||
( bo -> getWindow () == puGetWindow () ) )
|
||||
{
|
||||
int obWidth, obHeight ;
|
||||
bo -> getSize ( &obWidth, &obHeight ) ;
|
||||
bo -> setPosition ( 0, puGetWindowHeight() - obHeight ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ( y < 0 ) && ( bo->getType () & PUCLASS_POPUPMENU ) )
|
||||
{
|
||||
/* IF the object's bottom left corner lies outside the window, THEN */
|
||||
/* move the object to the top left - JCJ and Fay 5 Jun 2002 */
|
||||
int absx, absy ;
|
||||
bo -> getAbsolutePosition (&absx, &absy) ;
|
||||
if ( absy < 0 )
|
||||
ydraw -= absy ;
|
||||
}
|
||||
}
|
||||
|
||||
bo -> draw ( xdraw, ydraw ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void puGroup::recalc_bbox ( void )
|
||||
{
|
||||
puBox contents ;
|
||||
contents . empty () ;
|
||||
|
||||
for ( puObject *bo = dlist ;
|
||||
bo != NULL ;
|
||||
bo = bo -> getNextObject() )
|
||||
contents . extend ( bo -> getBBox() ) ;
|
||||
|
||||
if ( contents . isEmpty () )
|
||||
{
|
||||
abox . max[0] = abox . min[0] ;
|
||||
abox . max[1] = abox . min[1] ;
|
||||
}
|
||||
else
|
||||
{
|
||||
abox . max[0] = abox . min[0] + contents . max[0] ;
|
||||
abox . max[1] = abox . min[1] + contents . max[1] ;
|
||||
}
|
||||
|
||||
puObject::recalc_bbox () ;
|
||||
}
|
||||
|
||||
|
||||
void puGroup::doHit ( int, int, int, int )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
puGroup::~puGroup ()
|
||||
{
|
||||
puObject *bo = getLastChild () ;
|
||||
|
||||
while ( bo != NULL )
|
||||
{
|
||||
dlist = bo ;
|
||||
bo = bo -> getPrevObject() ;
|
||||
puDeleteObject ( dlist ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void puGroup::setChildStyle ( int childs, int which, int recursive )
|
||||
{
|
||||
puObject *curr_obj ;
|
||||
|
||||
for ( curr_obj = getFirstChild () ;
|
||||
curr_obj != NULL ;
|
||||
curr_obj = curr_obj->getNextObject () )
|
||||
{
|
||||
if ( ( recursive == TRUE ) && ( curr_obj->getType () & PUCLASS_GROUP ) )
|
||||
((puGroup*)curr_obj)->setChildStyle ( childs, style, TRUE ) ;
|
||||
else
|
||||
{
|
||||
if ( curr_obj->getType () & childs )
|
||||
curr_obj->setStyle ( style ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void puGroup::setChildBorderThickness ( int childs, int t, int recursive )
|
||||
{
|
||||
puObject *curr_obj ;
|
||||
|
||||
for ( curr_obj = getFirstChild () ;
|
||||
curr_obj != NULL ;
|
||||
curr_obj = curr_obj->getNextObject () )
|
||||
{
|
||||
if ( ( recursive == TRUE ) && ( curr_obj->getType () & PUCLASS_GROUP ) )
|
||||
((puGroup*)curr_obj)->setChildBorderThickness ( childs, t, TRUE ) ;
|
||||
else
|
||||
{
|
||||
if ( curr_obj->getType () & childs )
|
||||
curr_obj->setBorderThickness ( t ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void puGroup::setChildColour ( int childs, int which, float r, float g, float b, float a, int recursive )
|
||||
{
|
||||
puObject *curr_obj ;
|
||||
|
||||
for ( curr_obj = getFirstChild () ;
|
||||
curr_obj != NULL ;
|
||||
curr_obj = curr_obj->getNextObject () )
|
||||
{
|
||||
if ( ( recursive == TRUE ) && ( curr_obj->getType () & PUCLASS_GROUP ) )
|
||||
((puGroup*)curr_obj)->setChildColour ( childs, which, r, g, b, a, TRUE ) ;
|
||||
else
|
||||
{
|
||||
if ( curr_obj->getType () & childs )
|
||||
curr_obj->setColour ( which, r, g, b, a ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void puGroup::setChildColourScheme ( int childs, float r, float g, float b, float a, int recursive )
|
||||
{
|
||||
puObject *curr_obj ;
|
||||
|
||||
for ( curr_obj = getFirstChild () ;
|
||||
curr_obj != NULL ;
|
||||
curr_obj = curr_obj->getNextObject () )
|
||||
{
|
||||
if ( ( recursive == TRUE ) && ( curr_obj->getType () & PUCLASS_GROUP ) )
|
||||
((puGroup*)curr_obj)->setChildColourScheme ( childs, r, g, b, a, TRUE ) ;
|
||||
else
|
||||
{
|
||||
if ( curr_obj->getType () & childs )
|
||||
curr_obj->setColourScheme ( r, g, b, a ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void puGroup::setChildLegendFont ( int childs, puFont f, int recursive )
|
||||
{
|
||||
puObject *curr_obj ;
|
||||
|
||||
for ( curr_obj = getFirstChild () ;
|
||||
curr_obj != NULL ;
|
||||
curr_obj = curr_obj->getNextObject () )
|
||||
{
|
||||
if ( ( recursive == TRUE ) && ( curr_obj->getType () & PUCLASS_GROUP ) )
|
||||
((puGroup*)curr_obj)->setChildLegendFont ( childs, f, TRUE ) ;
|
||||
else
|
||||
{
|
||||
if ( curr_obj->getType () & childs )
|
||||
curr_obj->setLegendFont ( f ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void puGroup::setChildLabelFont ( int childs, puFont f, int recursive )
|
||||
{
|
||||
puObject *curr_obj ;
|
||||
|
||||
for ( curr_obj = getFirstChild () ;
|
||||
curr_obj != NULL ;
|
||||
curr_obj = curr_obj->getNextObject () )
|
||||
{
|
||||
if ( ( recursive == TRUE ) && ( curr_obj->getType () & PUCLASS_GROUP ) )
|
||||
((puGroup*)curr_obj)->setChildLabelFont ( childs, f, TRUE ) ;
|
||||
else
|
||||
{
|
||||
if ( curr_obj->getType () & childs )
|
||||
curr_obj->setLabelFont ( f ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,438 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puInput,puObject)
|
||||
|
||||
|
||||
void puInput::normalize_cursors ( void )
|
||||
{
|
||||
int sl = strlen ( getStringValue () ) ;
|
||||
|
||||
/* Clamp the positions to the limits of the text. */
|
||||
|
||||
if ( cursor_position < 0 ) cursor_position = 0 ;
|
||||
if ( select_start_position < 0 ) select_start_position = 0 ;
|
||||
if ( select_end_position < 0 ) select_end_position = 0 ;
|
||||
if ( cursor_position > sl ) cursor_position = sl ;
|
||||
if ( select_start_position > sl ) select_start_position = sl ;
|
||||
if ( select_end_position > sl ) select_end_position = sl ;
|
||||
|
||||
/* Swap the ends of the select window if they get crossed over */
|
||||
|
||||
if ( select_end_position < select_start_position )
|
||||
{
|
||||
int tmp = select_end_position ;
|
||||
select_end_position = select_start_position ;
|
||||
select_start_position = tmp ;
|
||||
}
|
||||
}
|
||||
|
||||
void puInput::removeSelectRegion ( void )
|
||||
{
|
||||
char *p = new char [ strlen ( getStringValue () )
|
||||
+ select_start_position - select_end_position
|
||||
+ 1 ] ;
|
||||
strncpy ( p, getStringValue (), select_start_position ) ;
|
||||
strcpy ( p + select_start_position,
|
||||
getStringValue () + select_end_position ) ;
|
||||
setValue ( p ) ;
|
||||
delete [] p ;
|
||||
|
||||
cursor_position = select_end_position = select_start_position ;
|
||||
}
|
||||
|
||||
|
||||
static char *chop_to_width ( puFont fnt, const char *s, int width, int *ncut )
|
||||
{
|
||||
char *res = new char [ strlen ( s ) + 1 ] ;
|
||||
int n = 0 ;
|
||||
int w ;
|
||||
|
||||
do
|
||||
{
|
||||
strcpy ( res, & s[n] ) ;
|
||||
n++ ;
|
||||
w = fnt.getStringWidth ( res ) + 2 * PUSTR_RGAP + PUSTR_LGAP ;
|
||||
} while ( w >= width ) ;
|
||||
|
||||
if ( ncut != NULL ) *ncut = n-1 ;
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
void puInput::draw ( int dx, int dy )
|
||||
{
|
||||
normalize_cursors () ;
|
||||
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
/* 3D Input boxes look nicest if they are always in inverse style. */
|
||||
|
||||
abox.draw ( dx, dy, ( (style==PUSTYLE_SMALL_BEVELLED ||
|
||||
style==PUSTYLE_SMALL_SHADED) ) ? -style :
|
||||
(accepting ? -style : style ), colour, FALSE, border_thickness ) ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
int xx = legendFont.getStringWidth ( " " ) ;
|
||||
int yy = ( abox.max[1] - abox.min[1] - legendFont.getStringHeight () ) / 2 ;
|
||||
|
||||
int ncut ;
|
||||
char *s2 ;
|
||||
|
||||
if ( accepting )
|
||||
{
|
||||
/* Highlight the select area */
|
||||
|
||||
if ( select_end_position > 0 &&
|
||||
select_end_position != select_start_position )
|
||||
{
|
||||
s2 = chop_to_width ( legendFont, getStringValue(), abox.max[0]-abox.min[0], &ncut ) ;
|
||||
|
||||
int sep = select_end_position - ncut ;
|
||||
int ssp = select_start_position - ncut ;
|
||||
|
||||
if ( sep < 0 ) sep = 0 ;
|
||||
if ( ssp < 0 ) ssp = 0 ;
|
||||
|
||||
if ( ssp < sep )
|
||||
{
|
||||
s2 [ sep ] = '\0' ;
|
||||
int cpos2 = legendFont.getStringWidth ( s2 ) +
|
||||
xx + dx + abox.min[0] ;
|
||||
s2 [ ssp ] = '\0' ;
|
||||
int cpos1 = legendFont.getStringWidth ( s2 ) +
|
||||
xx + dx + abox.min[0] ;
|
||||
|
||||
glColor3f ( 1.0f, 1.0f, 0.7f ) ;
|
||||
glRecti ( cpos1, dy + abox.min[1] + 2 ,
|
||||
cpos2, dy + abox.max[1] - 2 ) ;
|
||||
}
|
||||
|
||||
/* Required because "chop_to_width" allocates the string space */
|
||||
|
||||
delete [] s2 ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the text */
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the text */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transp */
|
||||
|
||||
s2 = chop_to_width ( legendFont, getStringValue(),
|
||||
abox.max[0]-abox.min[0], &ncut ) ;
|
||||
|
||||
legendFont.drawString ( s2,
|
||||
dx + abox.min[0] + xx,
|
||||
dy + abox.min[1] + yy ) ;
|
||||
|
||||
|
||||
if ( accepting )
|
||||
{
|
||||
/* Draw the 'I' bar cursor. */
|
||||
|
||||
if ( cursor_position - ncut >= 0 )
|
||||
{
|
||||
s2 [ cursor_position-ncut ] = '\0' ;
|
||||
|
||||
int cpos = legendFont.getStringWidth ( s2 ) + xx + dx + abox.min[0] ;
|
||||
int top = yy + legendFont.getStringHeight () ;
|
||||
int bot = yy - legendFont.getStringDescender() ;
|
||||
|
||||
glColor4fv ( colour [ PUCOL_MISC ] ) ;
|
||||
glBegin ( GL_LINES ) ;
|
||||
glVertex2i ( cpos , dy + abox.min[1] + bot ) ;
|
||||
glVertex2i ( cpos , dy + abox.min[1] + top ) ;
|
||||
glVertex2i ( cpos - 1, dy + abox.min[1] + bot ) ;
|
||||
glVertex2i ( cpos - 1, dy + abox.min[1] + top ) ;
|
||||
glVertex2i ( cpos - 4, dy + abox.min[1] + bot ) ;
|
||||
glVertex2i ( cpos + 3, dy + abox.min[1] + bot ) ;
|
||||
glVertex2i ( cpos - 4, dy + abox.min[1] + top ) ;
|
||||
glVertex2i ( cpos + 3, dy + abox.min[1] + top ) ;
|
||||
glEnd () ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Required because "chop_to_width" allocates the string space */
|
||||
|
||||
delete [] s2 ;
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puInput::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
/* Active widget exists and is not this one; call its down callback if it exists */
|
||||
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
puMoveToLast ( this );
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
/* Most GUI's activate a button on button-UP not button-DOWN. */
|
||||
|
||||
/* Find the position of the mouse on the line of text */
|
||||
|
||||
int ncut ;
|
||||
char *s2 = chop_to_width ( legendFont, getStringValue(),
|
||||
abox.max[0]-abox.min[0], &ncut ) ;
|
||||
int i = strlen ( s2 ) ;
|
||||
|
||||
int length, prev_length ;
|
||||
length = legendFont.getStringWidth ( s2 ) + abox.min[0] ;
|
||||
prev_length = length ;
|
||||
|
||||
while ( ( x <= prev_length ) && ( i > 0 ) )
|
||||
{
|
||||
prev_length = length ;
|
||||
s2[--i] = '\0' ;
|
||||
length = legendFont.getStringWidth ( s2 ) + abox.min[0] ;
|
||||
}
|
||||
|
||||
/* Required because "chop_to_width" allocates the string space */
|
||||
delete [] s2 ;
|
||||
|
||||
if ( ( x - length ) > ( prev_length - x ) )
|
||||
i++ ; /* Mouse is closer to next character than previous character */
|
||||
|
||||
i += ncut ;
|
||||
|
||||
/* Process the mouse click. */
|
||||
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
|
||||
{
|
||||
lowlight () ;
|
||||
|
||||
accepting = TRUE ;
|
||||
cursor_position = i ;
|
||||
normalize_cursors () ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
else if ( updown == PU_DOWN )
|
||||
{
|
||||
/*
|
||||
* We get here if the active edge is not down but the mouse button has
|
||||
* been pressed. Start a selection if this isn't the initial activation
|
||||
* of the widget.
|
||||
*/
|
||||
|
||||
if ( this == puActiveWidget() )
|
||||
{
|
||||
select_start_position = i ;
|
||||
select_end_position = i ;
|
||||
}
|
||||
}
|
||||
else if ( updown == PU_DRAG )
|
||||
{
|
||||
|
||||
if ( (select_end_position - i) > (i - select_start_position) )
|
||||
select_start_position = i ; /* Cursor closer to start than to end */
|
||||
else
|
||||
select_end_position = i ; /* Cursor closer to end than to start */
|
||||
|
||||
if (select_start_position > select_end_position)
|
||||
{
|
||||
i = select_end_position ;
|
||||
select_end_position = select_start_position ;
|
||||
select_start_position = i ;
|
||||
}
|
||||
}
|
||||
else
|
||||
highlight () ;
|
||||
}
|
||||
else
|
||||
lowlight () ;
|
||||
}
|
||||
|
||||
|
||||
int puInput::checkKey ( int key, int /* updown */ )
|
||||
{
|
||||
extern void puSetPasteBuffer ( char *ch ) ;
|
||||
extern char *puGetPasteBuffer ( void ) ;
|
||||
|
||||
if ( ! isAcceptingInput() || ! isActive () || ! isVisible () || ( window != puGetWindow () ) )
|
||||
return FALSE ;
|
||||
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
/* Active widget exists and is not this one; call its down callback if it exists */
|
||||
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
normalize_cursors () ;
|
||||
|
||||
char *p = NULL ;
|
||||
|
||||
int char_used = TRUE ;
|
||||
|
||||
switch ( key )
|
||||
{
|
||||
case PU_KEY_PAGE_UP :
|
||||
case PU_KEY_PAGE_DOWN :
|
||||
case PU_KEY_INSERT : return FALSE ;
|
||||
|
||||
case PU_KEY_UP :
|
||||
case PU_KEY_DOWN :
|
||||
case 0x1B /* ESC */ :
|
||||
case '\t' :
|
||||
case '\r' :
|
||||
case '\n' : /* Carriage return/Line Feed/TAB -- End of input */
|
||||
rejectInput () ;
|
||||
normalize_cursors () ;
|
||||
invokeCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
break ;
|
||||
|
||||
case PU_KEY_HOME : cursor_position = 0 ; break ;
|
||||
case PU_KEY_END :
|
||||
cursor_position = strlen ( getStringValue () ) ;
|
||||
break ;
|
||||
case PU_KEY_LEFT : cursor_position-- ; break ;
|
||||
case PU_KEY_RIGHT : cursor_position++ ; break ;
|
||||
default : char_used = FALSE ;
|
||||
}
|
||||
|
||||
if ( ! input_disabled && ! char_used )
|
||||
{
|
||||
switch ( key )
|
||||
{
|
||||
case '\b' : /* Backspace */
|
||||
if ( select_start_position != select_end_position )
|
||||
removeSelectRegion () ;
|
||||
else if ( cursor_position > 0 )
|
||||
{
|
||||
p = new char [ strlen ( getStringValue () ) ] ;
|
||||
strncpy ( p, getStringValue (), cursor_position - 1 ) ;
|
||||
strcpy ( p + cursor_position - 1,
|
||||
getStringValue () + cursor_position ) ;
|
||||
cursor_position-- ;
|
||||
}
|
||||
|
||||
break ;
|
||||
|
||||
case 0x7F : /* DEL */
|
||||
if ( select_start_position != select_end_position )
|
||||
removeSelectRegion () ;
|
||||
else if ( cursor_position != (int)strlen ( getStringValue() ) )
|
||||
{
|
||||
p = new char [ strlen ( getStringValue () ) ] ;
|
||||
strncpy ( p, getStringValue (), cursor_position ) ;
|
||||
strcpy ( p + cursor_position,
|
||||
getStringValue () + cursor_position + 1 ) ;
|
||||
}
|
||||
|
||||
break ;
|
||||
|
||||
case 0x15 /* ^U */ : setValue ( "\0" ) ; break ;
|
||||
case 0x03 /* ^C */ :
|
||||
case 0x18 /* ^X */ : /* Cut or copy selected text */
|
||||
if ( select_start_position != select_end_position )
|
||||
{
|
||||
p = getStringValue () ;
|
||||
char ch = p[select_end_position] ;
|
||||
p[select_end_position] = '\0' ;
|
||||
puSetPasteBuffer ( p + select_start_position ) ;
|
||||
p[select_end_position] = ch ;
|
||||
|
||||
if ( key == 0x18 ) /* Cut, remove text from string */
|
||||
removeSelectRegion () ;
|
||||
|
||||
/*
|
||||
So we don't set the widget to its value at the end of the
|
||||
function
|
||||
*/
|
||||
|
||||
p = NULL ;
|
||||
}
|
||||
|
||||
break ;
|
||||
|
||||
case 0x16 /* ^V */ : /* Paste buffer into text */
|
||||
if ( select_start_position != select_end_position )
|
||||
removeSelectRegion () ;
|
||||
|
||||
p = new char [ strlen ( getStringValue () )
|
||||
+ strlen ( puGetPasteBuffer () )
|
||||
+ 1 ] ;
|
||||
strncpy ( p, getStringValue (), cursor_position ) ;
|
||||
strcpy ( p + cursor_position, puGetPasteBuffer () ) ;
|
||||
strcat ( p, getStringValue () + cursor_position ) ;
|
||||
cursor_position += strlen ( puGetPasteBuffer () ) ;
|
||||
|
||||
break ;
|
||||
|
||||
default:
|
||||
if ( key < ' ' || key > 127 ) return FALSE ;
|
||||
if ( valid_data )
|
||||
{
|
||||
if ( !strchr ( valid_data, key ) ) return TRUE ;
|
||||
}
|
||||
|
||||
if ( select_start_position != select_end_position ) // remove selected text
|
||||
removeSelectRegion () ;
|
||||
|
||||
p = new char [ strlen ( getStringValue () ) + 2 ] ;
|
||||
strncpy ( p, getStringValue (), cursor_position ) ;
|
||||
p[cursor_position] = key ;
|
||||
strcpy ( p + cursor_position + 1,
|
||||
getStringValue () + cursor_position ) ;
|
||||
|
||||
cursor_position++ ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( p != NULL )
|
||||
setValue ( p ) ; /* Set the widget value to the new string */
|
||||
|
||||
delete [] p ;
|
||||
}
|
||||
|
||||
normalize_cursors () ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puInterface,puGroup)
|
||||
|
||||
|
||||
#define PUSTACK_MAX 100
|
||||
|
||||
static int currLiveInterface = -1 ;
|
||||
static puInterface *liveInterfaceStack [ PUSTACK_MAX ] ;
|
||||
|
||||
void puPushLiveInterface ( puInterface *in )
|
||||
{
|
||||
if ( currLiveInterface < PUSTACK_MAX - 1 )
|
||||
liveInterfaceStack [ ++currLiveInterface ] = in ;
|
||||
else
|
||||
ulSetError ( UL_WARNING, "PUI: Too many live puInterfaces open at once!\n" ) ;
|
||||
}
|
||||
|
||||
void puPopLiveInterface ( puInterface *in )
|
||||
{
|
||||
if ( currLiveInterface <= 0 )
|
||||
{
|
||||
ulSetError ( UL_WARNING, "PUI: Live puInterface stack is empty!\n" ) ;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( in == NULL )
|
||||
--currLiveInterface ;
|
||||
else
|
||||
{
|
||||
for ( int i = currLiveInterface ; i >= 0 ; i-- )
|
||||
{
|
||||
if ( in == liveInterfaceStack [ i ] )
|
||||
{
|
||||
/* Handle interfaces that are buried in the stack */
|
||||
while ( i < currLiveInterface )
|
||||
{
|
||||
liveInterfaceStack [ i ] = liveInterfaceStack [ i+1 ] ;
|
||||
i++ ;
|
||||
}
|
||||
|
||||
--currLiveInterface ;
|
||||
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int puNoLiveInterface ( void )
|
||||
{
|
||||
return currLiveInterface < 0 ;
|
||||
}
|
||||
|
||||
puInterface *puGetUltimateLiveInterface ( void )
|
||||
{
|
||||
if ( currLiveInterface < 0 )
|
||||
ulSetError ( UL_FATAL, "PUI: No Live Interface! Forgot to call puInit ?\n" ) ;
|
||||
|
||||
return liveInterfaceStack [ 0 ] ;
|
||||
}
|
||||
|
||||
|
||||
puInterface *puGetBaseLiveInterface ( void )
|
||||
{
|
||||
if ( currLiveInterface < 0 )
|
||||
ulSetError ( UL_FATAL, "PUI: No Live Interface! Forgot to call puInit ?\n" ) ;
|
||||
|
||||
/*
|
||||
Work down the interface stack until you
|
||||
either get to the bottom or find a block
|
||||
in the form of a puDialogBox.
|
||||
*/
|
||||
|
||||
for ( int i = currLiveInterface ; i > 0 ; i-- )
|
||||
if ( liveInterfaceStack [ i ] -> getType () & PUCLASS_DIALOGBOX )
|
||||
return liveInterfaceStack [ i ] ;
|
||||
|
||||
return liveInterfaceStack [ 0 ] ;
|
||||
}
|
||||
|
||||
|
||||
puInterface::~puInterface ()
|
||||
{
|
||||
puObject *bo = getLastChild () ;
|
||||
|
||||
while ( bo != NULL )
|
||||
{
|
||||
dlist = bo ;
|
||||
bo = bo -> getPrevObject() ;
|
||||
puDeleteObject ( dlist ) ;
|
||||
}
|
||||
|
||||
dlist = NULL ;
|
||||
|
||||
puPopLiveInterface ( this ) ;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/****
|
||||
* NAME
|
||||
* puListBox
|
||||
*
|
||||
* DESCRIPTION
|
||||
* list of strings
|
||||
*
|
||||
* AUTHOR
|
||||
* Dave McClurg <dpm@efn.org>
|
||||
*
|
||||
* CREATION DATE
|
||||
* August 2000
|
||||
*
|
||||
* MODIFICATION HISTORY
|
||||
* John Fay - many improvements
|
||||
****/
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puListBox,puButton)
|
||||
|
||||
|
||||
puListBox::puListBox ( int minx, int miny, int maxx, int maxy, char** _list ) :
|
||||
puButton ( minx, miny, maxx, maxy )
|
||||
{
|
||||
type |= PUCLASS_LISTBOX ;
|
||||
|
||||
newList ( _list ) ;
|
||||
}
|
||||
|
||||
|
||||
void puListBox::newList ( char ** _list )
|
||||
{
|
||||
list = _list ;
|
||||
|
||||
if ( list == NULL )
|
||||
num = 0 ;
|
||||
else
|
||||
for ( num = 0 ; list [ num ] != NULL ; num++ )
|
||||
/* Count number of items */ ;
|
||||
|
||||
top = 0 ;
|
||||
|
||||
/* Set index of selected item */
|
||||
setValue ( -1 ) ;
|
||||
|
||||
puPostRefresh () ;
|
||||
}
|
||||
|
||||
|
||||
void puListBox::setTopItem( int item_index )
|
||||
{
|
||||
top = item_index ;
|
||||
if ( top < 0 )
|
||||
top = 0 ;
|
||||
else if ( top > num-1 )
|
||||
top = num-1;
|
||||
|
||||
puPostRefresh () ;
|
||||
}
|
||||
|
||||
|
||||
void puListBox::draw ( int dx, int dy )
|
||||
{
|
||||
if ( !visible || ( window != puGetWindow () ) || list == NULL ) return ;
|
||||
|
||||
abox.draw ( dx, dy, style, colour, isReturnDefault(), border_thickness ) ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the text */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
int xsize = abox.max[0] - abox.min[0] + 1 ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
int yinc = legendFont.getStringHeight () + PUSTR_BGAP ;
|
||||
int num_vis = getNumVisible () ;
|
||||
|
||||
int selected ;
|
||||
getValue ( &selected ) ;
|
||||
|
||||
for ( int i = top ; i < num && i < top + num_vis ; i++ )
|
||||
{
|
||||
if ( i == selected )
|
||||
glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ;
|
||||
else
|
||||
glColor4f ( 0.0f, 0.0f, 0.0f, 1.0f ) ;
|
||||
|
||||
int x = PUSTR_LGAP ;
|
||||
int y = yinc * ((i-top)+1) ;
|
||||
|
||||
int xx = dx + abox.min[0] + x ;
|
||||
int yy = dy + abox.max[1] - y ;
|
||||
|
||||
int width ;
|
||||
char str [ PUSTRING_MAX ] ;
|
||||
strcpy ( str, list [ i ] ) ;
|
||||
|
||||
/*
|
||||
Does the string fit into the box?
|
||||
|
||||
If not, chop it down one character at a time until
|
||||
it does fit.
|
||||
*/
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
width = legendFont.getStringWidth ( (char *)str ) + PUSTR_LGAP ;
|
||||
|
||||
if ( width < xsize )
|
||||
break ;
|
||||
|
||||
/*
|
||||
Nibble off one character and try again
|
||||
(Do that sneakily by replacing the last 4 characters with 3 dots)
|
||||
*/
|
||||
|
||||
strcpy ( & str [ strlen(str) - 4 ], "..." ) ;
|
||||
}
|
||||
|
||||
legendFont.drawString ( (char*)str, xx, yy ) ;
|
||||
}
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puListBox::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
|
||||
{
|
||||
lowlight () ;
|
||||
|
||||
int yinc = legendFont.getStringHeight () + PUSTR_BGAP ;
|
||||
int idx = top + ( abox.max[1] - PUSTR_BGAP - y ) / yinc;
|
||||
if ( idx < 0 )
|
||||
idx = 0;
|
||||
else if ( idx >= num )
|
||||
idx = num-1;
|
||||
|
||||
setValue ( idx ) ;
|
||||
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
else
|
||||
highlight () ;
|
||||
}
|
||||
else
|
||||
lowlight () ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "pu.h"
|
||||
|
||||
/*
|
||||
Include GLUT
|
||||
*/
|
||||
|
||||
#ifndef PU_NOT_USING_GLUT
|
||||
# ifdef FREEGLUT_IS_PRESENT
|
||||
# include <GL/freeglut.h>
|
||||
# else
|
||||
# ifdef __APPLE__
|
||||
# include <GLUT/glut.h>
|
||||
# else
|
||||
# include <GL/glut.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puMenuBar,puInterface)
|
||||
|
||||
|
||||
void puMenuBar_drop_down_the_menu ( puObject *b )
|
||||
{
|
||||
// Inputs: b = pointer to the button on the menu which has been pushed
|
||||
// p = pointer to the popup menu which is b's submenu
|
||||
|
||||
puPopupMenu *p = (puPopupMenu *) b -> getUserData () ;
|
||||
|
||||
if ( b -> getIntegerValue () )
|
||||
{
|
||||
/*
|
||||
SJBL Test hack.
|
||||
*/
|
||||
puDeactivateWidget () ;
|
||||
|
||||
p->reveal () ; // Reveal the submenu
|
||||
|
||||
// If the parent floats in its own window, and the submenu drops off the window,
|
||||
// expand the window to fit.
|
||||
|
||||
#ifndef PU_NOT_USING_GLUT
|
||||
puGroup *parent = p -> getParent () ;
|
||||
|
||||
if ( ( parent != parent -> getParent () ) && parent -> getFloating () )
|
||||
{
|
||||
int temp_window = puGetWindow () ;
|
||||
glutSetWindow ( parent -> getWindow () ) ;
|
||||
|
||||
puBox *par_box = parent -> getBBox () ;
|
||||
puBox *cur_box = p -> getBBox () ;
|
||||
int x_min = (cur_box->min[0] < 0) ? par_box->min[0] + cur_box->min[0] : par_box->min[0] ;
|
||||
int x_max = (par_box->max[0] > par_box->min[0] + cur_box->max[0]) ?
|
||||
par_box->max[0] : par_box->min[0] + cur_box->max[0] ;
|
||||
int y_min = (cur_box->min[1] < 0) ? par_box->min[1] + cur_box->min[1] : par_box->min[1] ;
|
||||
int y_max = (par_box->max[1] > par_box->min[1] + cur_box->max[1]) ?
|
||||
par_box->max[1] : par_box->min[1] + cur_box->max[1] ;
|
||||
int x_siz = glutGet ( (GLenum)GLUT_WINDOW_WIDTH ) ;
|
||||
int y_siz = glutGet ( (GLenum)GLUT_WINDOW_HEIGHT ) ;
|
||||
if ( x_siz < (x_max - x_min) ) x_siz = x_max - x_min ; // Adjust the present size
|
||||
if ( y_siz < (y_max - y_min) ) y_siz = y_max - y_min ;
|
||||
|
||||
glutReshapeWindow ( x_siz, y_siz ) ;
|
||||
|
||||
x_min = par_box->min[0] - x_min ;
|
||||
y_min = y_siz - ( par_box->max[1] - par_box->min[1] ) ;
|
||||
|
||||
/* If the parent window is SUPPOSED to be stuck at the top of the screen, move it.
|
||||
- JCJ 6 June 2002 */
|
||||
if (parent -> getVStatus () == 1)
|
||||
parent -> setPosition ( x_min, y_min ) ;
|
||||
|
||||
glutSetWindow ( temp_window ) ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
p->hide () ;
|
||||
|
||||
for ( puObject *child = b -> getParent () -> getFirstChild () ;
|
||||
child != NULL ; child = child -> getNextObject() )
|
||||
{
|
||||
if (( child -> getType() & PUCLASS_BUTTON ) != 0 && child != b ) child -> clrValue () ;
|
||||
if (( child -> getType() & PUCLASS_POPUPMENU ) != 0 && child != p ) child -> hide () ;
|
||||
}
|
||||
|
||||
// Move the popup menu to the last item in the "dlist" so it is drawn last
|
||||
// (in front of everything else).
|
||||
|
||||
puMoveToLast ( p );
|
||||
}
|
||||
|
||||
void puMenuBar::add_submenu ( const char *str, char *items[], puCallback _cb[],
|
||||
void *_user_data[] )
|
||||
{
|
||||
int w, h ;
|
||||
getSize ( &w, &h ) ;
|
||||
|
||||
puOneShot *b ;
|
||||
|
||||
if ( bar_height > 0 )
|
||||
{
|
||||
b = new puOneShot ( w+10,
|
||||
0,
|
||||
w+10 + PUSTR_LGAP + puGetDefaultLegendFont().getStringWidth ( str ) + PUSTR_RGAP,
|
||||
bar_height ) ;
|
||||
b -> setLegend ( str ) ;
|
||||
}
|
||||
else
|
||||
b = new puOneShot ( w+10, 0, str ) ;
|
||||
|
||||
b -> setStyle ( PUSTYLE_SPECIAL_UNDERLINED ) ;
|
||||
b -> setColourScheme ( colour[PUCOL_FOREGROUND][0],
|
||||
colour[PUCOL_FOREGROUND][1],
|
||||
colour[PUCOL_FOREGROUND][2],
|
||||
colour[PUCOL_FOREGROUND][3] ) ;
|
||||
b -> setCallback ( puMenuBar_drop_down_the_menu ) ;
|
||||
b -> setActiveDirn ( PU_UP_AND_DOWN ) ;
|
||||
|
||||
puPopupMenu *p = new puPopupMenu ( w+10, 0 ) ;
|
||||
|
||||
b -> setUserData ( p ) ;
|
||||
|
||||
if ( _user_data != NULL )
|
||||
for ( int i = 0 ; items[i] != NULL ; i++ )
|
||||
p -> add_item ( items[i], _cb[i], _user_data[i] ) ;
|
||||
else
|
||||
for ( int i = 0 ; items[i] != NULL ; i++ )
|
||||
p -> add_item ( items[i], _cb[i] ) ;
|
||||
|
||||
p->close () ;
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
void puMenuBar::close (void)
|
||||
{
|
||||
puInterface::close () ;
|
||||
|
||||
if ( dlist == NULL )
|
||||
return ;
|
||||
|
||||
int width = 0 ;
|
||||
puObject *ob ;
|
||||
|
||||
/*
|
||||
Use alternate objects - which gets the puOneShot/puPopupMenu pairs
|
||||
*/
|
||||
|
||||
for ( ob = dlist ; ob != NULL ; ob = ob -> getNextObject() )
|
||||
{
|
||||
int w, h ;
|
||||
|
||||
/* Reposition the button so it looks nice */
|
||||
|
||||
ob -> getSize ( &w, &h ) ;
|
||||
ob -> setPosition ( width, 0 ) ;
|
||||
ob = ob -> getNextObject() ;
|
||||
|
||||
/* Reposition the submenu so it sits under the button */
|
||||
|
||||
int w2, h2 ;
|
||||
ob -> getSize ( &w2, &h2 ) ;
|
||||
ob -> setPosition ( width, -h2 ) ;
|
||||
|
||||
/* Next please! */
|
||||
width += w ;
|
||||
}
|
||||
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,505 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puObject,puValue)
|
||||
|
||||
|
||||
inline float clamp01 ( float x )
|
||||
{
|
||||
return (x >= 1.0f) ? 1.0f : x ;
|
||||
}
|
||||
|
||||
static void load_colour_scheme ( float col[][4], float r, float g,
|
||||
float b, float a )
|
||||
{
|
||||
puSetColour ( col [ PUCOL_FOREGROUND ], r, g, b, a ) ;
|
||||
puSetColour ( col [ PUCOL_BACKGROUND ], r/2.0f, g/2.0f, b/2.0f, a ) ;
|
||||
puSetColour ( col [ PUCOL_HIGHLIGHT ], clamp01(r*1.3f), clamp01(g*1.3f),
|
||||
clamp01(b*1.3f), a ) ;
|
||||
|
||||
if ( 4.0f * g + 3.0f * r + b > 4.0f )
|
||||
{
|
||||
puSetColour ( col [ PUCOL_LEGEND ], 0.0f, 0.0f, 0.0f, a ) ;
|
||||
puSetColour ( col [ PUCOL_MISC ], 0.0f, 0.0f, 0.0f, a ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
puSetColour ( col [ PUCOL_LEGEND ], 1.0f, 1.0f, 1.0f, a ) ;
|
||||
puSetColour ( col [ PUCOL_MISC ], 1.0f, 1.0f, 1.0f, a ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int defaultStyle = PUSTYLE_DEFAULT ;
|
||||
static int defaultBorderThickness = 5 ;
|
||||
static puFont defaultLegendFont ;
|
||||
static puFont defaultLabelFont ;
|
||||
static float defaultColourScheme [ 4 ] ;
|
||||
|
||||
void puSetDefaultStyle ( int style )
|
||||
{
|
||||
defaultStyle = style ;
|
||||
|
||||
switch ( abs(style) )
|
||||
{
|
||||
case PUSTYLE_SPECIAL_UNDERLINED :
|
||||
defaultBorderThickness = 1 ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_SMALL_BEVELLED :
|
||||
case PUSTYLE_SMALL_SHADED :
|
||||
case PUSTYLE_BOXED :
|
||||
defaultBorderThickness = 2 ;
|
||||
break ;
|
||||
|
||||
case PUSTYLE_BEVELLED :
|
||||
case PUSTYLE_SHADED :
|
||||
case PUSTYLE_DROPSHADOW :
|
||||
defaultBorderThickness = 5 ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
int puGetDefaultStyle ( void ) { return defaultStyle ; }
|
||||
|
||||
void puSetDefaultBorderThickness ( int t ) { defaultBorderThickness = t ; }
|
||||
int puGetDefaultBorderThickness ( void ) { return defaultBorderThickness ; }
|
||||
|
||||
void puSetDefaultFonts ( puFont legendFont, puFont labelFont )
|
||||
{
|
||||
defaultLegendFont = legendFont ;
|
||||
defaultLabelFont = labelFont ;
|
||||
}
|
||||
|
||||
puFont puGetDefaultLabelFont ( void ) { return defaultLabelFont ; }
|
||||
puFont puGetDefaultLegendFont ( void ) { return defaultLegendFont ; }
|
||||
|
||||
void puGetDefaultFonts ( puFont *legendFont, puFont *labelFont )
|
||||
{
|
||||
if ( legendFont ) *legendFont = defaultLegendFont ;
|
||||
if ( labelFont ) *labelFont = defaultLabelFont ;
|
||||
}
|
||||
|
||||
void puSetDefaultColourScheme ( float r, float g, float b, float a )
|
||||
{
|
||||
defaultColourScheme[0] = r ;
|
||||
defaultColourScheme[1] = g ;
|
||||
defaultColourScheme[2] = b ;
|
||||
defaultColourScheme[3] = a ;
|
||||
load_colour_scheme ( _puDefaultColourTable, r, g, b, a ) ;
|
||||
}
|
||||
|
||||
void puGetDefaultColourScheme ( float *r, float *g, float *b, float *a )
|
||||
{
|
||||
if ( r ) *r = defaultColourScheme[0] ;
|
||||
if ( g ) *g = defaultColourScheme[1] ;
|
||||
if ( b ) *b = defaultColourScheme[2] ;
|
||||
if ( a ) *a = defaultColourScheme[3] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void puObject::setColourScheme ( float r, float g, float b, float a )
|
||||
{
|
||||
load_colour_scheme ( colour, r, g, b, a ) ;
|
||||
puPostRefresh () ;
|
||||
}
|
||||
|
||||
puObject::puObject ( int minx, int miny, int maxx, int maxy ) : puValue ()
|
||||
{
|
||||
type |= PUCLASS_OBJECT ;
|
||||
|
||||
bbox.min[0] = abox.min[0] = minx ;
|
||||
bbox.min[1] = abox.min[1] = miny ;
|
||||
bbox.max[0] = abox.max[0] = maxx ;
|
||||
bbox.max[1] = abox.max[1] = maxy ;
|
||||
|
||||
active_mouse_edge = PU_UP ;
|
||||
style = defaultStyle ;
|
||||
visible = active = TRUE ;
|
||||
highlighted = FALSE ;
|
||||
am_default = FALSE ;
|
||||
window = puGetWindow () ;
|
||||
v_status = 0 ;
|
||||
isSubWidget = FALSE ;
|
||||
|
||||
cb = NULL ;
|
||||
active_cb = NULL ;
|
||||
down_cb = NULL ;
|
||||
r_cb = NULL ;
|
||||
border_thickness = defaultBorderThickness ;
|
||||
render_data = NULL ;
|
||||
user_data = NULL ;
|
||||
next = prev = NULL ;
|
||||
label = NULL ;
|
||||
labelPlace = PUPLACE_LABEL_DEFAULT ;
|
||||
labelFont = defaultLabelFont ;
|
||||
legend = NULL ;
|
||||
legendFont = defaultLegendFont ;
|
||||
legendPlace = PUPLACE_LEGEND_DEFAULT ;
|
||||
|
||||
for ( int i = 0 ; i < PUCOL_MAX ; i++ )
|
||||
puSetColour ( colour[i], _puDefaultColourTable[i] ) ;
|
||||
|
||||
parent = NULL ;
|
||||
|
||||
if ( ! puNoGroup() )
|
||||
puGetCurrGroup() -> add ( this ) ;
|
||||
|
||||
puPostRefresh () ;
|
||||
}
|
||||
|
||||
|
||||
puObject::~puObject ()
|
||||
{
|
||||
if ( parent != this && parent != NULL )
|
||||
parent -> remove ( this ) ;
|
||||
|
||||
if ( this == puActiveWidget () )
|
||||
puDeactivateWidget () ;
|
||||
|
||||
puPostRefresh () ;
|
||||
}
|
||||
|
||||
void puObject::recalc_bbox ( void )
|
||||
{
|
||||
bbox = abox ;
|
||||
|
||||
if ( label != NULL )
|
||||
{
|
||||
switch ( labelPlace ) // Extend the bounding box left and right
|
||||
{
|
||||
case PUPLACE_ABOVE_LEFT :
|
||||
case PUPLACE_UPPER_LEFT :
|
||||
case PUPLACE_CENTERED_LEFT :
|
||||
case PUPLACE_LOWER_LEFT :
|
||||
case PUPLACE_BELOW_LEFT :
|
||||
bbox.min[0] -= labelFont.getStringWidth ( label ) + PUSTR_LGAP ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_ABOVE_RIGHT :
|
||||
case PUPLACE_UPPER_RIGHT :
|
||||
case PUPLACE_CENTERED_RIGHT :
|
||||
case PUPLACE_LOWER_RIGHT :
|
||||
case PUPLACE_BELOW_RIGHT :
|
||||
bbox.max[0] += labelFont.getStringWidth ( label ) + PUSTR_RGAP ;
|
||||
break ;
|
||||
}
|
||||
|
||||
switch ( labelPlace ) // Extend the bounding box up and down
|
||||
{
|
||||
case PUPLACE_ABOVE_LEFT :
|
||||
case PUPLACE_TOP_LEFT :
|
||||
case PUPLACE_TOP_CENTERED :
|
||||
case PUPLACE_TOP_RIGHT :
|
||||
case PUPLACE_ABOVE_RIGHT :
|
||||
bbox.max[1] += labelFont.getStringHeight ( label ) + labelFont.getStringDescender () +
|
||||
PUSTR_TGAP ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_BELOW_LEFT :
|
||||
case PUPLACE_BOTTOM_LEFT :
|
||||
case PUPLACE_BOTTOM_CENTERED :
|
||||
case PUPLACE_BOTTOM_RIGHT :
|
||||
case PUPLACE_BELOW_RIGHT :
|
||||
bbox.min[1] -= labelFont.getStringHeight ( label ) + labelFont.getStringDescender () +
|
||||
PUSTR_BGAP ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( parent != NULL )
|
||||
parent -> recalc_bbox () ;
|
||||
}
|
||||
|
||||
void puObject::getAbsolutePosition ( int *x, int *y ) const
|
||||
{
|
||||
puGroup *par ;
|
||||
*x = abox.min[0] ;
|
||||
*y = abox.min[1] ;
|
||||
|
||||
for ( par = getParent () ; par != NULL ; par = par -> getParent () )
|
||||
{
|
||||
int x_offset, y_offset ;
|
||||
par -> getPosition ( &x_offset, &y_offset ) ;
|
||||
|
||||
*x += x_offset ;
|
||||
*y += y_offset ;
|
||||
}
|
||||
}
|
||||
|
||||
void puObject::draw_legend ( int dx, int dy )
|
||||
{
|
||||
if ( legend == NULL )
|
||||
return ;
|
||||
|
||||
int xx, yy ;
|
||||
|
||||
int lgap = PUSTR_LGAP ;
|
||||
int rgap = PUSTR_RGAP ;
|
||||
int tgap = PUSTR_TGAP ;
|
||||
int bgap = PUSTR_BGAP ;
|
||||
|
||||
if ( ( abs(style) != PUSTYLE_NONE ) &&
|
||||
( abs(style) != PUSTYLE_PLAIN ) &&
|
||||
( abs(style) != PUSTYLE_DROPSHADOW ) )
|
||||
{
|
||||
if ( abs(style) != PUSTYLE_SPECIAL_UNDERLINED )
|
||||
{
|
||||
lgap += getBorderThickness () ;
|
||||
rgap += getBorderThickness () ;
|
||||
tgap += getBorderThickness () ;
|
||||
}
|
||||
bgap += getBorderThickness () ;
|
||||
}
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the legend */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LEGEND ][0],
|
||||
colour [ PUCOL_LEGEND ][1],
|
||||
colour [ PUCOL_LEGEND ][2],
|
||||
colour [ PUCOL_LEGEND ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
switch ( getLegendPlace() )
|
||||
{
|
||||
case PUPLACE_TOP_LEFT :
|
||||
case PUPLACE_CENTERED_LEFT :
|
||||
case PUPLACE_BOTTOM_LEFT :
|
||||
case PUPLACE_LOWER_LEFT :
|
||||
xx = lgap ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_TOP_CENTERED :
|
||||
case PUPLACE_CENTERED_CENTERED :
|
||||
case PUPLACE_BOTTOM_CENTERED :
|
||||
xx = ( abox.max[0] - abox.min[0] - legendFont.getStringWidth (legend) ) / 2 ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_TOP_RIGHT :
|
||||
case PUPLACE_CENTERED_RIGHT :
|
||||
case PUPLACE_BOTTOM_RIGHT :
|
||||
case PUPLACE_LOWER_RIGHT :
|
||||
xx = abox.max[0] - abox.min[0] - legendFont.getStringWidth ( legend ) - rgap ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
ulSetError ( UL_WARNING, "PUI: Unrecognised LEGEND place %d", getLegendPlace() ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
switch ( getLegendPlace() )
|
||||
{
|
||||
case PUPLACE_TOP_LEFT :
|
||||
case PUPLACE_TOP_CENTERED :
|
||||
case PUPLACE_TOP_RIGHT :
|
||||
yy = abox.max[1] - abox.min[1] - legendFont.getStringHeight ( legend ) -
|
||||
legendFont.getStringDescender () - tgap ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_CENTERED_LEFT :
|
||||
case PUPLACE_CENTERED_CENTERED :
|
||||
case PUPLACE_CENTERED_RIGHT :
|
||||
case PUPLACE_LOWER_LEFT : /* Backwards compatibility to PUPLACE_LEFT */
|
||||
case PUPLACE_LOWER_RIGHT : /* Backwards compatibility to PUPLACE_RIGHT */
|
||||
default :
|
||||
yy = ( abox.max[1] - abox.min[1] +
|
||||
legendFont.getStringHeight ( legend ) ) / 2 -
|
||||
legendFont.getStringHeight () ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_BOTTOM_LEFT :
|
||||
case PUPLACE_BOTTOM_CENTERED :
|
||||
case PUPLACE_BOTTOM_RIGHT :
|
||||
yy = bgap + legendFont.getStringDescender () ;
|
||||
break ;
|
||||
}
|
||||
|
||||
legendFont.drawString ( legend, dx + abox.min[0] + xx,
|
||||
dy + abox.min[1] + yy ) ;
|
||||
}
|
||||
|
||||
void puObject::draw_label ( int dx, int dy )
|
||||
{
|
||||
if ( label == NULL )
|
||||
return ;
|
||||
|
||||
int xx, yy ;
|
||||
|
||||
/* If greyed out then halve the opacity when drawing the label */
|
||||
|
||||
if ( active )
|
||||
glColor4fv ( colour [ PUCOL_LABEL ] ) ;
|
||||
else
|
||||
glColor4f ( colour [ PUCOL_LABEL ][0],
|
||||
colour [ PUCOL_LABEL ][1],
|
||||
colour [ PUCOL_LABEL ][2],
|
||||
colour [ PUCOL_LABEL ][3] / 2.0f ) ; /* 50% more transparent */
|
||||
|
||||
switch ( getLabelPlace() )
|
||||
{
|
||||
case PUPLACE_ABOVE_LEFT :
|
||||
case PUPLACE_UPPER_LEFT :
|
||||
case PUPLACE_CENTERED_LEFT :
|
||||
case PUPLACE_LOWER_LEFT :
|
||||
case PUPLACE_BELOW_LEFT :
|
||||
xx = 0 ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_TOP_LEFT :
|
||||
case PUPLACE_BOTTOM_LEFT :
|
||||
xx = abox.min[0] - bbox.min[0] + PUSTR_LGAP ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_TOP_CENTERED :
|
||||
case PUPLACE_BOTTOM_CENTERED :
|
||||
xx = ( bbox.max[0] - bbox.min[0] - labelFont.getStringWidth ( label ) ) / 2 ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_TOP_RIGHT :
|
||||
case PUPLACE_BOTTOM_RIGHT :
|
||||
xx = abox.max[0] - bbox.min[0] - labelFont.getStringWidth ( label ) - PUSTR_RGAP ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_ABOVE_RIGHT :
|
||||
case PUPLACE_UPPER_RIGHT :
|
||||
case PUPLACE_CENTERED_RIGHT :
|
||||
case PUPLACE_LOWER_RIGHT :
|
||||
case PUPLACE_BELOW_RIGHT :
|
||||
xx = bbox.max[0] - bbox.min[0] - labelFont.getStringWidth ( label ) ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
ulSetError ( UL_WARNING, "PUI: Unrecognised LABEL place %d", getLegendPlace() ) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
switch ( getLabelPlace() )
|
||||
{
|
||||
case PUPLACE_ABOVE_LEFT :
|
||||
case PUPLACE_TOP_LEFT :
|
||||
case PUPLACE_TOP_CENTERED :
|
||||
case PUPLACE_TOP_RIGHT :
|
||||
case PUPLACE_ABOVE_RIGHT :
|
||||
yy = bbox.max[1] - bbox.min[1] - labelFont.getStringHeight () -
|
||||
labelFont.getStringDescender () ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_UPPER_LEFT :
|
||||
case PUPLACE_UPPER_RIGHT :
|
||||
yy = abox.max[1] - bbox.min[1] - labelFont.getStringHeight ( label ) - PUSTR_TGAP ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_CENTERED_LEFT :
|
||||
case PUPLACE_CENTERED_RIGHT :
|
||||
default :
|
||||
yy = ( bbox.max[1] - bbox.min[1] +
|
||||
labelFont.getStringHeight ( label ) ) / 2 -
|
||||
labelFont.getStringHeight () ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_LOWER_LEFT :
|
||||
case PUPLACE_LOWER_RIGHT :
|
||||
yy = abox.min[1] - bbox.min[1] + labelFont.getStringDescender () + PUSTR_BGAP ;
|
||||
break ;
|
||||
|
||||
case PUPLACE_BELOW_LEFT :
|
||||
case PUPLACE_BOTTOM_LEFT :
|
||||
case PUPLACE_BOTTOM_CENTERED :
|
||||
case PUPLACE_BOTTOM_RIGHT :
|
||||
case PUPLACE_BELOW_RIGHT :
|
||||
yy = labelFont.getStringDescender () ;
|
||||
break ;
|
||||
}
|
||||
|
||||
labelFont.drawString ( label, dx + bbox.min[0] + xx,
|
||||
dy + bbox.min[1] + yy ) ;
|
||||
}
|
||||
|
||||
|
||||
int puObject::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( updown == PU_UP )
|
||||
return FALSE ;
|
||||
|
||||
if ( isReturnDefault() && ( key == '\r' || key == '\n' ) && ( window == puGetWindow () ) )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
checkHit ( PU_LEFT_BUTTON, PU_DOWN, (abox.min[0]+abox.max[0])/2,
|
||||
(abox.min[1]+abox.max[1])/2 ) ;
|
||||
checkHit ( PU_LEFT_BUTTON, PU_UP , (abox.min[0]+abox.max[0])/2,
|
||||
(abox.min[1]+abox.max[1])/2 ) ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
void puObject::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
puMoveToLast ( this );
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
|
||||
{
|
||||
lowlight () ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
else
|
||||
highlight () ;
|
||||
}
|
||||
else
|
||||
lowlight () ;
|
||||
}
|
||||
|
||||
int puObject::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( ( ( puGetPressedButton () || updown == PU_UP ) ) && isHit( x, y ) )
|
||||
{
|
||||
doHit ( button, updown, x, y ) ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puOneShot,puButton)
|
||||
|
||||
|
||||
void puOneShot::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
puButton::doHit ( button, updown, x, y ) ;
|
||||
setValue ( 0 ) ;
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puPopup,puInterface)
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puPopupMenu,puPopup)
|
||||
|
||||
|
||||
puObject *puPopupMenu::add_item ( const char *str, puCallback _cb,
|
||||
void *_user_data )
|
||||
{
|
||||
int w, h ;
|
||||
getSize ( &w, &h ) ;
|
||||
puOneShot *b = new puOneShot ( 0, h, str ) ;
|
||||
b->setStyle ( PUSTYLE_PLAIN ) ;
|
||||
b->setColourScheme ( colour[PUCOL_FOREGROUND][0],
|
||||
colour[PUCOL_FOREGROUND][1],
|
||||
colour[PUCOL_FOREGROUND][2],
|
||||
colour[PUCOL_FOREGROUND][3] ) ;
|
||||
b->setCallback ( _cb ) ;
|
||||
b->setLegendPlace ( PUPLACE_LOWER_LEFT ) ;
|
||||
b->setUserData ( _user_data ) ;
|
||||
recalc_bbox () ;
|
||||
return b ;
|
||||
}
|
||||
|
||||
void puPopupMenu::close ( void )
|
||||
{
|
||||
puPopup::close () ;
|
||||
|
||||
int widest = 0 ;
|
||||
puObject *ob = dlist ;
|
||||
|
||||
/*
|
||||
* June 17th, 1998, Shammi
|
||||
* There seems to be some mismatch with the
|
||||
* #define pumenusize and the actual size
|
||||
* There seems to be some overlap resulting
|
||||
* in more than one option being highlighted.
|
||||
* By setting the size to the actual values,
|
||||
* the overlap area seems to be less now.
|
||||
*/
|
||||
|
||||
int w, h ;
|
||||
|
||||
for ( ob = dlist ; ob != NULL ; ob = ob -> getNextObject() )
|
||||
{
|
||||
ob -> getSize ( &w, &h ) ;
|
||||
|
||||
if ( w > widest ) widest = w ;
|
||||
}
|
||||
|
||||
for ( ob = dlist ; ob != NULL ; ob = ob -> getNextObject() )
|
||||
{
|
||||
ob -> getSize ( &w, &h ) ;
|
||||
ob -> setSize ( widest, h ) ;
|
||||
}
|
||||
|
||||
recalc_bbox () ;
|
||||
}
|
||||
|
||||
|
||||
int puPopupMenu::checkKey ( int key, int updown )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () || ( window != puGetWindow () ) )
|
||||
return FALSE ;
|
||||
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown == PU_DOWN )
|
||||
{
|
||||
hide () ;
|
||||
|
||||
/* Turn everything off ready for next time. */
|
||||
|
||||
for ( puObject *bo = dlist ; bo != NULL ; bo = bo -> getNextObject() )
|
||||
bo -> clrValue () ;
|
||||
}
|
||||
|
||||
puObject *bo ;
|
||||
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
for ( bo = dlist ;
|
||||
bo -> getNextObject() != NULL ;
|
||||
bo = bo -> getNextObject() )
|
||||
/* Find the last object in our list. */ ;
|
||||
|
||||
for ( ; bo != NULL ; bo = bo -> getPrevObject() )
|
||||
if ( bo -> checkKey ( key, updown ) )
|
||||
return TRUE ;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
int puPopupMenu::checkHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( dlist == NULL || ! isVisible () || ! isActive () || ( window != puGetWindow () ) )
|
||||
return FALSE ;
|
||||
|
||||
/* If an item is going to fall out the bottom of the window and puGroup will */
|
||||
/* move it upward (around line 303 of puGroup.cxx), then make sure checkhit */
|
||||
/* realizes the thing has moved -- JCJ and Fay 5 June 2002 */
|
||||
|
||||
int absx, absy ;
|
||||
getAbsolutePosition (&absx, &absy) ;
|
||||
if ( absy < 0 )
|
||||
y += absy ;
|
||||
|
||||
/* Must test 'isHit' before making the menu invisible! */
|
||||
|
||||
/*
|
||||
* June 17th, 1998, Shammi :
|
||||
* There seemed to be a miscalculation with the menus initially
|
||||
* Therefore I moved the recalculation stuff before the clearing.
|
||||
*/
|
||||
|
||||
/*
|
||||
This might be a bit redundant - but it's too hard to keep
|
||||
track of changing abox sizes when daughter objects are
|
||||
changing sizes.
|
||||
*/
|
||||
|
||||
int hit = isHit ( x, y ) ;
|
||||
|
||||
/* If the mouse is clicked on another widget, hide the window - JCJ 18 Jun 2002 */
|
||||
if ( updown != PU_DRAG && !hit )
|
||||
hide () ;
|
||||
|
||||
recalc_bbox();
|
||||
x -= abox.min[0] ;
|
||||
y -= abox.min[1] ;
|
||||
|
||||
/*
|
||||
* June 17th, 1998, Shammi :
|
||||
* Also clear the menu when the dragging the mouse and not hit.
|
||||
*/
|
||||
|
||||
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN ||
|
||||
( updown == PU_DRAG && !hit ) )
|
||||
{
|
||||
|
||||
/* June 17th, 1998, Shammi :
|
||||
* Do not hide the menu if mouse is dragged out
|
||||
*/
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
hide () ;
|
||||
|
||||
/* Turn everything off ready for next time. */
|
||||
|
||||
/* June 17th, 1998, Shammi:
|
||||
* Make sure we check for a hit, if the mouse is moved
|
||||
* out of the menu.
|
||||
*/
|
||||
|
||||
for ( puObject *bo = dlist ; bo != NULL ; bo = bo -> getNextObject() )
|
||||
{
|
||||
if ( ! hit )
|
||||
bo -> checkHit ( button, updown, x , y ) ;
|
||||
|
||||
bo -> clrValue () ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! hit )
|
||||
return FALSE ;
|
||||
|
||||
puObject *bo ;
|
||||
int objecthit = FALSE ;
|
||||
/*
|
||||
We have to walk the list backwards to ensure that
|
||||
the click order is the same as the DRAW order.
|
||||
*/
|
||||
|
||||
/* June 17th, 1998, Shammi :
|
||||
* If the mouse is dragged and the menuItem is not hit,
|
||||
* clear it
|
||||
*/
|
||||
|
||||
for ( bo = dlist ;
|
||||
bo -> getNextObject() != NULL ;
|
||||
bo = bo -> getNextObject() )
|
||||
if ( updown == PU_DRAG && ! bo -> checkHit ( button, updown, x, y ) )
|
||||
bo -> clrValue () ;
|
||||
|
||||
/* Find the last object in our list. */ ;
|
||||
|
||||
/* Following code permits highlighting and lowlighting */
|
||||
/* of oneshots underneath a PopupMenu. */
|
||||
/* - JCJ and Fay 31 May 2002 */
|
||||
|
||||
for ( ; bo != NULL ; bo = bo -> getPrevObject() )
|
||||
{
|
||||
puBox *box = bo->getABox () ;
|
||||
if ( ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
|
||||
( y >= box->min[1] ) && ( y <= box->max[1] ) )
|
||||
bo->highlight () ;
|
||||
else
|
||||
bo->lowlight () ;
|
||||
/* Since actually RETURNing here would break the for loop early and kill the */
|
||||
/* correct lowlighting, just set a var to check later. - JCJ 3 Jun 2002 */
|
||||
if ( bo -> checkHit ( button, updown, x, y ) )
|
||||
objecthit = TRUE ;
|
||||
}
|
||||
|
||||
/* If the object was hit in the above for loop, then it.. was hit.*/
|
||||
if (objecthit)
|
||||
return TRUE ;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puRange,puObject)
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
/*
|
||||
PLIB - A Suite of Portable Game Libraries
|
||||
Copyright (C) 1998,2002 Steve Baker
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "puLocal.h"
|
||||
|
||||
UL_RTTI_DEF1(puScrollBar,puSlider)
|
||||
|
||||
|
||||
void puScrollBar::draw ( int dx, int dy )
|
||||
{
|
||||
extern void puDrawArrowButtonTriangle ( int pos_x, int pos_y, int size_x, int size_y,
|
||||
puColour colour, int arrow_type, int active ) ;
|
||||
|
||||
if ( !visible || ( window != puGetWindow () ) ) return ;
|
||||
|
||||
if ( r_cb )
|
||||
r_cb ( this, dx, dy, render_data ) ;
|
||||
else
|
||||
{
|
||||
puBox box = abox ;
|
||||
|
||||
int width = isVertical () ? abox.max[0] - abox.min[0] : abox.max[1] - abox.min[1] ;
|
||||
|
||||
/* Draw the arrow buttons */
|
||||
|
||||
if ( arrow_count == 2 ) /* Double-arrow buttons */
|
||||
{
|
||||
if ( isVertical () )
|
||||
{
|
||||
box.min[1] = abox.max[1] - width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_FASTUP, fast_up_arrow_active ) ;
|
||||
box.min[1] = abox.min[1] ;
|
||||
box.max[1] = box.min[1] + width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_FASTDOWN, fast_down_arrow_active ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
box.min[0] = abox.max[0] - width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_FASTRIGHT, fast_up_arrow_active ) ;
|
||||
box.min[0] = abox.min[0] ;
|
||||
box.max[0] = box.min[0] + width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_FASTLEFT, fast_down_arrow_active ) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( arrow_count > 0 ) /* Single-arrow buttons */
|
||||
{
|
||||
if ( isVertical () )
|
||||
{
|
||||
box.min[1] = abox.max[1] - arrow_count * width ;
|
||||
box.max[1] = box.min[1] + width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_UP, up_arrow_active ) ;
|
||||
box.max[1] = abox.min[1] + arrow_count * width ;
|
||||
box.min[1] = box.max[1] - width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_DOWN, down_arrow_active ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
box.min[0] = abox.max[0] - arrow_count * width ;
|
||||
box.max[0] = box.min[0] + width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_RIGHT, up_arrow_active ) ;
|
||||
box.max[0] = abox.min[0] + arrow_count * width ;
|
||||
box.min[0] = box.max[0] - width ;
|
||||
box.draw ( dx, dy, style, colour, FALSE, border_thickness ) ;
|
||||
puDrawArrowButtonTriangle ( dx+box.min[0]+width/2, dy+box.min[1]+width/2, width, width, colour [ PUCOL_MISC ],
|
||||
PUARROW_LEFT, down_arrow_active ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the surrounding box */
|
||||
|
||||
box.min[0] = abox.min[0] + ( isVertical () ? 0 : arrow_count * width ) ;
|
||||
box.max[0] = abox.max[0] - ( isVertical () ? 0 : arrow_count * width ) ;
|
||||
box.min[1] = abox.min[1] + ( isVertical () ? arrow_count * width : 0 ) ;
|
||||
box.max[1] = abox.max[1] - ( isVertical () ? arrow_count * width : 0 ) ;
|
||||
|
||||
if ( ( style == PUSTYLE_BEVELLED ) ||
|
||||
( style == PUSTYLE_SHADED ) )
|
||||
box.draw ( dx, dy, -PUSTYLE_BOXED, colour, FALSE, 2 ) ;
|
||||
else
|
||||
box.draw ( dx, dy, -style, colour, FALSE, border_thickness ) ;
|
||||
|
||||
/* Draw the slider box */
|
||||
|
||||
float val = getFloatValue () ;
|
||||
|
||||
draw_slider_box ( dx, dy, box, ( val - getMinValue () ) / ( getMaxValue () - getMinValue () ) ) ;
|
||||
|
||||
draw_legend ( dx, dy ) ;
|
||||
}
|
||||
|
||||
draw_label ( dx, dy ) ;
|
||||
}
|
||||
|
||||
|
||||
void puScrollBar::doHit ( int button, int updown, int x, int y )
|
||||
{
|
||||
if ( puActiveWidget() && ( this != puActiveWidget() ) )
|
||||
{
|
||||
puActiveWidget() -> invokeDownCallback () ;
|
||||
puDeactivateWidget () ;
|
||||
}
|
||||
|
||||
if ( updown != PU_DRAG )
|
||||
puMoveToLast ( this );
|
||||
|
||||
if ( button == PU_LEFT_BUTTON && updown == PU_UP )
|
||||
{
|
||||
puDeactivateWidget () ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( button == PU_LEFT_BUTTON )
|
||||
{
|
||||
int width = isVertical () ? abox.max[0] - abox.min[0] : abox.max[1] - abox.min[1] ;
|
||||
|
||||
float next_value = getFloatValue () ;
|
||||
float step = getStepSize () ;
|
||||
if ( step == 0.0 ) step = ( getMaxValue () - getMinValue () ) / 10.0 ;
|
||||
|
||||
/* Check for hitting a button */
|
||||
|
||||
int sd = isVertical() ;
|
||||
int coord = ( isVertical() ? y : x ) ;
|
||||
|
||||
if( arrow_count == 2 )
|
||||
{
|
||||
if ( coord < abox.min[sd] + width ) /* Fast down button */
|
||||
next_value -= 10.0 * step ;
|
||||
|
||||
if ( coord > abox.max[sd] - width ) /* Fast up button */
|
||||
next_value += 10.0 * step ;
|
||||
}
|
||||
|
||||
if ( arrow_count > 0 )
|
||||
{
|
||||
if ( ( coord < abox.min[sd] + arrow_count*width ) && ( coord > abox.min[sd] + (arrow_count-1)*width ) ) /* Down button */
|
||||
next_value -= step ;
|
||||
|
||||
if ( ( coord > abox.max[sd] - arrow_count*width ) && ( coord < abox.max[sd] - (arrow_count-1)*width ) ) /* Down button */
|
||||
next_value += step ;
|
||||
}
|
||||
|
||||
/* Check for hitting the slider bar */
|
||||
|
||||
if ( ( coord > abox.min[sd]+arrow_count*width ) && ( coord < abox.max[sd]-arrow_count*width ) )
|
||||
{
|
||||
int sz = abox.max [sd] - abox.min [sd] - 2 * arrow_count * width ;
|
||||
|
||||
if ( sz <= 0 )
|
||||
next_value = 0.5f ;
|
||||
else
|
||||
{
|
||||
next_value = ( float(coord - arrow_count * width - abox.min[sd]) - float(sz) * slider_fraction / 2.0f ) /
|
||||
( float(sz) * (1.0f - slider_fraction) ) ;
|
||||
}
|
||||
|
||||
next_value = (next_value < 0.0f) ? 0.0f : (next_value > 1.0f) ? 1.0f : next_value ;
|
||||
next_value = getMinValue () + next_value * ( getMaxValue () - getMinValue () ) ;
|
||||
}
|
||||
|
||||
if ( next_value < getMinValue () ) next_value = getMinValue () ;
|
||||
if ( next_value > getMaxValue () ) next_value = getMaxValue () ;
|
||||
setValue ( checkStep (next_value) );
|
||||
|
||||
switch ( cb_mode )
|
||||
{
|
||||
case PUSLIDER_CLICK :
|
||||
if ( updown == active_mouse_edge )
|
||||
{
|
||||
last_cb_value = next_value ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_DELTA : /* Deprecated! */
|
||||
if ( fabs ( last_cb_value - next_value ) >= cb_delta )
|
||||
{
|
||||
last_cb_value = next_value ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
}
|
||||
break ;
|
||||
|
||||
case PUSLIDER_ALWAYS :
|
||||
default :
|
||||
last_cb_value = next_value ;
|
||||
puSetActiveWidget ( this, x, y ) ;
|
||||
invokeCallback () ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user