Gosu Namespace Reference

The library's main namespace. More...

Namespaces

namespace  Colors
namespace  Win
 

Implementation helpers for the Windows platform.


Classes

class  SampleInstance
 An instance of a Sample playing. 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 in that they can only be played one at a time and without panning or speed parameters. More...
class  Bitmap
 Rectangular area of pixels, each represented by a Color value. More...
class  Color
 Represents an RGBA color value with 8 bits for each channel. More...
class  Font
 A font can be used to draw text on a Graphics object very flexibly. 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...
struct  GLTexInfo
 Contains information about the underlying OpenGL texture and the u/v space used for image data. More...
class  ImageData
 The ImageData class is an abstract base class for drawable images. More...
class  Button
 Very lightweight class that identifies a button (keyboard, mouse or other device). More...
struct  Touch
 Struct that saves information about a touch on the surface of a multi- touch device. 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  Writer
 Utility class that points to a specific position in a resource and offers an interface for sequential writing. More...
class  Resource
 Base class for resources. More...
class  Buffer
 Piece of memory with the Resource interface. More...
class  File
 File with the Resource interface. More...
class  MessageSocket
 Wraps an UDP socket. More...
class  CommSocket
 Wraps a TCP socket that is used for one part of bi-directional communication. More...
class  ListenerSocket
 Wraps a TCP socket that waits on a specific port and can create CommSocket instances via its onConnection event. More...
class  TextInput
 TextInput instances are invisible objects that build a text string from input, using the current operating system's keyboard layout. More...
class  Window
 Convenient all-in-one class that serves as the foundation of a standard Gosu application. More...

Typedefs

typedef double ZPos
 Represents the Z position of something drawn with Gosu's graphics system.
typedef std::tr1::array
< double, 16 > 
Transform
typedef std::vector< TouchTouches
typedef std::tr1::uint32_t SocketAddress
 Addresses are returned from and given to Gosu functions in host byte order.
typedef std::tr1::uint16_t SocketPort
 Ports are returned from and given to Gosu functions in host byte order.

Enumerations

