Gosu
Classes | Typedefs | Enumerations | Functions | Variables
Gosu Namespace Reference

The library's main namespace. More...

Classes

class  Bitmap
 Rectangular area of pixels, each represented by a Color value. More...
 
class  Buffer
 Piece of memory with the Resource interface. More...
 
class  Button
 Very lightweight class that identifies a button (keyboard, mouse or other device). 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
 A font can be used to draw text on a Graphics object very flexibly. 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  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  SampleInstance
 An instance of a Sample playing. 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< TouchTouches
 

Enumerations

enum  ButtonName {
  KB_RANGE_BEGIN, KB_ESCAPE = 41, KB_F1 = 58, KB_F2 = 59,
  KB_F3 = 60, KB_F4 = 61, KB_F5 = 62, KB_F6 = 63,
  KB_F7 = 64, KB_F8 = 65, KB_F9 = 66, KB_F10 = 67,
  KB_F11 = 68, KB_F12 = 69, KB_0 = 39, KB_1 = 30,
  KB_2 = 31, KB_3 = 32, KB_4 = 33, KB_5 = 34,
  KB_6 = 35, KB_7 = 36, KB_8 = 37, KB_9 = 38,
  KB_TAB = 43, KB_RETURN = 40, KB_SPACE = 44, KB_LEFT_SHIFT = 225,
  KB_RIGHT_SHIFT = 229, KB_LEFT_CONTROL = 224, KB_RIGHT_CONTROL = 228, KB_LEFT_ALT = 226,
  KB_RIGHT_ALT = 230, KB_LEFT_META = 227, KB_RIGHT_META = 231, KB_BACKSPACE = 42,
  KB_LEFT = 80, KB_RIGHT = 79, KB_UP = 82, KB_DOWN = 81,
  KB_HOME = 74, KB_END = 77, KB_INSERT = 73, KB_DELETE = 76,
  KB_PAGE_UP = 75, KB_PAGE_DOWN = 78, KB_ENTER = 88, KB_BACKTICK = 53,
  KB_MINUS = 45, KB_EQUALS = 46, KB_LEFT_BRACKET = 47, KB_RIGHT_BRACKET = 48,
  KB_BACKSLASH = 49, KB_SEMICOLON = 51, KB_APOSTROPHE = 52, KB_COMMA = 54,
  KB_PERIOD = 55, KB_SLASH = 49, KB_A = 4, KB_B = 5,
  KB_C = 6, KB_D = 7, KB_E = 8, KB_F = 9,
  KB_G = 10, KB_H = 11, KB_I = 12, KB_J = 13,
  KB_K = 14, KB_L = 15, KB_M = 16, KB_N = 17,
  KB_O = 18, KB_P = 19, KB_Q = 20, KB_R = 21,
  KB_S = 22, KB_T = 23, KB_U = 24, KB_V = 25,
  KB_W = 26, KB_X = 27, KB_Y = 28, KB_Z = 29,
  KB_ISO = 100, KB_NUMPAD_0 = 98, KB_NUMPAD_1 = 89, KB_NUMPAD_2 = 90,
  KB_NUMPAD_3 = 91, KB_NUMPAD_4 = 92, KB_NUMPAD_5 = 93, KB_NUMPAD_6 = 94,
  KB_NUMPAD_7 = 95, KB_NUMPAD_8 = 96, KB_NUMPAD_9 = 97, KB_NUMPAD_PLUS = 87,
  KB_NUMPAD_MINUS = 86, KB_NUMPAD_MULTIPLY = 85, KB_NUMPAD_DIVIDE = 84, KB_RANGE_END = 0xff,
  MS_RANGE_BEGIN, MS_LEFT = MS_RANGE_BEGIN, MS_MIDDLE, MS_RIGHT,
  MS_WHEEL_UP, MS_WHEEL_DOWN, MS_OTHER_0, MS_OTHER_1,
  MS_OTHER_2, MS_OTHER_3, MS_OTHER_4, MS_OTHER_5,
  MS_OTHER_6, MS_OTHER_7, MS_RANGE_END = 0x110, GP_RANGE_BEGIN,
  GP_LEFT = GP_RANGE_BEGIN, GP_RIGHT, GP_UP, GP_DOWN,
  GP_BUTTON_0, GP_BUTTON_1, GP_BUTTON_2, GP_BUTTON_3,
  GP_BUTTON_4, GP_BUTTON_5, GP_BUTTON_6, GP_BUTTON_7,
  GP_BUTTON_8, GP_BUTTON_9, GP_BUTTON_10, GP_BUTTON_11,
  GP_BUTTON_12, GP_BUTTON_13, GP_BUTTON_14, GP_BUTTON_15,
  GP_0_LEFT, GP_0_RIGHT, GP_0_UP, GP_0_DOWN,
  GP_0_BUTTON_0, GP_0_BUTTON_1, GP_0_BUTTON_2, GP_0_BUTTON_3,
  GP_0_BUTTON_4, GP_0_BUTTON_5, GP_0_BUTTON_6, GP_0_BUTTON_7,
  GP_0_BUTTON_8, GP_0_BUTTON_9, GP_0_BUTTON_10, GP_0_BUTTON_11,
  GP_0_BUTTON_12, GP_0_BUTTON_13, GP_0_BUTTON_14, GP_0_BUTTON_15,
  GP_1_LEFT, GP_1_RIGHT, GP_1_UP, GP_1_DOWN,
  GP_1_BUTTON_0, GP_1_BUTTON_1, GP_1_BUTTON_2, GP_1_BUTTON_3,
  GP_1_BUTTON_4, GP_1_BUTTON_5, GP_1_BUTTON_6, GP_1_BUTTON_7,
  GP_1_BUTTON_8, GP_1_BUTTON_9, GP_1_BUTTON_10, GP_1_BUTTON_11,
  GP_1_BUTTON_12, GP_1_BUTTON_13, GP_1_BUTTON_14, GP_1_BUTTON_15,
  GP_2_LEFT, GP_2_RIGHT, GP_2_UP, GP_2_DOWN,
  GP_2_BUTTON_0, GP_2_BUTTON_1, GP_2_BUTTON_2, GP_2_BUTTON_3,
  GP_2_BUTTON_4, GP_2_BUTTON_5, GP_2_BUTTON_6, GP_2_BUTTON_7,
  GP_2_BUTTON_8, GP_2_BUTTON_9, GP_2_BUTTON_10, GP_2_BUTTON_11,
  GP_2_BUTTON_12, GP_2_BUTTON_13, GP_2_BUTTON_14, GP_2_BUTTON_15,
  GP_3_LEFT, GP_3_RIGHT, GP_3_UP, GP_3_DOWN,
  GP_3_BUTTON_0, GP_3_BUTTON_1, GP_3_BUTTON_2, GP_3_BUTTON_3,
  GP_3_BUTTON_4, GP_3_BUTTON_5, GP_3_BUTTON_6, GP_3_BUTTON_7,
  GP_3_BUTTON_8, GP_3_BUTTON_9, GP_3_BUTTON_10, GP_3_BUTTON_11,
  GP_3_BUTTON_12, GP_3_BUTTON_13, GP_3_BUTTON_14, GP_3_BUTTON_15,
  GP_RANGE_END = GP_3_BUTTON_15, NUM_BUTTONS = GP_RANGE_END + 1, NUM_GAMEPADS = 4, NO_BUTTON = 0xffffffff,
  KB_NUM = KB_RANGE_END - KB_RANGE_BEGIN + 1, MS_NUM = MS_RANGE_END - MS_RANGE_BEGIN + 1, GP_NUM = GP_RANGE_END - GP_RANGE_BEGIN + 1, GP_NUM_PER_GAMEPAD = GP_NUM / (NUM_GAMEPADS + 1)
}
 List of button ids that can be used with Gosu::Input. More...
 
