Graphics.hpp
Go to the documentation of this file.
1 
2 
3 
4 #ifndef GOSU_GRAPHICS_HPP
5 #define GOSU_GRAPHICS_HPP
6 
7 #include <Gosu/Fwd.hpp>
8 #include <Gosu/Color.hpp>
9 #include <Gosu/GraphicsBase.hpp>
10 #include <Gosu/TR1.hpp>
11 #include <memory>
12 
13 namespace Gosu
14 {
16  unsigned screenWidth();
17 
19  unsigned screenHeight();
20 
24  unsigned const MAX_TEXTURE_SIZE = 1024;
25 
26  typedef std::tr1::array<double, 16> Transform;
27  Transform translate(double x, double y);
28  Transform rotate(double angle, double aroundX = 0, double aroundY = 0);
29  Transform scale(double factor);
30  Transform scale(double factorX, double factorY, double fromX = 0, double fromY = 0);
31 
35  class Graphics
36  {
37  struct Impl;
38  const std::auto_ptr<Impl> pimpl;
39 
40  public:
41  Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
42  ~Graphics();
43 
44  // Undocumented until I have thought about this...
45  void setResolution(unsigned virtualWidth, unsigned virtualHeight);
46  // End of Undocumented
47 
48  unsigned width() const;
49  unsigned height() const;
50  bool fullscreen() const;
51 
54  bool begin(Color clearWithColor = Color::BLACK);
56  void end();
59  void flush();
60 
63  void beginGL();
65  void endGL();
72  void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
73 
75  void beginClipping(double x, double y, double width, double height);
77  void endClipping();
78 
80  void beginRecording();
86  std::auto_ptr<Gosu::ImageData> endRecording(int width, int height);
87 
89  void pushTransform(const Transform& transform);
91  void popTransform();
92 
97  void drawLine(double x1, double y1, Color c1,
98  double x2, double y2, Color c2,
99  ZPos z, AlphaMode mode = amDefault);
100 
101  void drawTriangle(double x1, double y1, Color c1,
102  double x2, double y2, Color c2,
103  double x3, double y3, Color c3,
104  ZPos z, AlphaMode mode = amDefault);
105 
106  void drawQuad(double x1, double y1, Color c1,
107  double x2, double y2, Color c2,
108  double x3, double y3, Color c3,
109  double x4, double y4, Color c4,
110  ZPos z, AlphaMode mode = amDefault);
111 
114  std::auto_ptr<ImageData> createImage(const Bitmap& src,
115  unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
116  unsigned borderFlags);
117  };
118 }
119 
120 #endif