gosu 0.7.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. data/COPYING.txt +29 -0
  2. data/Gosu/Async.hpp +48 -0
  3. data/Gosu/Audio.hpp +145 -0
  4. data/Gosu/AutoLink.hpp +16 -0
  5. data/Gosu/Bitmap.hpp +85 -0
  6. data/Gosu/ButtonsMac.hpp +114 -0
  7. data/Gosu/ButtonsWin.hpp +111 -0
  8. data/Gosu/ButtonsX.hpp +115 -0
  9. data/Gosu/Color.hpp +172 -0
  10. data/Gosu/Directories.hpp +36 -0
  11. data/Gosu/Font.hpp +59 -0
  12. data/Gosu/Fwd.hpp +31 -0
  13. data/Gosu/Gosu.hpp +26 -0
  14. data/Gosu/Graphics.hpp +86 -0
  15. data/Gosu/GraphicsBase.hpp +45 -0
  16. data/Gosu/IO.hpp +255 -0
  17. data/Gosu/Image.hpp +148 -0
  18. data/Gosu/ImageData.hpp +45 -0
  19. data/Gosu/Input.hpp +116 -0
  20. data/Gosu/Math.hpp +95 -0
  21. data/Gosu/Platform.hpp +61 -0
  22. data/Gosu/RotFlip.hpp +116 -0
  23. data/Gosu/Sockets.hpp +129 -0
  24. data/Gosu/Text.hpp +47 -0
  25. data/Gosu/TextInput.hpp +57 -0
  26. data/Gosu/Timing.hpp +16 -0
  27. data/Gosu/Utility.hpp +24 -0
  28. data/Gosu/WinUtility.hpp +76 -0
  29. data/Gosu/Window.hpp +84 -0
  30. data/GosuImpl/Async.cpp +37 -0
  31. data/GosuImpl/AudioFmod.cpp +417 -0
  32. data/GosuImpl/AudioSDL.cpp +255 -0
  33. data/GosuImpl/DirectoriesMac.mm +38 -0
  34. data/GosuImpl/DirectoriesUnix.cpp +48 -0
  35. data/GosuImpl/DirectoriesWin.cpp +42 -0
  36. data/GosuImpl/FileUnix.cpp +100 -0
  37. data/GosuImpl/FileWin.cpp +83 -0
  38. data/GosuImpl/Graphics/Bitmap.cpp +116 -0
  39. data/GosuImpl/Graphics/BitmapBMP.cpp +232 -0
  40. data/GosuImpl/Graphics/BitmapColorKey.cpp +39 -0
  41. data/GosuImpl/Graphics/BitmapPNG.cpp +276 -0
  42. data/GosuImpl/Graphics/BitmapUtils.cpp +67 -0
  43. data/GosuImpl/Graphics/BlockAllocator.cpp +127 -0
  44. data/GosuImpl/Graphics/BlockAllocator.hpp +34 -0
  45. data/GosuImpl/Graphics/Color.cpp +126 -0
  46. data/GosuImpl/Graphics/Common.hpp +21 -0
  47. data/GosuImpl/Graphics/DrawOp.hpp +154 -0
  48. data/GosuImpl/Graphics/Font.cpp +110 -0
  49. data/GosuImpl/Graphics/Graphics.cpp +295 -0
  50. data/GosuImpl/Graphics/Image.cpp +159 -0
  51. data/GosuImpl/Graphics/LargeImageData.cpp +115 -0
  52. data/GosuImpl/Graphics/LargeImageData.hpp +37 -0
  53. data/GosuImpl/Graphics/RotFlip.cpp +184 -0
  54. data/GosuImpl/Graphics/TexChunk.cpp +77 -0
  55. data/GosuImpl/Graphics/TexChunk.hpp +40 -0
  56. data/GosuImpl/Graphics/Text.cpp +223 -0
  57. data/GosuImpl/Graphics/TextMac.cpp +242 -0
  58. data/GosuImpl/Graphics/TextPangoFT.cpp +186 -0
  59. data/GosuImpl/Graphics/TextWin.cpp +172 -0
  60. data/GosuImpl/Graphics/Texture.cpp +104 -0
  61. data/GosuImpl/Graphics/Texture.hpp +34 -0
  62. data/GosuImpl/IO.cpp +48 -0
  63. data/GosuImpl/InputMac.mm +677 -0
  64. data/GosuImpl/InputWin.cpp +444 -0
  65. data/GosuImpl/InputX.cpp +158 -0
  66. data/GosuImpl/MacUtility.hpp +48 -0
  67. data/GosuImpl/Math.cpp +49 -0
  68. data/GosuImpl/RubyGosu.swg +474 -0
  69. data/GosuImpl/RubyGosuStub.mm +17 -0
  70. data/GosuImpl/RubyGosu_DllMain.cxx +30 -0
  71. data/GosuImpl/RubyGosu_wrap.cxx +8521 -0
  72. data/GosuImpl/RubyGosu_wrap.h +31 -0
  73. data/GosuImpl/Sockets/CommSocket.cpp +304 -0
  74. data/GosuImpl/Sockets/ListenerSocket.cpp +60 -0
  75. data/GosuImpl/Sockets/MessageSocket.cpp +136 -0
  76. data/GosuImpl/Sockets/Socket.cpp +145 -0
  77. data/GosuImpl/Sockets/Sockets.hpp +66 -0
  78. data/GosuImpl/TextInputMac.mm +207 -0
  79. data/GosuImpl/TextInputWin.cpp +197 -0
  80. data/GosuImpl/TextInputX.cpp +201 -0
  81. data/GosuImpl/TextTTFWin.cpp +247 -0
  82. data/GosuImpl/TimingUnix.cpp +17 -0
  83. data/GosuImpl/TimingWin.cpp +28 -0
  84. data/GosuImpl/Utility.cpp +140 -0
  85. data/GosuImpl/WinMain.cpp +69 -0
  86. data/GosuImpl/WinUtility.cpp +137 -0
  87. data/GosuImpl/WindowMac.mm +466 -0
  88. data/GosuImpl/WindowWin.cpp +447 -0
  89. data/GosuImpl/WindowX.cpp +392 -0
  90. data/GosuImpl/X11vroot.h +118 -0
  91. data/README.txt +13 -0
  92. data/Rakefile +178 -0
  93. data/examples/ChipmunkIntegration.rb +275 -0
  94. data/examples/CptnRuby.rb +231 -0
  95. data/examples/MoreChipmunkAndRMagick.rb +155 -0
  96. data/examples/OpenGLIntegration.rb +232 -0
  97. data/examples/RMagickIntegration.rb +449 -0
  98. data/examples/TextInput.cpp +170 -0
  99. data/examples/TextInput.rb +139 -0
  100. data/examples/Tutorial.cpp +215 -0
  101. data/examples/Tutorial.rb +137 -0
  102. data/examples/media/Beep.wav +0 -0
  103. data/examples/media/CptnRuby Gem.png +0 -0
  104. data/examples/media/CptnRuby Map.txt +25 -0
  105. data/examples/media/CptnRuby Tileset.png +0 -0
  106. data/examples/media/CptnRuby.png +0 -0
  107. data/examples/media/Cursor.png +0 -0
  108. data/examples/media/Earth.png +0 -0
  109. data/examples/media/Explosion.wav +0 -0
  110. data/examples/media/LargeStar.png +0 -0
  111. data/examples/media/Sky.jpg +0 -0
  112. data/examples/media/Smoke.png +0 -0
  113. data/examples/media/Soldier.png +0 -0
  114. data/examples/media/Space.png +0 -0
  115. data/examples/media/Star.png +0 -0
  116. data/examples/media/Starfighter.bmp +0 -0
  117. data/linux/Makefile.in +98 -0
  118. data/linux/configure +5658 -0
  119. data/linux/configure.ac +126 -0
  120. data/linux/extconf.rb +11 -0
  121. data/mac/English.lproj/InfoPlist.strings +0 -0
  122. data/mac/Gosu-Info.plist +26 -0
  123. data/mac/Gosu.xcodeproj/project.pbxproj +1194 -0
  124. data/mac/RubyGosu Template-Info.plist +26 -0
  125. data/mac/libboost_thread_1_34_1_universal.a +0 -0
  126. data/mac/libboost_thread_d_1_34_1_universal.a +0 -0
  127. data/mac/libfmod_universal.a +0 -0
  128. data/mac/libpng_universal.a +0 -0
  129. data/mac/libz_universal.a +0 -0
  130. data/reference/Async_8hpp-source.html +70 -0
  131. data/reference/Audio_8hpp-source.html +114 -0
  132. data/reference/Audio_8hpp.html +50 -0
  133. data/reference/AutoLink_8hpp-source.html +38 -0
  134. data/reference/AutoLink_8hpp.html +34 -0
  135. data/reference/Bitmap_8hpp-source.html +85 -0
  136. data/reference/Bitmap_8hpp.html +58 -0
  137. data/reference/ButtonsMac_8hpp-source.html +133 -0
  138. data/reference/ButtonsWin_8hpp-source.html +133 -0
  139. data/reference/ButtonsX_8hpp-source.html +134 -0
  140. data/reference/Color_8hpp-source.html +169 -0
  141. data/reference/Color_8hpp.html +85 -0
  142. data/reference/Directories_8hpp-source.html +42 -0
  143. data/reference/Directories_8hpp.html +46 -0
  144. data/reference/Font_8hpp-source.html +65 -0
  145. data/reference/Font_8hpp.html +41 -0
  146. data/reference/Fwd_8hpp-source.html +52 -0
  147. data/reference/Fwd_8hpp.html +37 -0
  148. data/reference/Gosu_8hpp-source.html +48 -0
  149. data/reference/Gosu_8hpp.html +34 -0
  150. data/reference/GraphicsBase_8hpp-source.html +57 -0
  151. data/reference/GraphicsBase_8hpp.html +56 -0
  152. data/reference/Graphics_8hpp-source.html +96 -0
  153. data/reference/Graphics_8hpp.html +53 -0
  154. data/reference/IO_8hpp-source.html +255 -0
  155. data/reference/IO_8hpp.html +74 -0
  156. data/reference/ImageData_8hpp-source.html +62 -0
  157. data/reference/ImageData_8hpp.html +43 -0
  158. data/reference/Image_8hpp-source.html +126 -0
  159. data/reference/Image_8hpp.html +48 -0
  160. data/reference/Input_8hpp-source.html +118 -0
  161. data/reference/Input_8hpp.html +50 -0
  162. data/reference/Math_8hpp-source.html +92 -0
  163. data/reference/Math_8hpp.html +74 -0
  164. data/reference/Platform_8hpp-source.html +83 -0
  165. data/reference/Platform_8hpp.html +73 -0
  166. data/reference/RotFlip_8hpp-source.html +138 -0
  167. data/reference/RotFlip_8hpp.html +77 -0
  168. data/reference/Sockets_8hpp-source.html +130 -0
  169. data/reference/Sockets_8hpp.html +66 -0
  170. data/reference/TextInput_8hpp-source.html +64 -0
  171. data/reference/TextInput_8hpp.html +41 -0
  172. data/reference/Text_8hpp-source.html +51 -0
  173. data/reference/Text_8hpp.html +46 -0
  174. data/reference/Timing_8hpp-source.html +36 -0
  175. data/reference/Timing_8hpp.html +42 -0
  176. data/reference/Utility_8hpp-source.html +44 -0
  177. data/reference/Utility_8hpp.html +48 -0
  178. data/reference/WinUtility_8hpp-source.html +79 -0
  179. data/reference/WinUtility_8hpp.html +64 -0
  180. data/reference/Window_8hpp-source.html +91 -0
  181. data/reference/Window_8hpp.html +41 -0
  182. data/reference/annotated.html +51 -0
  183. data/reference/classGosu_1_1Audio-members.html +34 -0
  184. data/reference/classGosu_1_1Audio.html +46 -0
  185. data/reference/classGosu_1_1Bitmap-members.html +44 -0
  186. data/reference/classGosu_1_1Bitmap.html +263 -0
  187. data/reference/classGosu_1_1Buffer-members.html +44 -0
  188. data/reference/classGosu_1_1Buffer.html +78 -0
  189. data/reference/classGosu_1_1Buffer.png +0 -0
  190. data/reference/classGosu_1_1Button-members.html +36 -0
  191. data/reference/classGosu_1_1Button.html +143 -0
  192. data/reference/classGosu_1_1Color-members.html +56 -0
  193. data/reference/classGosu_1_1Color.html +387 -0
  194. data/reference/classGosu_1_1File-members.html +41 -0
  195. data/reference/classGosu_1_1File.html +69 -0
  196. data/reference/classGosu_1_1File.png +0 -0
  197. data/reference/classGosu_1_1Font-members.html +39 -0
  198. data/reference/classGosu_1_1Font.html +309 -0
  199. data/reference/classGosu_1_1Graphics-members.html +50 -0
  200. data/reference/classGosu_1_1Graphics.html +234 -0
  201. data/reference/classGosu_1_1Image-members.html +45 -0
  202. data/reference/classGosu_1_1Image.html +518 -0
  203. data/reference/classGosu_1_1ImageData-members.html +37 -0
  204. data/reference/classGosu_1_1ImageData.html +60 -0
  205. data/reference/classGosu_1_1Input-members.html +44 -0
  206. data/reference/classGosu_1_1Input.html +223 -0
  207. data/reference/classGosu_1_1MessageSocket-members.html +40 -0
  208. data/reference/classGosu_1_1MessageSocket.html +233 -0
  209. data/reference/classGosu_1_1Resource-members.html +39 -0
  210. data/reference/classGosu_1_1Resource.html +116 -0
  211. data/reference/classGosu_1_1Resource.png +0 -0
  212. data/reference/classGosu_1_1Sample-members.html +37 -0
  213. data/reference/classGosu_1_1Sample.html +200 -0
  214. data/reference/classGosu_1_1SampleInstance-members.html +38 -0
  215. data/reference/classGosu_1_1SampleInstance.html +169 -0
  216. data/reference/classGosu_1_1Song-members.html +43 -0
  217. data/reference/classGosu_1_1Song.html +260 -0
  218. data/reference/classGosu_1_1TextInput-members.html +38 -0
  219. data/reference/classGosu_1_1TextInput.html +121 -0
  220. data/reference/classGosu_1_1Window-members.html +50 -0
  221. data/reference/classGosu_1_1Window.html +271 -0
  222. data/reference/doxyfile +233 -0
  223. data/reference/doxygen.css +433 -0
  224. data/reference/doxygen.png +0 -0
  225. data/reference/files.html +54 -0
  226. data/reference/functions.html +236 -0
  227. data/reference/functions_enum.html +45 -0
  228. data/reference/functions_func.html +227 -0
  229. data/reference/functions_vars.html +47 -0
  230. data/reference/hierarchy.html +53 -0
  231. data/reference/index.html +26 -0
  232. data/reference/namespaceGosu.html +2890 -0
  233. data/reference/namespaceGosu_1_1Colors.html +70 -0
  234. data/reference/namespaceGosu_1_1Win.html +275 -0
  235. data/reference/namespacemembers.html +216 -0
  236. data/reference/namespacemembers_enum.html +52 -0
  237. data/reference/namespacemembers_eval.html +54 -0
  238. data/reference/namespacemembers_func.html +185 -0
  239. data/reference/namespacemembers_type.html +46 -0
  240. data/reference/namespacemembers_vars.html +46 -0
  241. data/reference/namespaces.html +35 -0
  242. data/reference/tab_b.gif +0 -0
  243. data/reference/tab_l.gif +0 -0
  244. data/reference/tab_r.gif +0 -0
  245. data/reference/tabs.css +102 -0
  246. data/windows/Gosu.sln +29 -0
  247. data/windows/Gosu.vcproj +553 -0
  248. data/windows/RubyGosu.vcproj +138 -0
  249. metadata +305 -0
