| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include "BsViewport.h"
- #include "BsException.h"
- #include "BsRenderTarget.h"
- #include "BsMath.h"
- #include "BsRenderSystem.h"
- namespace BansheeEngine
- {
- const Color Viewport::DEFAULT_CLEAR_COLOR = Color(143.0f / 255.0f, 111.0f / 255.0f, 0);
- Viewport::Viewport()
- :mTarget(nullptr), mClearColor(DEFAULT_CLEAR_COLOR), mRequiresColorClear(true), mRequiresDepthClear(true),
- mRequiresStencilClear(false), mStencilClearValue(0), mDepthClearValue(1.0f)
- {
- updateArea();
- }
- Viewport::Viewport(const RenderTargetPtr& target, float x, float y, float width, float height)
- :mTarget(target), mNormArea(x, y, width, height), mClearColor(DEFAULT_CLEAR_COLOR), mRequiresColorClear(true),
- mRequiresDepthClear(true), mRequiresStencilClear(false), mStencilClearValue(0), mDepthClearValue(1.0f)
- {
- updateArea();
- }
- Viewport::~Viewport()
- { }
- void Viewport::targetResized()
- {
- updateArea();
- }
- void Viewport::updateArea()
- {
- if(mTarget != nullptr)
- {
- float height = (float) mTarget->getHeight();
- float width = (float) mTarget->getWidth();
- mArea.x = (int) (mNormArea.x * width);
- mArea.y = (int) (mNormArea.y * height);
- mArea.width = (int) (mNormArea.width * width);
- mArea.height = (int) (mNormArea.height * height);
- }
- }
- void Viewport::setArea(float x, float y, float width, float height)
- {
- mNormArea.x = x;
- mNormArea.y = y;
- mNormArea.width = width;
- mNormArea.height = height;
- updateArea();
- }
- void Viewport::setRequiresClear(bool colorClear, bool depthClear, bool stencilClear)
- {
- mRequiresColorClear = colorClear;
- mRequiresDepthClear = depthClear;
- mRequiresStencilClear = stencilClear;
- }
- void Viewport::setClearValues(const Color& clearColor, float clearDepth, UINT16 clearStencil)
- {
- mClearColor = clearColor;
- mDepthClearValue = clearDepth;
- mStencilClearValue = clearStencil;
- }
- Viewport Viewport::clone()
- {
- return *this;
- }
- }
|