| 1 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield |
|---|
| 2 | * |
|---|
| 3 | * This library is open source and may be redistributed and/or modified under |
|---|
| 4 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
|---|
| 5 | * (at your option) any later version. The full license is in LICENSE file |
|---|
| 6 | * included with this distribution, and on the openscenegraph.org website. |
|---|
| 7 | * |
|---|
| 8 | * This library is distributed in the hope that it will be useful, |
|---|
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | * OpenSceneGraph Public License for more details. |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | #ifndef OSG_RENDERINFO |
|---|
| 15 | #define OSG_RENDERINFO 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/State> |
|---|
| 18 | #include <osg/View> |
|---|
| 19 | |
|---|
| 20 | namespace osg { |
|---|
| 21 | |
|---|
| 22 | class RenderInfo |
|---|
| 23 | { |
|---|
| 24 | public: |
|---|
| 25 | |
|---|
| 26 | RenderInfo(): |
|---|
| 27 | _view(0) {} |
|---|
| 28 | |
|---|
| 29 | RenderInfo(const RenderInfo& rhs): |
|---|
| 30 | _state(rhs._state), |
|---|
| 31 | _view(rhs._view), |
|---|
| 32 | _cameras(rhs._cameras), |
|---|
| 33 | _userData(rhs._userData) {} |
|---|
| 34 | |
|---|
| 35 | RenderInfo(State* state, View* view): |
|---|
| 36 | _state(state), |
|---|
| 37 | _view(view) {} |
|---|
| 38 | |
|---|
| 39 | RenderInfo& operator = (const RenderInfo& rhs) |
|---|
| 40 | { |
|---|
| 41 | _state = rhs._state; |
|---|
| 42 | _view = rhs._view; |
|---|
| 43 | _cameras = rhs._cameras; |
|---|
| 44 | _userData = rhs._userData; |
|---|
| 45 | return *this; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | unsigned int getContextID() const { return _state.valid() ? _state->getContextID() : 0; } |
|---|
| 49 | |
|---|
| 50 | void setState(State* state) { _state = state; } |
|---|
| 51 | State* getState() { return _state.get(); } |
|---|
| 52 | const State* getState() const { return _state.get(); } |
|---|
| 53 | |
|---|
| 54 | void setView(View* view) { _view = view; } |
|---|
| 55 | View* getView() { return _view; } |
|---|
| 56 | const View* getView() const { return _view; } |
|---|
| 57 | |
|---|
| 58 | void pushCamera(Camera* camera) { _cameras.push_back(camera); } |
|---|
| 59 | void popCamera() { if (!_cameras.empty()) _cameras.pop_back(); } |
|---|
| 60 | |
|---|
| 61 | Camera* getCurrentCamera() { return _cameras.empty() ? 0 : _cameras.back(); } |
|---|
| 62 | |
|---|
| 63 | void setUserData(Referenced* userData) { _userData = userData; } |
|---|
| 64 | Referenced* getUserData() { return _userData.get(); } |
|---|
| 65 | const Referenced* getUserData() const { return _userData.get(); } |
|---|
| 66 | |
|---|
| 67 | protected: |
|---|
| 68 | |
|---|
| 69 | typedef std::vector<Camera*> Cameras; |
|---|
| 70 | |
|---|
| 71 | ref_ptr<State> _state; |
|---|
| 72 | View* _view; |
|---|
| 73 | Cameras _cameras; |
|---|
| 74 | ref_ptr<Referenced> _userData; |
|---|
| 75 | }; |
|---|
| 76 | |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | #endif |
|---|