00001
00002
00003
00004 #ifndef GOSU_GRAPHICS_HPP
00005 #define GOSU_GRAPHICS_HPP
00006
00007 #include <Gosu/Fwd.hpp>
00008 #include <Gosu/Color.hpp>
00009 #include <Gosu/GraphicsBase.hpp>
00010 #include <Gosu/TR1.hpp>
00011 #include <memory>
00012
00013 namespace Gosu
00014 {
00016 unsigned screenWidth();
00017
00019 unsigned screenHeight();
00020
00024 unsigned const MAX_TEXTURE_SIZE = 1024;
00025
00026 typedef std::tr1::array<double, 16> Transform;
00027 Transform translate(double x, double y);
00028 Transform rotate(double angle, double aroundX = 0, double aroundY = 0);
00029 Transform scale(double factor);
00030 Transform scale(double factorX, double factorY, double fromX = 0, double fromY = 0);
00031
00035 class Graphics
00036 {
00037 struct Impl;
00038 const std::auto_ptr<Impl> pimpl;
00039
00040 public:
00041 Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
00042 ~Graphics();
00043
00044
00045 void setResolution(unsigned virtualWidth, unsigned virtualHeight);
00046
00047
00048 unsigned width() const;
00049 unsigned height() const;
00050 bool fullscreen() const;
00051
00054 bool begin(Color clearWithColor = Color::BLACK);
00056 void end();
00059 void flush();
00060
00063 void beginGL();
00065 void endGL();
00074 void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
00075
00077 void beginClipping(double x, double y, double width, double height);
00079 void endClipping();
00080
00082 void beginRecording();
00085 std::auto_ptr<Gosu::ImageData> endRecording();
00086
00088 void pushTransform(const Transform& transform);
00090 void popTransform();
00091
00093 void drawLine(double x1, double y1, Color c1,
00094 double x2, double y2, Color c2,
00095 ZPos z, AlphaMode mode = amDefault);
00096
00097 void drawTriangle(double x1, double y1, Color c1,
00098 double x2, double y2, Color c2,
00099 double x3, double y3, Color c3,
00100 ZPos z, AlphaMode mode = amDefault);
00101
00102 void drawQuad(double x1, double y1, Color c1,
00103 double x2, double y2, Color c2,
00104 double x3, double y3, Color c3,
00105 double x4, double y4, Color c4,
00106 ZPos z, AlphaMode mode = amDefault);
00107
00110 std::auto_ptr<ImageData> createImage(const Bitmap& src,
00111 unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
00112 unsigned borderFlags);
00113 };
00114 }
00115
00116 #endif