enum  ButtonName {
  kbRangeBegin, kbEscape = 41, kbF1 = 58, kbF2 = 59,
  kbF3 = 60, kbF4 = 61, kbF5 = 62, kbF6 = 63,
  kbF7 = 64, kbF8 = 65, kbF9 = 66, kbF10 = 67,
  kbF11 = 68, kbF12 = 69, kb0 = 39, kb1 = 30,
  kb2 = 31, kb3 = 32, kb4 = 33, kb5 = 34,
  kb6 = 35, kb7 = 36, kb8 = 37, kb9 = 38,
  kbTab = 43, kbReturn = 40, kbSpace = 44, kbLeftShift = 225,
  kbRightShift = 229, kbLeftControl = 224, kbRightControl = 228, kbLeftAlt = 226,
  kbRightAlt = 230, kbLeftMeta = 227, kbRightMeta = 231, kbBackspace = 42,
  kbLeft = 80, kbRight = 79, kbUp = 82, kbDown = 81,
  kbHome = 74, kbEnd = 77, kbInsert = 73, kbDelete = 76,
  kbPageUp = 75, kbPageDown = 78, kbEnter = 88, kbBacktick = 53,
  kbMinus = 45, kbEqual = 46, kbBracketLeft = 47, kbBracketRight = 48,
  kbBackslash = 49, kbSemicolon = 51, kbApostrophe = 52, kbComma = 54,
  kbPeriod = 55, kbSlash = 49, kbA = 4, kbB = 5,
  kbC = 6, kbD = 7, kbE = 8, kbF = 9,
  kbG = 10, kbH = 11, kbI = 12, kbJ = 13,
  kbK = 14, kbL = 15, kbM = 16, kbN = 17,
  kbO = 18, kbP = 19, kbQ = 20, kbR = 21,
  kbS = 22, kbT = 23, kbU = 24, kbV = 25,
  kbW = 26, kbX = 27, kbY = 28, kbZ = 29,
  kbISO = 100, kbNumpad0 = 98, kbNumpad1 = 89, kbNumpad2 = 90,
  kbNumpad3 = 91, kbNumpad4 = 92, kbNumpad5 = 93, kbNumpad6 = 94,
  kbNumpad7 = 95, kbNumpad8 = 96, kbNumpad9 = 97, kbNumpadAdd = 87,
  kbNumpadSubtract = 86, kbNumpadMultiply = 85, kbNumpadDivide = 84, kbRangeEnd = 0xff,
  msRangeBegin, msLeft = msRangeBegin, msMiddle, msRight,
  msWheelUp, msWheelDown, msOther0, msOther1,
  msOther2, msOther3, msOther4, msOther5,
  msOther6, msOther7, msRangeEnd = 0x110, gpRangeBegin,
  gpLeft = gpRangeBegin, gpRight, gpUp, gpDown,
  gpButton0, gpButton1, gpButton2, gpButton3,
  gpButton4, gpButton5, gpButton6, gpButton7,
  gpButton8, gpButton9, gpButton10, gpButton11,
  gpButton12, gpButton13, gpButton14, gpButton15,
  gp0Left, gp0Right, gp0Up, gp0Down,
  gp0Button0, gp0Button1, gp0Button2, gp0Button3,
  gp0Button4, gp0Button5, gp0Button6, gp0Button7,
  gp0Button8, gp0Button9, gp0Button10, gp0Button11,
  gp0Button12, gp0Button13, gp0Button14, gp0Button15,
  gp1Left, gp1Right, gp1Up, gp1Down,
  gp1Button0, gp1Button1, gp1Button2, gp1Button3,
  gp1Button4, gp1Button5, gp1Button6, gp1Button7,
  gp1Button8, gp1Button9, gp1Button10, gp1Button11,
  gp1Button12, gp1Button13, gp1Button14, gp1Button15,
  gp2Left, gp2Right, gp2Up, gp2Down,
  gp2Button0, gp2Button1, gp2Button2, gp2Button3,
  gp2Button4, gp2Button5, gp2Button6, gp2Button7,
  gp2Button8, gp2Button9, gp2Button10, gp2Button11,
  gp2Button12, gp2Button13, gp2Button14, gp2Button15,
  gp3Left, gp3Right, gp3Up, gp3Down,
  gp3Button0, gp3Button1, gp3Button2, gp3Button3,
  gp3Button4, gp3Button5, gp3Button6, gp3Button7,
  gp3Button8, gp3Button9, gp3Button10, gp3Button11,
  gp3Button12, gp3Button13, gp3Button14, gp3Button15,
  gpRangeEnd = gp3Button15, numButtons = gpRangeEnd + 1, numGamepads = 4, noButton = 0xffffffff,
  kbNum = kbRangeEnd - kbRangeBegin + 1, msNum = msRangeEnd - msRangeBegin + 1, gpNum = gpRangeEnd - gpRangeBegin + 1, gpNumPerGamepad = gpNum / (numGamepads + 1)
}
 List of button ids that can be used with Gosu::Input. More...
enum  AlphaMode { amDefault, amAdd, amAdditive = amAdd, amMultiply }
 Determines the way colors are combined when one is drawn onto another. More...
enum  FontFlags { ffBold = 1, ffItalic = 2, ffUnderline = 4, ffCombinations = 8 }
enum  TextAlign { taLeft, taRight, taCenter, taJustify }
enum  BorderFlags {
  bfSmooth = 0, bfTileableLeft = 1, bfTileableTop = 2, bfTileableRight = 4,
  bfTileableBottom = 8, bfTileable = bfTileableLeft | bfTileableTop | bfTileableRight | bfTileableBottom
}
 Flags that affect the tileability of an image. More...
enum  ByteOrder { boLittle, boBig, boDontCare }
enum  FileMode { fmRead, fmReplace, fmAlter }
enum  CommMode { cmRaw, cmManaged }
 Defines the way in which data is collected until the onReceive event is called for CommSockets. More...

