OgreViewport.h
Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028 #ifndef __Viewport_H__
    00029 #define __Viewport_H__
    00030
    00031 #include "OgrePrerequisites.h"
    00032 #include "OgreCommon.h"
    00033 #include "OgreColourValue.h"
    00034 #include "OgreFrustum.h"
    00035
    00036 namespace Ogre {
    00056     class _OgreExport Viewport : public ViewportAlloc
    00057     {
    00058     public:
    00060         class _OgreExport Listener
    00061         {
    00062         public:
    00063             virtual ~Listener() {}
    00064
    00066             virtual void viewportCameraChanged(Viewport* viewport) {}
    00067
    00069             virtual void viewportDimensionsChanged(Viewport* viewport) {}
    00070
    00072             virtual void viewportDestroyed(Viewport* viewport) {}
    00073         };
    00074
    00097         Viewport(
    00098             Camera* camera,
    00099             RenderTarget* target,
    00100             Real left, Real top,
    00101             Real width, Real height,
    00102             int ZOrder);
    00103
    00106         virtual ~Viewport();
    00107
    00115         void _updateDimensions(void);
    00116
    00119         void update(void);
    00120
    00133         void clear(unsigned int buffers = FBT_COLOUR | FBT_DEPTH,
    00134                    const ColourValue& colour = ColourValue::Black,
    00135                    Real depth = 1.0f, unsigned short stencil = 0);
    00136
    00139         RenderTarget* getTarget(void) const;
    00140
    00143         Camera* getCamera(void) const;
    00144
    00146         void setCamera(Camera* cam);
    00147
    00149         int getZOrder(void) const;
    00153         Real getLeft(void) const;
    00154
    00158         Real getTop(void) const;
    00159
    00164         Real getWidth(void) const;
    00169         Real getHeight(void) const;
    00174         int getActualLeft(void) const;
    00179         int getActualTop(void) const;
    00183         int getActualWidth(void) const;
    00188         int getActualHeight(void) const;
    00189
    00202         void setDimensions(Real left, Real top, Real width, Real height);
    00203
    00206         void setOrientationMode(OrientationMode orientationMode, bool setDefault = true);
    00207
    00210         OrientationMode getOrientationMode() const;
    00211
    00214         static void setDefaultOrientationMode(OrientationMode orientationMode);
    00215
    00218         static OrientationMode getDefaultOrientationMode();
    00219
    00223         void setBackgroundColour(const ColourValue& colour);
    00224
    00227         const ColourValue& getBackgroundColour(void) const;
    00228
    00232         void setDepthClear( Real depth );
    00233
    00236         Real getDepthClear(void) const;
    00237
    00247         void setClearEveryFrame(bool clear, unsigned int buffers = FBT_COLOUR | FBT_DEPTH);
    00248
    00251         bool getClearEveryFrame(void) const;
    00252
    00254         unsigned int getClearBuffers(void) const;
    00255
    00267         void setAutoUpdated(bool autoupdate);
    00271         bool isAutoUpdated() const;
    00272
    00280         void setMaterialScheme(const String& schemeName)
    00281         { mMaterialSchemeName = schemeName; }
    00282
    00285         const String& getMaterialScheme(void) const
    00286         { return mMaterialSchemeName; }
    00287
    00290         void getActualDimensions(
    00291             int &left, int &top, int &width, int &height ) const;
    00292
    00293         bool _isUpdated(void) const;
    00294         void _clearUpdatedFlag(void);
    00295
    00298         unsigned int _getNumRenderedFaces(void) const;
    00299
    00302         unsigned int _getNumRenderedBatches(void) const;
    00303
    00314         void setOverlaysEnabled(bool enabled);
    00315
    00318         bool getOverlaysEnabled(void) const;
    00319
    00330         void setSkiesEnabled(bool enabled);
    00331
    00334         bool getSkiesEnabled(void) const;
    00335
    00344         void setShadowsEnabled(bool enabled);
    00345
    00348         bool getShadowsEnabled(void) const;
    00349
    00350
    00359         void setVisibilityMask(uint32 mask) { mVisibilityMask = mask; }
    00360
    00364         uint getVisibilityMask(void) const { return mVisibilityMask; }
    00365
    00378         virtual void setRenderQueueInvocationSequenceName(const String& sequenceName);
    00380         virtual const String& getRenderQueueInvocationSequenceName(void) const;
    00382         RenderQueueInvocationSequence* _getRenderQueueInvocationSequence(void);
    00383
    00385         void pointOrientedToScreen(const Vector2 &v, int orientationMode, Vector2 &outv);
    00386         void pointOrientedToScreen(Real orientedX, Real orientedY, int orientationMode,
    00387                                    Real &screenX, Real &screenY);
    00388
    00390         void addListener(Listener* l);
    00392         void removeListener(Listener* l);
    00393
    00394     protected:
    00395         Camera* mCamera;
    00396         RenderTarget* mTarget;
    00397         // Relative dimensions, irrespective of target dimensions (0..1)
    00398         float mRelLeft, mRelTop, mRelWidth, mRelHeight;
    00399         // Actual dimensions, based on target dimensions
    00400         int mActLeft, mActTop, mActWidth, mActHeight;
    00402         int mZOrder;
    00404         ColourValue mBackColour;
    00405         Real mDepthClearValue;
    00406         bool mClearEveryFrame;
    00407         unsigned int mClearBuffers;
    00408         bool mUpdated;
    00409         bool mShowOverlays;
    00410         bool mShowSkies;
    00411         bool mShowShadows;
    00412         uint32 mVisibilityMask;
    00413         // Render queue invocation sequence name
    00414         String mRQSequenceName;
    00415         RenderQueueInvocationSequence* mRQSequence;
    00417         String mMaterialSchemeName;
    00419         OrientationMode mOrientationMode;
    00420         static OrientationMode mDefaultOrientationMode;
    00421
    00423         bool mIsAutoUpdated;
    00424
    00425         typedef vector<Listener*>::type ListenerList;
    00426         ListenerList mListeners;
    00427     };
    00431 }
    00432
    00433 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:24