@@ -0,0 +1,115 @@
1
+ #ifndef GOSU_BUTTONSX_HPP
2
+ #define GOSU_BUTTONSX_HPP
3
+
4
+ namespace Gosu
5
+ {
6
+ //! Enumerates all the named button ids that can be used with Gosu::Input.
7
+ //! This enumeration contains ids for non-character keyboard keys (kb*),
8
+ //! mouse buttons and mouse wheel (ms*) and gamepad buttons (gp*).
9
+ enum ButtonName
10
+ {
11
+ kbRangeBegin = 0x01,
12
+ kbEscape = XK_Escape,
13
+ kbF1 = XK_F1,
14
+ kbF2 = XK_F2,
15
+ kbF3 = XK_F3,
16
+ kbF4 = XK_F4,
17
+ kbF5 = XK_F5,
18
+ kbF6 = XK_F6,
19
+ kbF7 = XK_F7,
20
+ kbF8 = XK_F8,
21
+ kbF9 = XK_F9,
22
+ kbF10 = XK_F10,
23
+ kbF11 = XK_F11,
24
+ kbF12 = XK_F12,
25
+ kb1 = XK_1,
26
+ kb2 = XK_2,
27
+ kb3 = XK_3,
28
+ kb4 = XK_4,
29
+ kb5 = XK_5,
30
+ kb6 = XK_6,
31
+ kb7 = XK_7,
32
+ kb8 = XK_8,
33
+ kb9 = XK_9,
34
+ kb0 = XK_0,
35
+ kbTab = XK_Tab,
36
+ kbReturn = XK_Return,
37
+ kbSpace = XK_space,
38
+ kbLeftShift = XK_Shift_L,
39
+ kbRightShift = XK_Shift_R,
40
+ kbLeftControl = XK_Control_L,
41
+ kbRightControl = XK_Control_R,
42
+ kbLeftAlt = XK_Alt_L,
43
+ kbRightAlt = XK_Alt_R,
44
+ kbLeftMeta = 0, // TODO?!
45
+ kbRightMeta = 0,
46
+ kbBackspace = XK_BackSpace,
47
+ kbLeft = XK_Left,
48
+ kbRight = XK_Right,
49
+ kbUp = XK_Up,
50
+ kbDown = XK_Down,
51
+ kbHome = XK_Home,
52
+ kbEnd = XK_End,
53
+ kbInsert = XK_Insert,
54
+ kbDelete = XK_Delete,
55
+ kbPageUp = XK_Prior,
56
+ kbPageDown = XK_Next,
57
+ kbEnter = XK_KP_Enter,
58
+ kbNumpad1 = XK_KP_1,
59
+ kbNumpad2 = XK_KP_2,
60
+ kbNumpad3 = XK_KP_3,
61
+ kbNumpad4 = XK_KP_4,
62
+ kbNumpad5 = XK_KP_5,
63
+ kbNumpad6 = XK_KP_6,
64
+ kbNumpad7 = XK_KP_7,
65
+ kbNumpad8 = XK_KP_8,
66
+ kbNumpad9 = XK_KP_9,
67
+ kbNumpad0 = XK_KP_0,
68
+ kbNumpadAdd = XK_KP_Add,
69
+ kbNumpadSubtract = XK_KP_Subtract,
70
+ kbNumpadMultiply = XK_KP_Multiply,
71
+ kbNumpadDivide = XK_KP_Divide,
72
+ kbRangeEnd = 0xffff,
73
+
74
+ msRangeBegin,
75
+ msLeft = msRangeBegin,
76
+ msRight,
77
+ msMiddle,
78
+ msWheelUp,
79
+ msWheelDown,
80
+ msRangeEnd,
81
+
82
+ gpRangeBegin,
83
+ gpLeft = gpRangeBegin,
84
+ gpRight,
85
+ gpUp,
86
+ gpDown,
87
+ gpButton0,
88
+ gpButton1,
89
+ gpButton2,
90
+ gpButton3,
91
+ gpButton4,
92
+ gpButton5,
93
+ gpButton6,
94
+ gpButton7,
95
+ gpButton8,
96
+ gpButton9,
97
+ gpButton10,
98
+ gpButton11,
99
+ gpButton12,
100
+ gpButton13,
101
+ gpButton14,
102
+ gpButton15,
103
+ gpRangeEnd = gpButton15,
104
+
105
+ kbNum = kbRangeEnd - kbRangeBegin + 1,
106
+ msNum = msRangeEnd - msRangeBegin + 1,
107
+ gpNum = gpRangeEnd - gpRangeBegin + 1,
108
+
109
+ numButtons = gpRangeEnd,
110
+ noButton = 0xffffffff
111
+ };
112
+ }
113
+
114
+ #endif
115
+
@@ -0,0 +1,172 @@
1
+ //! \file Color.hpp
2
+ //! Interface of the Color class.
3
+
4
+ #ifndef GOSU_COLOR_HPP
5
+ #define GOSU_COLOR_HPP
6
+
7
+ #include <boost/cstdint.hpp>
8
+
9
+ namespace Gosu
10
+ {
11
+ //! Represents an ARGB color value with 8 bits for each channel. Can be
12
+ //! implicitly constructed from literals of the form 0xaarrggbb. Has fast
13
+ //! value semantics.
14
+ class Color
15
+ {
16
+ boost::uint32_t rep;
17
+
18
+ public:
19
+ typedef boost::uint8_t Channel;
20
+
21
+ //! The default constructor does not initialize the color to any value.
22
+ Color()
23
+ {
24
+ }
25
+
26
+ //! Conversion constructor for literals of the form 0xaarrggbb.
27
+ //! (C++ only.)
28
+ Color(boost::uint32_t argb)
29
+ : rep(argb)
30
+ {
31
+ }
32
+
33
+ Color(Channel red, Channel green, Channel blue)
34
+ {
35
+ rep = (0xff << 24) | (red << 16) | (green << 8) | blue;
36
+ }
37
+
38
+ Color(Channel alpha, Channel red, Channel green, Channel blue)
39
+ {
40
+ rep = (alpha << 24) | (red << 16) | (green << 8) | blue;
41
+ }
42
+
43
+ //! Constructs a color from the given hue/saturation/value triple.
44
+ //! Ranges of these values are given as 0..360, 0..1 and 0..1,
45
+ //! respectively.
46
+ //! The alpha value is set to 1 from this method.
47
+ static Color fromHSV(double h, double s, double v);
48
+ static Color fromAHSV(Channel alpha, double h, double s, double v);
49
+
50
+ Channel alpha() const
51
+ {
52
+ return static_cast<Channel>((rep >> 24) & 0xff);
53
+ }
54
+
55
+ Channel red() const
56
+ {
57
+ return static_cast<Channel>((rep >> 16) & 0xff);
58
+ }
59
+
60
+ Channel green() const
61
+ {
62
+ return static_cast<Channel>((rep >> 8) & 0xff);
63
+ }
64
+
65
+ Channel blue() const
66
+ {
67
+ return static_cast<Channel>(rep & 0xff);
68
+ }
69
+
70
+ void setAlpha(Channel value)
71
+ {
72
+ rep &= 0x00ffffff;
73
+ rep |= value << 24;
74
+ }
75
+
76
+ void setRed(Channel value)
77
+ {
78
+ rep &= 0xff00ffff;
79
+ rep |= value << 16;
80
+ }
81
+
82
+ void setGreen(Channel value)
83
+ {
84
+ rep &= 0xffff00ff;
85
+ rep |= value << 8;
86
+ }
87
+
88
+ void setBlue(Channel value)
89
+ {
90
+ rep &= 0xffffff00;
91
+ rep |= value;
92
+ }
93
+
94
+ //! Returns the hue of the color, in the usual range of 0..360.
95
+ double hue() const;
96
+
97
+ //! Changes the current color so hue() will return h.
98
+ void setHue(double h);
99
+
100
+ //! Returns the saturation of the color, in the range of 0..1.
101
+ double saturation() const;
102
+
103
+ //! Changes the current color so saturation() will return s.
104
+ void setSaturation(double s);
105
+
106
+ //! Returns the value (brightness) of the color, in the range of 0..1.
107
+ double value() const;
108
+
109
+ //! Changes the current color so value() will return v.
110
+ void setValue(double v);
111
+
112
+ //! Returns the color in 0xaarrggbb representation.
113
+ boost::uint32_t argb() const
114
+ {
115
+ return rep;
116
+ }
117
+
118
+ //! Returns the color in 0x00bbggrr representation.
119
+ boost::uint32_t bgr() const
120
+ {
121
+ return red() | (rep & 0x0000ff00) | blue() << 16;
122
+ }
123
+
124
+ //! Returns the color in 0xaabbggrr representation.
125
+ boost::uint32_t abgr() const
126
+ {
127
+ return alpha() << 24 | bgr();
128
+ }
129
+ };
130
+
131
+ // Causes weird errors when included in the SWIG wrapping process.
132
+ // If, with a future version of SWIG, this can be included and
133
+ // require 'gosu'; include Gosu
134
+ // works from within Ruby, the #ifndef guard can be removed.
135
+ #ifndef SWIG
136
+ inline bool operator==(Color a, Color b)
137
+ {
138
+ return a.argb() == b.argb();
139
+ }
140
+
141
+ inline bool operator!=(Color a, Color b)
142
+ {
143
+ return a.argb() != b.argb();
144
+ }
145
+ #endif
146
+
147
+ //! Interpolates linearly between two colors, with a given weight towards
148
+ //! the second color.
149
+ //! Specialization of the general function in Gosu/Math.hpp.
150
+ Color interpolate(Color a, Color b, double weight = 0.5);
151
+
152
+ //! Combines two colors as if their channels were mapped to the 0..1 range
153
+ //! and then multiplied with each other.
154
+ Color multiply(Color a, Color b);
155
+
156
+ //! Namespace which contains some predefined colors.
157
+ namespace Colors
158
+ {
159
+ const Color none = 0x00000000;
160
+ const Color black = 0xff000000;
161
+ const Color gray = 0xff808080;
162
+ const Color white = 0xffffffff;
163
+ const Color red = 0xffff0000;
164
+ const Color green = 0xff00ff00;
165
+ const Color blue = 0xff0000ff;
166
+ const Color yellow = 0xffffff00;
167
+ const Color fuchsia = 0xffff00ff;
168
+ const Color cyan = 0xff00ffff;
169
+ }
170
+ }
171
+
172
+ #endif
@@ -0,0 +1,36 @@
1
+ //! \file Directories.hpp
2
+ //! Access to a small set of system paths.
3
+
4
+ #ifndef GOSU_DIRECTORIES_HPP
5
+ #define GOSU_DIRECTORIES_HPP
6
+
7
+ #include <string>
8
+
9
+ namespace Gosu
10
+ {
11
+ //! Prefix for a program's own resources.
12
+ //! On Windows, the executable's containing directory.
13
+ //! On OS X, the application's Resources subdirectory.
14
+ //! On Linux, the current directory.
15
+ std::wstring resourcePrefix();
16
+
17
+ //! Prefix for resources of a group of programs.
18
+ //! On Windows, the executable's containing directory.
19
+ //! On OS X, the application's containing subdirectory.
20
+ //! On Linux, the current directory.
21
+ std::wstring sharedResourcePrefix();
22
+
23
+ //! Prefix for user settings.
24
+ //! On Windows, the same as %APPDATA%.
25
+ //! On OS X, the user's Library/Preferences folder.
26
+ //! On Linux, the home directory plus a trailing dot for hidden files.
27
+ std::wstring userSettingsPrefix();
28
+
29
+ //! Prefix for user documents, e.g. save games.
30
+ //! On Windows, the My Documents folder.
31
+ //! On OS X, the user's Documents folder.
32
+ //! On Linux, the home directory.
33
+ std::wstring userDocsPrefix();
34
+ }
35
+
36
+ #endif
@@ -0,0 +1,59 @@
1
+ //! \file Font.hpp
2
+ //! Interface of the Font class.
3
+
4
+ #ifndef GOSU_FONT_HPP
5
+ #define GOSU_FONT_HPP
6
+
7
+ #include <Gosu/Fwd.hpp>
8
+ #include <Gosu/Color.hpp>
9
+ #include <Gosu/GraphicsBase.hpp>
10
+ #include <boost/scoped_ptr.hpp>
11
+ #include <string>
12
+
13
+ namespace Gosu
14
+ {
15
+ //! A font can be used to draw text on a Graphics object very flexibly.
16
+ //! Fonts are ideal for small texts that change regularly. For large,
17
+ //! static texts you should use createBitmap and turn the result into
18
+ //! an image.
19
+ class Font
20
+ {
21
+ struct Impl;
22
+ boost::scoped_ptr<Impl> pimpl;
23
+
24
+ public:
25
+ //! Constructs a font that can be drawn onto the graphics object.
26
+ //! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
27
+ //! \param height Height of the font, in pixels.
28
+ Font(Graphics& graphics, const std::wstring& fontName,
29
+ unsigned height);
30
+ ~Font();
31
+
32
+ //! Returns the height of the font, in pixels.
33
+ unsigned height() const;
34
+
35
+ //! Returns the width the given text would occupy if drawn.
36
+ double textWidth(const std::wstring& text, double factorX = 1) const;
37
+
38
+ //! Draws text so the top left corner of the text is at (x; y).
39
+ void draw(const std::wstring& text, double x, double y, ZPos z,
40
+ double factorX = 1, double factorY = 1,
41
+ Color c = Colors::white, AlphaMode mode = amDefault) const;
42
+
43
+ //! Draws text at a position relative to (x; y).
44
+ //! \param relX Determines where the text is drawn horizontally. If
45
+ //! relX is 0.0, the text will be to the right of x, if it is 1.0,
46
+ //! the text will be to the left of x, if it is 0.5, it will be
47
+ //! centered on x. Of course, all real numbers are possible values.
48
+ //! \param relY See relX.
49
+ void drawRel(const std::wstring& text, double x, double y, ZPos z,
50
+ double relX, double relY, double factorX = 1, double factorY = 1,
51
+ Color c = Colors::white, AlphaMode mode = amDefault) const;
52
+
53
+ void drawRot(const std::wstring& text, double x, double y, ZPos z, double angle,
54
+ double factorX = 1, double factorY = 1,
55
+ Color c = Colors::white, AlphaMode mode = amDefault) const;
56
+ };
57
+ }
58
+
59
+ #endif
@@ -0,0 +1,31 @@
1
+ //! \file Fwd.hpp
2
+ //! Contains declarations of all of Gosu's available classes.
3
+
4
+ #ifndef GOSU_FWD_HPP
5
+ #define GOSU_FWD_HPP
6
+
7
+ //! The library's main namespace.
8
+ namespace Gosu
9
+ {
10
+ class Audio;
11
+ class Bitmap;
12
+ class Buffer;
13
+ class Color;
14
+ class File;
15
+ class Font;
16
+ class Graphics;
17
+ class Image;
18
+ class ImageData;
19
+ class Input;
20
+ class Reader;
21
+ class Resource;
22
+ class RotFlip;
23
+ class Sample;
24
+ class Song;
25
+ class TextInput;
26
+ class Timer;
27
+ class Window;
28
+ class Writer;
29
+ }
30
+
31
+ #endif
@@ -0,0 +1,26 @@
1
+ //! \file Gosu.hpp
2
+ //! Umbrella header for lazy people with fast compilers, or pre-compiled headers.
3
+
4
+ #ifndef GOSU_GOSU_HPP
5
+ #define GOSU_GOSU_HPP
6
+
7
+ #include <Gosu/Audio.hpp>
8
+ #include <Gosu/Bitmap.hpp>
9
+ #include <Gosu/Color.hpp>
10
+ #include <Gosu/Directories.hpp>
11
+ #include <Gosu/Font.hpp>
12
+ #include <Gosu/Graphics.hpp>
13
+ #include <Gosu/Image.hpp>
14
+ #include <Gosu/ImageData.hpp>
15
+ #include <Gosu/Input.hpp>
16
+ #include <Gosu/IO.hpp>
17
+ #include <Gosu/Math.hpp>
18
+ #include <Gosu/Platform.hpp>
19
+ #include <Gosu/RotFlip.hpp>
20
+ #include <Gosu/Sockets.hpp>
21
+ #include <Gosu/Text.hpp>
22
+ #include <Gosu/TextInput.hpp>
23
+ #include <Gosu/Timing.hpp>
24
+ #include <Gosu/Window.hpp>
25
+
26
+ #endif
@@ -0,0 +1,86 @@
1
+ //! \file Graphics.hpp
2
+ //! Interface of the Graphics class.
3
+
4
+ #ifndef GOSU_GRAPHICS_HPP
5
+ #define GOSU_GRAPHICS_HPP
6
+
7
+ #include <Gosu/Fwd.hpp>
8
+ #include <Gosu/Color.hpp>
9
+ #include <Gosu/GraphicsBase.hpp>
10
+ #include <boost/scoped_ptr.hpp>
11
+ #include <memory>
12
+
13
+ namespace Gosu
14
+ {
15
+ //! Flags that affect the softness of a border.
16
+ enum BorderFlags
17
+ {
18
+ bfSoft = 0,
19
+ bfHardLeft = 1,
20
+ bfHardTop = 2,
21
+ bfHardRight = 4,
22
+ bfHardBottom = 8,
23
+ bfHard = bfHardLeft | bfHardTop | bfHardRight | bfHardBottom
24
+ };
25
+
26
+ //! Serves as the target of all drawing and provides basic drawing
27
+ //! functionality.
28
+ //! Usually created by Gosu::Window.
29
+ class Graphics
30
+ {
31
+ struct Impl;
32
+ boost::scoped_ptr<Impl> pimpl;
33
+
34
+ public:
35
+ Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
36
+ ~Graphics();
37
+
38
+ // Undocumented until I have thought about this...
39
+ double factorX() const;
40
+ double factorY() const;
41
+ void setResolution(unsigned virtualWidth, unsigned virtualHeight);
42
+ // End of Undocumented
43
+
44
+ unsigned width() const;
45
+ unsigned height() const;
46
+ bool fullscreen() const;
47
+
48
+ //! Prepares the graphics object for drawing. Nothing must be drawn
49
+ //! without calling begin.
50
+ bool begin(Color clearWithColor = Colors::black);
51
+ //! Every call to begin must have a matching call to end.
52
+ void end();
53
+ //! Finishes all pending Gosu drawing operations and executes
54
+ //! the following OpenGL code in a clean environment.
55
+ void beginGL();
56
+ //! Resets Gosu into its default rendering state.
57
+ void endGL();
58
+ // Enables clipping to a specified rectangle.
59
+ void beginClipping(int x, int y, unsigned width, unsigned height);
60
+ // Disables clipping.
61
+ void endClipping();
62
+
63
+ void drawLine(double x1, double y1, Color c1,
64
+ double x2, double y2, Color c2,
65
+ ZPos z, AlphaMode mode = amDefault);
66
+
67
+ void drawTriangle(double x1, double y1, Color c1,
68
+ double x2, double y2, Color c2,
69
+ double x3, double y3, Color c3,
70
+ ZPos z, AlphaMode mode = amDefault);
71
+
72
+ void drawQuad(double x1, double y1, Color c1,
73
+ double x2, double y2, Color c2,
74
+ double x3, double y3, Color c3,
75
+ double x4, double y4, Color c4,
76
+ ZPos z, AlphaMode mode = amDefault);
77
+
78
+ //! Turns a portion of a bitmap into something that can be drawn on
79
+ //! this graphics object.
80
+ std::auto_ptr<ImageData> createImage(const Bitmap& src,
81
+ unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
82
+ unsigned borderFlags);
83
+ };
84
+ }
85
+
86
+ #endif