Functions

void loadImageFile (Bitmap &bitmap, const std::wstring &filename)
 Loads any supported image into a Bitmap.
void loadImageFile (Bitmap &bitmap, Reader input)
 Loads any supported image into a Bitmap.
void saveImageFile (const Bitmap &bitmap, const std::wstring &filename)
 Saves a Bitmap to a file.
void saveImageFile (const Bitmap &bitmap, Gosu::Writer writer, const std::wstring &formatHint=L"png")
 Saves a Bitmap to an arbitrary resource.
void applyColorKey (Bitmap &bitmap, Color key)
 Set the alpha value of all pixels which are equal to the color key to zero.
void unapplyColorKey (Bitmap &bitmap, Color background)
 The reverse of applyColorKey.
void applyBorderFlags (Bitmap &dest, const Bitmap &source, unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight, unsigned borderFlags)
GOSU_DEPRECATED Reader loadFromBMP (Bitmap &bmp, Reader reader)
GOSU_DEPRECATED Writer saveToBMP (const Bitmap &bmp, Writer writer)
GOSU_DEPRECATED Reader loadFromPNG (Bitmap &bmp, Reader reader)
GOSU_DEPRECATED Writer saveToPNG (const Bitmap &bmp, Writer writer)
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.
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.
std::wstring resourcePrefix ()
 Prefix for a program's own resources.
std::wstring sharedResourcePrefix ()
 Prefix for resources of a group of programs.
std::wstring userSettingsPrefix ()
 Prefix for user settings.
std::wstring userDocsPrefix ()
 Prefix for user documents, e.g.
unsigned screenWidth ()
 Returns the width, in pixels, of the user's primary screen.
unsigned screenHeight ()
 Returns the height, in pixels, of the user's primary screen.
Transform translate (double x, double y)
Transform rotate (double angle, double aroundX=0, double aroundY=0)
Transform scale (double factor)
Transform scale (double factorX, double factorY, double fromX=0, double fromY=0)
Transform concat (const Transform &lhs, const Transform &rhs)
std::vector< Gosu::ImageloadTiles (Graphics &graphics, const Bitmap &bmp, int tileWidth, int tileHeight, bool tileable)
std::vector< Gosu::ImageloadTiles (Graphics &graphics, const std::wstring &bmp, int tileWidth, int tileHeight, bool tileable)
template<typename Container >
void imagesFromTiledBitmap (Graphics &graphics, const std::wstring &filename, int tileWidth, int tileHeight, bool tileable, Container &appendTo)
 Convenience function that splits a BMP or PNG file into an array of small rectangles and creates images from them.
template<typename Container >
void imagesFromTiledBitmap (Graphics &graphics, const Bitmap &bmp, int tileWidth, int tileHeight, bool tileable, Container &appendTo)
 Convenience function that splits a bitmap into an area of array rectangles and creates images from them.
bool operator== (Button lhs, Button rhs)
 Tests whether two Buttons identify the same physical button.
bool operator!= (Button lhs, Button rhs)
bool operator< (Button lhs, Button rhs)
int fps ()
 Returns the current framerate, as determined by an unspecified and possibly horrible algorithm.
void loadFile (Buffer &buffer, const std::wstring &filename)
 Loads a whole file into a buffer.
void saveFile (const Buffer &buffer, const std::wstring &filename)
 Creates or overwrites a file with the contents of a buffer.
long trunc (double value)
 Truncates the fractional part of a real value.
long round (double value)
 Rounds a real value towards the next integer.
double random (double min, double max)
 Returns a real value between min (inclusive) and max (exclusive).
double gosuToRadians (double angle)
 Translates between Gosu's angle system (where 0 is at the top) and radians (where 0 is at the right).
double radiansToGosu (double angle)
 Translates between Gosu's angle system (where 0 is at the top) and radians (where 0 is at the right).
double degreesToRadians (double angle)
 Translates between degrees (used by Gosu) and radians, i.e.
double radiansToDegrees (double angle)
 Translates between degrees (used by Gosu) and radians, i.e.
