Serves as the target of all drawing and provides primitive drawing functionality. More...
Public Member Functions | |
Graphics (unsigned physicalWidth, unsigned physicalHeight, bool fullscreen) | |
~Graphics () | |
void | setResolution (unsigned virtualWidth, unsigned virtualHeight) |
unsigned | width () const |
unsigned | height () const |
bool | fullscreen () const |
bool | begin (Color clearWithColor=Color::BLACK) |
Prepares the graphics object for drawing. | |
void | end () |
Every call to begin must have a matching call to end. | |
void | flush () |
Flushes the Z queue to the screen and starts a new one. | |
void | beginGL () |
Finishes all pending Gosu drawing operations and executes the following OpenGL code in a clean environment. | |
void | endGL () |
Resets Gosu into its default rendering state. | |
void | scheduleGL (const std::tr1::function< void()> &functor, ZPos z) |
(Experimental) Schedules a custom GL functor to be executed at a certain Z level. | |
void | beginClipping (double x, double y, double width, double height) |
Enables clipping to a specified rectangle. | |
void | endClipping () |
Disables clipping. | |
void | beginRecording () |
Starts recording a macro. Cannot be nested. | |
std::auto_ptr< Gosu::ImageData > | endRecording (int width, int height) |
Finishes building the macro and returns it as a drawable object. | |
void | pushTransform (const Transform &transform) |
Pushes one transformation onto the transformation stack. | |
void | popTransform () |
Pops one transformation from the transformation stack. | |
void | drawLine (double x1, double y1, Color c1, double x2, double y2, Color c2, ZPos z, AlphaMode mode=amDefault) |
Draws a line from one point to another (last pixel exclusive). | |
void | drawTriangle (double x1, double y1, Color c1, double x2, double y2, Color c2, double x3, double y3, Color c3, ZPos z, AlphaMode mode=amDefault) |
void | drawQuad (double x1, double y1, Color c1, double x2, double y2, Color c2, double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z, AlphaMode mode=amDefault) |
std::auto_ptr< ImageData > | createImage (const Bitmap &src, unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight, unsigned borderFlags) |
Turns a portion of a bitmap into something that can be drawn on this graphics object. |
Serves as the target of all drawing and provides primitive drawing functionality.
Usually created internally by Gosu::Window.
Definition at line 45 of file Graphics.hpp.
Gosu::Graphics::Graphics | ( | unsigned | physicalWidth, |
unsigned | physicalHeight, | ||
bool | fullscreen | ||
) |
Gosu::Graphics::~Graphics | ( | ) |
bool Gosu::Graphics::begin | ( | Color | clearWithColor = Color::BLACK | ) |
Prepares the graphics object for drawing.
Nothing must be drawn without calling begin.
void Gosu::Graphics::beginClipping | ( | double | x, |
double | y, | ||
double | width, | ||
double | height | ||
) |
Enables clipping to a specified rectangle.
void Gosu::Graphics::beginGL | ( | ) |
Finishes all pending Gosu drawing operations and executes the following OpenGL code in a clean environment.
void Gosu::Graphics::beginRecording | ( | ) |
Starts recording a macro. Cannot be nested.
std::auto_ptr<ImageData> Gosu::Graphics::createImage | ( | const Bitmap & | src, |
unsigned | srcX, | ||
unsigned | srcY, | ||
unsigned | srcWidth, | ||
unsigned | srcHeight, | ||
unsigned | borderFlags | ||
) |
Turns a portion of a bitmap into something that can be drawn on this graphics object.
void Gosu::Graphics::drawLine | ( | double | x1, |
double | y1, | ||
Color | c1, | ||
double | x2, | ||
double | y2, | ||
Color | c2, | ||
ZPos | z, | ||
AlphaMode | mode = amDefault |
||
) |
Draws a line from one point to another (last pixel exclusive).
Note: OpenGL lines are not reliable at all and may have a missing pixel at the start or end point. Please only use this for debugging purposes. Otherwise, use a quad or image to simulate lines, or contribute a better drawLine to Gosu.
void Gosu::Graphics::drawQuad | ( | double | x1, |
double | y1, | ||
Color | c1, | ||
double | x2, | ||
double | y2, | ||
Color | c2, | ||
double | x3, | ||
double | y3, | ||
Color | c3, | ||
double | x4, | ||
double | y4, | ||
Color | c4, | ||
ZPos | z, | ||
AlphaMode | mode = amDefault |
||
) |
void Gosu::Graphics::drawTriangle | ( | double | x1, |
double | y1, | ||
Color | c1, | ||
double | x2, | ||
double | y2, | ||
Color | c2, | ||
double | x3, | ||
double | y3, | ||
Color | c3, | ||
ZPos | z, | ||
AlphaMode | mode = amDefault |
||
) |
void Gosu::Graphics::end | ( | ) |
Every call to begin must have a matching call to end.
void Gosu::Graphics::endClipping | ( | ) |
Disables clipping.
void Gosu::Graphics::endGL | ( | ) |
Resets Gosu into its default rendering state.
std::auto_ptr<Gosu::ImageData> Gosu::Graphics::endRecording | ( | int | width, |
int | height | ||
) |
Finishes building the macro and returns it as a drawable object.
The width and height affect nothing about the recording process, the resulting macro will simply return these values when you ask it. Most usually, the return value is passed to Image::Image().
void Gosu::Graphics::flush | ( | ) |
Flushes the Z queue to the screen and starts a new one.
Useful for games that are *very* composite in nature (splitscreen).
bool Gosu::Graphics::fullscreen | ( | ) | const |
unsigned Gosu::Graphics::height | ( | ) | const |
void Gosu::Graphics::popTransform | ( | ) |
Pops one transformation from the transformation stack.
void Gosu::Graphics::pushTransform | ( | const Transform & | transform | ) |
Pushes one transformation onto the transformation stack.
void Gosu::Graphics::scheduleGL | ( | const std::tr1::function< void()> & | functor, |
ZPos | z | ||
) |
(Experimental) Schedules a custom GL functor to be executed at a certain Z level.
The functor is called in a clean GL context (as given by beginGL/endGL). Gosu's rendering up to the Z level may not yet have been glFlush()ed. Note: You may not call any Gosu rendering functions from within the functor, and you must schedule it from within Window::draw's call tree.
void Gosu::Graphics::setResolution | ( | unsigned | virtualWidth, |
unsigned | virtualHeight | ||
) |
unsigned Gosu::Graphics::width | ( | ) | const |