enum  AlphaMode { AM_DEFAULT, AM_INTERPOLATE = AM_DEFAULT, AM_ADD, AM_MULTIPLY }
 Determines the way colors are combined when one is drawn onto another. More...
 
enum  FontFlags { FF_BOLD = 1, FF_ITALIC = 2, FF_UNDERLINE = 4, FF_COMBINATIONS = 8 }
 
enum  Alignment { AL_LEFT, AL_RIGHT, AL_CENTER, AL_JUSTIFY }
 
enum  ImageFlags {
  IF_SMOOTH = 0, IF_TILEABLE_LEFT = 1 << 1, IF_TILEABLE_TOP = 1 << 2, IF_TILEABLE_RIGHT = 1 << 3,
  IF_TILEABLE_BOTTOM = 1 << 4, IF_TILEABLE = IF_TILEABLE_LEFT | IF_TILEABLE_TOP | IF_TILEABLE_RIGHT | IF_TILEABLE_BOTTOM, IF_RETRO = 1 << 5
}
 Flags that affect the tileability or interpolation of an image. More...
 
enum  ByteOrder { BO_LITTLE, BO_BIG, BO_DONT_CARE }
 
enum  FileMode { FM_READ, FM_REPLACE, FM_ALTER }
 

Functions

void load_image_file (Bitmap &bitmap, const std::string &filename)
 Loads any supported image into a Bitmap. More...
 