double offsetX (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.
double offsetY (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.
double angle (double fromX, double fromY, double toX, double toY, double def=0)
 Returns the angle from point 1 to point 2 in degrees, where 0.0 means upwards.
double angleDiff (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).
double normalizeAngle (double angle)
 Normalizes an angle to fit into the range [0; 360[.
template<typename T >
square (T value)
 Returns value * value.
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.
template<typename T >
boundBy (T value, T min, T max)
int wrap (int value, int min, int max)
 Returns (value-min) % (max-min) + min, where % always has a positive result for max > min.
float wrap (float value, float min, float max)
 Returns (value-min) % (max-min) + min, where % always has a positive result for max > min.
double wrap (double value, double min, double max)
 Returns (value-min) % (max-min) + min, where % always has a positive result for max > min.
double distanceSqr (double x1, double y1, double x2, double y2)
 Returns the square of the distance between two points.
double distance (double x1, double y1, double x2, double y2)
 Returns the distance between two points.
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.
template<typename T >
littleToNative (T t)
template<typename T >
nativeToLittle (T t)
template<typename T >
bigToNative (T t)
template<typename T >
nativeToBig (T t)
SocketAddress stringToAddress (const std::string &s)
 Tries to convert a dotted IP4 string into an address suitable for socket functions.
std::string addressToString (SocketAddress address)
 Converts an address into a dotted IP4 string.
std::wstring defaultFontName ()
 Returns the name of a neutral font that is available on the current platform.
unsigned textWidth (const std::wstring &text, const std::wstring &fontName, unsigned fontHeight, unsigned fontFlags=0)
 Returns the width an unformatted line of text would span on a bitmap if it were drawn using drawText with the same arguments.
void drawText (Bitmap &bitmap, const std::wstring &text, int x, int y, Color c, const std::wstring &fontName, unsigned fontHeight, unsigned fontFlags=0)
 Draws a line of unformatted text on a bitmap.
Bitmap createText (const std::wstring &text, const std::wstring &fontName, unsigned fontHeight, unsigned fontFlags=0)
 Creates a bitmap that is filled with a line of formatted text given to the function.
Bitmap createText (const std::wstring &text, const std::wstring &fontName, unsigned fontHeight, int lineSpacing, unsigned width, TextAlign align, unsigned fontFlags=0)
 Creates a bitmap that is filled with the formatted text given to the function.
void registerEntity (const std::wstring &name, const Bitmap &replacement)
 Registers a new HTML-style entity that can subsequently be used with Gosu::Font and Gosu::createText.
void sleep (unsigned milliseconds)
 Freezes the current thread for at least the specified time.
unsigned long milliseconds ()
 Incrementing, possibly wrapping millisecond timer.
std::wstring utf8ToWstring (const std::string &utf8)
 Converts an std::string into an std::wstring.
std::string wstringToUTF8 (const std::wstring &ws)
 Converts an std::wstring into an std::string.
std::wstring widen (const std::string &s)
 Converts an std::string into an std::wstring using local encoding.
std::string narrow (const std::wstring &ws)
 Converts an std::wstring into an std::string using local encoding.
std::string language ()
 Returns the user's preferred language, at the moment of calling the function.

Variables

class GOSU_DEPRECATED Audio
unsigned const MAX_TEXTURE_SIZE = 1024
 Returns the maximum size of an texture that will be allocated internally by Gosu.
GOSU_DEPRECATED const double zImmediate = -std::numeric_limits<double>::infinity()
const ByteOrder nativeByteOrder = boLittle
const ByteOrder otherByteOrder = boBig
const double pi = 3.1415926536
 Pi.
const SocketPort anyPort = 0
 Constant that can be used as a placeholder for an arbitrary port, e.g.

Detailed Description

The library's main namespace.


Typedef Documentation

typedef std::tr1::uint32_t Gosu::SocketAddress

Addresses are returned from and given to Gosu functions in host byte order.

Definition at line 15 of file Sockets.hpp.

typedef std::tr1::uint16_t Gosu::SocketPort

Ports are returned from and given to Gosu functions in host byte order.

Definition at line 18 of file Sockets.hpp.

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

Definition at line 71 of file Input.hpp.

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

Definition at line 95 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, that is, they are performed last.

Definition at line 16 of file GraphicsBase.hpp.


Enumeration Type Documentation

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

Enumerator:
amDefault 

The color's channels will be interpolated.

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

amAdd 

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.

amAdditive 
amMultiply 

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

Definition at line 40 of file GraphicsBase.hpp.

Flags that affect the tileability of an image.

Enumerator:
bfSmooth 
bfTileableLeft 
bfTileableTop 
bfTileableRight 
bfTileableBottom 
bfTileable 

Definition at line 72 of file GraphicsBase.hpp.

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:
kbRangeBegin 
kbEscape 
kbF1 
kbF2 
kbF3 
kbF4 
kbF5 
kbF6 
kbF7 
kbF8 
kbF9 
kbF10 
kbF11 
kbF12 
kb0 
kb1 
kb2 
kb3 
kb4 
kb5 
kb6 
kb7 
kb8 
kb9 
kbTab 
kbReturn 
kbSpace 
kbLeftShift 
kbRightShift 
kbLeftControl 
kbRightControl 
kbLeftAlt 
kbRightAlt 
kbLeftMeta 
kbRightMeta 
kbBackspace 
kbLeft 
kbRight 
kbUp 
kbDown 
kbHome 
kbEnd 
kbInsert 
kbDelete 
kbPageUp 
kbPageDown 
kbEnter 
kbBacktick 
kbMinus 
kbEqual 
kbBracketLeft 
kbBracketRight 
kbBackslash 
kbSemicolon 
kbApostrophe 
kbComma 
kbPeriod 
kbSlash 
kbA 
kbB 
kbC 
kbD 
kbE 
kbF 
kbG 
kbH 
kbI 
kbJ 
kbK 
kbL 
kbM 
kbN 
kbO 
kbP 
kbQ 
kbR 
kbS 
kbT 
kbU 
kbV 
kbW 
kbX 
kbY 
kbZ 
kbISO 
kbNumpad0 
kbNumpad1 
kbNumpad2 
kbNumpad3 
kbNumpad4 
kbNumpad5 
kbNumpad6 
kbNumpad7 
kbNumpad8 
kbNumpad9 
kbNumpadAdd 
kbNumpadSubtract 
kbNumpadMultiply 
kbNumpadDivide 
kbRangeEnd 
msRangeBegin 
msLeft 
msMiddle 
msRight 
msWheelUp 
msWheelDown 
msOther0 
msOther1 
msOther2 
msOther3 
msOther4 
msOther5 
msOther6 
msOther7 
msRangeEnd 
gpRangeBegin 
gpLeft 
gpRight 
gpUp 
gpDown 
gpButton0 
gpButton1 
gpButton2 
gpButton3 
gpButton4 
gpButton5 
gpButton6 
gpButton7 
gpButton8 
gpButton9 
gpButton10 
gpButton11 
gpButton12 
gpButton13 
gpButton14 
gpButton15 
gp0Left 
gp0Right 
gp0Up 
gp0Down 
gp0Button0 
gp0Button1 
gp0Button2 
gp0Button3 
gp0Button4 
gp0Button5 
gp0Button6 
gp0Button7 
gp0Button8 
gp0Button9 
gp0Button10 
gp0Button11 
gp0Button12 
gp0Button13 
gp0Button14 
gp0Button15 
gp1Left 
gp1Right 
gp1Up 
gp1Down 
gp1Button0 
gp1Button1 
gp1Button2 
gp1Button3 
gp1Button4 
gp1Button5 
gp1Button6 
gp1Button7 
gp1Button8 
gp1Button9 
gp1Button10 
gp1Button11 
gp1Button12 
gp1Button13 
gp1Button14 
gp1Button15 
gp2Left 
gp2Right 
gp2Up 
gp2Down 
gp2Button0 
gp2Button1 
gp2Button2 
gp2Button3 
gp2Button4 
gp2Button5 
gp2Button6 
gp2Button7 
gp2Button8 
gp2Button9 
gp2Button10 
gp2Button11 
gp2Button12 
gp2Button13 
gp2Button14 
gp2Button15 
gp3Left 
gp3Right 
gp3Up 
gp3Down 
gp3Button0 
gp3Button1 
gp3Button2 
gp3Button3 
gp3Button4 
gp3Button5 
gp3Button6 
gp3Button7 
gp3Button8 
gp3Button9 
gp3Button10 
gp3Button11 
gp3Button12 
gp3Button13 
gp3Button14 
gp3Button15 
gpRangeEnd 
numButtons 
numGamepads 
noButton 
kbNum 
msNum 
gpNum 
gpNumPerGamepad 

Definition at line 23 of file Buttons.hpp.

Enumerator:
boLittle 
boBig 
boDontCare 

Definition at line 18 of file IO.hpp.

Defines the way in which data is collected until the onReceive event is called for CommSockets.

Enumerator:
cmRaw 
cmManaged 

Definition at line 80 of file Sockets.hpp.

Enumerator:
fmRead 

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

fmReplace 

Writes data to a file.

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

fmAlter 

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

Definition at line 232 of file IO.hpp.

Enumerator:
ffBold 
ffItalic 
ffUnderline 
ffCombinations 

Definition at line 55 of file GraphicsBase.hpp.

Enumerator:
taLeft 
taRight 
taCenter 
taJustify 

Definition at line 63 of file GraphicsBase.hpp.


Function Documentation

std::string Gosu::addressToString ( SocketAddress  address)

Converts an address into a dotted IP4 string.

double Gosu::angle ( double  fromX,
double  fromY,
double  toX,
double  toY,
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.

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

void Gosu::applyBorderFlags ( Bitmap &  dest,
const Bitmap &  source,
unsigned  srcX,
unsigned  srcY,
unsigned  srcWidth,
unsigned  srcHeight,
unsigned  borderFlags 
)
void Gosu::applyColorKey ( 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.

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

Definition at line 29 of file Platform.hpp.

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

Definition at line 99 of file Math.hpp.

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

Referenced by boundBy().

Transform Gosu::concat ( const Transform &  lhs,
const Transform &  rhs 
)
Bitmap Gosu::createText ( const std::wstring &  text,
const std::wstring &  fontName,
unsigned  fontHeight,
unsigned  fontFlags = 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.
fontNameName of a system font, or a filename to a TTF file (must contain '/').
fontHeightHeight of the font in pixels.
fontFlagsBinary combination of members of the FontFlags enum.
Bitmap Gosu::createText ( const std::wstring &  text,
const std::wstring &  fontName,
unsigned  fontHeight,
int  lineSpacing,
unsigned  width,
TextAlign  align,
unsigned  fontFlags = 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.
fontNameName of a system font, or a filename to a TTF file (must contain '/').
fontHeightHeight of the font in pixels.
lineSpacingSpacing 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.
fontFlagsBinary combination of members of the FontFlags enum.
std::wstring Gosu::defaultFontName ( )

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

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

References pi.

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

Returns the distance between two points.

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

Returns the square of the distance between two points.

Definition at line 118 of file Math.hpp.

References square().

void Gosu::drawText ( Bitmap &  bitmap,
const std::wstring &  text,
int  x,
int  y,
Color  c,
const std::wstring &  fontName,
unsigned  fontHeight,
unsigned  fontFlags = 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.
fontNameName of a system font, or a filename to a TTF file (must contain '/').
fontHeightHeight, in pixels, of the text.
fontFlagsBinary combination of members of the FontFlags enum.
int Gosu::fps ( )

Returns the current framerate, as determined by an unspecified and possibly horrible algorithm.

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

References pi.

template<typename Container >
void Gosu::imagesFromTiledBitmap ( Graphics &  graphics,
const std::wstring &  filename,
int  tileWidth,
int  tileHeight,
bool  tileable,
Container &  appendTo 
)

Convenience function that splits a BMP or PNG file into an array of small rectangles and creates images from them.

Parameters:
tileWidthIf positive, specifies the width of one tile in pixels. If negative, the bitmap is divided into -tileWidth rows.
tileHeightSee tileWidth.
appendToSTL container to which the images will be appended. Must provide a push_back member function; vector<tr1::shared_ptr<Image>> or boost::ptr_vector<Image> are good choices.

Definition at line 97 of file Image.hpp.

References loadTiles().

template<typename Container >
void Gosu::imagesFromTiledBitmap ( Graphics &  graphics,
const Bitmap &  bmp,
int  tileWidth,
int  tileHeight,
bool  tileable,
Container &  appendTo 
)

Convenience function that splits a bitmap into an area of array rectangles and creates images from them.

Parameters:
tileWidthIf positive, specifies the width of one tile in pixels. If negative, the bitmap is divided into -tileWidth rows.
tileHeightSee tileWidth.
appendToSTL container to which the images will be appended. Must provide a push_back member function; std::vector<std::tr1::shared_ptr<Image>> or boost::ptr_vector<Image> are good choices.

Definition at line 113 of file Image.hpp.

References loadTiles().

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

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.

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'. You can rely only on the first two letters being a common language abbreviation.

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

Definition at line 25 of file Platform.hpp.

void Gosu::loadFile ( Buffer &  buffer,
const std::wstring &  filename 
)

Loads a whole file into a buffer.

GOSU_DEPRECATED Reader Gosu::loadFromBMP ( Bitmap &  bmp,
Reader  reader 
)
GOSU_DEPRECATED Reader Gosu::loadFromPNG ( Bitmap &  bmp,
Reader  reader 
)
void Gosu::loadImageFile ( Bitmap &  bitmap,
const std::wstring &  filename 
)

Loads any supported image into a Bitmap.

void Gosu::loadImageFile ( Bitmap &  bitmap,
Reader  input 
)

Loads any supported image into a Bitmap.

std::vector<Gosu::Image> Gosu::loadTiles ( Graphics &  graphics,
const Bitmap &  bmp,
int  tileWidth,
int  tileHeight,
bool  tileable 
)

Referenced by imagesFromTiledBitmap().

std::vector<Gosu::Image> Gosu::loadTiles ( Graphics &  graphics,
const std::wstring &  bmp,
int  tileWidth,
int  tileHeight,
bool  tileable 
)
unsigned long Gosu::milliseconds ( )

Incrementing, possibly wrapping millisecond timer.

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.

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

Converts an std::wstring into an std::string using local encoding.

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

Definition at line 36 of file Platform.hpp.

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

Definition at line 26 of file Platform.hpp.

double Gosu::normalizeAngle ( double  angle)

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

double Gosu::offsetX ( 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.
double Gosu::offsetY ( 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.
bool Gosu::operator!= ( Button  lhs,
Button  rhs 
)

Definition at line 51 of file Input.hpp.

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

Definition at line 172 of file Color.hpp.

References Gosu::Color::gl().

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

Definition at line 55 of file Input.hpp.

References Gosu::Button::id().

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

Definition at line 162 of file Color.hpp.

References Gosu::Color::gl().

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

Tests whether two Buttons identify the same physical button.

Definition at line 47 of file Input.hpp.

References Gosu::Button::id().

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

Definition at line 167 of file Color.hpp.

References Gosu::Color::gl().

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

References pi.

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

References pi.

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.

void Gosu::registerEntity ( const std::wstring &  name,
const Bitmap &  replacement 
)

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

The name is given without & and ;.

std::wstring Gosu::resourcePrefix ( )

Prefix for a program's own resources.

On Windows, the executable's containing directory. On OS X, the application's Resources subdirectory. On Linux, the current directory.

Transform Gosu::rotate ( double  angle,
double  aroundX = 0,
double  aroundY = 0 
)
long Gosu::round ( double  value)

Rounds a real value towards the next integer.

Definition at line 20 of file Math.hpp.

void Gosu::saveFile ( const Buffer &  buffer,
const std::wstring &  filename 
)

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

void Gosu::saveImageFile ( const Bitmap &  bitmap,
const std::wstring &  filename 
)

Saves a Bitmap to a file.

void Gosu::saveImageFile ( const Bitmap &  bitmap,
Gosu::Writer  writer,
const std::wstring &  formatHint = L"png" 
)

Saves a Bitmap to an arbitrary resource.

GOSU_DEPRECATED Writer Gosu::saveToBMP ( const Bitmap &  bmp,
Writer  writer 
)
GOSU_DEPRECATED Writer Gosu::saveToPNG ( const Bitmap &  bmp,
Writer  writer 
)
Transform Gosu::scale ( double  factor)
Transform Gosu::scale ( double  factorX,
double  factorY,
double  fromX = 0,
double  fromY = 0 
)
unsigned Gosu::screenHeight ( )

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

unsigned Gosu::screenWidth ( )

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

std::wstring Gosu::sharedResourcePrefix ( )

Prefix for resources of a group of programs.

On Windows, the executable's containing directory. On OS X, the application's containing subdirectory. On Linux, the current directory.

void Gosu::sleep ( unsigned  milliseconds)

Freezes the current thread for at least the specified time.

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

Returns value * value.

Definition at line 80 of file Math.hpp.

Referenced by distanceSqr().

SocketAddress Gosu::stringToAddress ( const std::string &  s)

Tries to convert a dotted IP4 string into an address suitable for socket functions.

If the string supplied is not such a string, it tries to look up the host via DNS. If both methods fail, zero is returned.

unsigned Gosu::textWidth ( const std::wstring &  text,
const std::wstring &  fontName,
unsigned  fontHeight,
unsigned  fontFlags = 0 
)

Returns the width an unformatted line of text would span on a bitmap if it were drawn using drawText 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.
fontNameName of a system font, or a filename to a TTF file (must contain '/').
Transform Gosu::translate ( double  x,
double  y 
)
long Gosu::trunc ( double  value)

Truncates the fractional part of a real value.

Equivalent to static_cast<long>.

Definition at line 14 of file Math.hpp.

void Gosu::unapplyColorKey ( Bitmap &  bitmap,
Color  background 
)

The reverse of applyColorKey.

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

std::wstring Gosu::userDocsPrefix ( )

Prefix for user documents, e.g.

save games. On Windows, the My Documents folder. On OS X, the user's Documents folder. On Linux, the home directory.

std::wstring Gosu::userSettingsPrefix ( )

Prefix for user settings.

On Windows, the same as APPDATA%. On OS X, the user's Library/Preferences folder. On Linux, the home directory plus a trailing dot for hidden files.

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

Converts an std::string into an std::wstring.

std::wstring Gosu::widen ( const std::string &  s)

Converts an std::string into an std::wstring using local encoding.

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.

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.

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

Converts an std::wstring into an std::string.


Variable Documentation

Constant that can be used as a placeholder for an arbitrary port, e.g.

when starting to listen.

Definition at line 22 of file Sockets.hpp.

class GOSU_DEPRECATED Gosu::Audio

Definition at line 24 of file Audio.hpp.

unsigned const 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 24 of file Graphics.hpp.

const ByteOrder Gosu::nativeByteOrder = boLittle

Definition at line 22 of file IO.hpp.

Definition at line 22 of file IO.hpp.

Referenced by Gosu::Reader::readPod(), and Gosu::Writer::writePod().

const double Gosu::pi = 3.1415926536

Pi.

Definition at line 10 of file Math.hpp.

Referenced by degreesToRadians(), gosuToRadians(), radiansToDegrees(), and radiansToGosu().

GOSU_DEPRECATED const double Gosu::zImmediate = -std::numeric_limits<double>::infinity()

Definition at line 106 of file GraphicsBase.hpp.