rubysdl-2.1.2/LICENSE0000644000175000017500000006347711740061051012643 0ustar ohaiohai GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 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. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] 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 Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these 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 other code 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. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. 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, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser 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 combine 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) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) 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. d) 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. e) 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 materials to be 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 with 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 Lesser 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 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. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser 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 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. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! rubysdl-2.1.2/MANIFEST0000644000175000017500000000307211740061051012750 0ustar ohaiohaiMANIFEST README.ja README.en NEWS.ja NEWS.en LICENSE depend extconf.rb lib/rubysdl_aliases.rb lib/sdl.rb lib/rubysdl_compatible_ver1.rb rubysdl.h rubysdl_ref.rd rubysdl_ref.html rubysdl_ref.en.rd rubysdl_ref.en.html rubysdl_event.c rubysdl_event_key.c rubysdl_main.c rubysdl_mixer.c rubysdl_mouse.c rubysdl_sge_video.c rubysdl_time.c rubysdl_video.c rubysdl_wm.c rubysdl_ttf.c rubysdl_cdrom.c rubysdl_joystick.c rubysdl_image.c rubysdl_opengl.c rubysdl_pixel.c rubysdl_smpeg.c rubysdl_sdlskk.c rubysdl_kanji.c rubysdl_rwops.c SDL_kanji.c SDL_kanji.h sample/testsprite.rb sample/playwave.rb sample/movesp.rb sample/alpha.rb sample/sgetest.rb sample/font.rb sample/cdrom.rb sample/playmod.rb sample/testgl.rb sample/testgl_old.rb sample/icon.bmp sample/cursor.rb sample/event2.rb sample/joy2.rb sample/plaympeg.rb sample/cursor.bmp sample/transformblit.rb sample/randrect.rb sample/sdlskk.rb sample/ellipses.rb sample/collision.rb sample/stetris.rb sample/aadraw.rb sample/alphadraw.rb sample/fpstimer.rb sample/bfont.rb sample/font.bmp sample/kanji.rb sample/sample.ttf sample/load_from_io.rb sample/icon.png sample/icon.bmp.gz doc/Makefile doc/rsd.rb doc/cdrom.rsd doc/collision.rsd doc/event.rsd doc/font.rsd doc/general.rsd doc/init.rsd doc/joystick.rsd doc/mixer.rsd doc/mpeg.rsd doc/sdlskk.rsd doc/time.rsd doc/video.rsd doc/wm.rsd doc-en/Makefile doc-en/cdrom.rsd doc-en/collision.rsd doc-en/event.rsd doc-en/font.rsd doc-en/general.rsd doc-en/init.rsd doc-en/joystick.rsd doc-en/mixer.rsd doc-en/mpeg.rsd doc-en/opengl.rsd doc-en/sdlskk.rsd doc-en/time.rsd doc-en/video.rsd doc-en/wm.rsd rubysdl-2.1.2/NEWS.en0000644000175000017500000001766511740061051012734 0ustar ohaiohaiversion 2.1.2 Improbe the handling of strings Fix following methods * SDL::Surface#draw_bezier Update documents version 2.1.1 Fix a compile problem on MacOS X Rename sdl.so to sdl_ext Add following constants * SDL::Mixer::NO_FADING * SDL::Mixer::FADING_OUT * SDL::Mixer::FADING_IN * SDL::TRANSFORM_AA(for compatible with 1.x) * SDL::TRANSFORM_TMAP(for compatible with 1.x) * SDL::TRANSFORM_SAFE(for compatible with 1.x) Fix documents Remove obsolete documents version 2.1.0 add following methods * SDL::TTF#close * SDL::TTF#closed? * SDL::BMFont#close * SDL::BMFont#closed? * SDL::Kanji#close * SDL::Kanji#closed? * SDL::Surface#destroyed? * SDL::Joystick#closed? * SDL::Mixer::Wave#destroyed? * SDL::Mixer::Music#destroyed? * SDL::Kanji#get_coding_system modify documents Async following methods on Ruby 1.9 * SDL::Event#wait * SDL.delay Ruby m17n support on Ruby 1.9 * SDL::WM.set_caption * SDL::WM.caption * SDL::TTF#draw_solid * SDL::TTF#draw_blended * SDL::TTF#draw_shaded * SDL::TTF#render_solid * SDL::TTF#render_blended * SDL::TTF#render_shaded * SDL::Kanji#put * SDL::Kanji#putTate * SDL::SDLSKK#str Fix the bug of following methods * SDL::MPEG#move version 2.0.1b fix sample bug fix SDL::MPEG.info version 2.0.1 fix some compile errors/warnings raise SDL::Surface::VideoMemoryLost when video memory is lost when calling SDL::Surface.blit version 2.0 some changes for ruby 1.9 fix SDL_RWops code Fix/Improve documents Improve English documents Add following methods * SDL::Surface#load_bmp_from_string * SDL::Surface#load_from_string * SDL::Mixer::Wave#load_from_string * SDL::Mixer.playing_channels version 2.0 alpha 1 Remove following methods * SDL::Surface#draw_ellispe * SDL::Surface#draw_filled_ellispe * SDL::Surface#rotate_surface * SDL::Surface#rotate_scaled_surface * SDL.rotate * SDL.rotate_blit * SDL.rotate_scaled_blit * SDL.rotate_xy_scaled Remove Old SDL::Event, and rename SDL::Event2 to SDL::Event Change internal implementation Add following methods * SDL::Surface#destroy * SDL::Joystick#close * SDL::Mixer#close * SDL::Mixer::Wave#destroy * SDL::Mixer::Music#destroy Add module SDL::GL Change behavior of following methods * SDL::Surface#draw_line * SDL::Surface#draw_circle * SDL::Surface#draw_rect * SDL::Surface#draw_ellipse * SDL::Surface#draw_bezier Rename following methods * SDL.auto_lock? -> SDL::Surface.auto_lock? * SDL.auto_lock_on -> SDL::Surface.auto_lock_on * SDL.auto_lock_off -> SDL::Surface.auto_lock_off * SDL.transform_blit -> SDL::Surface#transform_blit * SDL.blitSurface -> SDL::Surface.blit * SDL.get_video_surface -> SDL::Screen.get * SDL.set_video_mode -> SDL::Screen.open * SDL.check_video_mode -> SDL::Screen.check_mode * SDL.list_modes -> SDL::Screen.list_modes * SDL.set_gamma -> SDL::Screen.set_gamma * SDL.get_gamma_ramp -> SDL::Screen.get_gamma_ramp * SDL.set_gamma_ramp -> SDL::Screen.set_gamma_ramp * SDL.video_driver_name -> SDL::Screen.driver_name * SDL.video_info -> SDL::Screen.info * SDL::Surface#get_rgb -> SDL::PixelFormat#get_rgb * SDL::Surface#get_rgba -> SDL::PixelFormat#get_rgba * SDL::Surface#map_rgb -> SDL::PixelFormat#map_rgb * SDL::Surface#map_rgba -> SDL::PixelFormat#map_rgba * SDL::Surface#get_palette -> SDL::PixelFormat#palette * SDL::Surface#bpp -> SDL::PixelFormat#bpp * SDL::Surface#bytes_per_pixel -> SDL::PixelFormat#bytes_per_pixel * SDL::Surface#[RGBA]mask -> SDL::PixelFormat#[RGBA]mask * SDL::Surface#[RGBA]shift -> SDL::PixelFormat#[RGBA]shift * SDL::Surface#[RGBA]loss -> SDL::PixelFormat#[RGBA]loss * SDL::Surface#colorkey -> SDL::PixelFormat#colorkey * SDL::Surface#alpha -> SDL::PixelFormat#alpha * SDL.get_GL_attr -> SDL::GL.get_attr * SDL.set_GL_attr -> SDL::GL.set_attr * SDL.GL_swap_buffers -> SDL::GL.swap_buffers Move following constants * GL_RED_SIZE -> GL::RED_SIZE * GL_GREEN_SIZE -> GL::GREEN_SIZE * GL_BLUE_SIZE -> GL::BLUE_SIZE * GL_ALPHA_SIZE -> GL::ALPHA_SIZE * GL_BUFFER_SIZE -> GL::BUFFER_SIZE * GL_DOUBLEBUFFER -> GL::DOUBLEBUFFER * GL_DEPTH_SIZE -> GL::DEPTH_SIZE * GL_STENCIL_SIZE -> GL::STENCIL_SIZE * GL_ACCUM_RED_SIZE -> GL::ACCUM_RED_SIZE * GL_ACCUM_GREEN_SIZE -> GL::ACCUM_GREEN_SIZE * GL_ACCUM_BLUE_SIZE -> GL::ACCUM_BLUE_SIZE * GL_ACCUM_ALPHA_SIZE -> GL::ACCUM_ALPHA_SIZE version 1.3.1 Fix the bug that we cannot compile when SMEPG is installed but SDL_mixer is not installed.(1.2.0's change is incomplete) Add following methods SDL::Surface#Rloss SDL::Surface#Gloss SDL::Surface#Bloss SDL::Surface#Aloss SDL::Surface#Rshift SDL::Surface#Gshift SDL::Surface#Bshift SDL::Surface#Ashift SDL::Surface#pitch SDL::Surface#bytes_per_pixel Fix following methods SDL::Surface.pixels version 1.3.0 Fix/Improve documents Add constant SDL::NOFRAME Add following methods SDL::Screen.update_rects SDL::Event2.pump SDL::Mixer.driver_name SDL::Surface.blit SDL::Mixer.driver_name Fix following methods SDL.video_driver_name version 1.2.0 Add Japanese reference Add following methods SDL::MPEG#render_final SDL::Surface.load_bmp_from_io SDL::Surface.load_from_io SDL::Mixer::Wave.load_from_io SDL::Mixer::Music.load_from_string Fix the bug that we cannot compile when SMEPG is installed but SDL_mixer is not installed. version 1.1.0 Change Japanese reference Add following methods SDL::CD.framesToMSF SDL::CD.MSFToFrames SDL::CD#in_drive? SDL::Mixer.playChannelTimed SDL::Mixer.fadeInChannel SDL::Mixer.fadeInChannelTimed SDL::Mixer.expire SDL::Mixer.fading SDL::Mixer.fadeOut SDL::Mixer.fadingMusic SDL::Mouse.show? SDL::CollisionMap#w SDL::CollisionMap#h SDL::BMFont#textSize SDL::TTF#init? Add following class SDL::Event2::VideoExpose Fix bugs in SDL::Key.press? SDL::TTF#familyName SDL::TTF#styleName SDL::BMFont Add some constants about key repeat version 1.0.0 Add following methods SDL::Surface#drawBezier SDL::Surface#drawAABezier SDL::Surface#drawBezierAlpha SDL::Surface#drawAABezierAlpha Fix bugs in SDL::MPEG#setDisplay version 0.9.5 Fix bugs in SDL::Surface#getPalette and SDL::Surface#copyRect Add SDL::WM.grubInput, SDL.quit, SDL.putenv and SDL.getenv Fix trivial typo Fix documentation of SDL::TTF#textSize version 0.9.4 Add SDL::Surface#pixels, SDL::Surface#[RGBA]mask and SDL::Surface.new_from Modyfy SDL::Surface.new Add a little OpenGL document version 0.9.3 Support bitmap font drawing with sge Support bdf font drawing with SDL_kanji Add following methods SDL::TTF#height SDL::TTF#ascent SDL::TTF#descent SDL::TTF#lineSkip SDL::Surface#copyRect Fix some warnings Fix a critical bug in SDLSKK module Setup OpenGL by default version 0.9.2 Primitive draw with anti-alias and alpha blending is now available. Modify SDL.transformBlit for alpha blending. version 0.9.1 Fix two critical bugs in event module. version 0.9 Support SDLSKK 0.4, and stop supporting 0.3. Add collision detection function. ( thanks to Wayne Conrad ) Improve MPEG playback function. Enable to load multiple mpeg files. Add sample. ( thanks to Simon Strandgaard ) version 0.8.3 Add following methods because of typo. ( thanks to Wayne Conrad ) SDL::Surface#drawEllipse SDL::Surface#drawFilledEllipse Fix following method. ( thanks to moumar ) SDL.videoInfo version 0.8.2 Support SDLSKK 0.3, and stop supporting 0.2. Bug fix about Joystick subsystem. Add following methods. SDL::Screen#toggleFullScreen SDL::Key.getKeyName Add aliases into documents. version 0.8.1 bug fix version 0.8 Support SDLSKK. Change SDL's finalizer (Thanks to Tamura). Change some methods' name. SDL::CD.name -> SDL::CD.indexName SDL::Joystick.name -> SDL::Joystick.indexName Add Ruby like ( uncapitalized and separated by underbars ) aliases. Add following methods. SDL::Mixer.allocateChannels SDL::TTF#renderSolidUTF8 SDL::TTF#renderBlendedUTF8 SDL::TTF#renderShadedUTF8 SDL::TTF#faces SDL::TTF#fixedWidth? SDL::TTF#familyName SDL::TTF#styleName SDL.videoDriverName SDL.getGammaRamp SDL.setGammaRamp SDL::Surface#saveBMP SDL::Surface#displayFormatAlpha SDL::Surface#getClipRect SDL.autoLock? SDL.autoLockON SDL.autoLockOFF Extend following method. SDL.blitSurace2rubysdl-2.1.2/NEWS.ja0000644000175000017500000002207411740061051012712 0ustar ohaiohaiversion 2.1.2 Ruby$B$NJ8;zNs$H(BC$B$NJ8;zNs$NJQ49$r87L)$K$9$k$h$&$K$7$?(B $B0J2<$N%a%=%C%I$N%P%0$r=$@5(B * SDL::Surface#draw_bezier $B%I%-%e%a%s%H$N=$@5(B version 2.1.1 Ruby 1.9$B$H(BMacOS X$B$G%3%s%Q%$%k$G$-$J$$LdBj$r=$@5(B sdl.so $B$r(B sdl_ext $B$H$$$&L>A0$KJQ99(B $B0J2<$NDj?t$rDI2C(B * SDL::Mixer::NO_FADING * SDL::Mixer::FADING_OUT * SDL::Mixer::FADING_IN * SDL::TRANSFORM_AA(for compatible with 1.x) * SDL::TRANSFORM_TMAP(for compatible with 1.x) * SDL::TRANSFORM_SAFE(for compatible with 1.x) $B%I%-%e%a%s%H$N=$@5(B $B8E$$%I%-%e%a%s%H$r:o=|(B version 2.1.0 $B0J2<$N%a%=%C%I$rDI2C(B * SDL::TTF#close * SDL::TTF#closed? * SDL::BMFont#close * SDL::BMFont#closed? * SDL::Kanji#close * SDL::Kanji#closed? * SDL::Surface#destroyed? * SDL::Joystick#closed? * SDL::Mixer::Wave#destroyed? * SDL::Mixer::Music#destroyed? * SDL::Kanji#get_coding_system $B%I%-%e%a%s%H$N=$@5(B $B0J2<$N%a%=%C%I$N8F$S$@$7Cf$K(B1.9$B$G%9%l%C%I@Z$jBX$(2DG=$KJQ99(B * SDL::Event#wait * SDL.delay $B0J2<$N%a%=%C%I$G(BRuby$B$N(Bm17n$B5!G=$rMxMQ$9$k$h$&$KJQ99(B * SDL::WM.set_caption * SDL::WM.caption * SDL::TTF#draw_solid * SDL::TTF#draw_blended * SDL::TTF#draw_shaded * SDL::TTF#render_solid * SDL::TTF#render_blended * SDL::TTF#render_shaded * SDL::Kanji#put * SDL::Kanji#putTate * SDL::SDLSKK#str $B0J2<$N%a%=%C%I$N%P%0$r=$@5(B * SDL::MPEG#move version 2.0.1b $B%5%s%W%k$N%P%0$r=$@5(B SDL::MPEG.info$B$r=$@5(B version 2.0.1 $B%3%s%Q%$%k$G$-$J$$>l9g$,$"$k$N$r=$@5(B SDL::Surface.blit$B$G%S%G%*%a%b%j$,%m%9%H$7$?>l9g$K(B $BNc30(BSDL::Surface::VideoMemoryLost$B$rH/@8$5$;$k$h$&$K$7$?!#(B version 2.0 ruby 1.9$B$G;H$($k$h$&$KJQ99(B SDL_RWops$BBP1~$r=$@5$7!"(BSDL::Mixer::Wave.load_from_io$B$,;H$($k$h$&$K$7$?!#(B $B%I%-%e%a%s%H$N2~A1(B($BFC$K1Q8lHG(B) $B0J2<$N%a%=%C%I$rDI2C(B * SDL::Surface#load_bmp_from_string * SDL::Surface#load_from_string * SDL::Mixer::Wave#load_from_string * SDL::Mixer.playing_channels version 2.0 alpha 1 $BFbIt9=B$$rBgI}$KJQ99(B SDL::Event2$B$r(BSDL::Event$B$KJQ99$7!"$+$D$F$N(BSDL::Event$B$OGQ;_(B $B0J2<$N%a%=%C%I$rGQ;_(B * SDL::Surface#draw_ellispe * SDL::Surface#draw_filled_ellispe * SDL::Surface#rotate_surface * SDL::Surface#rotate_scaled_surface * SDL.rotate * SDL.rotate_blit * SDL.rotate_scaled_blit * SDL.rotate_xy_scaled $B0J2<$N%a%=%C%I$rDI2C(B * SDL::Surface#destroy * SDL::Joystick#close * SDL::Mixer#close * SDL::Mixer::Wave#destroy * SDL::Mixer::Music#destroy SDL::GL$B%b%8%e!<%k$rDI2C(B SDL::PixelFormat(SDL::Surface::Format$B$N$[$&$,NI$$!)(B)$B$N SDL::Surface.auto_lock? * SDL.auto_lock_on -> SDL::Surface.auto_lock_on * SDL.auto_lock_off -> SDL::Surface.auto_lock_off * SDL.transform_blit -> SDL::Surface#transform_blit * SDL.blitSurface -> SDL::Surface.blit * SDL.get_video_surface -> SDL::Screen.get * SDL.set_video_mode -> SDL::Screen.open * SDL.check_video_mode -> SDL::Screen.check_mode * SDL.list_modes -> SDL::Screen.list_modes * SDL.set_gamma -> SDL::Screen.set_gamma * SDL.get_gamma_ramp -> SDL::Screen.get_gamma_ramp * SDL.set_gamma_ramp -> SDL::Screen.set_gamma_ramp * SDL.video_driver_name -> SDL::Screen.driver_name * SDL.video_info -> SDL::Screen.info * SDL::Surface#get_rgb -> SDL::PixelFormat#get_rgb * SDL::Surface#get_rgba -> SDL::PixelFormat#get_rgba * SDL::Surface#map_rgb -> SDL::PixelFormat#map_rgb * SDL::Surface#map_rgba -> SDL::PixelFormat#map_rgba * SDL::Surface#get_palette -> SDL::PixelFormat#palette * SDL::Surface#bpp -> SDL::PixelFormat#bpp * SDL::Surface#bytes_per_pixel -> SDL::PixelFormat#bytes_per_pixel * SDL::Surface#[RGBA]mask -> SDL::PixelFormat#[RGBA]mask * SDL::Surface#[RGBA]shift -> SDL::PixelFormat#[RGBA]shift * SDL::Surface#[RGBA]loss -> SDL::PixelFormat#[RGBA]loss * SDL::Surface#colorkey -> SDL::PixelFormat#colorkey * SDL::Surface#alpha -> SDL::PixelFormat#alpha * SDL.get_GL_attr -> SDL::GL.get_attr * SDL.set_GL_attr -> SDL::GL.set_attr * SDL.GL_swap_buffers -> SDL::GL.swap_buffers $B0J2<$N$h$&$KDj?t$r0\F0!#5lMh$N$b$N$bMxMQ$O$G$-$^$9!#(B * GL_RED_SIZE -> GL::RED_SIZE * GL_GREEN_SIZE -> GL::GREEN_SIZE * GL_BLUE_SIZE -> GL::BLUE_SIZE * GL_ALPHA_SIZE -> GL::ALPHA_SIZE * GL_BUFFER_SIZE -> GL::BUFFER_SIZE * GL_DOUBLEBUFFER -> GL::DOUBLEBUFFER * GL_DEPTH_SIZE -> GL::DEPTH_SIZE * GL_STENCIL_SIZE -> GL::STENCIL_SIZE * GL_ACCUM_RED_SIZE -> GL::ACCUM_RED_SIZE * GL_ACCUM_GREEN_SIZE -> GL::ACCUM_GREEN_SIZE * GL_ACCUM_BLUE_SIZE -> GL::ACCUM_BLUE_SIZE * GL_ACCUM_ALPHA_SIZE -> GL::ACCUM_ALPHA_SIZE OpenGL$B4XO"$N%I%-%e%a%s%H$rDI2C(B version 1.3.1 SMPEG$BM-!"(BSDL_mixer$BL5$N>l9g$NLdBj$r=$@5(B $B0J2<$N%a%=%C%I$rDI2C(B SDL::Surface#Rloss SDL::Surface#Gloss SDL::Surface#Bloss SDL::Surface#Aloss SDL::Surface#Rshift SDL::Surface#Gshift SDL::Surface#Bshift SDL::Surface#Ashift SDL::Surface#pitch SDL::Surface#bytes_per_pixel $B0J2<$N%a%=%C%I$r=$@5(B SDL::Surface.pixels version 1.3.0 $B%I%-%e%a%s%H$r=$@5(B/$B2~A1(B $BDj?t(BSDL::NOFRAME$B$,Dj5A$5$l$F$$$J$+$C$?$N$r=$@5(B $B0J2<$N%a%=%C%I$rDI2C(B SDL::Screen#update_rects SDL::Event2.pump SDL::Screen.open SDL::Surface.blit SDL::Mixer.driver_name $B0J2<$N%a%=%C%I$r=$@5(B SDL.video_driver_name version 1.2.0 $BF|K\8l$N%j%U%!%l%s%9$N(BMPEG$B$N9`L\$r2CI.(B $B0J2<$N%a%=%C%I$rDI2C(B SDL::MPEG#render_final SDL::Surface.load_bmp_from_io SDL::Surface.load_from_io SDL::Mixer::Wave.load_from_io SDL::Mixer::Music.load_from_string SMPEG$BM-!"(BSDL_mixer$BL5$N>l9g$K%3%s%Q%$%k$G$-$J$$%P%0$r=$@5(B version 1.1.0 $BF|K\8l$N%j%U%!%l%s%9$rA4LL2~D{(B $B0J2<$N%a%=%C%I$rDI2C(B SDL::CD.framesToMSF SDL::CD.MSFToFrames SDL::CD#in_drive? SDL::Mixer.playChannelTimed SDL::Mixer.fadeInChannel SDL::Mixer.fadeInChannelTimed SDL::Mixer.expire SDL::Mixer.fading SDL::Mixer.fadeOut SDL::Mixer.fadingMusic SDL::Mouse.show? SDL::CollisionMap#w SDL::CollisionMap#h SDL::BMFont#textSize SDL::TTF#init? $B0J2<$N%/%i%9$rDI2C(B SDL::Event2::VideoExpose $B0J2<$N%a%=%C%I$N%P%0$r=$@5(B SDL::Key.press? SDL::TTF#familyName SDL::TTF#styleName $B0J2<$N%/%i%9$N=*N;;~%P%0$r=$@5(B SDL::BMFont $B%-!<%j%T!<%H4XO"$NDj?t$rDI2C(B version 1.0.0 $B0J2<$N%a%=%C%I$rDI2C(B SDL::Surface#drawBezier SDL::Surface#drawAABezier SDL::Surface#drawBezierAlpha SDL::Surface#drawAABezierAlpha $B0J2<$N%a%=%C%I$N%P%0$r=$@5(B SDL::MPEG#setDisplay version 0.9.5 $B0J2<$N%a%=%C%I$N%P%0$r=$@5(B SDL::Surface#getPalette SDL::Surface#copyRect $B0J2<$N%a%=%C%I$rDI2C(B SDL::WM.grubInput SDL.quit SDL.putenv SDL.getenv $B$5$5$$$J(Btypo$B$r=$@5(B $B%I%-%e%a%s%H$r0lIt=$@5(B(SDL::TTF#textSize) version 0.9.4 SDL::Surface#pixels, SDL::Surface#[RGBA]mask, SDL::Surface.new_from$B$rDI2C(B SDL::Surface.new$B$r3HD%(B OpenGL$B4XO"$N%I%-%e%a%s%H$r:GDc8B$NJ,DI2C(B version 0.9.3 sge$B$N(Bbitmap font$BIA2h5!G=$rDI2C(B SDL_kanji$B$K$h$k(Bbdf font$BIA2h5!G=$rDI2C(B SDL::TTF#height, #ascent, #descent, #lineSkip$B$rDI2C(B SDL::Surface#copyRect$B$rDI2C(B warning$B$,$G$kE@$r=$@5(B SDLSKK$B%$%s%?!<%U%'!<%9$NCWL?E*$J%P%0$r=$@5(B OpenGL$B$r%G%U%)%k%H$GM-8z$K$7$?(B version 0.9.2 sge$B$N%"%k%U%!IU$-?^7AIA2h!"%"%s%A%(%$%j%"%:IU$-?^7AIA2h$r%5%]!<%H(B SDL.transformBlit$B$r(BsetAlpha$B$G$N(Balpha$B$N@_Dj$rM-8z$K$9$k(B version 0.9.1 SDL::Event$B$H(BSDL::Event2$B$NCWL?E*$J%P%0$r=$@5(B version 0.9 SDLSKK 0.4$B$r%5%]!<%H!"(B0.3$B$N%5%]!<%H$rDd;_(B $B>WFMH=Dj5!G=$rDI2C(B ( thanks to Wayne Conrad ) MPEG$B:F@85!G=$r6/2=!#J#?t$N(BMPEG$B%U%!%$%k$rFI$_$3$a$k$h$&$K$9$k!"(BSDL_Mixer$B$K$h$k(B $B2;@<:F@85!G=$H$N6&B8$r2DG=$K$9$k$J$I$NJQ99$r$7$?!#(B $B%5%s%W%k$rDI2C!#(B( thanks to Simon Strandgaard ) version 0.8.3 $B0J2<$N%a%=%C%I$rDI2C(B(typo$B$N$?$a(B) ( thanks to Wayne Conrad ) SDL::Surface#drawEllipse SDL::Surface#drawFilledEllipse $B0J2<$N%a%=%C%I$r=$@5(B( thanks to moumar ) SDL.videoInfo version 0.8.2 SDLSKK 0.3$B$r%5%]!<%H!"(B0.2$B0JA0$O%5%]!<%H$7$J$$$3$H$K$7$?(B Joystick$B5!G=$N%P%0$r=$@5(B $B0J2<$N%a%=%C%I$rDI2C(B SDL::Screen#toggleFullScreen SDL::Key.getKeyName $B%I%-%e%a%s%H$K(Balias$B$r5-=R(B version 0.8.1 $B%P%0=$@5(B version 0.8 SDLSKK$B$N%5%]!<%H$r2C$($k!#(B $B=*N;=hM}$NJQ99(B($B$?$`$i$5$s$N%Q%C%A$J$I$K$h$k(B) $B%"%s%@!<%P!<6h@Z$j$N%a%=%C%IL>$rMxMQ$G$-$k$h$&$K$7$?(B( blit_surface $B$J$I(B ) $B%a%=%C%IL>$rJQ99(B SDL::CD.name -> SDL::CD.indexName SDL::Joystick.name -> SDL::Joystick.indexName $B0J2<$N%a%=%C%I$NDI2C(B SDL::Mixer.allocateChannels SDL::TTF#renderSolidUTF8 SDL::TTF#renderBlendedUTF8 SDL::TTF#renderShadedUTF8 SDL::TTF#faces SDL::TTF#fixedWidth? SDL::TTF#familyName SDL::TTF#styleName SDL.videoDriverName SDL.getGammaRamp SDL.setGammaRamp SDL::Surface#saveBMP SDL::Surface#displayFormatAlpha SDL::Surface#getClipRect SDL.autoLock? SDL.autoLockON SDL.autoLockOFF $B0J2<$N%a%=%C%I$r3HD%(B SDL.blitSurface2 rubysdl-2.1.2/README.en0000644000175000017500000001012511740061051013075 0ustar ohaiohai Ruby/SDL 2.1.2 Ohbayashi Ippei 1 What's Ruby/SDL Ruby/SDL is the ruby extension library to use SDL. SDL(Simple DirectMedia Layer) is a cross-platform multimedia library designed to provide fast access to the graphics framebuffer and audio devices. See http://www.libsdl.org/ if you want to know SDL in detail. 2 Platform This library supports Linux, Win32, MacOS X. This library perhaps works on FreeBSD and other standard Unix-like systems. 3 Library Needed Ruby/SDL needs Ruby and SDL and optionally uses SDL_image, SDL_mixer, SDL_ttf, SGE, OpenGL and SMPEG. Indispensable Ruby http://www.ruby-lang.org/ SDL http://www.libsdl.org/ Optional SDL_mixer http://www.libsdl.org/projects/SDL_mixer/index.html SDL_ttf http://www.libsdl.org/projects/SDL_ttf/index.html SDL_image http://www.libsdl.org/projects/SDL_image/index.html SGE http://www.etek.chalmers.se/~e8cal1/sge/ SMPEG http://www.icculus.org/smpeg/ SDLSKK http://www.kmc.gr.jp/~ohai/sdlskk.en.html 4 INSTALL Some packages are available: Debian's .deb, FreeBSD's ports, or Windows' zipfile. RubyGems are also available. You can install Ruby/SDL: gem install rubysdl You can install from source code as follows: (1)install Ruby See Ruby's document and install. (2)install SDL Extract SDL's source and run './configure' with '--disable-pthreads' option. On Linux using pthread with Ruby/SDL makes a problem. You can avoid this problem by other way (Please see rubysdl_doc.en.rd). And run 'make','make install'. (3)install SGE Run 'make' and 'make install'. (4)install SDL_mixer, SDL_ttf, SDL_image, SMPEG and SDLSKK See documents of these libraries and install them . (5)install this extension library,Ruby/SDL Run 'ruby extconf.rb','make' and 'make install'. (6) (Mac OS X user only) install rsdl Run 'gem install rsdl'. rsdl is a wrapper of the Ruby interpreter. This wrapper prepares Cocoa framework before running the interpreter. 5 USE Ruby/SDL Write "require 'sdl'" in your Ruby script. If your system is OS X, you must use rsdl command as an interpreter instead of ruby command. See following documents and samples if you want to know the detail. sample/*.rb Ruby/SDL samples. In some scripts, you have to prepare data such as "sample.wav" and "sample.mpg". rubysdl_ref.en.html The reference manual rubysdl_ref.en.rd RD style reference manual(the contents is same as rubysdl_ref.en.html) documents of SDL This is in SDL archive. Please read this when you want to know what does't describe these documents. 6 OpenGL You can use OpenGL with this library. (1) Setup OpenGL and SDL. (2) Install ruby-opengl (http://ruby-opengl.rubyforge.org/) (3) Run "ruby extconf.rb", "make", and "make install" (4) Write "require 'sdl'; require 'opengl'" in your script. We use OpenGL through ruby-opengl. Please see SDL's document,OpenGL document and sample/testgl.rb . 7 LICENSE This library is distributed under GNU LGPL version 2.1 or later, which can be found in the file "LICENSE". But samples, the Ruby scripts sample/*.rb, are not under LGPL, and you can use their files freely. 8 Thanks Thanks to ... Tamura : some patches and advertising Akinori MUSHA : Porting on FreeBSD Danny van Bruggen : some ideas are from his library "RUDL" akira yamada : patch of SDL::TTF, making packages of Vine and Debian. Wayne Conrad : some patches Christian Neukirchen, Kent Dahl : send a patch Keffin Barnaby : some patches Rorien Dunn, Dennis Ranke, Keita Urashima : bug reports and useful information Yusuke TABATA : introduce me into SDL world SDLdoc Japanese translation project : base of Ruby/SDL's reference manual Hara Yutaka: Sample TrueTypeFont, MacOS X support Members of #sdl-fan-jp @ FriendChat: bug reports and advices Cyross Makoto: Windows support 9 OTHER Some functions, especially SDL::MPEG methods and pallete handling methods, are not tested. 10 AUTHORS Ippei Obayashi: main developer Cyross Makoto: Windows suppport yhara: MacOS X support Please send comments and bug reports to the author. Author's mail address: ohai@kmc.gr.jp rubysdl-2.1.2/README.ja0000644000175000017500000001402011740061051013063 0ustar ohaiohai Ruby/SDL 2.1.2 大林一平 1 概要 これは、RubyからSDLの機能を使うための拡張ライブラリです。 SDLとは、Win32,Linux,BeOS,MacOS,FreeBSD,Solaris等で動く、クロスプラットフォームなゲーム開発用ライブラリです。 2 動作環境 LinuxのX上、Win32 また、FreeBSDで動作が確認され、Portsが作られたそうです。 BeOS上でも動くそうです。 MacOSXでも動いたそうです。ただしRubyに手を入れる必要があるようです。 それ以外では確認していません。 3 必要なライブラリ このライブラリは、rubyの処理系の他、以下のライブラリを必要とします。 SDL_mixer,SDL_ttf,SDL_image,SGE,smpeg,SDLSKKはなくてもかまいません。 SDL(必須) http://www.libsdl.org/ SDL_mixer(オプション) http://www.libsdl.org/projects/SDL_mixer/index.html SDL_ttf(オプション) http://www.libsdl.org/projects/SDL_ttf/index.html SDL_image(オプション) http://www.libsdl.org/projects/SDL_image/index.html SGE(オプション) http://www.etek.chalmers.se/~e8cal1/sge/ SMPEG(オプション) http://www.icculus.org/smpeg/ SDLSKK(オプション) http://www.kmc.gr.jp/~ohai/sdlskk.html また、SDL_kanjiを利用していますが、これはアーカイブに含めているので 別に用意する必要はありません。 4 インストール Linux上でのインストールを説明します。Unix系のOSならどれでも同じよう にできると思います。 Debian、Vine、その他様々なディストリビューションにはRuby/SDLのパッケージ があるのでそれを利用してもよいでしょう。 Windows上では別に用意しているバイナリを使用したほうが楽でしょう。 FreeBSDにはPortがあるのでそれを利用してください。 作者のWindowsの環境では、extconf.rbを使用せずMakefileを手で書いて コンパイルしていたりします。 (1)rubyのインストール rubyのドキュメント等に従ってインストールしてください。 (2)SDLのインストール ソースを展開してコンパイルする場合は、以下の通りにしてください。 ./configure --disable-pthreads (ここで--disable-pthreadsオプションをつけないとうまく動きません) (このオプションをつけても、SDLは全機能使えるようです) (Linux以外では必要ありません) (rubysdl_doc.rdの最後に--disable-pthreadsを付けなくとも良い方法も書いてあります) make make install (3)SGEのインストール make; make installでインストールされます。 (4)SDL_mixer,SDL_ttf,SDL_image,SMPEG,SDLSKKのインストール 附属のドキュメントに従ってインストールしてください。 (5)この拡張ライブラリ(Ruby/SDL)のインストール このライブラリのソースを展開したディレクトリ内で ruby extconf.rb make make install としてください。 (6) (MacOS Xのみ) rsdl のインストール gem install rsdl で rsdl をインストールしてください。 5 使い方 require 'sdl'で使えます。 MacOS Xの場合のみ、 ruby コマンドでなく rsdl コマンドで インタプリタを起動してください。 詳しくは、以下のファイルやドキュメントを見てください。 sample/*.rb サンプル 以下のサンプルがあります。 testsprite.rb 画像表示のサンプル playwave.rb PCMファイル演奏のサンプル sample.wav が必要 movesp.rb キー入力のサンプル alpha.rb アルファブレンディングのサンプル sgetest.rb sgeのプリミティブ描画のサンプル font.rb True Type Fontのサンプル playmod.rb modファイル演奏のサンプル sample.it が必要 testgl.rb OpenGLのサンプル cursor.rb マウスカーソルを変更するサンプルp transformblit.rb 回転縮小拡大のサンプル joy2.rb ジョイパッド入力のサンプル plaympeg.rb mpeg表示のサンプル sample.mpgが必要 sdlskk.rb SDLSKKのサンプル。フォントや辞書等必要 詳しくはサンプルのコメントを見てください bfont.rb ビットマップフォント表示のサンプル kanji.rb SDL_Kanji機能のサンプル。8x16.bdfとjiskan16.bdf という2つのbdfファイルが必要 collision.rb 衝突検出機能のサンプル その他 rubysdl_ref.rd, rubysdl_ref.html リファレンス Ruby/SDLのリファレンスマニュアルです。 rubysdl_doc_old.rd 古いリファレンス 古いリファレンスです。 SDLのドキュメント SDLのインストールのときに展開したファイルの中にあるはずです。 また、 http://www.tacoworks.jp/software/SDLdoc-jp/index-j.html から日本語のドキュメントも手に入ります。 リファレンスに書かれていないことはこれを見てください。 doc/ Makefile rsd.rb *.rsd リファレンスマニュアルの元データです。 6 OpenGLについて このライブラリによってOpenGLへのアクセスが可能になります。 (1) SDLからOpenGLを使えるように設定する。 (2) http://ruby-opengl.rubyforge.org/ をインストールする。 (3) ruby extconf.rb をするときに、--enable-opengl を指定する。 (4) make ; make install する。 この場合はRubyのスクリプト内でrequire 'opengl'をする必要があります。 インターフェースは ruby-opengl そのものなので、 これの使いかたは、SDLのドキュメント、OpenGLのドキュメント、 および sample/testgl.rb を見て調べてください。 7 ライセンス GNU LGPL(GNU Lesser General Public License) version 2.1 以降に従います。 詳しくはLICENSEを見てください。 ただし、sample/ 以下にあるサンプルプログラムはこれには従わず、 自由に利用してよいです。 8 謝辞 以下の人達に感謝します。 * FreeBSDでの動作確認をし、Portsを作っていただいたAkinori MUSHAさん。 * さまざまな意見を送ってくださり、いくつものパッチを送ってくださったり したたむらさん。 * そしてもうひとつのSDLのRuby拡張ライブラリ"RUDL"の作者である Danny van Bruggen さん(いくつかのアイデアをこのライブラリから得ました)。 * rubysdl_ttf.cの機能拡張パッチやVine、Debianのパッケージ作成などを していただいたやまだあきらさん。 * いくつかのパッチを下さった Wayne Conrad さん、Christian Neukirchenさん、 Keffin Barnabyさん。 * サンプルを提供してくださった Simon Strandgaard さん。 * 有用な情報、バグレポートをくださった Rorien Dunnさん、Dennis Rankeさん、 Keita Urashimaさん。 * SDLの存在を教えてくれ、Ruby/SDLを作るきっかけを与えてくれた田畑さん。 * SDLdoc 日本語翻訳プロジェクトにかかわったみなさま * サンプル用のフォントを提供してくれた原さん。 * #sdl-fan-jp@friend chat のみなさま * Windows版の管理をしてくださるサイロスさん 9 その他 まだテストされていない機能が多くあります(パレット関連 やMPEG関連のメソッドいくつかなど)。 10. 作者 大林一平: いろいろ サイロス誠: Windowsサポート yhara: MacOS Xサポート 要望、バグ報告、使用した感想等は、ohai@kmc.gr.jpにメールを出して ください。 以上 rubysdl-2.1.2/SDL_kanji.c0000644000175000017500000002021711740061051013561 0ustar ohaiohai#include "SDL_kanji.h" #include #include #include #include #define BUF 256 static void InitFont(Kanji_Font* font) { int i; for (i = 0; i < 96*96 + 256; i++) { font->moji[i] = 0; } } Kanji_Font* Kanji_OpenFont(const char* file, int size) { Kanji_Font* font; font = (Kanji_Font*)malloc(sizeof(Kanji_Font)); font->k_size = size; font->a_size = size / 2; font->sys = KANJI_JIS; InitFont(font); if (0 == Kanji_AddFont(font, file)) { return font; } else { free(font); return 0; } } static void ParseChar(Kanji_Font* font, int index, FILE* fp, int shift) { char buf[BUF]; int y; /* [h */ if (font->moji[index] != 0) return; font->moji[index] = (Uint32*)malloc(sizeof(Uint32)*font->k_size); for (y = 0; y < font->k_size; y++) { fgets(buf, BUF, fp); font->moji[index][y] = (strtol(buf, 0, 16) >> shift); } } static int ParseFont(Kanji_Font* font, FILE* fp) { char buf[BUF], *p; int index; int k_rshift, a_rshift; int s; for (s = 8; s < font->k_size; s += 8) {} k_rshift = s - font->k_size; for (s = 8; s < font->a_size; s += 8) {} a_rshift = s - font->a_size; while (1) { if (fgets(buf, BUF, fp) == NULL) { break; } if (strstr(buf, "ENCODING") != NULL) { p = strchr(buf, ' '); index = strtol(p, 0, 10); while (strstr(buf, "BITMAP") == NULL) { fgets(buf, BUF, fp); } if (index > 255) { index = (((index & 0xff00) >> 8) - 0x20) * 96 + (index & 0xff) - 0x20 + 0xff; ParseChar(font, index, fp, k_rshift); } else { ParseChar(font, index, fp, a_rshift); } } } return 0; } int Kanji_AddFont(Kanji_Font* font, const char* file) { FILE* fp; fp = fopen(file, "r"); if(fp==NULL){ fprintf(stderr, "cant open [%s]\n", file); return -1; } if (0 != ParseFont(font, fp)) return -1; fclose(fp); return 0; } int Kanji_FontHeight(Kanji_Font* font) { return font->k_size; } int Kanji_FontWidth(Kanji_Font* font, const char* text) { if (text == 0) return font->a_size; else return strlen(text) * font->a_size; } static void KanjiPutpixel(SDL_Surface *s,int x,int y,Uint32 pixel){ Uint8 *p,bpp; if(SDL_MUSTLOCK(s)){ if(SDL_LockSurface(s)<0) return; } bpp=s->format->BytesPerPixel; p=(Uint8*)(s->pixels)+y*s->pitch+x*bpp; switch(bpp){ case 1: *((Uint8 *)p)=(Uint8)pixel; break; case 2: *((Uint16 *)p)=(Uint16)pixel; break; case 4: *((Uint32 *)p)=pixel; break; } if(SDL_MUSTLOCK(s)){ SDL_UnlockSurface(s); } } static void euc2jis(unsigned char *c1, unsigned char *c2) { *c1 &= 0x7f; *c2 &= 0x7f; } static void sjis2jis(unsigned char *c1, unsigned char *c2) { if( *c2 < 0x9f ) { if( *c1 < 0xa0 ) { *c1 -= 0x81; *c1 *= 2; *c1 += 0x21; } else { *c1 -= 0xe0; *c1 *= 2; *c1 += 0x5f; } if( *c2 > 0x7f ) -- *c2; *c2 -= 0x1f; } else { if( *c1 < 0xa0 ) { *c1 -= 0x81; *c1 *= 2; *c1 += 0x22; } else { *c1 -= 0xe0; *c1 *= 2; *c1 += 0x60; } *c2 -= 0x7e; } } static void ConvertCodingSystem(Kanji_Font* font, unsigned char *c1, unsigned char *c2) { if (font->sys == KANJI_SJIS) { sjis2jis(c1, c2); } else if (font->sys == KANJI_EUC) { euc2jis(c1, c2); } } int Kanji_PutText(Kanji_Font* font, int dx, int dy, SDL_Surface* dst, const char* txt, SDL_Color fg) { Uint32 fgcol; int index; int x, y, cx = dx, cy = dy; unsigned char high, low; int minx, miny, maxx, maxy; int nowKanji = 0; const unsigned char* text = (const unsigned char*)txt; fgcol = SDL_MapRGB(dst->format, fg.r, fg.g, fg.b); while (*text != 0) { if (font->sys == KANJI_JIS && *text == 0x1b) { if (*(text+1) == 0x24 && *(text+2) == 0x42) { nowKanji = 1; } else if (*(text+1) == 0x28 && *(text+2) == 0x42) { nowKanji = 0; } text += 3; continue; } if (font->sys != KANJI_JIS) nowKanji = !isprint(*text); if (!nowKanji) { index = *text; text++; if (font->moji[index] == 0) { cx += font->a_size; continue; } minx = (cx >= 0) ? 0 : -cx; miny = (cy >= 0) ? 0 : -cy; maxx = (cx+font->a_size <= dst->w) ? font->a_size : dst->w-cx; maxy = (cy+font->k_size <= dst->h) ? font->k_size : dst->h-cy; for (y = miny; y < maxy; y++) { for (x = minx; x < maxx; x++) { if (font->moji[index][y] & (1 << (font->a_size-x-1))) { KanjiPutpixel(dst, cx+x, cy+y, fgcol); } } } cx += font->a_size; } else { high = *text; low = *(text+1); ConvertCodingSystem(font, &high, &low); index = (high - 0x20) * 96 + low - 0x20 + 0xff; text += 2; if (font->moji[index] == 0) { cx += font->k_size; continue; } minx = (cx >= 0) ? 0 : -cx; miny = (cy >= 0) ? 0 : -cy; maxx = (cx+font->k_size <= dst->w) ? font->k_size : dst->w-cx; maxy = (cy+font->k_size <= dst->h) ? font->k_size : dst->h-cy; for (y = miny; y < maxy; y++) { for (x = minx; x < maxx; x++) { if (font->moji[index][y] & (1 << (font->k_size-x-1))) { KanjiPutpixel(dst, cx+x, cy+y, fgcol); } } } cx += font->k_size; } } return 0; } int Kanji_PutTextTate(Kanji_Font* font, int dx, int dy, SDL_Surface* dst, const char* txt, SDL_Color fg) { Uint32 fgcol; int index; int x, y, cx = dx, cy = dy; unsigned char high, low; int minx, miny, maxx, maxy; int nowKanji = 0; const unsigned char* text = (const unsigned char*)txt; fgcol = SDL_MapRGB(dst->format, fg.r, fg.g, fg.b); while (*text != 0) { if (font->sys == KANJI_JIS && *text == 0x1b) { if (*(text+1) == 0x24 && *(text+2) == 0x42) { nowKanji = 1; } else if (*(text+1) == 0x28 && *(text+2) == 0x42) { nowKanji = 0; } text += 3; continue; } if (font->sys != KANJI_JIS) nowKanji = !isprint(*text); /* ASCII */ if (!nowKanji) { text++; } else { high = *text; low = *(text+1); ConvertCodingSystem(font, &high, &low); index = (high - 0x20) * 96 + low - 0x20 + 0xff; text += 2; if (font->moji[index] == 0) { cy += font->k_size; continue; } if (high == 0x21 && (low >= 0x22 || low <= 0x25)) { cx += font->k_size * 0.6; cy -= font->k_size * 0.6; } minx = (cx >= 0) ? 0 : -cx; miny = (cy >= 0) ? 0 : -cy; maxx = (cx+font->k_size <= dst->w) ? font->k_size : dst->w-cx; maxy = (cy+font->k_size <= dst->h) ? font->k_size : dst->h-cy; for (y = miny; y < maxy; y++) { for (x = minx; x < maxx; x++) { if (font->moji[index][y] & (1 << (font->k_size-x-1))) { KanjiPutpixel(dst, cx+x, cy+y, fgcol); } } } if (high == 0x21 && (low >= 0x22 || low <= 0x25)) { cx -= font->k_size * 0.6; cy += font->k_size * 1.6; } else { cy += font->k_size; } } } return 0; } SDL_Surface* Kanji_CreateSurface(Kanji_Font* font, const char* text, SDL_Color fg, int bpp) { SDL_Surface* textbuf; int len; Uint32 bgcol; if (text == NULL) return NULL; if (*text == 0 ) return NULL; len = strlen(text); textbuf = SDL_AllocSurface(SDL_SWSURFACE, font->a_size*len, font->k_size, bpp, 0, 0, 0, 0); if (textbuf == NULL) { fprintf(stderr,"ERROR: at Kanji_RenderText\n"); return NULL; } bgcol = SDL_MapRGB(textbuf->format, 255-fg.r, 255-fg.g, 255-fg.b); SDL_FillRect(textbuf, NULL, bgcol); SDL_SetColorKey(textbuf, SDL_SRCCOLORKEY, bgcol); Kanji_PutText(font, 0, 0, textbuf, text, fg); return textbuf; } SDL_Surface* Kanji_CreateSurfaceTate(Kanji_Font* font, const char* text, SDL_Color fg, int bpp) { SDL_Surface* textbuf; int len; Uint32 bgcol; if (text == NULL) return NULL; if (*text == 0 ) return NULL; len = strlen(text); textbuf = SDL_AllocSurface(SDL_SWSURFACE, font->k_size, font->a_size*len, bpp, 0, 0, 0, 0); if (textbuf == NULL) { fprintf(stderr,"ERROR: at Kanji_RenderText\n"); return NULL; } bgcol = SDL_MapRGB(textbuf->format, 255-fg.r, 255-fg.g, 255-fg.b); SDL_FillRect(textbuf, NULL, bgcol); SDL_SetColorKey(textbuf, SDL_SRCCOLORKEY, bgcol); Kanji_PutTextTate(font, 0, 0, textbuf, text, fg); return textbuf; } void Kanji_CloseFont(Kanji_Font* font) { int i; for (i = 0; i < 96*96 + 256; i++) { if (font->moji[i] != 0) { free(font->moji[i]); } } free(font); } void Kanji_SetCodingSystem(Kanji_Font* font, Kanji_CodingSystem sys) { font->sys = sys; } rubysdl-2.1.2/SDL_kanji.h0000644000175000017500000000240311740061051013563 0ustar ohaiohai#ifndef SDLbdf_h_ #define SDLbdf_h_ #include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { #endif typedef enum { KANJI_SJIS, KANJI_EUC, KANJI_JIS } Kanji_CodingSystem; typedef struct { int k_size; int a_size; Kanji_CodingSystem sys; /* AB */ Uint32* moji[96*96+256]; } Kanji_Font; Kanji_Font* Kanji_OpenFont(const char* file, int size); int Kanji_AddFont(Kanji_Font* font, const char* file); void Kanji_SetCodingSystem(Kanji_Font* font, Kanji_CodingSystem sys); int Kanji_FontHeight(Kanji_Font* font); /* text == 0 ASCII */ int Kanji_FontWidth(Kanji_Font* font, const char* text); SDL_Surface* Kanji_CreateSurface(Kanji_Font* font, const char* text, SDL_Color fg, int bpp); int Kanji_PutText(Kanji_Font* font, int dx, int dy, SDL_Surface* dst, const char* text, SDL_Color fg); SDL_Surface* Kanji_CreateSurfaceTate(Kanji_Font* font, const char* text, SDL_Color fg, int bpp); int Kanji_PutTextTate(Kanji_Font* font, int dx, int dy, SDL_Surface* dst, const char* text, SDL_Color fg); void Kanji_CloseFont(Kanji_Font* font); /* Ends C function definitions when using C++ */ #ifdef __cplusplus }; #endif #endif rubysdl-2.1.2/depend0000644000175000017500000000142611740061051013002 0ustar ohaiohairubysdl_event.o: rubysdl_event.c rubysdl.h rubysdl_event_key.o: rubysdl_event_key.c rubysdl.h rubysdl_main.o: rubysdl_main.c rubysdl.h rubysdl_video.o: rubysdl_video.c rubysdl.h rubysdl_mixer.o: rubysdl_mixer.c rubysdl.h rubysdl_time.o: rubysdl_time.c rubysdl.h rubysdl_wm.o: rubysdl_wm.c rubysdl.h rubysdl_mouse.o: rubysdl_mouse.c rubysdl.h rubysdl_sge_video.o: rubysdl_sge_video.c rubysdl.h rubysdl_image.o: rubysdl_image.c rubysdl.h rubysdl_ttf.o: rubysdl_ttf.c rubysdl.h rubysdl_joystick.o: rubysdl_joystick.c rubysdl.h rubysdl_cdrom.o: rubysdl_cdrom.c rubysdl.h rubysdl_pixel.o: rubysdl_pixel.c rubysdl.h rubysdl_smpeg.o: rubysdl_smpeg.c rubysdl.h rubysdl_sdlskk.o: rubysdl_sdlskk.c rubysdl.h rubysdl_kanji.o: rubysdl_kanji.c rubysdl.h SDL_kanji.h SDL_kanji.o: SDL_kanji.c SDL_kanji.h rubysdl-2.1.2/doc/0000755000175000017500000000000011740061051012362 5ustar ohaiohairubysdl-2.1.2/doc/init.rsd0000644000175000017500000000721611740061051014045 0ustar ohaiohai= 初期化 TOC Ruby/SDLを使う前には必ず@[init]で初期化する必要があります。@[init]は、 ユーザの指定したすべてのサブシステム(ビデオ、オーディオ、ジョイスティック、 タイマー、CD-ROMのいずれかあるいは全部)を初期化することができます。 == Methods %%% NAME init TYPE . PURPOSE SDLを初期化します。 PROTO init(flags) DESC SDLを初期化します。 すべてのRuby/SDLのメソッドを呼び出す前にこの関数が呼ばれなければいけません。 $[flags]にはSDLのどの部分を初期化するかを指定します。 :SDL::INIT_AUDIO オーディオサブシステム(音声出力機能)を初期化 :SDL::INIT_VIDEO ビデオサブシステム(画像出力機能とキーボード、マウス入力機能)を初期化 :SDL::INIT_CDROM CDROMサブシステム(CD再生機能)を初期化 :SDL::INIT_JOYSTICK ジョイスティックサブシステム(ジョイスティック入力機能)を初期化 :SDL::INIT_EVERYTHING 上に挙げた機能を全て初期化します。 EXCEPTION 失敗すると例外@[Error]が発生します。 %% NAME quit TYPE . PURPOSE SDLをシャットダウンします。 PROTO quit DESC 全てのSDLサブシステムをシャットダウンし、それらが確保したリソースをすべて解 放します。通常は自動で呼ばれるためユーザが明示的に呼びだす必要はありません。 SDLおよびRuby/SDLの仕様を理解した上で必要な場合のみ使ってください。 %% NAME inited_system TYPE . PURPOSE サブシステムが初期化されているかどうかをチェックします。 RVAL UINT PROTO inited_system(flags) initedSystem(flags) DESC これは、どのSDLサブシステムが@[初期化されているか|init]を報告します。 $[flags]には、調べたいサブシステムの論理和を指定します (指定できるサブシステムのフラグについては@[init]の項を参照してください)。 RET 初期化されているサブシステムの論理和を返します。 EXAMPLE # SDL.inited_systemの使いかた # 全てのサブシステムの初期化状態を得ます subsystem_init = SDL.inited_system(SDL::INIT_EVERYTHING) if subsystem_init & SDL::INIT_VIDEO puts "ビデオは初期化されています。" else puts "ビデオは初期化されていません。" end # 1つのサブシステムだけをチェックします if SDL.inited_system(SDL::INIT_VIDEO) != 0 puts "ビデオは初期化されています。" else puts "ビデオは初期化されていません。" end # 2つのサブシステムをチェックします subsystem_mask = SDL::INIT_VIDEO|SDL::INIT_AUDIO; if SDL.inited_system(subsystem_mask) == subsystem_mask puts "ビデオとオーディオはどちらも初期化されています。" else puts "ビデオとオーディオのどちらか、または両方が初期化されていません。" end SEEALSO init %% NAME getenv TYPE . PURPOSE 環境変数を得ます。 RVAL String PROTO getenv(var) DESC $[var]で指定した環境変数を得ます。 RET 環境変数の値を文字列で返します。 %% NAME putenv TYPE . PURPOSE 環境変数を変更します。 PROTO putenv(string) DESC 環境変数の追加または値の変更を行います。$[string] は "name=value" という形式を取ります。 Windows上でSDL_WINDOWIDやSDL_VIDEODRIVERといった環境変数を使って SDLの実行に影響を与えたいときに利用します。 SDLの仕様によりWindowsでは ENV を直接変更してもこれらの機能が使え ないためこのような関数が存在しま。Unix上では ENV を使うのと同じ 効果があります。 EXCEPTION 失敗時には例外@[Error]を発生させます。 EXAMPLE # http://moriq.tdiary.net/20051006.html より # Ruby/SDL と Apolloの併用 require 'phi' require 'sdl' # フォームの生成 form = Phi::Form.new $terminated = false form.on_close{ $terminated = true } form.caption = "Ruby/SDL on Phi::Form" # パネルをフォームの上に作る panel = Phi::Panel.new(form) panel.align = Phi::AL_LEFT # WINDOWID hackを使い、パネルにSDLのウインドウをのせる SDL.putenv("SDL_VIDEODRIVER=windib") SDL.putenv("SDL_WINDOWID=#{panel.handle}") form.show # SDL本体の初期化など SDL.init(SDL::INIT_VIDEO) screen = SDL.setVideoMode(640, 480, 16, SDL::SWSURFACE) # メインループ、とりあえず何もしない unless $terminated while event = SDL::Event.poll case event when SDL::Event::KeyDown, SDL::Event::Quit exit end end sleep 0.05 end rubysdl-2.1.2/doc/Makefile0000644000175000017500000000077411740061051014032 0ustar ohaiohai RSD = ruby rsd.rb RDFILES = general.rd init.rd video.rd opengl.rd wm.rd event.rd joystick.rd cdrom.rd mixer.rd time.rd font.rd collision.rd sdlskk.rd mpeg.rd RD2 = rd2 RD2OPT = -r rd/rd2html-lib.rb --html-lang=ja --html-charset=EUC-JP rubysdl_ref.html: rubysdl_ref.rd $(RD2) $(RD2OPT) --html-title="Ruby/SDL Reference Manual" $< > $@ || rm -f $@ rubysdl_ref.rd: $(RDFILES) cat $(RDFILES) > rubysdl_ref.rd %.rd: %.rsd $(RSD) < $< > $@ install: rubysdl_ref.html cp rubysdl_ref.html rubysdl_ref.rd .. rubysdl-2.1.2/doc/event.rsd0000644000175000017500000007064211740061051014226 0ustar ohaiohai= Event * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * (()) * Event関連メソッド TOC == Event system概要 イベント処理によってあなたのアプリケーションはユーザーからの 入力を受け取ることができます。 イベント処理は次のメソッドを呼ぶことで、(ビデオと一緒に)初期化されます。 SDL.init(SDL::INIT_VIDEO) 内部的には、SDL は処理されるまで待機している全てのイベントをイベントキューに 格納します。 @[Event.poll] や @[Event.wait] のようなメソッドを使うことで、 待機している入力イベントを見たり、処理することができます。 Ruby/SDLにおけるイベント処理の鍵は、@[Event]のサブクラス群です。 イベントキュー自身は@[Event](のサブクラス)のインスタンスの列と みなすことができます。それらのオブジェクトは@[Event.poll]を使って キューから読みだされ、 そしてそこに格納された情報の処理をアプリケーションがします。 @[Event]のサブクラスは以下の通りです。 * @[Event::Active] * @[Event::KeyDown] * @[Event::KeyUp] * @[Event::MouseMotion] * @[Event::MouseButtonDown] * @[Event::MouseButtonUp] * @[Event::JoyAxis] * @[Event::JoyBall] * @[Event::JoyHat] * @[Event::JoyButtonDown] * @[Event::JoyButtonUp] * @[Event::Quit] * @[Event::SysWM] * @[Event::VideoResize] * @[Event::VideoExpose] イベントクラスには以下の二つの用途があります。 * キューからイベントを読み出す * キューにイベントを登録する キューからイベントを読み出すには、 @[Event.poll] を使います。 ここでは、 @[Event.poll] を使った例を示します。 while event = SDL::Event.poll @[Event.poll] はイベントキューから次のイベントを 取り出して、キューから削除します。キューにイベントがないときは nil を返し、それ以外の場合は上に挙げたイベントクラスのインスタンス を返します。 次に、イベントの種類を判別するために case〜when 文を使います。 case event 次に、どの種類のイベントを知りたいのかということと、起こった イベントの種類を知らなければいけません。 ここでは、アプリケーション内のマウスポインタの動きを知りたいとします。 求めているイベントに対応するクラスは@[Event::MouseMotion] であることがわかります。case〜when 文の when の所にクラスを書くと、 そのクラスのインスタンスをcaseに与えたときに分岐することを利用します when SDL::Event::MouseMotion ここでは event は @[Event::MouseMotion] のインスタンスなので そのメソッドを使って情報を得ることができます。 puts "マウスカーソルが移動するイベントを受信しました。" puts "カーソルの位置は(#{event.x}, #{event.y})です。" else puts "ハンドルしていないイベントです!" end end puts "イベントキューは空です。" イベントキューにイベントを送ることもできますので、 イベントキューを双方向通信に利用することもできます。 @[Event.push]でイベントキューにイベントを送ることができます。 偽の入力イベントを作り出したりするために使うことができます。 ユーザイベントは Ruby/SDL では利用できません。 == SDL::Event イベントを取り扱うためのクラスです。実際のクラスはこのクラスのサブクラス として表されます。 == 過去との互換性 かつてSDL::Eventという名前だったクラスは廃止されました。 現在SDL::Eventという名前のクラスは以前は SDL::Event2という名前でした。 この変更のため、旧 SDL::Event を使っていると 互換性がありません。また、SDL::Event2という名前は互換性 のため残されています。 == SDL::Event::Active アプリケーションの可視性に関するイベントのクラスです。 マウスカーソルのウインドウの出入り、 キーボードフォーカスの得失、および 最小化/アイコン化されたり元に戻ったときに発生します。 上のいずれが生じたのかは @[Event::Active#state] でわかります。 * NOTES このイベントは、最初にウィンドウが作成されたときには発生しません。 METHODS(Event::Active) == SDL::Event::KeyDown キーボードを押したときに発生するイベントのクラスです。 METHODS(Event::KeyDown) == SDL::Event::KeyUp キーボードを離したときに発生するイベントのクラスです。 METHODS(Event::KeyUp) == SDL::Event::MouseMotion マウスを動かしたときに発生するイベントのクラスです。 簡単に言うと、 このイベントは アプリケーションウィンドウの中でユーザーがマウスを動かしたとき、 または @[Mouse.warp] が呼ばれた時に発生します。 現在のボタンの状態(@[Event::MouseMotion#state])とともに、 絶対座標(@[Event::MouseMotion#x] と @[Event::MouseMotion#y]) と相対座標(@[Event::MouseMotion#xrel] と @[Event::MouseMotion#yrel]) の両方が報告されます。 METHODS(Event::MouseMotion) == SDL::Event::MouseButtonDown マウスボタンを押したときのイベントのクラスです。 METHODS(Event::MouseButtonDown) == SDL::Event::MouseButtonUp マウスボタンを離したときのイベントのクラスです。 METHODS(Event::MouseButtonUp) == SDL::Event::JoyAxis ジョイスティックの軸イベントのクラスです。 ユーザがジョイスティックの軸を移動させるとこのイベントが発生します。 METHODS(Event::JoyAxis) * SEEALSO @[Joystick#num_axes]、@[Joystick#axis] == SDL::Event::JoyBall ジョイスティックのトラックボールの動きイベントのクラスです。 METHODS(Event::JoyBall) * SEEALSO @[Joystick#num_balls]、@[Joystick#ball] == SDL::Event::JoyHat ジョイスティックのハットスイッチの位置変化イベントのクラスです。 METHODS(Event::JoyHat) * SEEALSO @[Joystick#num_hats]、@[Joystick#hat] == SDL::Event::JoyButtonDown ジョイスティックのボタンが押し下げられたときに発生するイベントのクラスです。 METHODS(Event::JoyButtonDown) * SEEALSO @[Joystick#num_buttons]、@[Joystick#button] == SDL::Event::JoyButtonUp ジョイスティックのボタンを離したときに発生するイベントのクラスです。 METHODS(Event::JoyButtonUp) * SEEALSO @[Joystick#num_buttons]、@[Joystick#button] == SDL::Event::Quit 終了要請イベントのクラスです。 終了イベントを無視すると、 ユーザーはウィンドウを閉じることが不可能になります。 一方で、終了イベントを受け入れるならば、 アプリケーションウィンドウは閉じられて アプリケーションは見えなくなりますが、 画面更新はそれでも成功イベントを報告します。 == SDL::Event::SysWM プラットフォーム依存のウィンドウマネージャイベントのクラスです。 ウィンドウマネージャから処理できないイベントを受け取った時はいつでも 生成されます。Ruby/SDL からはいかなるイベントであるのかを知ることは できません。ただ存在するだけで有用でないイベントです。 Ruby からは無視する以外のことはできません。 == SDL::Event::VideoResize ウィンドウのリサイズイベントのクラスです。 SDL::RESIZABLE が $[flag] として @[Screen.open] に 渡された時は、ユーザーはアプリケーションウィンドウをリサイズすることが 許されます。 ウィンドウがリサイズされた時は、このイベントが発生し、 @[Event::VideoResize#w] と @[Event::VideoResize#h] から ウィンドウの新しい横幅と高さが得られます。 このイベントを受け取ると、ウィンドウは @[Screen.open]を使って新しい寸法にリサイズされるはずです。 == SDL::Event::VideoExpose 再描画に関するイベントのクラスです このイベントは他のアプリケーション、通常はウインドウマネージャによってscreen が変更されたときに発生し、再描画の必要性を通知します。 == SDL::Key キーボード入力関連を取り扱うモジュールです。 キーボード関連の定数とモジュール関数が定義されています。 METHODS(Key) === キーシンボル @[Key] にはキーボードのそれぞれのキーに対応する以下の定数が定義されています。 * SDL::Key::BACKSPACE '\b' backspace * SDL::Key::TAB '\t' tab * SDL::Key::CLEAR clear クリア * SDL::Key::RETURN '\r' return * SDL::Key::PAUSE pause * SDL::Key::ESCAPE '^[' escape * SDL::Key::SPACE ' ' space スペース * SDL::Key::EXCLAIM '!' exclaim 感嘆符 * SDL::Key::QUOTEDBL '"' quotedbl 二重引用符 * SDL::Key::HASH '#' hash ハッシュ(シャープ) * SDL::Key::DOLLAR '$' dollar ドル * SDL::Key::AMPERSAND '&' ampersand アンパサンド * SDL::Key::QUOTE ''' quote 引用符 * SDL::Key::LEFTPAREN '(' left parenthesis 左丸括弧 * SDL::Key::RIGHTPAREN ')' right parenthesis 右丸括弧 * SDL::Key::ASTERISK '*' asterisk アスタリスク * SDL::Key::PLUS '+' plus sign プラス * SDL::Key::COMMA ',' comma カンマ * SDL::Key::MINUS '-' minus sign マイナス * SDL::Key::PERIOD '.' period ピリオド * SDL::Key::SLASH '/' forward slash スラッシュ * SDL::Key::K0 '0' 0 * SDL::Key::K1 '1' 1 * SDL::Key::K2 '2' 2 * SDL::Key::K3 '3' 3 * SDL::Key::K4 '4' 4 * SDL::Key::K5 '5' 5 * SDL::Key::K6 '6' 6 * SDL::Key::K7 '7' 7 * SDL::Key::K8 '8' 8 * SDL::Key::K9 '9' 9 * SDL::Key::COLON ':' colon コロン * SDL::Key::SEMICOLON ';' semicolon セミコロン * SDL::Key::LESS '<' less-than sign 小なり * SDL::Key::EQUALS '=' equals sign イコール * SDL::Key::GREATER '>' greater-than sign 大なり * SDL::Key::QUESTION '?' question mark 疑問符 * SDL::Key::AT '@' at アットマーク * SDL::Key::LEFTBRACKET '[' left bracket 左かぎ括弧 * SDL::Key::BACKSLASH '\' backslash バックスラッシュ * SDL::Key::RIGHTBRACKET ']' right bracket 右かぎ括弧 * SDL::Key::CARET '^' caret キャレット * SDL::Key::UNDERSCORE '_' underscore アンダースコア * SDL::Key::BACKQUOTE '`' grave 逆引用符 * SDL::Key::A 'a' a * SDL::Key::B 'b' b * SDL::Key::C 'c' c * SDL::Key::D 'd' d * SDL::Key::E 'e' e * SDL::Key::F 'f' f * SDL::Key::G 'g' g * SDL::Key::H 'h' h * SDL::Key::I 'i' i * SDL::Key::J 'j' j * SDL::Key::K 'k' k * SDL::Key::L 'l' l * SDL::Key::M 'm' m * SDL::Key::N 'n' n * SDL::Key::O 'o' o * SDL::Key::P 'p' p * SDL::Key::Q 'q' q * SDL::Key::R 'r' r * SDL::Key::S 's' s * SDL::Key::T 't' t * SDL::Key::U 'u' u * SDL::Key::V 'v' v * SDL::Key::W 'w' w * SDL::Key::X 'x' x * SDL::Key::Y 'y' y * SDL::Key::Z 'z' z * SDL::Key::DELETE '^?' delete * SDL::Key::KP0 keypad 0 キーバッド(テンキー)の0 * SDL::Key::KP1 keypad 1 キーバッドの1 * SDL::Key::KP2 keypad 2 キーバッドの2 * SDL::Key::KP3 keypad 3 キーバッドの3 * SDL::Key::KP4 keypad 4 キーバッドの4 * SDL::Key::KP5 keypad 5 キーバッドの5 * SDL::Key::KP6 keypad 6 キーバッドの6 * SDL::Key::KP7 keypad 7 キーバッドの7 * SDL::Key::KP8 keypad 8 キーバッドの8 * SDL::Key::KP9 keypad 9 キーバッドの9 * SDL::Key::KP_PERIOD '.' keypad period キーバッドのピリオド * SDL::Key::KP_DIVIDE '/' keypad divide キーパッドの除算記号 * SDL::Key::KP_MULTIPLY '*' keypad multiply キーバッドの乗算記号 * SDL::Key::KP_MINUS '-' keypad minus キーバッドのマイナス * SDL::Key::KP_PLUS '+' keypad plus キーバッドのプラス * SDL::Key::KP_ENTER '\r' keypad enter キーパッドのenter * SDL::Key::KP_EQUALS '=' keypad equals キーパッドのイコール * SDL::Key::UP up arrow 上矢印 * SDL::Key::DOWN down arrow 下矢印 * SDL::Key::RIGHT right arrow 右矢印 * SDL::Key::LEFT left arrow 左矢印 * SDL::Key::INSERT insert * SDL::Key::HOME home * SDL::Key::END end * SDL::Key::PAGEUP page up * SDL::Key::PAGEDOWN page down * SDL::Key::F1 F1 * SDL::Key::F2 F2 * SDL::Key::F3 F3 * SDL::Key::F4 F4 * SDL::Key::F5 F5 * SDL::Key::F6 F6 * SDL::Key::F7 F7 * SDL::Key::F8 F8 * SDL::Key::F9 F9 * SDL::Key::F10 F10 * SDL::Key::F11 F11 * SDL::Key::F12 F12 * SDL::Key::F13 F13 * SDL::Key::F14 F14 * SDL::Key::F15 F15 * SDL::Key::NUMLOCK numlock * SDL::Key::CAPSLOCK capslock * SDL::Key::SCROLLOCK scrollock * SDL::Key::RSHIFT right shift 右shift * SDL::Key::LSHIFT left shift 左shift * SDL::Key::RCTRL right ctrl 右ctrl * SDL::Key::LCTRL left ctrl 左ctrl * SDL::Key::RALT right alt 右alt * SDL::Key::LALT left alt 左alt * SDL::Key::RMETA right meta 右meta * SDL::Key::LMETA left meta 左meta * SDL::Key::LSUPER left windows key 左windowsキー * SDL::Key::RSUPER right windows key 右windowsキー * SDL::Key::MODE mode shift モードシフト * SDL::Key::HELP help * SDL::Key::PRINT print-screen * SDL::Key::SYSREQ SysRq * SDL::Key::BREAK break * SDL::Key::MENU menu * SDL::Key::POWER power * SDL::Key::EURO euro ユーロ == SDL::Mouse マウス入力関連を取り扱うモジュールです。 マウス関連の定数とモジュール関数が定義されています。 METHODS(Mouse) == Methods %%% NAME poll MOD Event TYPE . PURPOSE 現在留まっているイベントを取り出します。 RVAL Event/nil PROTO poll DESC 現在留まっているイベントを取り出し、イベントがあるときはそのイベントを、 無いときは nil を返します。イベントが取り出されたときは キューからそのイベントを削除します。 EXAMPLE while event = SDL::Event.poll #キューに残っているイベントがなくなるまでループ case event # 適切なイベントタイプを処理 when SDL::Event::KeyDown # キー押下イベントを処理 puts "あ! キーを押しましたね" when SDL::Event::MouseMotion . . . else # 未処理のイベントを報告 puts "私にはよく分からないイベントです!" end end SEEALSO Event Event.wait %% NAME wait MOD Event TYPE . PURPOSE 次の利用可能なイベントが来るまで無限に待機します。 RVAL Event/nil PROTO wait DESC 次の利用可能なイベントが来るまで無限に待機し、 イベントが来たらそのイベントを返します。 返したイベントはキューから削除されます。 EXCEPTION イベントを待っている間にエラーがあった場合は例外 @[Error] を 発生させます。 NOTES Ruby 1.8では このメソッドを呼びイベントを待っている間はRubyのスレッドは 切り替わりません。 Ruby 1.9ではイベントを待っている間に他のRubyのスレッド に切り替わることが可能です。 SEEALSO Event.poll %% NAME push MOD Event TYPE . PURPOSE イベントをイベントキューにプッシュします。 PROTO push(event) DESC $[event] で指定したイベントをイベントキューにプッシュします。 NOTES デバイス入力イベントをキューにプッシュしても、 SDL 内のデバイスの状態は変わりません。 EXCEPTION * SEEALSO Event.poll %% NAME app_state MOD Event TYPE . PURPOSE アプリケーションの状態を得ます。 RVAL UINT PROTO app_state appState DESC アプリケーションの現在の状態を返します。戻り値は以下のビット和です。 :SDL::Event::APPMOUSEFOCUS マウスのフォーカスがあります。 :SDL::Event::APPINPUTFOCUS キーボードのフォーカスがあります。 :SDL::Event::APPACTIVE アプリケーションは可視状態です。 SEEALSO Event::Active %% NAME enable_unicode MOD Event TYPE . PURPOSE UNICODE変換を有効にします。 PROTO enable_unicode enableUNICODE DESC キーイベントに対応した文字コードを得るために、 まずこの関数を呼び出してUnicode変換を有効にしなければいけません。 変換を有効にすると、キーボードイベントのたびにちょっとした オーバーヘッドが発生するため、デフォルトでは変換は無効になっています。 変換を有効にすると、以後のキーダウンイベントでは、 @[Event::KeyDown#unicode] から対応する文字コードが得られます。 対応する文字コードが見つからないときは0が入ります。 NOTES 変換が有効なのはキーダウンイベントのみです。 キーリリースイベントは変換されません。 SEEALSO Event.disable_unicode Event.enable_unicode? %% NAME disable_unicode MOD Event TYPE . PURPOSE UNICODE変換を無効にします。 PROTO disable_unicode disableUNICODE DESC UNICODE変換を無効にします。詳しくは @[Event.enable_unicode] を見てください。 %% NAME enable_unicode? MOD Event TYPE . PURPOSE UNICODE変換が有効かどうか調べます。 RVAL true/false PROTO enable_unicode? enableUNICODE? DESC UNICODE変換が有効かどうか調べます。詳しくは @[Event.enable_unicode] を見てください。 %% NAME gain TYPE # MOD Event::Active PURPOSE 可視性を得たなら true を、失ったなら false を返します。 RVAL true/false PROTO gain DESC 可視性を得たことに対応するイベントなら true を、 失ったことに対応するイベントなら false を返します。 SEEALSO Event::Active Event::Active#state %% NAME state MOD Event::Active TYPE # PURPOSE どのような種類の可視性変更イベントが発生したのかを返します。 RVAL SDL::Event::APPMOUSEFOCUS/SDL::Event::APPINPUTFOCUS/SDL::Event::APPACTIVE PROTO state DESC マウスカーソルがウインドウの外に出たり(gain=false)、ウインドウ内に 入ったり(gain=true)したときは、SDL::Event::APPMOUSEFOCUS を返します。 アプリケーションがキーボードフォーカスを得たり(gain=true) 失ったり(gain=false)したときは、SDL::Event::APPINPUTFOCUS を 返します。これは通常他のアプリケーションがアクティブに なったときに発生します。 アプリケーションが最小化/アイコン化されたり(gain=false) 元に戻ったとき(gain=true)には SDL::Event::APPACTIVE を返します。 SEEALSO Event::Active Event::Active#gain %% NAME press MOD Event::KeyDown TYPE # PURPOSE trueを返します。 RVAL true PROTO press DESC 常に true を返します。 SEEALSO Event::KeyUp#press %% NAME sym MOD Event::KeyDown TYPE # PURPOSE 何のキーを押したかをキーシンボルで返します。 RVAL Integer PROTO sym DESC 何のキーを押したかを((<キーシンボル>))で返します。 SEEALSO Event::KeyDown#unicode %% NAME mod MOD Event::KeyDown TYPE # PURPOSE キー押下時のキーモディファイアの状態を返します。 RVAL UINT PROTO mod DESC キー押下時のキーモディファイアの状態を返します。 返り値は @[Key.mod_state] で得られるものと同じです。 SEEALSO Key.mod_state %% NAME unicode MOD Event::KeyDown TYPE # PURPOSE 変換された文字を返します。 RVAL UINT PROTO unicode DESC @[Event.enable_unicode] によって UNICODE 変換が有効にされた時には、 キーの押下に対応する UNICODE 文字を返します。 文字の上位 9 ビットが 0 の場合は、 ASCII 文字に対応しています。 変換が有効でない場合には0 を返します。 %% NAME press MOD Event::KeyUp TYPE # PURPOSE falseを返します。 RVAL false PROTO press DESC 常に false を返します。 SEEALSO Event::KeyDown#press %% NAME sym MOD Event::KeyUp TYPE # PURPOSE 何のキーを離したかをキーシンボルで返します。 RVAL Integer PROTO sym DESC 何のキーを離したかを((<キーシンボル>))で返します。 %% NAME mod MOD Event::KeyUp TYPE # PURPOSE キーモディファイアの状態を返します。 RVAL UINT PROTO mod DESC キーモディファイアの状態を返します。 返り値は @[Key.mod_state] で得られるものと同じです。 SEEALSO Key.mod_state %% NAME state MOD Event::MouseMotion TYPE # PURPOSE 現在のボタンの状態を返します。 RVAL UINT PROTO state DESC 現在のボタンの状態を返します。 以下の定数の論理和を取ったものを返します。 :SDL::Mouse::BUTTON_LMASK 左ボタン :SDL::Mouse::BUTTON_MMASK 中央ボタン :SDL::Mouse::BUTTON_RMASK 右ボタン SEEALSO Mouse.state %% NAME x MOD Event::MouseMotion TYPE # PURPOSE マウスの X 座標を返します。 RVAL UINT PROTO x DESC マウスの X 座標を正の整数で返します。 SEEALSO Mouse.state %% NAME y MOD Event::MouseMotion TYPE # PURPOSE マウスの Y 座標を返します。 RVAL UINT PROTO y DESC マウスの Y 座標を正の整数で返します。 SEEALSO Mouse.state %% NAME xrel MOD Event::MouseMotion TYPE # PURPOSE マウスの X 方向の相対的な動きを返します。 RVAL Integer PROTO xrel DESC マウスの X 座標の相対的な動きを整数で返します。 %% NAME yrel MOD Event::MouseMotion TYPE # PURPOSE マウスの Y 方向の相対的な動きを返します。 RVAL Integer PROTO yrel DESC マウスの Y 座標の相対的な動きを整数で返します。 %% NAME button MOD Event::MouseButtonDown TYPE # PURPOSE 押されたボタンの番号を返します。 PROTO button DESC どのボタンが押されたのかを返します。左、中央、右のボタンに対応して * SDL::Mouse::BUTTON_LEFT * SDL::Mouse::BUTTON_MIDDLE * SDL::Mouse::BUTTON_RIGHT が得られます。 %% NAME press MOD Event::MouseButtonDown TYPE # PURPOSE ボタン押し下げイベントかどうかを返します。 RVAL true PROTO press DESC ボタン押し下げイベントかどうかを返します。 常に true を返します。 SEEALSO Event::MouseButtonUp#press %% NAME x MOD Event::MouseButtonDown TYPE # PURPOSE マウスの X 座標を返します。 RVAL UINT PROTO x DESC マウスの X 座標を正の整数で返します。 SEEALSO Mouse.state %% NAME y MOD Event::MouseButtonDown TYPE # PURPOSE マウスの Y 座標を返します。 RVAL UINT PROTO y DESC マウスの Y 座標を正の整数で返します。 SEEALSO Mouse.state %% NAME button MOD Event::MouseButtonUp TYPE # PURPOSE 離されたボタンの番号を返します。 PROTO button DESC どのボタンが離されたのかを返します。左、中央、右のボタンに対応して * SDL::Mouse::BUTTON_LEFT * SDL::Mouse::BUTTON_MIDDLE * SDL::Mouse::BUTTON_RIGHT が得られます。 %% NAME press MOD Event::MouseButtonUp TYPE # PURPOSE ボタン押し下げイベントかどうかを返します。 RVAL false PROTO press DESC ボタン押し下げイベントかどうかを返します。 常に false を返します。 SEEALSO Event::MouseButtonDown#press %% NAME x MOD Event::MouseButtonUp TYPE # PURPOSE マウスの X 座標を返します。 RVAL UINT PROTO x DESC マウスの X 座標を正の整数で返します。 SEEALSO Mouse.state %% NAME y MOD Event::MouseButtonUp TYPE # PURPOSE マウスの Y 座標を返します。 RVAL UINT PROTO y DESC マウスの Y 座標を正の整数で返します。 SEEALSO Mouse.state %% NAME which MOD Event::JoyAxis TYPE # PURPOSE ジョイスティックデバイスの番号を返します。 RVAL Integer PROTO which DESC イベントが発生したジョイスティックのインデックスを返します。 SEEALSO Joystick Joystick#num_axes %% NAME axis MOD Event::JoyAxis TYPE # PURPOSE ジョイスティックの軸の番号を返します。 RVAL Integer PROTO axis DESC イベントが発生した軸のインデックスを返します。 SEEALSO Joystick %% NAME value MOD Event::JoyAxis TYPE # PURPOSE 軸の値を返します。 RVAL -32767 - 32767 PROTO value DESC 軸の現在の位置を -32767 から 32767 までの整数で返します。 SEEALSO Joystick Joystick#axis %% NAME which MOD Event::JoyBall TYPE # PURPOSE ジョイスティックデバイスの番号を返します。 RVAL Integer PROTO which DESC イベントが発生したジョイスティックのインデックスを返します。 SEEALSO Joystick %% NAME ball MOD Event::JoyBall TYPE # PURPOSE ジョイスティックのトラックボールの番号を返します。 RVAL Integer PROTO ball DESC イベントが発生したジョイスティックのトラックボールの インデックスを返します。 SEEALSO Joystick Joystick#num_balls %% NAME xrel MOD Event::JoyBall TYPE # PURPOSE X方向の相対的な動きを返します。 RVAL Integer PROTO xrel DESC X方向の相対的な動きを整数で返します。 SEEALSO Joystick Joystick#ball %% NAME yrel MOD Event::JoyBall TYPE # PURPOSE Y方向の相対的な動きを返します。 RVAL Integer PROTO yrel DESC Y方向の相対的な動きを整数で返します。 SEEALSO Joystick Joystick#ball %% NAME which MOD Event::JoyHat TYPE # PURPOSE ジョイスティックデバイスの番号を返します。 RVAL Integer PROTO which DESC イベントが発生したジョイスティックのインデックスを返します。 SEEALSO Joystick %% NAME hat MOD Event::JoyHat TYPE # PURPOSE ジョイスティックのハットスイッチの番号を返します。 RVAL Integer PROTO hat DESC イベントが発生したジョイスティックのハットスイッチのインデックスを返します。 SEEALSO Joystick Joystick#num_hats %% NAME value MOD Event::JoyHat TYPE # PURPOSE ハットスイッチの位置を返します。 RVAL UINT PROTO value DESC イベントが発生したハットスイッチの現在の位置を以下の値の論理和で 返します。 * SDL::Joystick::HAT_CENTERED * SDL::Joystick::HAT_UP * SDL::Joystick::HAT_RIGHT * SDL::Joystick::HAT_DOWN * SDL::Joystick::HAT_LEFT * SDL::Joystick::HAT_RIGHTUP * SDL::Joystick::HAT_RIGHTDOWN * SDL::Joystick::HAT_LEFTUP * SDL::Joystick::HAT_LEFTDOWN %% NAME which MOD Event::JoyButtonDown TYPE # PURPOSE ジョイスティックデバイスの番号を返します。 RVAL Integer PROTO which DESC イベントが発生したジョイスティックのインデックスを返します。 SEEALSO Joystick %% NAME button MOD Event::JoyButtonDown TYPE # PURPOSE ジョイスティックのボタンの番号を返します。 RVAL Integer PROTO button DESC イベントが発生したジョイスティックのボタンのインデックスを返します。 SEEALSO Joystick Joystick#num_buttons %% NAME press MOD Event::JoyButtonDown TYPE # PURPOSE ボタン押し下げイベントかどうかを返します。 RVAL true PROTO press DESC ボタン押し下げイベントかどうかを返します。 常に true を返します。 SEEALSO Event::JoyButtonUp#press Joystick#button %% NAME which MOD Event::JoyButtonUp TYPE # PURPOSE ジョイスティックデバイスの番号を返します。 RVAL Integer PROTO which DESC イベントが発生したジョイスティックのインデックスを返します。 SEEALSO Joystick %% NAME button MOD Event::JoyButtonUp TYPE # PURPOSE ジョイスティックのボタンの番号を返します。 RVAL Integer PROTO button DESC イベントが発生したジョイスティックのボタンのインデックスを返します。 SEEALSO Joystick Joystick#num_buttons %% NAME press MOD Event::JoyButtonUp TYPE # PURPOSE ボタン押し下げイベントかどうかを返します。 RVAL false PROTO press DESC ボタン押し下げイベントかどうかを返します。 常に false を返します。 SEEALSO Event::JoyButtonDown#press Joystick#button %% NAME w MOD Event::VideoResize TYPE # PURPOSE ウィンドウの新しい幅を返します。 RVAL Integer PROTO w DESC ウィンドウがリサイズされたときに、 ウィンドウの新しい幅を整数で返します。 %% NAME h MOD Event::VideoResize TYPE # PURPOSE ウィンドウの新しい高さを返します。 RVAL Integer PROTO h DESC ウィンドウがリサイズされたときに、 ウィンドウの新しい高さを整数で返します。 %% NAME scan MOD Key TYPE . PURPOSE キーボードの状態のスナップショットをとります。 PROTO scan DESC キーボードの状態のスナップショットをとります。 @[Key.press?]を使いこの関数で取った状態の情報を得ます。 この状態は @[Event.poll] や @[Event.wait] を呼ばないと更新されません。 SEEALSO Key.press? Event::KeyDown Event::KeyUp Event.poll %% NAME press? MOD Key TYPE . PURPOSE キーボードを押しているかどうかを返します。 RVAL true/false PROTO press?(key) DESC $[key]で指定したキーを押しているかどうかを返します。ここで返す値は 最も最近に呼んだ @[Key.scan] の時点での状態に基きます。 $[key] として((<キーシンボル>))を与えてください。 SEEALSO Key.scan Event::KeyDown Event::KeyUp %% NAME mod_state MOD Key TYPE . PURPOSE モディファイアキーの状態を得ます。 RVAL UINT PROTO mod_state modState DESC モディファイアキー(CTRL、ALTなど)の状態を返します。 以下の値の論理和が帰ります。 :SDL::Key::MOD_NONE 何も押していない :SDL::Key::MOD_LSHIFT 左シフト :SDL::Key::MOD_RSHIFT 右シフト :SDL::Key::MOD_LCTRL 左コントロール :SDL::Key::MOD_RCTRL 右コントロール :SDL::Key::MOD_LALT 左ALT :SDL::Key::MOD_RALT 右ALT :SDL::Key::MOD_LMETA 左メタキー :SDL::Key::MOD_RMETA 右メタキー :SDL::Key::MOD_NUM NumLock :SDL::Key::MOD_CAPS Caps :SDL::Key::MOD_MODE 以下のような定数も定義されています。 * SDL::Key::MOD_CTRL = SDL::Key::MOD_LCTRL|SDL::Key::MOD_RCTRL * SDL::Key::MOD_SHIFT = SDL::Key::MOD_LSHIFT|SDL::Key::MOD_RSHIFT * SDL::Key::MOD_ALT = SDL::Key::MOD_LALT|SDL::Key::MOD_RALT * SDL::Key::MOD_META = SDL::Key::MOD_LMETA|SDL::Key::MOD_RMETA SEEALSO Key.scan %% NAME get_key_name MOD Key TYPE . PURPOSE キーシンボルに対応する名前を得ます。 RVAL String PROTO get_key_name(key) getKeyName(key) DESC $[key] で与えた((<キーシンボル>))に対応する文字列を返します。 %% NAME enable_key_repeat MOD Key TYPE . PURPOSE キーリピートレートを設定します。 PROTO enable_key_repeat(delay,interval) enableKeyRepeat(delay,interval) DESC キーリピートレートを有効にします。 $[delay] は、リピートが開始されるまでの 時間を指定します。 その後に、$[interval]で指定された レートでリピートが始まります。 $[delay] と $[interval] は どちらもミリセカンド単位で指定します。 デフォルト値はそれぞれ SDL::Key::DEFAULT_REPEAT_DELAY と SDL::Key::DEFAULT_REPEAT_INTERVAL という定数で定義されています。 EXCEPTION レートの変更に失敗すると例外 SDL::Error が発生します。 SEEALSO Key.disable_key_repeat %% NAME disable_key_repeat MOD Key TYPE . PURPOSE キーリピートを無効にします。 PROTO disable_key_repeat disableKeyRepeat DESC キーリピートを無効にします。 EXCEPTION * SEEALSO Key.enable_key_repeat %% NAME state MOD Mouse TYPE . PURPOSE 現在のマウスの状態を得ます。 RVAL [Integer, Integer, true/false, true/false, true/false] PROTO state DESC 現在のマウスの状態を以下のような要素5個の配列で得ます。 [ マウスのX座標, マウスのY座標, 左ボタンが押されているか?, 中央ボタンが押されているか?, 右ボタンが押されているか? ] EXAMPLE x, y, lbutton, * = SDL::Mouse.state if lbutton print "マウス左ボタン が押されました。\n" end SEEALSO Event::MouseMotion Event::MouseButtonDown Event::MouseButtonUp %% NAME warp MOD Mouse TYPE . PURPOSE マウスカーソルの位置をセットします。 PROTO warp(x,y) DESC マウスカーソルの位置をセットします。(マウスモーションイベントを発生させます) SEEALSO Event::MouseMotion %% NAME show MOD Mouse TYPE . PURPOSE カーソルが画面に表示されるようにします。 PROTO show DESC カーソルを表示します。 カーソルは最初は表示されていますが、非表示にすることもできます。 SEEALSO Mouse.hide Mouse.show? %% NAME hide MOD Mouse TYPE . PURPOSE カーソルが画面に表示されないようにします。 PROTO hide DESC カーソルを非表示にします。 SEEALSO Mouse.show Mouse.show? %% NAME show? MOD Mouse TYPE . PURPOSE カーソルが画面に表示されているかどうかを返します。 RVAL true/false PROTO show? DESC カーソルが画面に表示されているなら trueを、 いなければ false を返します。 SEEALSO Mouse.show Mouse.hide %% NAME set_cursor MOD Mouse TYPE . PURPOSE 現在アクティブなマウスカーソルを設定します。 PROTO set_cursor(bitmap,white,black,transparent,inverted,hot_x=0,hot_y=0) setCursor(bitmap,white,black,transparent,inverted,hot_x=0,hot_y=0) DESC 現在アクティブなカーソルを指定されたものに設定します。 カーソルが現在見える状態にあるときは、この変更はすぐに表示に反映されます。 カーソルは $[bitmap] で @[Surface] のインスタンスを指定します。 カーソルは白黒2色で作られます。$[white] が白に対応するピクセル値、 $[black] が黒に対応するピクセル値、$[transparent]は透明に対応するピクセル値、 $[inverted] は反転色(なければ黒)に対応するピクセル値です。 またカーソルの横幅は 8 の倍数でなければいけません。 $[hot_x]、$[hot_y] はビットマップのどの点をマウスカーソルの位置とするかを 指定します。 SEEALSO Surface rubysdl-2.1.2/doc/cdrom.rsd0000644000175000017500000001704111740061051014203 0ustar ohaiohai= CD-ROM * (()) * (()) * (()) TOC == CD-ROM機能概説 SDL は一度に 32 までのローカル CD-ROM ドライブの オーディオ制御をサポートします。 トラック一覧の取得・再生・停止そして CD-ROM の取り出しを含む、 CD プレーヤの全ての基本的な機能を実行するためにこの API を使います。 (現在はマルチチェンジャーの CD ドライブはサポートしていません) Ruby/SDL のどの CD-ROM 関連メソッドを呼ぶ前に、 まず @[init](SDL::INIT_CDROM) を呼ばなければいけません。 これは CD-ROM ドライブを探してシステムをスキャンし、 プログラムがオーディオ制御できるようセットアップします。 ライブラリを初期化した後は、 @[CD.num_drives] を使って 利用可能なドライブがいくつあるかを知ることができます。 リストの最初のドライブはデフォルト CD-ROM ドライブです。 ドライブを選択し、@[CD.open] でオープンした後は、 ステータスをチェックし CD がドライブにあるなら再生を開始することができます。 CD-ROM は 1 つまたはそれ以上のトラックで構成され、 個々のトラックはある数の「フレーム」で構成されています。 フレームは CD の基礎データの単位で、 それぞれのフレームはサイズにして 2K であり、 CD は通常の再生スピードにおいて 1 秒間に 75(= SDL::CD::FPS) フレーム再生されます。 SDL は CD 上のフレーム数を使って動作しますが、 @[CD.frames_to_msf] を使うことで、 より見慣れた分/秒のフォーマットに簡単に変換することができます。 またこの変換の逆は @[CD.msf_to_frames] でできます。 == SDL::CD @[CD.open] によってオープンされた CDROM デバイスを表し、 ディスクにおけるトラックのレイアウトの情報を格納します。 == CD-ROM関連メソッド %%% NAME num_drives MOD CD TYPE . PURPOSE システム上の CD-ROM の数を返します。 RVAL Integer PROTO num_drives numDrives DESC システム上の CD-ROM の数を返します。 SEEALSO CD.open %% NAME index_name MOD CD TYPE . PURPOSE CD-ROM について、人間に読めるシステム非依存の ID を返します。 RVAL String PROTO index_name(drive) indexName(drive) DESC CD-ROM について、人間に読めるシステム非依存の ID を文字列で返します。 $[drive] はドライブのインデックス番号です。 インデックス番号は 0 で始まり、@[CD.num_drives]-1 で 終わります。 返り値は例えば以下のような文字列です。 * "/dev/cdrom" * "E:" * "/dev/disk/ide/1/master" SEEALSO CD.num_drives %% NAME open MOD CD TYPE . PURPOSE CD-ROM ドライブにアクセスするためにオープンします。 RVAL SDL::CD PROTO open(drive) DESC CD-ROM ドライブにアクセスするためにオープンします。 成功した場合は @[CD] のインスタンスを返します。 EXCEPTION ドライブが正しくないか、ビジー状態のときは例外 @[Error] を発生させます。 EXAMPLE SDL.init SDL::INIT_CDROM # CD ドライブをチェック if SDL::CD.num_drives == 0 # 見つからなかった STDERR.print "利用可能な CDROM デバイスがありません\n" exit 255 end begin # デフォルトドライブをオープン cdrom = SDL::CD.open(0) rescue SDL::Error # オープンできなかった STDERR.puts "ドライブがオープンできませんでした" exit 255 end # ボリュームの情報を表示 printf "名前: %s\n", SDL::CD.index_name(0) printf "トラック数: %d\n", cdrom.num_tracks num_tracks.times do |cur_track| min, sec, frame = SDL::CD.frames_to_msf(cdrom.track_length(cur_track)) printf "\tトラック %d: 長さ %d:%d\n", cur_track, min, sec end %% NAME status MOD CD TYPE # PURPOSE 指定されたドライブの現在の状態を返します。 RVAL UINT PROTO status DESC この関数は指定されたドライブの現在の状態を返します。 状態は次のいずれかです。 * SDL::CD::TRAYEMPTY * SDL::CD::STOPPED * SDL::CD::PLAYING * SDL::CD::PAUSED * SDL::CD::ERROR ドライブに CD が入っていると、 @[current_track], @[current_frame], @[num_tracks], @[track_type], @[track_lenght]の情報が更新されます。 EXAMPLE def play_track(track) raise "not cd in drive" unless $cdrom.in_drive? # 実際の CD のトラック数で切り捨て track = $cdrom.num_tracks-1 if track >= $cdrom.num_tracks $cdrom.play_tracks(track, 0, 1, 0) end %% NAME play MOD CD TYPE # PURPOSE CD を再生します。 PROTO play(start, length) DESC $[self] で示されるCDを フレーム $[start]から $[length] フレームだけ 再生します。 EXCEPTION * SEEALSO CD#play_tracks %% NAME play_tracks MOD CD TYPE # PURPOSE 指定された CD トラックを再生します。 PROTO play_tracks(start_track, start_frame, ntracks, nframes) DESC $[start_track] 番目のトラックから $[ntracks] トラック分、 指定された CD を再生します。 $[start_frame] は 再生を始める $[start_track] の先頭から数えた フレームのオフセット値です。 $[nframes] は 再生を終了する最後のトラック ($[start_track]+$[ntracks]) の 先頭から数えたフレームのオフセット値です。 このメソッドは、@[CD#status]を 呼んで CD のトラック情報を取得した後にのみ、呼ぶべきです。 NOTES データトラックは無視されます。 EXCEPTION * EXAMPLE # 前もって cdrom がオープンされたデバイスだと仮定 # CD 全体を再生 if cdrom.in_drive? cdrom.play_tracks 0, 0, 0, 0 end # 最初のトラックを再生 if cdrom.in_drive? cdrom.play_tracks 0, 0, 1, 0 end # 2 番目のトラックの最初から 15 秒を再生 if cdrom.in_drive? cdrom.play_tracks 1, 0, 0, SDL::CD::FPS*15 end SEEALSO CD#play CD#status %% NAME pause MOD CD TYPE # PURPOSE CD-ROM の再生を一時停止します。 PROTO pause DESC 指定された CD-ROM の再生を一時停止します。 EXCEPTION * SEEALSO CD#play CD#resume %% NAME resume MOD CD TYPE # PURPOSE CD-ROM の再生を再開します。 PROTO resume DESC 指定した CD-ROM の再生を再開します。 EXCEPTION * SEEALSO CD#play CD#pause %% NAME stop MOD CD TYPE # PURPOSE CD-ROM の再生を停止します。 PROTO stop DESC 指定された CD-ROM の再生を停止します。 EXCEPTION * SEEALSO CD#play %% NAME eject MOD CD TYPE # PURPOSE CD-ROM を取り出します。 PROTO eject DESC 指定された CD-ROM を取り出します。 EXCEPTION * %% NAME num_tracks MOD CD TYPE # PURPOSE CD のトラック数を返します。 RVAL Integer PROTO num_tracks numTracks DESC 指定された CD-ROM のトラック数を返します。 @[CD#status]で内容が更新されます。 SEEALSO CD#status %% NAME current_track MOD CD TYPE # PURPOSE 現在のトラックを返します。 RVAL Integer PROTO current_track currentTrack DESC 指定された CD-ROM の現在のトラックを返します。 @[CD#status]で内容が更新されます。 SEEALSO CD#status %% NAME current_frame MOD CD TYPE # PURPOSE トラック内の現在のフレームオフセット値を返します。 RVAL Integer PROTO current_frame currentFrame DESC 指定された CD-ROM のトラック内の現在演奏しているフレームオフセット値を返します。 @[CD#status]で内容が更新されます。 SEEALSO CD#status %% NAME track_type MOD CD TYPE # PURPOSE トラックの種類を返します。 RVAL UINT PROTO track_type(track) trackType(track) DESC $[track] で指定したトラックの種類を返します。 SDL::CD::AUDIO_TRACK か SDL::CD::DATA_TRACK のいずれかを返します。 %% NAME track_length MOD CD TYPE # PURPOSE トラックの長さを返します。 RVAL Integer PROTO track_length(track) trackLength(track) DESC $[track] で指定したトラックの長さをフレーム単位で返します。 %% NAME in_drive? MOD CD TYPE # PURPOSE ドライブにディスクがあるかどうかを調べます。 RVAL true/false PROTO in_drive? DESC ドライブにディスクがあるなら true を返します。 SEEALSO CD#status %% NAME frames_to_msf MOD CD TYPE . PURPOSE フレーム数を分/秒/フレームに分解します。 RVAL [Integer, Integer, Integer] PROTO frames_to_msf(frames) framesToMSF(frames) DESC フレーム数を分/秒/フレームに変換し、[分, 秒, フレーム] という整数3個の 配列にして返します。 SEEALSO CD.msf_to_frames %% NAME msf_to_frames MOD CD TYPE . PURPOSE 分/秒/フレームという値をフレーム数に変換します。 RVAL Integer PROTO msf_to_frames(min, sec, frames) MSFToFrames(min, sec, frames) DESC 分/秒/フレームという値をフレーム数に変換します。 SEEALSO CD.frames_to_msf %% NAME close MOD CD TYPE # PURPOSE CDデバイスをクローズします。 PROTO close DESC $[self]をクローズします。 SEEALSO CD.open CD#closed? %% NAME closed? MOD CD TYPE # PURPOSE CDデバイスがクローズされたかどうかを返します。 PROTO closed? DESC @[CD#close]によってデバイスがクローズされたかどうかを 返します。 SEEALSO CD#close rubysdl-2.1.2/doc/mixer.rsd0000644000175000017500000004565011740061051014232 0ustar ohaiohai= Audio * ((