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
00096 void drawLine(double x1, double y1, Color c1,
00097 double x2, double y2, Color c2,
00098 ZPos z, AlphaMode mode = amDefault);
00099
00100 void drawTriangle(double x1, double y1, Color c1,
00101 double x2, double y2, Color c2,
00102 double x3, double y3, Color c3,
00103 ZPos z, AlphaMode mode = amDefault);
00104
00105 void drawQuad(double x1, double y1, Color c1,
00106 double x2, double y2, Color c2,
00107 double x3, double y3, Color c3,
00108 double x4, double y4, Color c4,
00109 ZPos z, AlphaMode mode = amDefault);
00110
00113 std::auto_ptr<ImageData> createImage(const Bitmap& src,
00114 unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
00115 unsigned borderFlags);
00116 };
00117 }
00118
00119 #endif