# HG changeset patch # User William Pitcock # Date 1193518343 18000 # Node ID 9bdb5aba5e007523f3972561db564df8abe2c291 # Parent 3bbb2673419b043432ac74d9361f15bac717ed60 Backed out changeset 3bbb2673419b I've decided to put the projectM 1.x plugin back for now. diff -r 3bbb2673419b -r 9bdb5aba5e00 configure.ac --- a/configure.ac Sat Oct 27 12:14:37 2007 -0500 +++ b/configure.ac Sat Oct 27 15:52:23 2007 -0500 @@ -1402,6 +1402,36 @@ VISUALIZATION_PLUGINS="$VISUALIZATION_PLUGINS projectm" fi +dnl *** projectM (GL Milkdrop port) + +AC_ARG_ENABLE(projectm-1.0, +[ --disable-projectm-1.0 disable projectM 1.0+ vis plugin. (default=enabled)], +[have_projectm1=$enableval], +[have_projectm1=yes]) + +if test "$have_projectm1" = "yes"; then + PKG_CHECK_MODULES(LIBPROJECTM1, libprojectM >= 1.0, [have_projectm1="yes"], [have_projectm1="no"]) + AM_PATH_SDL(1.2.5, , [ + AC_MSG_WARN([*** SDL is not installed. projectM will not be built. ***]) + have_projectm1="no" + ]) + if test x$libprjM = xno; then + AC_MSG_WARN([*** libprojectM not found. + libprojectM is needed to build this package. + You can download libprojectM at http://projectm.sf.net/]) + fi + LIBPROJECTM1_datadir=`pkg-config --variable=pkgdatadir libprojectM`; + LIBPROJECTM1_sysconfdir=`pkg-config --variable=sysconfdir libprojectM`; + LIBPROJECTM1_prefix=`pkg-config --variable=prefix libprojectM`; + LIBPROJECTM1_CFLAGS="$LIBPROJECTM1_CFLAGS -DPROJECTM_DATADIR=\\\"$LIBPROJECTM1_datadir\\\" -DPROJECTM_SYSCONFDIR=\\\"$LIBPROJECTM1_sysconfdir\\\" -DPROJECTM_PREFIX=\\\"$LIBPROJECTM1_prefix\\\""; +fi +AC_SUBST(LIBPROJECTM1_LIBS) +AC_SUBST(LIBPROJECTM1_CFLAGS) + +if test "$have_projectm1" = "yes"; then + VISUALIZATION_PLUGINS="$VISUALIZATION_PLUGINS projectm-1.0" +fi + dnl *** TTA AC_ARG_ENABLE(tta, @@ -1637,6 +1667,7 @@ echo " Spectrum Analyzer: yes" echo " Paranormal Visualization Library: $have_paranormal" echo " projectM 0.x (GL milkdrop): $have_projectm" +echo " projectM 1.x (GL milkdrop): $have_projectm1" echo " RootVis plugin: $have_rootvis" echo echo " Transport" diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/COPYING --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/COPYING Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/ConfigFile.cxx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/ConfigFile.cxx Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,142 @@ +// ConfigFile.cpp + +#include "ConfigFile.h" + +using std::string; + +ConfigFile::ConfigFile( string filename, string delimiter, + string comment, string sentry ) + : myDelimiter(delimiter), myComment(comment), mySentry(sentry) +{ + // Construct a ConfigFile, getting keys and values from given file + + std::ifstream in( filename.c_str() ); + + if( !in ) throw file_not_found( filename ); + + in >> (*this); +} + + +ConfigFile::ConfigFile() + : myDelimiter( string(1,'=') ), myComment( string(1,'#') ) +{ + // Construct a ConfigFile without a file; empty +} + + +void ConfigFile::remove( const string& key ) +{ + // Remove key and its value + myContents.erase( myContents.find( key ) ); + return; +} + + +bool ConfigFile::keyExists( const string& key ) const +{ + // Indicate whether key is found + mapci p = myContents.find( key ); + return ( p != myContents.end() ); +} + + +/* static */ +void ConfigFile::trim( string& s ) +{ + // Remove leading and trailing whitespace + static const char whitespace[] = " \n\t\v\r\f"; + s.erase( 0, s.find_first_not_of(whitespace) ); + s.erase( s.find_last_not_of(whitespace) + 1U ); +} + + +std::ostream& operator<<( std::ostream& os, const ConfigFile& cf ) +{ + // Save a ConfigFile to os + for( ConfigFile::mapci p = cf.myContents.begin(); + p != cf.myContents.end(); + ++p ) + { + os << p->first << " " << cf.myDelimiter << " "; + os << p->second << std::endl; + } + return os; +} + + +std::istream& operator>>( std::istream& is, ConfigFile& cf ) +{ + // Load a ConfigFile from is + // Read in keys and values, keeping internal whitespace + typedef string::size_type pos; + const string& delim = cf.myDelimiter; // separator + const string& comm = cf.myComment; // comment + const string& sentry = cf.mySentry; // end of file sentry + const pos skip = delim.length(); // length of separator + + string nextline = ""; // might need to read ahead to see where value ends + + while( is || nextline.length() > 0 ) + { + // Read an entire line at a time + string line; + if( nextline.length() > 0 ) + { + line = nextline; // we read ahead; use it now + nextline = ""; + } + else + { + std::getline( is, line ); + } + + // Ignore comments + line = line.substr( 0, line.find(comm) ); + + // Check for end of file sentry + if( sentry != "" && line.find(sentry) != string::npos ) return is; + + // Parse the line if it contains a delimiter + pos delimPos = line.find( delim ); + if( delimPos < string::npos ) + { + // Extract the key + string key = line.substr( 0, delimPos ); + line.replace( 0, delimPos+skip, "" ); + + // See if value continues on the next line + // Stop at blank line, next line with a key, end of stream, + // or end of file sentry + bool terminate = false; + while( !terminate && is ) + { + std::getline( is, nextline ); + terminate = true; + + string nlcopy = nextline; + ConfigFile::trim(nlcopy); + if( nlcopy == "" ) continue; + + nextline = nextline.substr( 0, nextline.find(comm) ); + if( nextline.find(delim) != string::npos ) + continue; + if( sentry != "" && nextline.find(sentry) != string::npos ) + continue; + + nlcopy = nextline; + ConfigFile::trim(nlcopy); + if( nlcopy != "" ) line += "\n"; + line += nextline; + terminate = false; + } + + // Store key and value + ConfigFile::trim(key); + ConfigFile::trim(line); + cf.myContents[key] = line; // overwrites if key is repeated + } + } + + return is; +} diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/ConfigFile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/ConfigFile.h Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,253 @@ +// ConfigFile.h +// Class for reading named values from configuration files +// Richard J. Wagner v2.1 24 May 2004 wagnerr@umich.edu + +// Copyright (c) 2004 Richard J. Wagner +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +// Typical usage +// ------------- +// +// Given a configuration file "settings.inp": +// atoms = 25 +// length = 8.0 # nanometers +// name = Reece Surcher +// +// Named values are read in various ways, with or without default values: +// ConfigFile config( "settings.inp" ); +// int atoms = config.read( "atoms" ); +// double length = config.read( "length", 10.0 ); +// string author, title; +// config.readInto( author, "name" ); +// config.readInto( title, "title", string("Untitled") ); +// +// See file example.cpp for more examples. + +#ifndef CONFIGFILE_H +#define CONFIGFILE_H + +#include +#include +#include +#include +#include + +using std::string; + +class ConfigFile { +// Data +protected: + string myDelimiter; // separator between key and value + string myComment; // separator between value and comments + string mySentry; // optional string to signal end of file + std::map myContents; // extracted keys and values + + typedef std::map::iterator mapi; + typedef std::map::const_iterator mapci; + +// Methods +public: + ConfigFile( string filename, + string delimiter = "=", + string comment = "#", + string sentry = "EndConfigFile" ); + ConfigFile(); + + // Search for key and read value or optional default value + template T read( const string& key ) const; // call as read + template T read( const string& key, const T& value ) const; + template bool readInto( T& var, const string& key ) const; + template + bool readInto( T& var, const string& key, const T& value ) const; + + // Modify keys and values + template void add( string key, const T& value ); + void remove( const string& key ); + + // Check whether key exists in configuration + bool keyExists( const string& key ) const; + + // Check or change configuration syntax + string getDelimiter() const { return myDelimiter; } + string getComment() const { return myComment; } + string getSentry() const { return mySentry; } + string setDelimiter( const string& s ) + { string old = myDelimiter; myDelimiter = s; return old; } + string setComment( const string& s ) + { string old = myComment; myComment = s; return old; } + + // Write or read configuration + friend std::ostream& operator<<( std::ostream& os, const ConfigFile& cf ); + friend std::istream& operator>>( std::istream& is, ConfigFile& cf ); + +protected: + template static string T_as_string( const T& t ); + template static T string_as_T( const string& s ); + static void trim( string& s ); + + +// Exception types +public: + struct file_not_found { + string filename; + file_not_found( const string& filename_ = string() ) + : filename(filename_) {} }; + struct key_not_found { // thrown only by T read(key) variant of read() + string key; + key_not_found( const string& key_ = string() ) + : key(key_) {} }; +}; + + +/* static */ +template +string ConfigFile::T_as_string( const T& t ) +{ + // Convert from a T to a string + // Type T must support << operator + std::ostringstream ost; + ost << t; + return ost.str(); +} + + +/* static */ +template +T ConfigFile::string_as_T( const string& s ) +{ + // Convert from a string to a T + // Type T must support >> operator + T t; + std::istringstream ist(s); + ist >> t; + return t; +} + + +/* static */ +template<> +inline string ConfigFile::string_as_T( const string& s ) +{ + // Convert from a string to a string + // In other words, do nothing + return s; +} + + +/* static */ +template<> +inline bool ConfigFile::string_as_T( const string& s ) +{ + // Convert from a string to a bool + // Interpret "false", "F", "no", "n", "0" as false + // Interpret "true", "T", "yes", "y", "1", "-1", or anything else as true + bool b = true; + string sup = s; + for( string::iterator p = sup.begin(); p != sup.end(); ++p ) + *p = toupper(*p); // make string all caps + if( sup==string("FALSE") || sup==string("F") || + sup==string("NO") || sup==string("N") || + sup==string("0") || sup==string("NONE") ) + b = false; + return b; +} + + +template +T ConfigFile::read( const string& key ) const +{ + // Read the value corresponding to key + mapci p = myContents.find(key); + if( p == myContents.end() ) throw key_not_found(key); + return string_as_T( p->second ); +} + + +template +T ConfigFile::read( const string& key, const T& value ) const +{ + // Return the value corresponding to key or given default value + // if key is not found + mapci p = myContents.find(key); + if( p == myContents.end() ) return value; + return string_as_T( p->second ); +} + + +template +bool ConfigFile::readInto( T& var, const string& key ) const +{ + // Get the value corresponding to key and store in var + // Return true if key is found + // Otherwise leave var untouched + mapci p = myContents.find(key); + bool found = ( p != myContents.end() ); + if( found ) var = string_as_T( p->second ); + return found; +} + + +template +bool ConfigFile::readInto( T& var, const string& key, const T& value ) const +{ + // Get the value corresponding to key and store in var + // Return true if key is found + // Otherwise set var to given default + mapci p = myContents.find(key); + bool found = ( p != myContents.end() ); + if( found ) + var = string_as_T( p->second ); + else + var = value; + return found; +} + + +template +void ConfigFile::add( string key, const T& value ) +{ + // Add a key with given value + string v = T_as_string( value ); + trim(key); + trim(v); + myContents[key] = v; + return; +} + +#endif // CONFIGFILE_H + +// Release notes: +// v1.0 21 May 1999 +// + First release +// + Template read() access only through non-member readConfigFile() +// + ConfigurationFileBool is only built-in helper class +// +// v2.0 3 May 2002 +// + Shortened name from ConfigurationFile to ConfigFile +// + Implemented template member functions +// + Changed default comment separator from % to # +// + Enabled reading of multiple-line values +// +// v2.1 24 May 2004 +// + Made template specializations inline to avoid compiler-dependent linkage +// + Allowed comments within multiple-line values +// + Enabled blank line termination for multiple-line values +// + Added optional sentry to detect end of configuration file +// + Rewrote messy trimWhitespace() function as elegant trim() diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/Makefile Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,16 @@ +PLUGIN = projectm-1.0${PLUGIN_SUFFIX} + +SRCS = main.cxx \ + video_init.cxx \ + ConfigFile.cxx \ + main_visplugin.c + +include ../../buildsys.mk +include ../../extra.mk + +plugindir := ${plugindir}/${VISUALIZATION_PLUGIN_DIR} + +CFLAGS += ${PLUGIN_CFLAGS} +CXXFLAGS += ${PLUGIN_CFLAGS} +CPPFLAGS += ${PLUGIN_CPPFLAGS} ${MOWGLI_CFLAGS} ${DBUS_CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} ${PANGO_CFLAGS} ${ARCH_DEFINES} ${XML_CPPFLAGS} ${SDL_CFLAGS} ${LIBPROJECTM1_CFLAGS} -I../../intl -I../.. +LIBS += ${GTK_LIBS} ${GLIB_LIBS} ${PANGO_LIBS} ${SDL_LIBS} ${LIBPROJECTM1_LIBS} diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/main.cxx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/main.cxx Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,462 @@ +/* +projectM v1.01 - xmms-projectm.sourceforge.net +-------------------------------------------------- + +Lead Developers: Carmelo Piccione (carmelo.piccione@gmail.com) & + Peter Sperl (peter@sperl.com) + +We have also been advised by some professors at CMU, namely Roger B. Dannenberg. +http://www-2.cs.cmu.edu/~rbd/ + +The inspiration for this program was Milkdrop by Ryan Geiss. Obviously. + +This code is distributed under the GPL. + + +THANKS FOR THE CODE!!! +------------------------------------------------- +The base for this program was andy@nobugs.org's XMMS plugin tutorial +http://www.xmms.org/docs/vis-plugin.html + +We used some FFT code by Takuya OOURA instead of XMMS' built-in fft code +fftsg.c - http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html + +and some beat detection code was inspired by Frederic Patin @ +www.gamedev.net/reference/programming/features/beatdetection/ + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +#include +#include "ConfigFile.h" + +#include + +#include "sdltoprojectM.h" +#include "video_init.h" + +#include +#define CONFIG_FILE "/share/projectM/config.inp" + +// Forward declarations +extern "C" void projectM_xmms_init(void); +extern "C" void projectM_cleanup(void); +extern "C" void projectM_about(void); +extern "C" void projectM_configure(void); +extern "C" void projectM_playback_start(void); +extern "C" void projectM_playback_stop(void); +extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]); +extern "C" void projectM_render_freq(gint16 pcm_data[2][256]); +extern "C" int worker_func(void*); +std::string read_config(); +void saveSnapshotToFile(); + +extern "C" VisPlugin projectM_vtable; + +//extern preset_t * active_preset; + +//FILE * debugFile = fopen("./dwrite-dump", "wb"); + +// Our worker thread +SDL_Thread *worker_thread = NULL; +SDL_sem *sem = NULL; +SDL_Event event; + +SDL_Surface *screen; + + +projectM * globalPM = NULL; + +int maxsamples=512; + +int texsize=512; +int gx=32,gy=24; +int wvw=400,wvh=400; +int fvw=1024,fvh=768; +int fps=35, fullscreen=0; + +// char *title; + +gint disable_projectm(void *something) { + projectM_vtable.disable_plugin(&projectM_vtable); + return 0; +} + +Uint32 get_xmms_title(Uint32 something, void *somethingelse) { + static char check_title = 1; + static int last_pos; + static char *last_title = NULL; + int pos; + char *title = NULL; + + //Nice optimization, but we want the title no matter what so I can display it when the song changes +#if 0 + if(!(globalPM->showtitle%2)) { + /* Repeat less often when not showing title */ + return 1000; + } +#endif + + pos = audacious_drct_pl_get_pos(); + /* Only check every 1 second for title change, otherwise check pos */ + if(check_title || pos != last_pos) { + title = audacious_drct_pl_get_title(pos); + if(title && (!last_title || strcmp(last_title,title))) { + //globalPM->renderer->title = title; + //globalPM->renderer->drawtitle = 1; + + std::string titlepp(title); + globalPM->projectM_setTitle(titlepp); + g_free(last_title); + last_title = title; + } else if(title && last_title != title) { + /* New copy of last title */ + g_free(title); + } + check_title = !check_title; + } + last_pos = pos; + /* Repeat every 500ms */ + return 500; +} + +int capture = 0; + +int worker_func(void*) +{ +// char projectM_data[1024]; + SDL_TimerID title_timer = NULL; + std::string config_file; + config_file = read_config(); + ConfigFile config(config_file); + + int wvw = config.read( "Window Width", 512 ); + int wvh = config.read( "Window Height", 512 ); + + int fullscreen = 0; + if (config.read("Fullscreen", true)) fullscreen = 1; + else fullscreen = 0; + + init_display(wvw,wvh,&fvw,&fvh,fullscreen); + SDL_WM_SetCaption("projectM v1.00", "projectM v1.00"); + + /** Initialise projectM */ + + globalPM = new projectM(config_file); + SDL_SemPost(sem); + title_timer = SDL_AddTimer(500, get_xmms_title, NULL); + /** Initialise the thread */ + // SDL_SemTryWait(sem); + while ( SDL_SemValue(sem)==1 ) { + projectMEvent evt; + projectMKeycode key; + projectMModifier mod; + + /** Process SDL events */ + SDL_Event event; + while ( SDL_PollEvent( &event ) ) { + /** Translate into projectM codes and process */ + evt = sdl2pmEvent( event ); + + key = sdl2pmKeycode( event.key.keysym.sym ); + mod = sdl2pmModifier( event.key.keysym.mod ); + + if ( evt == PROJECTM_KEYDOWN ) { + + if(key == PROJECTM_K_c) + { + //SDL_SaveBMP(screen, "/home/pete/1.bmp"); + saveSnapshotToFile(); + } + if(key == PROJECTM_K_v) + { + // capture++; + } + if(key == PROJECTM_K_f) + { + + + int w, h; + if (fullscreen == 0) { + w = fvw; + h = fvh; + fullscreen = 1; + } else { + w = wvw; + h = wvh; + fullscreen = 0; + } + + resize_display(w, h, fullscreen); + globalPM->projectM_resetGL( w, h ); + } + else globalPM->key_handler(evt,key,mod); + + } + else if ( evt == PROJECTM_VIDEORESIZE ) + { + + + + wvw=event.resize.w; + wvh=event.resize.h; + + + resize_display(wvw,wvh,fullscreen); + globalPM->projectM_resetGL( wvw, wvh ); + + } + else if ( evt == PROJECTM_VIDEOQUIT ) { + + (void) g_idle_add ((GSourceFunc) disable_projectm, NULL); + } + } + + /** Add the waveform data */ + + + /** Render the new frame */ + // strcpy(title,xmms_remote_get_playlist_title(projectM_vtable.xmms_session, xmms_remote_get_playlist_pos(projectM_vtable.xmms_session))); + + //printf("%s\n",title); + // strcpy(globalPM->title,title); + + globalPM->renderFrame(); + + + + SDL_GL_SwapBuffers(); + + if (capture % 2 == 1) saveSnapshotToFile(); + // SDL_SemPost(sem); + } + + if(title_timer) + SDL_RemoveTimer(title_timer); + delete globalPM; + + + return 0; +} + +extern "C" void projectM_xmms_init(void) +{ + + /* First, initialize SDL's video subsystem. */ + // std::cerr << "sdl init begin" << std::endl; + if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 ) { + /* Failed, exit. */ + fprintf( stderr, "Video initialization failed: %s\n", + SDL_GetError( ) ); + //projectM_vtable.disable_plugin (&projectM_vtable); + return; + + } + sem = SDL_CreateSemaphore(0); + // printf("projectM plugin: Initializing\n"); + + SDL_EnableUNICODE(1); + + worker_thread = SDL_CreateThread ( *worker_func, NULL); + +} + + + +extern "C" void projectM_cleanup(void) +{ + + if(!sem) return; + SDL_SemWait(sem); + if(worker_thread) SDL_WaitThread(worker_thread, NULL); + // SDL_KillThread(worker_thread); + //printf("killed thread\n"); + + SDL_DestroySemaphore(sem); + //printf("Destroy Mutex\n"); + SDL_Quit(); + + sem = NULL; + worker_thread = NULL; + + // printf("projectM plugin: Cleanup completed\n"); +} +extern "C" void projectM_about(void) +{ + printf("projectM plugin: About\n"); +} +extern "C" void projectM_configure(void) +{ + printf("projectM plugin: Configure\n"); +} +extern "C" void projectM_playback_start(void) +{//thread_control = GO; + printf("projectM plugin: Playback starting\n"); +} +extern "C" void projectM_playback_stop(void) +{//thread_control = STOP; + printf("projectM plugin: Playback stopping\n"); +} +extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]) +{ + //SDL_mutexP(mutex); while ( SDL_SemValue(sem)==1 ) + if ( SDL_SemValue(sem)==1 ) + globalPM->pcm->addPCM16(pcm_data); + + //SDL_mutexV(mutex); + +} + +extern "C" void projectM_render_freq(gint16 freq_data[2][256]) +{ + printf("NO GOOD\n"); + } + +std::string read_config() +{ + +// int n; + + char num[512]; + FILE *in; + FILE *out; + + char* home; + char projectM_home[1024]; + char projectM_config[1024]; + + strcpy(projectM_config, PROJECTM_PREFIX); + strcpy(projectM_config+strlen(PROJECTM_PREFIX), CONFIG_FILE); + projectM_config[strlen(PROJECTM_PREFIX)+strlen(CONFIG_FILE)]='\0'; + //printf("dir:%s \n",projectM_config); + home=getenv("HOME"); + strcpy(projectM_home, home); + strcpy(projectM_home+strlen(home), "/.projectM/config.inp"); + projectM_home[strlen(home)+strlen("/.projectM/config.inp")]='\0'; + + + if ((in = fopen(projectM_home, "r")) != 0) + { + //printf("reading ~/.projectM/config.inp \n"); + fclose(in); + return std::string(projectM_home); + } + else + { + printf("trying to create ~/.projectM/config.inp \n"); + + strcpy(projectM_home, home); + strcpy(projectM_home+strlen(home), "/.projectM"); + projectM_home[strlen(home)+strlen("/.projectM")]='\0'; + mkdir(projectM_home,0755); + + strcpy(projectM_home, home); + strcpy(projectM_home+strlen(home), "/.projectM/config.inp"); + projectM_home[strlen(home)+strlen("/.projectM/config.inp")]='\0'; + + if((out = fopen(projectM_home,"w"))!=0) + { + + if ((in = fopen(projectM_config, "r")) != 0) + { + + while(fgets(num,80,in)!=NULL) + { + fputs(num,out); + } + fclose(in); + fclose(out); + + + if ((in = fopen(projectM_home, "r")) != 0) + { + printf("created ~/.projectM/config.inp successfully\n"); + fclose(in); + return std::string(projectM_home); + } + else{printf("This shouldn't happen, using implementation defualts\n");abort();} + } + else{printf("Cannot find projectM default config, using implementation defaults\n");abort();} + } + else + { + printf("Cannot create ~/.projectM/config.inp, using default config file\n"); + if ((in = fopen(projectM_config, "r")) != 0) + { printf("Successfully opened default config file\n"); + fclose(in); + return std::string(projectM_config);} + else{ printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); abort();} + } + + } + + abort(); +} + +int frame = 1; + + +void saveSnapshotToFile() +{ + char dumpPath[512]; + char Home[512]; + //char *home; + + SDL_Surface * bitmap; + + GLint viewport[4]; + long bytewidth; + GLint width, height; + long bytes; + + glReadBuffer(GL_FRONT); + glGetIntegerv(GL_VIEWPORT, viewport); + + width = viewport[2]; + height = viewport[3]; + + bytewidth = width * 4; + bytewidth = (bytewidth + 3) & ~3; + bytes = bytewidth * height; + + /* + glFinish(); + glPixelStorei(GL_PACK_ALIGNMENT, 4); + glPixelStorei(GL_PACK_ROW_LENGTH, 0); + glPixelStorei(GL_PACK_SKIP_ROWS, 0); + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + */ + + + bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,0,0,0,0); + glReadPixels(0, 0, width, height, + GL_BGRA, + GL_UNSIGNED_INT_8_8_8_8_REV, + bitmap->pixels); + + sprintf(dumpPath, "/.projectM/%.8d.bmp", frame++); + // home=getenv("HOME"); + strcpy(Home, getenv("HOME")); + strcpy(Home+strlen(Home), dumpPath); + Home[strlen(Home)]='\0'; + SDL_SaveBMP(bitmap, Home); + + SDL_FreeSurface(bitmap); + + +} + diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/main_visplugin.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/main_visplugin.c Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,28 @@ +#include + +extern void projectM_xmms_init(void); +extern void projectM_cleanup(void); +extern void projectM_about(void); +extern void projectM_configure(void); +extern void projectM_playback_start(void); +extern void projectM_playback_stop(void); +extern void projectM_render_pcm(gint16 pcm_data[2][512]); +extern void projectM_render_freq(gint16 pcm_data[2][256]); + +VisPlugin projectM_vtable = { + .description = "projectM v1.0", + .num_pcm_chs_wanted = 2, + .init = projectM_xmms_init, + .cleanup = projectM_cleanup, + .about = projectM_about, + .configure = projectM_configure, + .playback_start = projectM_playback_start, + .playback_stop = projectM_playback_stop, + .render_pcm = projectM_render_pcm, + .render_freq = projectM_render_freq, +}; + +VisPlugin *projectM_vplist[] = { &projectM_vtable, NULL }; + +DECLARE_PLUGIN(projectm, NULL, NULL, NULL, NULL, NULL, NULL, + projectM_vplist, NULL); diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/sdltoprojectM.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/sdltoprojectM.h Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,148 @@ +/** + * $Id: sdltoprojectM.h,v 1.1.1.1 2005/12/23 18:42:00 psperl Exp $ + * + * Translates SDL -> projectM variables + * + * $Log: sdltoprojectM.h,v $ + * Revision 1.1.1.1 2005/12/23 18:42:00 psperl + * Initial Import + * + * Revision 1.1 2004/10/08 00:35:28 cvs + * Moved and imported + * + * Revision 1.1.1.1 2004/10/04 12:56:00 cvs + * Imported + * + */ + +#ifndef _SDLTOPROJECTM_H +#define _SDLTOPROJECTM_H + +#include "libprojectM/event.h" +#ifdef WIN32 +#include +#else +#include +#endif + +projectMEvent sdl2pmEvent( SDL_Event event ) { \ + + switch ( event.type ) { \ + case SDL_VIDEORESIZE: + return PROJECTM_VIDEORESIZE; \ + case SDL_KEYUP: \ + return PROJECTM_KEYUP; \ + case SDL_KEYDOWN: \ + return PROJECTM_KEYDOWN; \ + case SDL_QUIT: \ + return PROJECTM_VIDEOQUIT; \ + default: + return PROJECTM_KEYUP; \ + } \ + } \ + +projectMKeycode sdl2pmKeycode( SDLKey keysym ) { \ + switch ( keysym ) { \ + case SDLK_F1: \ + return PROJECTM_K_F1; \ + case SDLK_F2: \ + return PROJECTM_K_F2; \ + case SDLK_F3: \ + return PROJECTM_K_F3; \ + case SDLK_F4: \ + return PROJECTM_K_F4; \ + case SDLK_F5: \ + return PROJECTM_K_F5; \ + case SDLK_F6: \ + return PROJECTM_K_F6; \ + case SDLK_F7: \ + return PROJECTM_K_F7; \ + case SDLK_F8: \ + return PROJECTM_K_F8; \ + case SDLK_F9: \ + return PROJECTM_K_F9; \ + case SDLK_F10: \ + return PROJECTM_K_F10; \ + case SDLK_F11: \ + return PROJECTM_K_F11; \ + case SDLK_F12: \ + return PROJECTM_K_F12; \ + case SDLK_ESCAPE: \ + return PROJECTM_K_ESCAPE; + case SDLK_a: + return PROJECTM_K_a; + case SDLK_b: + return PROJECTM_K_b; + case SDLK_c: + return PROJECTM_K_c; + case SDLK_d: + return PROJECTM_K_d; + case SDLK_e: + return PROJECTM_K_e; + case SDLK_f: + return PROJECTM_K_f; + case SDLK_g: + return PROJECTM_K_g; + case SDLK_h: + return PROJECTM_K_h; + case SDLK_i: + return PROJECTM_K_i; + case SDLK_j: + return PROJECTM_K_j; + case SDLK_k: + return PROJECTM_K_k; + case SDLK_l: + return PROJECTM_K_l; + case SDLK_m: + return PROJECTM_K_m; + case SDLK_n: + return PROJECTM_K_n; + case SDLK_o: + return PROJECTM_K_o; + case SDLK_p: + return PROJECTM_K_p; + case SDLK_q: + return PROJECTM_K_q; + case SDLK_r: + return PROJECTM_K_r; + case SDLK_s: + return PROJECTM_K_s; + case SDLK_t: + return PROJECTM_K_t; + case SDLK_u: + return PROJECTM_K_u; + case SDLK_v: + return PROJECTM_K_v; + case SDLK_w: + return PROJECTM_K_w; + case SDLK_x: + return PROJECTM_K_x; + case SDLK_y: + return PROJECTM_K_y; + case SDLK_z: + return PROJECTM_K_z; + case SDLK_UP: + return PROJECTM_K_UP; + case SDLK_RETURN: + return PROJECTM_K_RETURN; + case SDLK_RIGHT: + return PROJECTM_K_RIGHT; + case SDLK_LEFT: + return PROJECTM_K_LEFT; + case SDLK_DOWN: + return PROJECTM_K_DOWN; + case SDLK_PAGEUP: + return PROJECTM_K_PAGEUP; + case SDLK_PAGEDOWN: + return PROJECTM_K_PAGEDOWN; + + default: \ + return PROJECTM_K_NONE; \ + } \ + } \ + +projectMModifier sdl2pmModifier( SDLMod mod ) { \ + return PROJECTM_KMOD_LSHIFT; \ + } \ + +#endif /** _SDLTOPROJECTM_H */ diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/video_init.cxx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/video_init.cxx Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,93 @@ +//video_init.c - SDL/Opengl Windowing Creation/Resizing Functions +// +//by Peter Sperl +// +//Opens an SDL Window and creates an OpenGL session +//also able to handle resizing and fullscreening of windows +//just call init_display again with differant variables + +#include +#include +#include +#include "video_init.h" +#include +extern SDL_Surface *screen; +extern int texsize; + +void resize_display(int w, int h, int f) { + int flags; + if (f) flags = SDL_OPENGL|SDL_HWSURFACE|SDL_FULLSCREEN; + else flags = SDL_OPENGL|SDL_HWSURFACE|SDL_RESIZABLE; +// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + screen = SDL_SetVideoMode( w, h, 0, flags ) ; + if(screen == 0 ) { + fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); + return; + } + + SDL_ShowCursor(f ? SDL_DISABLE : SDL_ENABLE); +} + +//init_display +// +//Sets screen to new width and height (w,h) +//Also switches between fullscreen and windowed +//with the boolean f (fullscreen) +void init_display(int w, int h, int *fvw, int *fvh, int f) +{ + + /* Information about the current video settings. */ + const SDL_VideoInfo* info = NULL; + int bpp = 0; + /* Flags we will pass into SDL_SetVideoMode. */ + int flags = 0; + + + /* Let's get some video information. */ + info = SDL_GetVideoInfo( ); + if( !info ) { + /* This should probably never happen. */ + fprintf( stderr, "Video query failed: %s\n", + SDL_GetError( ) ); + // projectM_vtable.disable_plugin (&projectM_vtable); + return; + } + +// printf("Screen Resolution: %d x %d\n", info->current_w, info->current_h); +// XXX + *fvw = w; + *fvh = h; + bpp = info->vfmt->BitsPerPixel; + //SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + //SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + //SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + + // SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 8 ); + // SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 8 ); + // SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + if (f==0) + flags = SDL_OPENGL|SDL_HWSURFACE|SDL_RESIZABLE; + else flags = SDL_OPENGL|SDL_HWSURFACE|SDL_FULLSCREEN; + screen= SDL_SetVideoMode( w, h, bpp, flags ) ; + if(screen == 0 ) { + /* + * This could happen for a variety of reasons, + * including DISPLAY not being set, the specified + * resolution not being available, etc. + */ + fprintf( stderr, "Video mode set failed: %s\n", + SDL_GetError( ) ); + + // projectM_vtable.disable_plugin (&projectM_vtable); + return; + + } + + // setup_opengl(w,h); + //gluOrtho2D(0, w, 0, h); +} + + diff -r 3bbb2673419b -r 9bdb5aba5e00 src/projectm-1.0/video_init.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/video_init.h Sat Oct 27 15:52:23 2007 -0500 @@ -0,0 +1,5 @@ + + void init_display( int w, int h, int *fvw, int *fvh, int fullscreen ); + void resize_display( int w, int h, int fullscreen ); + +