00001 #ifndef __VIEWPORT_GL__
00002 #define __VIEWPORT_GL__
00003
00004 #include <QDomDocument>
00005 #include <QDomElement>
00006
00007 namespace apig {
00008
00012 class ViewportGL {
00013 public:
00014 ViewportGL();
00015 ViewportGL(int x, int y, int w, int h) : x(x), y(y), w(w), h(h) {}
00016
00017 void getGL();
00018 void setGL() const;
00019
00020 ViewportGL subViewport(int wSub, int hSub);
00021 ViewportGL subViewport(int margin, float ratio);
00022 ViewportGL subViewport(int margin);
00023
00024 ViewportGL subViewport(ViewportGL relativeView) const;
00025 ViewportGL relativeViewport(ViewportGL view) const;
00026
00027 void setUnitSquare(ViewportGL subView) const;
00028
00029 void pushScreenMatrices() const;
00030 void popScreenMatrices() const;
00031
00032 void drawScreenQuad(bool filled = true, float z = 0) const;
00033
00034
00035 float ratio() const { return float(h) / float(w); }
00036
00037
00038 static void pushFrame2D(float xmin, float xmax, float ymin, float ymax);
00039 static void popFrame2D();
00040
00041 static void push();
00042 static void pop();
00043
00044 QDomElement domElement(const QString &name, QDomDocument &document) const;
00045 void initFromDOMElement(const QDomElement &element);
00046
00047 public:
00048 int x, y, w, h;
00049 };
00050
00051 }
00052
00053 #endif
00054