void load_image_file (Bitmap &bitmap, 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 &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...
 
void unapply_color_key (Bitmap &bitmap, Color background)
 The reverse of apply_color_key. More...
 
void apply_border_flags (Bitmap &dest, const Bitmap &source, unsigned src_x, unsigned src_y, unsigned src_width, unsigned src_height, unsigned border_flags)
 
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::Imageload_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::Imageload_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...
 
bool operator== (Button lhs, Button rhs)
 Tests whether two Buttons identify the same physical button. More...
 
bool operator!= (Button lhs, Button rhs)
 
bool operator< (Button lhs, Button rhs)
 
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...
 
long trunc (double value)
 Truncates the fractional part of a real value. More...
 
long round (double value)
 Rounds a real value towards the next integer. 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 >
square (T value)
 Returns value * value. More...
 
template<typename 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 >
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 >
little_to_native (T t)
 
template<typename T >
native_to_little (T t)
 
template<typename T >
big_to_native (T t)
 
template<typename 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...
 
unsigned text_width (const std::string &text, const std::string &font_name, unsigned 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...
 
void draw_text (Bitmap &bitmap, const std::string &text, int x, int y, Color c, const std::string &font_name, unsigned font_height, unsigned font_flags=0)
 Draws a line of unformatted text on a bitmap. More...
 
Bitmap create_text (const std::string &text, const std::string &font_name, unsigned font_height, unsigned font_flags=0)
 Creates a bitmap that is filled with a line of formatted text given to the function. More...
 
Bitmap create_text (const std::string &text, const std::string &font_name, unsigned font_height, int line_spacing, unsigned width, Alignment align, unsigned font_flags=0)
 Creates a bitmap that is filled with the formatted text given to the function. More...
 
void register_entity (const std::string &name, const Bitmap &replacement)
 Registers a new HTML-style entity that can subsequently be used with Gosu::Font and Gosu::create_text. 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::wstring utf8_to_wstring (const std::string &utf8)
 Converts an UTF-8 to UCS-4 or UTF-16, depending on the platform's interpretation of wstring. More...
 
std::string wstring_to_utf8 (const std::wstring &ws)
 Converts an UCS-4 or UTF-16 to UTF-8, depending on the platform's interpretation of wstring. More...
 
bool has_extension (const std::string &filename, const char *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 ()
 Returns the width (in pixels) of the user's primary screen. More...
 
unsigned screen_height ()
 Returns the height (in pixels) of the user's primary screen. More...
 
unsigned available_width ()
 Returns the maximum width (in 'points') that is available for a non-fullscreen Window. More...
 
unsigned available_height ()
 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...
 

Detailed Description

The library's main namespace.

Typedef Documentation

◆ Touches

typedef std::vector<Touch> Gosu::Touches

Definition at line 49 of file Input.hpp.

◆ Transform

typedef std::array<double, 16> Gosu::Transform

Definition at line 67 of file GraphicsBase.hpp.

◆ ZPos

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.

Enumeration Type Documentation

◆ Alignment

Enumerator
AL_LEFT 
AL_RIGHT 
AL_CENTER 
AL_JUSTIFY 

Definition at line 40 of file GraphicsBase.hpp.

◆ AlphaMode

Determines the way colors are combined when one is drawn onto another.

Enumerator
AM_DEFAULT 
AM_INTERPOLATE 

The color's channels will be interpolated.

The alpha channel specifies the opacity of the new color, 255 is full opacity.

AM_ADD 

The colors' channels will be added.

The alpha channel specifies the percentage of the new color's channels that will be added to the old color's channels.

AM_MULTIPLY 

The color's channels will be multiplied with each other.

Definition at line 18 of file GraphicsBase.hpp.

◆ ButtonName

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_*) and gamepad buttons (GP_*).

Enumerator
K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TTON_9 
GP_2_BUTTON_10 
GP_2_BUTTON_11 
GP_2_BUTTON_12 
GP_2_BUTTON_13 
GP_2_BUTTON_14 
GP_2_BUTTON_15 
GP_3_LEFT 
GP_3_RIGHT 
GP_3_UP 
GP_3_DOWN 
GP_3_BUTTON_0 
GP_3_BUTTON_1 
GP_3_BUTTON_2 
GP_3_BUTTON_3 
GP_3_BUTTON_4 
GP_3_BUTTON_5 
GP_3_BUTTON_6 
GP_3_BUTTON_7 
GP_3_BUTTON_8 
GP_3_BUTTON_9 
GP_3_BUTTON_10 
GP_3_BUTTON_11 
GP_3_BUTTON_12 
GP_3_BUTTON_13 
GP_3_BUTTON_14 
GP_3_BUTTON_15 
GP_RANGE_END 
NUM_BUTTONS 
NUM_GAMEPADS 
NO_BUTTON 
KB_NUM 
MS_NUM 
GP_NUM 
GP_NUM_PER_GAMEPAD 

Definition at line 10 of file Buttons.hpp.

◆ ByteOrder

Enumerator
BO_LITTLE 
BO_BIG 
BO_DONT_CARE 

Definition at line 17 of file IO.hpp.

◆ FileMode

Enumerator
FM_READ 

Opens an existing file for reading; throws an exception if the file cannot be found.

FM_REPLACE 

Writes data to a file.

If the file already exists, is emptied on opening. If the file does not exist, it is created.

FM_ALTER 

Opens or creates a file with writing access, but does not clear existing contents.

Definition at line 221 of file IO.hpp.

◆ FontFlags

Enumerator
FF_BOLD 
FF_ITALIC 
FF_UNDERLINE 
FF_COMBINATIONS 

Definition at line 32 of file GraphicsBase.hpp.

◆ 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.

Function Documentation

◆ angle()

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().

◆ angle_diff()

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().

◆ apply_border_flags()

void Gosu::apply_border_flags ( Bitmap dest,
const Bitmap source,
unsigned  src_x,
unsigned  src_y,
unsigned  src_width,
unsigned  src_height,
unsigned  border_flags 
)

Referenced by Gosu::Bitmap::data().

◆ apply_color_key()

void Gosu::apply_color_key ( Bitmap bitmap,
Color  key 
)

Set the alpha value of all pixels which are equal to the color key to zero.

Color values are adjusted so that no borders show up when the image is stretched or rotated.

Referenced by Gosu::Bitmap::data().

◆ available_height()

unsigned Gosu::available_height ( )

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.

◆ available_width()

unsigned Gosu::available_width ( )

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.

◆ big_to_native()

template<typename T >
T Gosu::big_to_native ( t)

Definition at line 28 of file Platform.hpp.

◆ clamp()

template<typename T >
T Gosu::clamp ( value,
min,
max 
)

Returns min if value is smaller than min, max if value is larger than max and value otherwise.

Definition at line 92 of file Math.hpp.

References wrap().

◆ concat()

Transform Gosu::concat ( const Transform lhs,
const Transform rhs 
)

◆ create_text() [1/2]

Bitmap Gosu::create_text ( const std::string &  text,
const std::string &  font_name,
unsigned  font_height,
unsigned  font_flags = 0 
)

Creates a bitmap that is filled with a line of formatted text given to the function.

The line can contain line breaks and HTML-like markup.

Parameters
textFormatted text.
font_nameName of a system font, or a filename to a TTF file (must contain '/').
font_heightHeight of the font in pixels.
font_flagsBinary combination of members of the FontFlags enum.

◆ create_text() [2/2]

Bitmap Gosu::create_text ( const std::string &  text,
const std::string &  font_name,
unsigned  font_height,
int  line_spacing,
unsigned  width,
Alignment  align,
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.

Parameters
textFormatted text.
font_nameName of a system font, or a filename to a TTF file (must contain '/').
font_heightHeight of the font in pixels.
line_spacingSpacing between two lines of text in pixels. Can be negative to make text stick together more closely.
widthWidth 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.
font_flagsBinary combination of members of the FontFlags enum.

◆ default_font_name()

std::string Gosu::default_font_name ( )

Returns the name of a neutral font that is available on the current platform.

◆ degrees_to_radians()

double Gosu::degrees_to_radians ( 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 52 of file Math.hpp.

References M_PI.

◆ distance()

double Gosu::distance ( double  x1,
double  y1,
double  x2,
double  y2 
)

Returns the distance between two points.

Referenced by distance_sqr().

◆ 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 113 of file Math.hpp.

References distance(), and square().

◆ draw_text()

void Gosu::draw_text ( Bitmap bitmap,
const std::string &  text,
int  x,
int  y,
Color  c,
const std::string &  font_name,
unsigned  font_height,
unsigned  font_flags = 0 
)

Draws a line of unformatted text on a bitmap.

This is a very low-level function that does not understand any of Gosu's HTML-like markup.

Parameters
textUnformatted text.
font_nameName of a system font, or a filename to a TTF file (must contain '/').
font_heightHeight, in pixels, of the text.
font_flagsBinary combination of members of the FontFlags enum.

◆ fps()

int Gosu::fps ( )

Returns the current framerate.

◆ gosu_to_radians()

double Gosu::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).

Definition at line 39 of file Math.hpp.

References M_PI.

◆ has_extension()

bool Gosu::has_extension ( const std::string &  filename,
const char *  extension 
)

Returns true if the filename has the given extension.

The comparison is case-insensitive, but you must pass the extension in lower case.

◆ interpolate() [1/2]

template<typename T >
T Gosu::interpolate ( a,
b,
double  weight = 0.5 
)

Interpolates a value between a and b, weight being the bias towards the second value.

Examples: interpolate(0, 10, 0.5) == 5, interpolate(-10, 10, 0.25) == 5, interpolate(0, 10, -0.5) == -5.

Definition at line 125 of file Math.hpp.

◆ interpolate() [2/2]

Color Gosu::interpolate ( Color  a,
Color  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!=().

◆ language()

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.

◆ little_to_native()

template<typename T >
T Gosu::little_to_native ( t)

Definition at line 24 of file Platform.hpp.

◆ load_file()

void Gosu::load_file ( Buffer buffer,
const std::string &  filename 
)

Loads a whole file into a buffer.

◆ load_image_file() [1/2]

void Gosu::load_image_file ( Bitmap bitmap,
const std::string &  filename 
)

Loads any supported image into a Bitmap.

Referenced by Gosu::Bitmap::data().

◆ load_image_file() [2/2]

void Gosu::load_image_file ( Bitmap bitmap,
Reader  input 
)

Loads any supported image into a Bitmap.

◆ load_tiles() [1/2]

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.

Parameters
tile_widthIf positive, specifies the width of one tile in pixels. If negative, the bitmap is divided into -tile_width rows.
tile_heightSee tile_width.

◆ load_tiles() [2/2]

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.

Parameters
tile_widthIf positive, specifies the width of one tile in pixels. If negative, the bitmap is divided into -tile_width rows.
tile_heightSee tile_width.

◆ milliseconds()

unsigned long Gosu::milliseconds ( )

Returns the milliseconds since first calling this function.

Can wrap after running for a long time.

◆ multiply()

Color Gosu::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.

Referenced by operator!=().

◆ native_to_big()

template<typename T >
T Gosu::native_to_big ( t)

Definition at line 35 of file Platform.hpp.

◆ native_to_little()

template<typename T >
T Gosu::native_to_little ( t)

Definition at line 25 of file Platform.hpp.

◆ normalize_angle()

double Gosu::normalize_angle ( double  angle)

Normalizes an angle to fit into the range [0; 360[.

Referenced by radians_to_degrees().

◆ offset_x()

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.

Parameters
angleAngle in degrees where 0.0 means upwards.

Referenced by radians_to_degrees().

◆ offset_y()

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.

Parameters
angleAngle in degrees where 0.0 means upwards.

Referenced by radians_to_degrees().

◆ operator!=() [1/2]

bool Gosu::operator!= ( Button  lhs,
Button  rhs 
)

Definition at line 35 of file Input.hpp.

◆ operator!=() [2/2]

bool Gosu::operator!= ( Color  a,
Color  b 
)

Definition at line 150 of file Color.hpp.

References Gosu::Color::gl(), interpolate(), and multiply().

◆ operator<() [1/2]

bool Gosu::operator< ( Button  lhs,
Button  rhs 
)

Definition at line 36 of file Input.hpp.

References Gosu::Button::id().

◆ operator<() [2/2]

bool Gosu::operator< ( Color  a,
Color  b 
)

Definition at line 148 of file Color.hpp.

References Gosu::Color::gl().

◆ operator==() [1/2]

bool Gosu::operator== ( Button  lhs,
Button  rhs 
)

Tests whether two Buttons identify the same physical button.

Definition at line 34 of file Input.hpp.

References Gosu::Button::id().

◆ operator==() [2/2]

bool Gosu::operator== ( Color  a,
Color  b 
)

Definition at line 149 of file Color.hpp.

References Gosu::Color::gl().

◆ radians_to_degrees()

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 58 of file Math.hpp.

References angle(), angle_diff(), M_PI, normalize_angle(), offset_x(), and offset_y().

◆ radians_to_gosu()

double Gosu::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).

Definition at line 45 of file Math.hpp.

References M_PI.

◆ random()

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.

Referenced by round().

◆ register_entity()

void Gosu::register_entity ( const std::string &  name,
const Bitmap replacement 
)

Registers a new HTML-style entity that can subsequently be used with Gosu::Font and Gosu::create_text.

The name is given without & and ;.

◆ resource_prefix()

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).

◆ rotate()

Transform Gosu::rotate ( double  angle,
double  around_x = 0,
double  around_y = 0 
)

◆ round()

long Gosu::round ( double  value)

Rounds a real value towards the next integer.

Definition at line 23 of file Math.hpp.

References random().

◆ save_file()

void Gosu::save_file ( const Buffer buffer,
const std::string &  filename 
)

Creates or overwrites a file with the contents of a buffer.

◆ save_image_file() [1/2]

void Gosu::save_image_file ( const Bitmap bitmap,
const std::string &  filename 
)

Saves a Bitmap to a file.

Referenced by Gosu::Bitmap::data().

◆ save_image_file() [2/2]

void Gosu::save_image_file ( const Bitmap bitmap,
Writer  writer,
const std::string &  format_hint = "png" 
)

Saves a Bitmap to an arbitrary resource.

◆ scale() [1/2]

Transform Gosu::scale ( double  factor)

◆ scale() [2/2]

Transform Gosu::scale ( double  scale_x,
double  scale_y,
double  from_x = 0,
double  from_y = 0 
)

◆ screen_height()

unsigned Gosu::screen_height ( )

Returns the height (in pixels) of the user's primary screen.

◆ screen_width()

unsigned Gosu::screen_width ( )

Returns the width (in pixels) of the user's primary screen.

◆ shared_resource_prefix()

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).

◆ sleep()

void Gosu::sleep ( unsigned  milliseconds)

Freezes the current thread for at least the specified time.

◆ square()

template<typename T >
T Gosu::square ( value)

Returns value * value.

Definition at line 84 of file Math.hpp.

Referenced by distance_sqr().

◆ text_width()

unsigned Gosu::text_width ( const std::string &  text,
const std::string &  font_name,
unsigned  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.

This is a very low-level function that does not understand any of Gosu's HTML-like markup.

Parameters
textUnformatted text.
font_nameName of a system font, or a filename to a TTF file (must contain '/').

◆ translate()

Transform Gosu::translate ( double  x,
double  y 
)

◆ trunc()

long Gosu::trunc ( double  value)

Truncates the fractional part of a real value.

Equivalent to static_cast<long>.

Definition at line 17 of file Math.hpp.

◆ unapply_color_key()

void Gosu::unapply_color_key ( Bitmap bitmap,
Color  background 
)

The reverse of apply_color_key.

Resets all fully transparent pixels by a background color, makes all other pixels fully opaque.

Referenced by Gosu::Bitmap::data().

◆ use_resource_directory()

void Gosu::use_resource_directory ( )

Changes the current directory to the result of resource_prefix().

◆ user_documents_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.

◆ user_settings_prefix()

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.

◆ utf8_to_wstring()

std::wstring Gosu::utf8_to_wstring ( const std::string &  utf8)

Converts an UTF-8 to UCS-4 or UTF-16, depending on the platform's interpretation of wstring.

◆ wrap() [1/3]

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().

◆ wrap() [2/3]

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.

◆ wrap() [3/3]

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.

◆ wstring_to_utf8()

std::string Gosu::wstring_to_utf8 ( const std::wstring &  ws)

Converts an UCS-4 or UTF-16 to UTF-8, depending on the platform's interpretation of wstring.

Variable Documentation

◆ BO_NATIVE

const ByteOrder Gosu::BO_NATIVE = BO_LITTLE

Definition at line 21 of file IO.hpp.

◆ BO_OTHER

const ByteOrder Gosu::BO_OTHER = BO_BIG

Definition at line 21 of file IO.hpp.

◆ LICENSES

const std::string Gosu::LICENSES

A block of legal copy that your game is obliged to display somewhere.

◆ MAX_TEXTURE_SIZE

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.

◆ VERSION

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".