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 public:
00054 virtual const char* className() { return "vl::Viewport"; }
00055 Viewport();
00056 Viewport(int x, int y, int w, int h);
00057
00058 void activate() const;
00059
00060 bool null() { return mWidth == 0 || mHeight == 0; }
00061
00062 void set(int x, int y, int w, int h) { mX = x; mY = y; mWidth = w; mHeight = h; }
00063 void setX(int x) { mX = x; }
00064 int x() const { return mX; }
00065 void setY(int y) { mY = y; }
00066 int y() const { return mY; }
00067 void setWidth(int width) { mWidth = width; }
00068 int width() const { return mWidth; }
00069 void setHeight(int height) { mHeight = height; }
00070 int height() const { return mHeight; }
00071 fvec2 center() const { return fvec2(mX + mWidth / 2.0f, mY + mHeight / 2.0f); }
00072
00076 RectI rect() const { return RectI(x(),y(),width(),height()); }
00077
00078 void setClearColor(float r, float g, float b, float a) { mClearColor = fvec4(r,g,b,a); }
00079 void setClearColor(const fvec4& color) { mClearColor = color; }
00080 const fvec4& clearColor() const { return mClearColor; }
00081
00082 void setClearColorInt(int r, int g, int b, int a) { mClearColorInt = ivec4(r,g,b,a); }
00083 void setClearColorInt(const ivec4& color) { mClearColorInt = color; }
00084 const ivec4& clearColorInt() const { return mClearColorInt; }
00085
00086 void setClearColorUInt(unsigned int r, unsigned int g, unsigned int b, unsigned int a) { mClearColorUInt = uvec4(r,g,b,a); }
00087 void setClearColorUInt(const uvec4& color) { mClearColorUInt = color; }
00088 const uvec4& clearColorUInt() const { return mClearColorUInt; }
00089
00090 void setClearStencil(int stencil) { mClearStencil = stencil; }
00091 int clearStencil() const { return mClearStencil; }
00092
00093 void setClearDepth(Real depth) { mClearDepth = depth; }
00094 Real clearDepth() const { return mClearDepth; }
00095
00096 void setClearFlags(EClearFlags clear_flags) { mClearFlags = clear_flags; }
00097 EClearFlags clearFlags() const { return mClearFlags; }
00098
00099 void setClearColorMode(EClearColorMode mode) { mClearColorMode = mode; }
00100 EClearColorMode clearColorMode() const { return mClearColorMode; }
00101
00105 bool isPointInside(int x, int y, int render_target_height) const;
00106
00107 protected:
00108 fvec4 mClearColor;
00109 ivec4 mClearColorInt;
00110 uvec4 mClearColorUInt;
00111
00112 Real mClearDepth;
00113 int mClearStencil;
00114 EClearFlags mClearFlags;
00115 EClearColorMode mClearColorMode;
00116 int mX;
00117 int mY;
00118 int mWidth;
00119 int mHeight;
00120 };
00121 }
00122
00123 #endif