Graphics.hpp
Go to the documentation of this file.
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         // Undocumented until I have thought about this...
00045         void setResolution(unsigned virtualWidth, unsigned virtualHeight);
00046         // End of Undocumented
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();
00072         void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
00073         
00075         void beginClipping(double x, double y, double width, double height);
00077         void endClipping();
00078         
00080         void beginRecording();
00086         std::auto_ptr<Gosu::ImageData> endRecording(int width, int height);
00087         
00089         void pushTransform(const Transform& transform);
00091         void popTransform();
00092 
00097         void drawLine(double x1, double y1, Color c1,
00098             double x2, double y2, Color c2,
00099             ZPos z, AlphaMode mode = amDefault);
00100 
00101         void drawTriangle(double x1, double y1, Color c1,
00102             double x2, double y2, Color c2,
00103             double x3, double y3, Color c3,
00104             ZPos z, AlphaMode mode = amDefault);
00105 
00106         void drawQuad(double x1, double y1, Color c1,
00107             double x2, double y2, Color c2,
00108             double x3, double y3, Color c3,
00109             double x4, double y4, Color c4,
00110             ZPos z, AlphaMode mode = amDefault);
00111 
00114         std::auto_ptr<ImageData> createImage(const Bitmap& src,
00115             unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
00116             unsigned borderFlags);
00117     };
00118 }
00119 
00120 #endif