gosu 0.9.2-x64-mingw32 → 0.10.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,204 +0,0 @@
1
- //! \file Color.hpp
2
- //! Interface of the Color class.
3
-
4
- #ifndef GOSU_COLOR_HPP
5
- #define GOSU_COLOR_HPP
6
-
7
- #include <Gosu/Platform.hpp>
8
- #include <Gosu/TR1.hpp>
9
-
10
- namespace Gosu
11
- {
12
- //! Represents an RGBA color value with 8 bits for each channel. Can be
13
- //! implicitly constructed from literals of the form 0xaarrggbb. Has fast
14
- //! value semantics.
15
- //! The four-byte layout in memory is RGBA. On Big-Endian machines the
16
- //! unsigned int interpretation is 0xrrggbbaa, on Little-Endian machines
17
- //! it is 0xaabbggrr.
18
- class Color
19
- {
20
- std::tr1::uint32_t rep;
21
- #ifdef GOSU_IS_LITTLE_ENDIAN
22
- enum { RED_OFFSET = 0, GREEN_OFFSET = 8, BLUE_OFFSET = 16, ALPHA_OFFSET = 24 };
23
- #else
24
- enum { RED_OFFSET = 24, GREEN_OFFSET = 16, BLUE_OFFSET = 8, ALPHA_OFFSET = 0 };
25
- #endif
26
-
27
- public:
28
- typedef std::tr1::uint8_t Channel;
29
- static const unsigned GL_FORMAT = 0x1908; // GL_RGBA
30
-
31
- //! The default constructor does not initialize the color to any value.
32
- Color()
33
- {
34
- }
35
-
36
- //! Conversion constructor for literals of the form 0xaarrggbb.
37
- Color(unsigned argb)
38
- {
39
- *this = Color((argb >> 24) & 0xff, (argb >> 16) & 0xff,
40
- (argb >> 8) & 0xff, (argb >> 0) & 0xff);
41
- }
42
-
43
- Color(Channel red, Channel green, Channel blue)
44
- {
45
- *this = Color(0xff, red, green, blue);
46
- }
47
-
48
- Color(Channel alpha, Channel red, Channel green, Channel blue)
49
- {
50
- rep = (alpha << ALPHA_OFFSET) | (red << RED_OFFSET) |
51
- (green << GREEN_OFFSET) | (blue << BLUE_OFFSET);
52
- }
53
-
54
- //! Constructs a color from the given hue/saturation/value triple.
55
- //! Ranges of these values are given as 0..360, 0..1 and 0..1,
56
- //! respectively.
57
- //! The alpha value is set to 1 from this method.
58
- static Color fromHSV(double h, double s, double v);
59
- static Color fromAHSV(Channel alpha, double h, double s, double v);
60
-
61
- Channel red() const
62
- {
63
- return static_cast<Channel>(rep >> RED_OFFSET);
64
- }
65
-
66
- Channel green() const
67
- {
68
- return static_cast<Channel>(rep >> GREEN_OFFSET);
69
- }
70
-
71
- Channel blue() const
72
- {
73
- return static_cast<Channel>(rep >> BLUE_OFFSET);
74
- }
75
-
76
- Channel alpha() const
77
- {
78
- return static_cast<Channel>(rep >> ALPHA_OFFSET);
79
- }
80
-
81
- void setRed(Channel value)
82
- {
83
- rep &= ~(0xff << RED_OFFSET);
84
- rep |= value << RED_OFFSET;
85
- }
86
-
87
- void setGreen(Channel value)
88
- {
89
- rep &= ~(0xff << GREEN_OFFSET);
90
- rep |= value << GREEN_OFFSET;
91
- }
92
-
93
- void setBlue(Channel value)
94
- {
95
- rep &= ~(0xff << BLUE_OFFSET);
96
- rep |= value << BLUE_OFFSET;
97
- }
98
-
99
- void setAlpha(Channel value)
100
- {
101
- rep &= ~(0xff << ALPHA_OFFSET);
102
- rep |= value << ALPHA_OFFSET;
103
- }
104
-
105
- //! Returns the hue of the color, in the usual range of 0..360.
106
- double hue() const;
107
-
108
- //! Changes the current color so hue() will return h.
109
- void setHue(double h);
110
-
111
- //! Returns the saturation of the color, in the range of 0..1.
112
- double saturation() const;
113
-
114
- //! Changes the current color so saturation() will return s.
115
- void setSaturation(double s);
116
-
117
- //! Returns the value (brightness) of the color, in the range of 0..1.
118
- double value() const;
119
-
120
- //! Changes the current color so value() will return v.
121
- void setValue(double v);
122
-
123
- //! Returns the color in 0xaarrggbb representation.
124
- std::tr1::uint32_t argb() const
125
- {
126
- return alpha() << 24 | red() << 16 | green() << 8 | blue();
127
- }
128
-
129
- //! Returns the color in 0x00bbggrr representation. Useful for Win32 programming.
130
- std::tr1::uint32_t bgr() const
131
- {
132
- return blue() << 16 | green() << 8 | red();
133
- }
134
-
135
- //! Returns the color in 0xaabbggrr representation.
136
- std::tr1::uint32_t abgr() const
137
- {
138
- return alpha() << 24 | blue() << 16 | green() << 8 | red();
139
- }
140
-
141
- //! Returns the internal representation of the color (RGBA in memory).
142
- std::tr1::uint32_t gl() const
143
- {
144
- return rep;
145
- }
146
-
147
- static const Color NONE;
148
- static const Color BLACK;
149
- static const Color GRAY;
150
- static const Color WHITE;
151
-
152
- static const Color AQUA;
153
- static const Color RED;
154
- static const Color GREEN;
155
- static const Color BLUE;
156
- static const Color YELLOW;
157
- static const Color FUCHSIA;
158
- static const Color CYAN;
159
- };
160
-
161
- #ifndef SWIG
162
- inline bool operator<(Color a, Color b)
163
- {
164
- return a.gl() < b.gl();
165
- }
166
-
167
- inline bool operator==(Color a, Color b)
168
- {
169
- return a.gl() == b.gl();
170
- }
171
-
172
- inline bool operator!=(Color a, Color b)
173
- {
174
- return a.gl() != b.gl();
175
- }
176
-
177
- //! Interpolates linearly between two colors, with a given weight towards
178
- //! the second color.
179
- //! Specialization of the general function in Gosu/Math.hpp.
180
- Color interpolate(Color a, Color b, double weight = 0.5);
181
-
182
- //! Combines two colors as if their channels were mapped to the 0..1 range
183
- //! and then multiplied with each other.
184
- Color multiply(Color a, Color b);
185
-
186
- namespace Colors
187
- {
188
- GOSU_DEPRECATED const Color none (0x00000000);
189
- GOSU_DEPRECATED const Color black (0xff000000);
190
- GOSU_DEPRECATED const Color gray (0xff808080);
191
- GOSU_DEPRECATED const Color white (0xffffffff);
192
-
193
- GOSU_DEPRECATED const Color aqua (0xff00ffff);
194
- GOSU_DEPRECATED const Color red (0xffff0000);
195
- GOSU_DEPRECATED const Color green (0xff00ff00);
196
- GOSU_DEPRECATED const Color blue (0xff0000ff);
197
- GOSU_DEPRECATED const Color yellow (0xffffff00);
198
- GOSU_DEPRECATED const Color fuchsia (0xffff00ff);
199
- GOSU_DEPRECATED const Color cyan (0xff00ffff);
200
- }
201
- #endif
202
- }
203
-
204
- #endif
@@ -1,36 +0,0 @@
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
@@ -1,87 +0,0 @@
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 <Gosu/Platform.hpp>
11
- #include <Gosu/Text.hpp>
12
- #include <Gosu/TR1.hpp>
13
- #include <string>
14
-
15
- namespace Gosu
16
- {
17
- //! A font can be used to draw text on a Graphics object very flexibly.
18
- //! Fonts are ideal for small texts that change regularly. For large,
19
- //! static texts you should use createBitmap and turn the result into
20
- //! an image.
21
- class Font
22
- {
23
- struct Impl;
24
- std::tr1::shared_ptr<Impl> pimpl;
25
-
26
- public:
27
- //! Constructs a font that can be drawn onto the graphics object.
28
- //! \param fontName Name of a system font, or a filename to a TTF
29
- //! file (must contain '/', does not work on Linux).
30
- //! \param fontHeight Height of the font, in pixels.
31
- //! \param fontFlags Flags used to render individual characters of
32
- //! the font.
33
- Font(unsigned fontHeight, const std::wstring& fontName = defaultFontName(),
34
- unsigned fontFlags = ffBold);
35
-
36
- //! Returns the name of the font that was used to create it.
37
- std::wstring name() const;
38
-
39
- //! Returns the height of the font, in pixels.
40
- unsigned height() const;
41
-
42
- //! Returns the flags used to create the font characters.
43
- unsigned flags() const;
44
-
45
- //! Returns the width, in pixels, the given text would occupy if drawn.
46
- double textWidth(const std::wstring& text, double factorX = 1) const;
47
-
48
- //! Draws text so the top left corner of the text is at (x; y).
49
- //! \param text Formatted text without line-breaks.
50
- void draw(const std::wstring& text, double x, double y, ZPos z,
51
- double factorX = 1, double factorY = 1,
52
- Color c = Color::WHITE, AlphaMode mode = amDefault) const;
53
-
54
- //! Draws text at a position relative to (x; y).
55
- //! \param relX Determines where the text is drawn horizontally. If
56
- //! relX is 0.0, the text will be to the right of x, if it is 1.0,
57
- //! the text will be to the left of x, if it is 0.5, it will be
58
- //! centered on x. Of course, all real numbers are possible values.
59
- //! \param relY See relX.
60
- void drawRel(const std::wstring& text, double x, double y, ZPos z,
61
- double relX, double relY, double factorX = 1, double factorY = 1,
62
- Color c = Color::WHITE, AlphaMode mode = amDefault) const;
63
-
64
- //! Maps a letter to a specific image instead of generating one using
65
- //! Gosu's built-in text rendering. This can only be called once per
66
- //! character, and the character must not have been drawn before.
67
- //! This ensures that Fonts are still sort of immutable.
68
- void setImage(wchar_t wc, unsigned fontFlags, const Gosu::Image& image);
69
- //! A shortcut for mapping a character to an image regardless of fontFlags.
70
- //! Later versions might apply faux italics or faux bold to it (to be decided!).
71
- void setImage(wchar_t wc, const Gosu::Image& image);
72
-
73
- #ifndef SWIG
74
- GOSU_DEPRECATED Font(Graphics& graphics, const std::wstring& fontName,
75
- unsigned fontHeight, unsigned fontFlags = ffBold);
76
-
77
- GOSU_DEPRECATED
78
- #endif
79
- //! DEPRECATED: Analogous to draw, but rotates the text by a given angle.
80
- //! Use Graphics::pushTransform to achieve the same effect.
81
- void drawRot(const std::wstring& text, double x, double y, ZPos z, double angle,
82
- double factorX = 1, double factorY = 1,
83
- Color c = Color::WHITE, AlphaMode mode = amDefault) const;
84
- };
85
- }
86
-
87
- #endif
@@ -1,31 +0,0 @@
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 Button;
14
- class Color;
15
- class File;
16
- class Font;
17
- class Graphics;
18
- class Image;
19
- class ImageData;
20
- class Input;
21
- class Reader;
22
- class Resource;
23
- class Sample;
24
- class Song;
25
- class TextInput;
26
- class Timer;
27
- class Window;
28
- class Writer;
29
- }
30
-
31
- #endif
@@ -1,34 +0,0 @@
1
- //! \file Gosu.hpp
2
- //! Umbrella header for lazy people with fast compilers, or pre-compiled headers.
3
-
4
- //! \mainpage Gosu C++ Documentation
5
- //!
6
- //! These pages serve as a reference on the C++ interface of Gosu. For a higher-level
7
- //! discussion of concepts and ideas behind the library, see the Wiki entries linked
8
- //! from the official website, http://www.libgosu.org/.
9
-
10
- #ifndef GOSU_GOSU_HPP
11
- #define GOSU_GOSU_HPP
12
-
13
- #include <Gosu/Audio.hpp>
14
- #include <Gosu/Bitmap.hpp>
15
- #include <Gosu/Color.hpp>
16
- #include <Gosu/Directories.hpp>
17
- #include <Gosu/Font.hpp>
18
- #include <Gosu/Graphics.hpp>
19
- #include <Gosu/Image.hpp>
20
- #include <Gosu/ImageData.hpp>
21
- #include <Gosu/Input.hpp>
22
- #include <Gosu/Inspection.hpp>
23
- #include <Gosu/IO.hpp>
24
- #include <Gosu/Math.hpp>
25
- #include <Gosu/Platform.hpp>
26
- #include <Gosu/Sockets.hpp>
27
- #include <Gosu/Text.hpp>
28
- #include <Gosu/TextInput.hpp>
29
- #include <Gosu/Timing.hpp>
30
- #include <Gosu/Utility.hpp>
31
- #include <Gosu/Version.hpp>
32
- #include <Gosu/Window.hpp>
33
-
34
- #endif
@@ -1,125 +0,0 @@
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 <Gosu/TR1.hpp>
11
- #include <memory>
12
-
13
- namespace Gosu
14
- {
15
- struct DrawOp;
16
-
17
- //! Returns the maximum size of an texture that will be allocated
18
- //! internally by Gosu.
19
- //! Useful when extending Gosu using OpenGL.
20
- unsigned const MAX_TEXTURE_SIZE = 1024;
21
-
22
- //! Serves as the target of all drawing and provides primitive drawing
23
- //! functionality.
24
- //! Usually created internally by Gosu::Window.
25
- //
26
- // TODO: This class should be separated into a Gosu::Viewport class, which
27
- // carries the width/height/fullscreen attributes, and global Gosu::drawFoo
28
- // functions. A Window then has a Viewport, and in theory, multiple windows
29
- // could have their own viewports etc.
30
- class Graphics
31
- {
32
- struct Impl;
33
-
34
- const GOSU_UNIQUE_PTR<Impl> pimpl;
35
-
36
- #if defined(GOSU_CPP11_ENABLED)
37
- // explicitly forbid copying and moving
38
- Graphics(Graphics&&) = delete;
39
- Graphics& operator=(Graphics&&) = delete;
40
- Graphics(const Graphics&) = delete;
41
- Graphics& operator=(const Graphics&) = delete;
42
- #endif
43
-
44
- public:
45
- Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
46
- ~Graphics();
47
-
48
- void setResolution(unsigned virtualWidth, unsigned virtualHeight,
49
- double horizontalBlackBarWidth = 0, double verticalBlackBarHeight = 0);
50
-
51
- unsigned width() const;
52
- unsigned height() const;
53
- bool fullscreen() const;
54
-
55
- //! Prepares the graphics object for drawing. Nothing must be drawn
56
- //! without calling begin.
57
- bool begin(Color clearWithColor = Color::BLACK);
58
- //! Every call to begin must have a matching call to end.
59
- void end();
60
-
61
- //! Flushes the Z queue to the screen and starts a new one.
62
- //! Useful for games that are *very* composite in nature (splitscreen).
63
- static void flush();
64
-
65
- //! Finishes all pending Gosu drawing operations and executes
66
- //! the following OpenGL code in a clean environment.
67
- static void beginGL();
68
- //! Resets Gosu into its default rendering state.
69
- static void endGL();
70
- //! Schedules a custom GL functor to be executed at a certain Z level.
71
- //! The functor is called in a clean GL context (as given by beginGL/endGL).
72
- //! Gosu's rendering up to the Z level may not yet have been glFlush()ed.
73
- //! Note: You may not call any Gosu rendering functions from within the
74
- //! functor, and you must schedule it from within Window::draw's call tree.
75
- static void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
76
-
77
- //! Enables clipping to a specified rectangle.
78
- static void beginClipping(double x, double y, double width, double height);
79
- //! Disables clipping.
80
- static void endClipping();
81
-
82
- //! Starts recording a macro. Cannot be nested.
83
- static void beginRecording();
84
- //! Finishes building the macro and returns it as a drawable object.
85
- //! The width and height affect nothing about the recording process,
86
- //! the resulting macro will simply return these values when you ask
87
- //! it.
88
- //! Most usually, the return value is passed to Image::Image().
89
- static GOSU_UNIQUE_PTR<Gosu::ImageData> endRecording(int width, int height);
90
-
91
- //! Pushes one transformation onto the transformation stack.
92
- static void pushTransform(const Transform& transform);
93
- //! Pops one transformation from the transformation stack.
94
- static void popTransform();
95
-
96
- //! Draws a line from one point to another (last pixel exclusive).
97
- //! Note: OpenGL lines are not reliable at all and may have a missing pixel at the start
98
- //! or end point. Please only use this for debugging purposes. Otherwise, use a quad or
99
- //! image to simulate lines, or contribute a better drawLine to Gosu.
100
- static void drawLine(double x1, double y1, Color c1,
101
- double x2, double y2, Color c2,
102
- ZPos z, AlphaMode mode = amDefault);
103
-
104
- static void drawTriangle(double x1, double y1, Color c1,
105
- double x2, double y2, Color c2,
106
- double x3, double y3, Color c3,
107
- ZPos z, AlphaMode mode = amDefault);
108
-
109
- static void drawQuad(double x1, double y1, Color c1,
110
- double x2, double y2, Color c2,
111
- double x3, double y3, Color c3,
112
- double x4, double y4, Color c4,
113
- ZPos z, AlphaMode mode = amDefault);
114
-
115
- //! For internal use only.
116
- static void scheduleDrawOp(const DrawOp& op);
117
-
118
- //! Turns a portion of a bitmap into something that can be drawn on a Graphics object.
119
- static GOSU_UNIQUE_PTR<ImageData> createImage(const Bitmap& src,
120
- unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
121
- unsigned imageFlags);
122
- };
123
- }
124
-
125
- #endif