Gosu
|
Classes | |
class | Bitmap |
A two-dimensional array area of pixels, each represented by a Color value. More... | |
class | Buffer |
Piece of memory with the Resource interface. More... | |
class | Channel |
Sample::play returns a Channel that represents the sound being played. More... | |
class | Color |
Represents an RGBA color value with 8 bits for each channel. More... | |
class | File |
File with the Resource interface. More... | |
class | Font |
Fonts are ideal for drawing short, dynamic strings. More... | |
struct | GLTexInfo |
Contains information about the underlying OpenGL texture and the u/v space used for image data. More... | |
class | Graphics |
Serves as the target of all drawing and provides primitive drawing functionality. More... | |
class | Image |
Provides functionality for drawing rectangular images. More... | |
class | ImageData |
The ImageData class is an abstract base class for drawable images. More... | |
class | Input |
Manages initialization and shutdown of the input system. More... | |
class | Noncopyable |
class | Reader |
Utility class that points to a specific position in a resource and offers an interface for sequential reading. More... | |
class | Resource |
Base class for resources. More... | |
class | Sample |
A sample is a short sound that is completely loaded in memory, can be played multiple times at once and offers very flexible playback parameters. More... | |
class | Song |
Songs are less flexible than samples. More... | |
class | TextInput |
TextInput instances are invisible objects that build a text string from input, using the current operating system's keyboard layout. More... | |
struct | Touch |
Struct that saves information about a touch on the surface of a multi-touch device. More... | |
class | Window |
Convenient all-in-one class that serves as the foundation of a standard Gosu application. More... | |
class | Writer |
Utility class that points to a specific position in a resource and offers an interface for sequential writing. More... | |
Typedefs | |
typedef double | ZPos |
Represents the Z position of something drawn with Gosu's graphics system. More... | |
typedef std::array< double, 16 > | Transform |
typedef std::vector< Touch > | Touches |
Functions | |
Bitmap | load_image_file (const std::string &filename) |
Loads any supported image into a Bitmap. More... | |
Bitmap | load_image_file (Reader input) |
Loads any supported image into a Bitmap. More... | |
void | save_image_file (const Bitmap &bitmap, const std::string &filename) |
Saves a Bitmap to a file. More... | |
void | save_image_file (const Bitmap &bitmap, Writer writer, const std::string_view &format_hint="png") |
Saves a Bitmap to an arbitrary resource. More... | |
void | apply_color_key (Bitmap &bitmap, Color key) |
Set the alpha value of all pixels which are equal to the color key to zero. More... | |
Bitmap | apply_border_flags (unsigned image_flags, const Bitmap &source, int src_x, int src_y, int src_width, int src_height) |
bool | operator< (Color a, Color b) |
bool | operator== (Color a, Color b) |
bool | operator!= (Color a, Color b) |
Color | interpolate (Color a, Color b, double weight=0.5) |
Interpolates linearly between two colors, with a given weight towards the second color. More... | |
Color | multiply (Color a, Color b) |
Combines two colors as if their channels were mapped to the 0..1 range and then multiplied with each other. More... | |
void | use_resource_directory () |
Changes the current directory to the result of resource_prefix(). More... | |
std::string | resource_prefix () |
Prefix for a program's own resources. More... | |
std::string | shared_resource_prefix () |
Prefix for shared resources of a group of programs. More... | |
std::string | user_settings_prefix () |
Prefix for user settings. More... | |
std::string | user_documents_prefix () |
Prefix for user documents, e.g. More... | |
Transform | translate (double x, double y) |
Transform | rotate (double angle, double around_x=0, double around_y=0) |
Transform | scale (double factor) |
Transform | scale (double scale_x, double scale_y, double from_x=0, double from_y=0) |
Transform | concat (const Transform &lhs, const Transform &rhs) |
std::vector< Gosu::Image > | load_tiles (const Bitmap &bmp, int tile_width, int tile_height, unsigned image_flags=IF_SMOOTH) |
Convenience function that slices an image file into a grid and creates images from them. More... | |
std::vector< Gosu::Image > | load_tiles (const std::string &filename, int tile_width, int tile_height, unsigned image_flags=IF_SMOOTH) |
Convenience function that slices a bitmap into a grid and creates images from them. More... | |
int | fps () |
Returns the current framerate. More... | |
void | load_file (Buffer &buffer, const std::string &filename) |
Loads a whole file into a buffer. More... | |
void | save_file (const Buffer &buffer, const std::string &filename) |
Creates or overwrites a file with the contents of a buffer. More... | |
double | random (double min, double max) |
Returns a real value between min (inclusive) and max (exclusive). More... | |
double | gosu_to_radians (double angle) |
Translates between Gosu's angle system (where 0 is at the top) and radians (where 0 is at the right). More... | |
double | radians_to_gosu (double angle) |
Translates between Gosu's angle system (where 0 is at the top) and radians (where 0 is at the right). More... | |
double | degrees_to_radians (double angle) |
Translates between degrees (used by Gosu) and radians, i.e. More... | |
double | radians_to_degrees (double angle) |
Translates between degrees (used by Gosu) and radians, i.e. More... | |
double | offset_x (double angle, double radius) |
Returns the horizontal distance between the origin and the point to which you would get if you moved radius pixels in the direction specified by angle. More... | |
double | offset_y (double angle, double radius) |
Returns the vertical distance between the origin and the point to which you would get if you moved radius pixels in the direction specified by angle. More... | |
double | angle (double from_x, double from_y, double to_x, double to_y, double def=0) |
Returns the angle from point 1 to point 2 in degrees, where 0.0 means upwards. More... | |
double | angle_diff (double angle1, double angle2) |
Returns the smallest angle that can be added to angle1 to get to angle2 (can be negative if counter-clockwise movement is shorter). More... | |
double | normalize_angle (double angle) |
Normalizes an angle to fit into the range [0; 360[. More... | |
template<typename T > | |
T | square (T value) |
Returns value * value. More... | |
template<typename T > | |
T | clamp (T value, T min, T max) |
Returns min if value is smaller than min, max if value is larger than max and value otherwise. More... | |
int | wrap (int value, int min, int max) |
Returns (value-min) % (max-min) + min, where % always has a positive result for max > min. More... | |
float | wrap (float value, float min, float max) |
Returns (value-min) % (max-min) + min, where % always has a positive result for max > min. More... | |
double | wrap (double value, double min, double max) |
Returns (value-min) % (max-min) + min, where % always has a positive result for max > min. More... | |
double | distance_sqr (double x1, double y1, double x2, double y2) |
Returns the square of the distance between two points. More... | |
double | distance (double x1, double y1, double x2, double y2) |
Returns the distance between two points. More... | |
template<typename T > | |
T | interpolate (T a, T b, double weight=0.5) |
Interpolates a value between a and b, weight being the bias towards the second value. More... | |
template<typename T > | |
T | little_to_native (T t) |
template<typename T > | |
T | native_to_little (T t) |
template<typename T > | |
T | big_to_native (T t) |
template<typename T > | |
T | native_to_big (T t) |
std::string | default_font_name () |
Returns the name of a neutral font that is available on the current platform. More... | |
double | text_width (const std::u32string &text, const std::string &font_name, double font_height, unsigned font_flags=0) |
Returns the width an unformatted line of text would span on a bitmap if it were drawn using draw_text with the same arguments. More... | |
double | draw_text (Bitmap &bitmap, double x, double y, Color c, const std::u32string &text, const std::string &font_name, double font_height, unsigned font_flags=0) |
Draws a line of unformatted text on a bitmap. More... | |
Bitmap | layout_text (const std::string &text, const std::string &font_name, double font_height, double line_spacing=0, int width=-1, Alignment align=AL_LEFT, unsigned font_flags=0) |
Creates a bitmap that is filled with the formatted text given to the function. More... | |
Bitmap | layout_markup (const std::string &markup, const std::string &font_name, double font_height, double line_spacing=0, int width=-1, Alignment align=AL_LEFT, unsigned font_flags=0) |
Creates a bitmap that is filled with the formatted text given to the function. More... | |
void | sleep (unsigned milliseconds) |
Freezes the current thread for at least the specified time. More... | |
unsigned long | milliseconds () |
Returns the milliseconds since first calling this function. More... | |
std::u32string | utf8_to_composed_utc4 (const std::string &utf8) |
bool | has_extension (std::string_view filename, std::string_view extension) |
Returns true if the filename has the given extension. More... | |
std::string | language () |
Returns the user's preferred language, at the moment of calling the function. More... | |
unsigned | screen_width (Window *window=nullptr) |
Returns the width (in pixels) of a screen. More... | |
unsigned | screen_height (Window *window=nullptr) |
Returns the height (in pixels) of the user's primary screen. More... | |
unsigned | available_width (Window *window=nullptr) |
Returns the maximum width (in 'points') that is available for a non-fullscreen Window. More... | |
unsigned | available_height (Window *window=nullptr) |
Returns the maximum height (in 'points') that is available for a non-fullscreen Window. More... | |
Variables | |
const unsigned | MAX_TEXTURE_SIZE = 1024 |
Returns the maximum size of an texture that will be allocated internally by Gosu. More... | |
const ByteOrder | BO_NATIVE = BO_LITTLE |
const ByteOrder | BO_OTHER = BO_BIG |
const std::string | VERSION |
A string that contains the full version of the Gosu library, like "0.7.50" or "1.0.0.pre5". More... | |
const std::string | LICENSES |
A block of legal copy that your game is obliged to display somewhere. More... | |
typedef std::vector<Touch> Gosu::Touches |
typedef std::array<double, 16> Gosu::Transform |
Definition at line 67 of file GraphicsBase.hpp.
typedef double Gosu::ZPos |
Represents the Z position of something drawn with Gosu's graphics system.
Draw calls with higher ZPos values will cover those with a lower ZPos value.
Definition at line 14 of file GraphicsBase.hpp.
enum Gosu::Alignment |
Enumerator | |
---|---|
AL_LEFT | |
AL_RIGHT | |
AL_CENTER | |
AL_JUSTIFY |
Definition at line 40 of file GraphicsBase.hpp.
enum Gosu::AlphaMode |
Determines the way colors are combined when one is drawn onto another.
Definition at line 18 of file GraphicsBase.hpp.
enum Gosu::Axis |
List of axis IDs that can be used with Gosu::Input.
Definition at line 268 of file Buttons.hpp.
enum Gosu::Button |
List of button IDs that can be used with Gosu::Input.
This enumeration contains IDs for keyboard keys (KB_*), mouse buttons and mouse wheel (MS_*), as well as gamepad buttons (GP_*).
Definition at line 8 of file Buttons.hpp.
enum Gosu::ByteOrder |
enum Gosu::FileMode |
enum Gosu::FontFlags |
Enumerator | |
---|---|
FF_BOLD | |
FF_ITALIC | |
FF_UNDERLINE | |
FF_COMBINATIONS |
Definition at line 32 of file GraphicsBase.hpp.
enum Gosu::ImageFlags |
Flags that affect the tileability or interpolation of an image.
Enumerator | |
---|---|
IF_SMOOTH | |
IF_TILEABLE_LEFT | |
IF_TILEABLE_TOP | |
IF_TILEABLE_RIGHT | |
IF_TILEABLE_BOTTOM | |
IF_TILEABLE | |
IF_RETRO | Apply nearest-neighbor interpolation when scaling this image up or down. |
Definition at line 49 of file GraphicsBase.hpp.
double Gosu::angle | ( | double | from_x, |
double | from_y, | ||
double | to_x, | ||
double | to_y, | ||
double | def = 0 |
||
) |
Returns the angle from point 1 to point 2 in degrees, where 0.0 means upwards.
Returns def if both points are equal.
Referenced by radians_to_degrees().
double Gosu::angle_diff | ( | double | angle1, |
double | angle2 | ||
) |
Returns the smallest angle that can be added to angle1 to get to angle2 (can be negative if counter-clockwise movement is shorter).
Referenced by radians_to_degrees().
Bitmap Gosu::apply_border_flags | ( | unsigned | image_flags, |
const Bitmap & | source, | ||
int | src_x, | ||
int | src_y, | ||
int | src_width, | ||
int | src_height | ||
) |
Referenced by Gosu::Bitmap::data().
Set the alpha value of all pixels which are equal to the color key to zero.
To reduce interpolation artefacts when stretching or rotating the resulting image, the color value of these pixels will also be adjusted to the average of their surrounding pixels.
Referenced by Gosu::Bitmap::data().
unsigned Gosu::available_height | ( | Window * | window = nullptr | ) |
Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
All windows larger than this size will automatically be shrunk to fit.
window | The result describes the screen on which the window is shown, or the primary screen if no window is given. |
Referenced by Gosu::Window::touch_cancelled().
unsigned Gosu::available_width | ( | Window * | window = nullptr | ) |
Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
All windows larger than this size will automatically be shrunk to fit.
window | The result describes the screen on which the window is shown, or the primary screen if no window is given. |
Referenced by Gosu::Window::touch_cancelled().
T Gosu::big_to_native | ( | T | t | ) |
Definition at line 28 of file Platform.hpp.
T Gosu::clamp | ( | T | value, |
T | min, | ||
T | max | ||
) |
std::string Gosu::default_font_name | ( | ) |
Returns the name of a neutral font that is available on the current platform.
double Gosu::degrees_to_radians | ( | double | angle | ) |
double Gosu::distance | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2 | ||
) |
Returns the distance between two points.
Referenced by distance_sqr().
double Gosu::distance_sqr | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2 | ||
) |
Returns the square of the distance between two points.
Definition at line 95 of file Math.hpp.
References distance(), and square().
double Gosu::draw_text | ( | Bitmap & | bitmap, |
double | x, | ||
double | y, | ||
Color | c, | ||
const std::u32string & | text, | ||
const std::string & | font_name, | ||
double | font_height, | ||
unsigned | font_flags = 0 |
||
) |
Draws a line of unformatted text on a bitmap.
This is a low-level function that does not understand any of Gosu's HTML-like markup.
text | A UCS-4 string, normalization: NFC. |
font_name | Name of a system font, or filename of a TTF file (must contain '/' or '.'). |
font_height | Height, in pixels, of the text. |
font_flags | Binary combination of members of the FontFlags enum. |
int Gosu::fps | ( | ) |
Returns the current framerate.
double Gosu::gosu_to_radians | ( | double | angle | ) |
bool Gosu::has_extension | ( | std::string_view | filename, |
std::string_view | extension | ||
) |
Returns true if the filename has the given extension.
The comparison is case-insensitive, but you must pass the extension in lower case.
T Gosu::interpolate | ( | T | a, |
T | b, | ||
double | weight = 0.5 |
||
) |
Interpolates linearly between two colors, with a given weight towards the second color.
Specialization of the general function in Gosu/Math.hpp.
Referenced by operator!=().
std::string Gosu::language | ( | ) |
Returns the user's preferred language, at the moment of calling the function.
Expect return values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans'. The first two letters will always be a language code.
Bitmap Gosu::layout_markup | ( | const std::string & | markup, |
const std::string & | font_name, | ||
double | font_height, | ||
double | line_spacing = 0 , |
||
int | width = -1 , |
||
Alignment | align = AL_LEFT , |
||
unsigned | font_flags = 0 |
||
) |
Creates a bitmap that is filled with the formatted text given to the function.
The line can contain line breaks and HTML-like markup.
text | Formatted text. |
font_name | Name of a system font, or filename of a TTF file (must contain '/' or '.'). |
font_height | Height of the font in pixels. |
line_spacing | Spacing between two lines of text in pixels. Can be negative to make text stick together more closely. |
width | Width of the bitmap that will be returned. Text will be split into multiple lines to avoid drawing over the right border. When a single word is too long, it will be truncated. A width smaller than 0 indicates that lines should not be wrapped, and the resulting bitmap will be as wide as the widest line. |
font_flags | Binary combination of members of the FontFlags enum. |
Bitmap Gosu::layout_text | ( | const std::string & | text, |
const std::string & | font_name, | ||
double | font_height, | ||
double | line_spacing = 0 , |
||
int | width = -1 , |
||
Alignment | align = AL_LEFT , |
||
unsigned | font_flags = 0 |
||
) |
Creates a bitmap that is filled with the formatted text given to the function.
The line can contain line breaks and HTML-like markup.
text | Formatted text. |
font_name | Name of a system font, or filename of a TTF file (must contain '/' or '.'). |
font_height | Height of the font in pixels. |
line_spacing | Spacing between two lines of text in pixels. Can be negative to make text stick together more closely. |
width | Width of the bitmap that will be returned. Text will be split into multiple lines to avoid drawing over the right border. When a single word is too long, it will be truncated. A width smaller than 0 indicates that lines should not be wrapped, and the resulting bitmap will be as wide as the widest line. |
font_flags | Binary combination of members of the FontFlags enum. |
T Gosu::little_to_native | ( | T | t | ) |
Definition at line 24 of file Platform.hpp.
void Gosu::load_file | ( | Buffer & | buffer, |
const std::string & | filename | ||
) |
Loads a whole file into a buffer.
Bitmap Gosu::load_image_file | ( | const std::string & | filename | ) |
Loads any supported image into a Bitmap.
Referenced by Gosu::Bitmap::data().
std::vector<Gosu::Image> Gosu::load_tiles | ( | const Bitmap & | bmp, |
int | tile_width, | ||
int | tile_height, | ||
unsigned | image_flags = IF_SMOOTH |
||
) |
Convenience function that slices an image file into a grid and creates images from them.
tile_width | If positive, specifies the width of one tile in pixels. If negative, the bitmap is divided into -tile_width rows. |
tile_height | See tile_width. |
std::vector<Gosu::Image> Gosu::load_tiles | ( | const std::string & | filename, |
int | tile_width, | ||
int | tile_height, | ||
unsigned | image_flags = IF_SMOOTH |
||
) |
Convenience function that slices a bitmap into a grid and creates images from them.
tile_width | If positive, specifies the width of one tile in pixels. If negative, the bitmap is divided into -tile_width rows. |
tile_height | See tile_width. |
unsigned long Gosu::milliseconds | ( | ) |
Returns the milliseconds since first calling this function.
Can wrap after running for a long time.
Combines two colors as if their channels were mapped to the 0..1 range and then multiplied with each other.
Referenced by operator!=().
T Gosu::native_to_big | ( | T | t | ) |
Definition at line 35 of file Platform.hpp.
T Gosu::native_to_little | ( | T | t | ) |
Definition at line 25 of file Platform.hpp.
double Gosu::normalize_angle | ( | double | angle | ) |
Normalizes an angle to fit into the range [0; 360[.
Referenced by radians_to_degrees().
double Gosu::offset_x | ( | double | angle, |
double | radius | ||
) |
Returns the horizontal distance between the origin and the point to which you would get if you moved radius pixels in the direction specified by angle.
angle | Angle in degrees where 0.0 means upwards. |
Referenced by radians_to_degrees().
double Gosu::offset_y | ( | double | angle, |
double | radius | ||
) |
Returns the vertical distance between the origin and the point to which you would get if you moved radius pixels in the direction specified by angle.
angle | Angle in degrees where 0.0 means upwards. |
Referenced by radians_to_degrees().
Definition at line 150 of file Color.hpp.
References Gosu::Color::gl(), interpolate(), and multiply().
Definition at line 148 of file Color.hpp.
References Gosu::Color::gl().
Definition at line 149 of file Color.hpp.
References Gosu::Color::gl().
double Gosu::radians_to_degrees | ( | double | angle | ) |
Translates between degrees (used by Gosu) and radians, i.e.
it does not change the 'origin' of the angle system.
Definition at line 40 of file Math.hpp.
References angle(), angle_diff(), M_PI, normalize_angle(), offset_x(), and offset_y().
double Gosu::radians_to_gosu | ( | double | angle | ) |
double Gosu::random | ( | double | min, |
double | max | ||
) |
Returns a real value between min (inclusive) and max (exclusive).
Uses std::rand, so you should call std::srand before using it.
std::string Gosu::resource_prefix | ( | ) |
Prefix for a program's own resources.
On Windows, the parent directory of the executable. On macOS, the 'Resources' directory inside the .app bundle. On Linux, the current directory (empty string).
Transform Gosu::rotate | ( | double | angle, |
double | around_x = 0 , |
||
double | around_y = 0 |
||
) |
void Gosu::save_file | ( | const Buffer & | buffer, |
const std::string & | filename | ||
) |
Creates or overwrites a file with the contents of a buffer.
void Gosu::save_image_file | ( | const Bitmap & | bitmap, |
const std::string & | filename | ||
) |
Saves a Bitmap to a file.
Referenced by Gosu::Bitmap::data().
void Gosu::save_image_file | ( | const Bitmap & | bitmap, |
Writer | writer, | ||
const std::string_view & | format_hint = "png" |
||
) |
Saves a Bitmap to an arbitrary resource.
Transform Gosu::scale | ( | double | factor | ) |
Transform Gosu::scale | ( | double | scale_x, |
double | scale_y, | ||
double | from_x = 0 , |
||
double | from_y = 0 |
||
) |
unsigned Gosu::screen_height | ( | Window * | window = nullptr | ) |
Returns the height (in pixels) of the user's primary screen.
window | The result describes the screen on which the window is shown, or the primary screen if no window is given. |
Referenced by Gosu::Window::touch_cancelled().
unsigned Gosu::screen_width | ( | Window * | window = nullptr | ) |
Returns the width (in pixels) of a screen.
window | The result describes the screen on which the window is shown, or the primary screen if no window is given. |
Referenced by Gosu::Window::touch_cancelled().
std::string Gosu::shared_resource_prefix | ( | ) |
Prefix for shared resources of a group of programs.
On Windows, the parent directory of the executable. On macOS, the parent directory of the .app bundle. On Linux, the current directory (empty string).
void Gosu::sleep | ( | unsigned | milliseconds | ) |
Freezes the current thread for at least the specified time.
T Gosu::square | ( | T | value | ) |
double Gosu::text_width | ( | const std::u32string & | text, |
const std::string & | font_name, | ||
double | font_height, | ||
unsigned | font_flags = 0 |
||
) |
Returns the width an unformatted line of text would span on a bitmap if it were drawn using draw_text with the same arguments.
text | A UCS-4 string, normalization: NFC. |
font_name | Name of a system font, or filename of a TTF file (must contain '/' or '.'). |
Transform Gosu::translate | ( | double | x, |
double | y | ||
) |
void Gosu::use_resource_directory | ( | ) |
Changes the current directory to the result of resource_prefix().
std::string Gosu::user_documents_prefix | ( | ) |
Prefix for user documents, e.g.
saved games. On Windows, the My Documents folder. On macOS, the user's Documents folder. On Linux, the home directory.
std::string Gosu::user_settings_prefix | ( | ) |
Prefix for user settings.
On Windows, the same as APPDATA%. On macOS, the user's Library/Preferences folder. On Linux, the home directory plus a trailing dot for hidden files.
std::u32string Gosu::utf8_to_composed_utc4 | ( | const std::string & | utf8 | ) |
int Gosu::wrap | ( | int | value, |
int | min, | ||
int | max | ||
) |
Returns (value-min) % (max-min) + min, where % always has a positive result for max > min.
The results are undefined for max <= min. Note: This means that max is exclusive.
Referenced by clamp().
float Gosu::wrap | ( | float | value, |
float | min, | ||
float | max | ||
) |
Returns (value-min) % (max-min) + min, where % always has a positive result for max > min.
The results are undefined for max <= min. Note: This means that max is exclusive.
double Gosu::wrap | ( | double | value, |
double | min, | ||
double | max | ||
) |
Returns (value-min) % (max-min) + min, where % always has a positive result for max > min.
The results are undefined for max <= min. Note: This means that max is exclusive.
const std::string Gosu::LICENSES |
A block of legal copy that your game is obliged to display somewhere.
const unsigned Gosu::MAX_TEXTURE_SIZE = 1024 |
Returns the maximum size of an texture that will be allocated internally by Gosu.
Useful when extending Gosu using OpenGL.
Definition at line 19 of file Graphics.hpp.
const std::string Gosu::VERSION |
A string that contains the full version of the Gosu library, like "0.7.50" or "1.0.0.pre5".