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 #ifdef GOSU_IS_MAC
00027
00028
00029
00030
00031 struct Transform
00032 {
00033 double value[16];
00034 bool operator==(const Transform &other) { for (int i = 0; i < 16; ++i) if ((*this)[i] != other[i]) return false; return true; }
00035 const double &operator[](std::size_t idx) const { return value[idx]; }
00036 double &operator[](std::size_t idx) { return value[idx]; }
00037 };
00038 #else
00039 typedef std::tr1::array<double, 16> Transform;
00040 #endif
00041 Transform translate(double x, double y);
00042 Transform rotate(double angle, double aroundX = 0, double aroundY = 0);
00043 Transform scale(double factor);
00044 Transform scale(double factorX, double factorY, double fromX = 0, double fromY = 0);
00045
00049 class Graphics
00050 {
00051 struct Impl;
00052 const std::auto_ptr<Impl> pimpl;
00053
00054 public:
00055 Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
00056 ~Graphics();
00057
00058
00059 void setResolution(unsigned virtualWidth, unsigned virtualHeight);
00060
00061
00062 unsigned width() const;
00063 unsigned height() const;
00064 bool fullscreen() const;
00065
00068 bool begin(Color clearWithColor = Color::BLACK);
00070 void end();
00073 void flush();
00074
00077 void beginGL();
00079 void endGL();
00086 void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
00087
00089 void beginClipping(double x, double y, double width, double height);
00091 void endClipping();
00092
00094 void beginRecording();
00100 std::auto_ptr<Gosu::ImageData> endRecording(int width, int height);
00101
00103 void pushTransform(const Transform& transform);
00105 void popTransform();
00106
00111 void drawLine(double x1, double y1, Color c1,
00112 double x2, double y2, Color c2,
00113 ZPos z, AlphaMode mode = amDefault);
00114
00115 void drawTriangle(double x1, double y1, Color c1,
00116 double x2, double y2, Color c2,
00117 double x3, double y3, Color c3,
00118 ZPos z, AlphaMode mode = amDefault);
00119
00120 void drawQuad(double x1, double y1, Color c1,
00121 double x2, double y2, Color c2,
00122 double x3, double y3, Color c3,
00123 double x4, double y4, Color c4,
00124 ZPos z, AlphaMode mode = amDefault);
00125
00128 std::auto_ptr<ImageData> createImage(const Bitmap& src,
00129 unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
00130 unsigned borderFlags);
00131 };
00132 }
00133
00134 #endif