Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef Viewport_INCLUDE_ONCE
00033 #define Viewport_INCLUDE_ONCE
00034
00035 #include <vlCore/Object.hpp>
00036 #include <vlCore/Rect.hpp>
00037 #include <vlCore/Vector4.hpp>
00038 #include <vlCore/vlnamespace.hpp>
00039 #include <vlGraphics/link_config.hpp>
00040
00041 namespace vl
00042 {
00043
00044
00045
00051 class VLGRAPHICS_EXPORT Viewport: public Object
00052 {
00053 VL_INSTRUMENT_CLASS(vl::Viewport, Object)
00054
00055 public:
00056 Viewport();
00057 Viewport(int x, int y, int w, int h);
00058
00059 void activate() const;
00060
00061 bool null() { return mWidth == 0 || mHeight == 0; }
00062
00063 void set(int x, int y, int w, int h) { mX = x; mY = y; mWidth = w; mHeight = h; }
00064 void setX(int x) { mX = x; }
00065 int x() const { return mX; }
00066 void setY(int y) { mY = y; }
00067 int y() const { return mY; }
00068 void setWidth(int width) { mWidth = width; }
00069 int width() const { return mWidth; }
00070 void setHeight(int height) { mHeight = height; }
00071 int height() const { return mHeight; }
00072 fvec2 center() const { return fvec2(mX + mWidth / 2.0f, mY + mHeight / 2.0f); }
00073
00077 RectI rect() const { return RectI(x(),y(),width(),height()); }
00078
00079 void setClearColor(float r, float g, float b, float a) { mClearColor = fvec4(r,g,b,a); }
00080 void setClearColor(const fvec4& color) { mClearColor = color; }
00081 const fvec4& clearColor() const { return mClearColor; }
00082
00083 void setClearColorInt(int r, int g, int b, int a) { mClearColorInt = ivec4(r,g,b,a); }
00084 void setClearColorInt(const ivec4& color) { mClearColorInt = color; }
00085 const ivec4& clearColorInt() const { return mClearColorInt; }
00086
00087 void setClearColorUInt(unsigned int r, unsigned int g, unsigned int b, unsigned int a) { mClearColorUInt = uvec4(r,g,b,a); }
00088 void setClearColorUInt(const uvec4& color) { mClearColorUInt = color; }
00089 const uvec4& clearColorUInt() const { return mClearColorUInt; }
00090
00091 void setClearStencil(int stencil) { mClearStencil = stencil; }
00092 int clearStencil() const { return mClearStencil; }
00093
00094 void setClearDepth(real depth) { mClearDepth = depth; }
00095 real clearDepth() const { return mClearDepth; }
00096
00098 void setClearFlags(EClearFlags clear_flags) { mClearFlags = clear_flags; }
00099 EClearFlags clearFlags() const { return mClearFlags; }
00100
00101 void setClearColorMode(EClearColorMode mode) { mClearColorMode = mode; }
00102 EClearColorMode clearColorMode() const { return mClearColorMode; }
00103
00107 bool isPointInside(int x, int y, int framebuffer_height) const;
00108
00109 protected:
00110 fvec4 mClearColor;
00111 ivec4 mClearColorInt;
00112 uvec4 mClearColorUInt;
00113
00114 real mClearDepth;
00115 int mClearStencil;
00116 EClearFlags mClearFlags;
00117 EClearColorMode mClearColorMode;
00118 int mX;
00119 int mY;
00120 int mWidth;
00121 int mHeight;
00122 };
00123 }
00124
00125 #endif