Ported all the render to texture examples across to using the new osg::CameraNode.

Added support for texture cube maps in FBO + CameraNode.
This commit is contained in:
Robert Osfield
2005-07-19 16:30:55 +00:00
parent 5c9bd792a3
commit 8dd013171c
23 changed files with 786 additions and 709 deletions

View File

@@ -16,6 +16,7 @@
#include <osg/Transform>
#include <osg/Viewport>
#include <osg/ColorMask>
#include <osg/CullSettings>
#include <osg/Texture>
#include <osg/Image>
@@ -37,32 +38,45 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
META_Node(osg, CameraNode);
/** Sets the clear color. */
inline void setClearColor(const Vec4& color) { _clearColor = color; }
/** Set the viewport of the scene view to use specified osg::Viewport. */
void setViewport(osg::Viewport* viewport)
{
_viewport = viewport;
}
/** Returns the clear color. */
inline const Vec4& getClearColor() const { return _clearColor; }
/** Set the clear mask used in glClear(..).
* Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
inline void setClearMask(GLbitfield mask) { _clearMask = mask; }
/** Set the viewport of the scene view to specified dimensions. */
void setViewport(int x,int y,int width,int height)
{
if (!_viewport) _viewport = new osg::Viewport;
_viewport->setViewport(x,y,width,height);
}
/** Get the clear mask.*/
inline GLbitfield getClearMask() const { return _clearMask; }
/** Set the color mask of the camera to use specified osg::ColorMask. */
void setColorMask(osg::ColorMask* colorMask);
/** Set the color mask of the camera to specified values. */
void setColorMask(bool red, bool green, bool blue, bool alpha);
/** Get the const ColorMask. */
const ColorMask* getColorMask() const { return _colorMask.get(); }
/** Get the ColorMask. */
ColorMask* getColorMask() { return _colorMask.get(); }
/** Set the viewport of the camera to use specified osg::Viewport. */
void setViewport(osg::Viewport* viewport);
/** Set the viewport of the camera to specified dimensions. */
void setViewport(int x,int y,int width,int height);
/** Get the const viewport. */
const Viewport* getViewport() const { return _viewport.get(); }
/** Get the viewport. */
Viewport* getViewport() { return _viewport.get(); }
/** Get the viewport of the scene view. */
void getViewport(int& x,int& y,int& width,int& height) const
{
if (_viewport.valid()) _viewport->getViewport(x,y,width,height);
}
enum TransformOrder
{
@@ -149,22 +163,6 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
/** Get the inverse view matrix.*/
Matrixd getInverseViewMatrix() const;
/** Sets the clear color. */
inline void setClearColor(const Vec4& color) { _clearColor = color; }
/** Returns the clear color. */
inline const Vec4& getClearColor() const { return _clearColor; }
/** Set the clear mask used in glClear(..).
* Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
inline void setClearMask(GLbitfield mask) { _clearMask = mask; }
/** Get the clear mask.*/
inline GLbitfield getClearMask() const { return _clearMask; }
enum RenderOrder
{
@@ -276,6 +274,7 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
Vec4 _clearColor;
GLbitfield _clearMask;
ref_ptr<ColorMask> _colorMask;
ref_ptr<Viewport> _viewport;
TransformOrder _transformOrder;

View File

@@ -19,6 +19,7 @@
#include <osg/GL>
#include <osg/Texture>
#include <osg/buffered_value>
#include <osg/CameraNode>
#ifndef GL_EXT_framebuffer_object
#define GL_EXT_framebuffer_object 1
@@ -256,6 +257,7 @@ namespace osg
explicit FrameBufferAttachment(Texture3D* target, int zoffset, int level = 0);
explicit FrameBufferAttachment(TextureCubeMap* target, int face, int level = 0);
explicit FrameBufferAttachment(TextureRectangle* target);
explicit FrameBufferAttachment(CameraNode::Attachment& attachment);
~FrameBufferAttachment();

View File

@@ -25,7 +25,12 @@ class OSG_EXPORT FrontFace : public StateAttribute
{
public :
FrontFace();
enum Mode {
CLOCKWISE = GL_CW,
COUNTER_CLOCKWISE = GL_CCW
};
FrontFace(Mode face=COUNTER_CLOCKWISE);
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
FrontFace(const FrontFace& ff,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
@@ -46,11 +51,6 @@ class OSG_EXPORT FrontFace : public StateAttribute
return 0; // passed all the above comparison macro's, must be equal.
}
enum Mode {
CLOCKWISE = GL_CW,
COUNTER_CLOCKWISE = GL_CCW
};
inline void setMode(Mode mode) { _mode = mode; }
inline Mode getMode() const { return _mode; }

View File

@@ -105,6 +105,12 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
/** Get the clear color.*/
int getClearStencil() const { return _clearStencil; }
void setInheritedRenderStageLightingMatrix(const osg::Matrix& matrix) { _inheritedRenderStageLightingMatrix = matrix; }
const osg::Matrix& getInheritedRenderStageLightingMatrix() const { return _inheritedRenderStageLightingMatrix; }
void setInheritedRenderStageLighting(RenderStageLighting* rsl) { _inheritedRenderStageLighting = rsl; }
RenderStageLighting* getInheritedRenderStageLighting() { return _inheritedRenderStageLighting.get(); }
void setRenderStageLighting(RenderStageLighting* rsl) { _renderStageLighting = rsl; }
RenderStageLighting* getRenderStageLighting() const
@@ -159,6 +165,8 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
double _clearDepth;
int _clearStencil;
mutable osg::Matrix _inheritedRenderStageLightingMatrix;
mutable osg::ref_ptr<RenderStageLighting> _inheritedRenderStageLighting;
mutable osg::ref_ptr<RenderStageLighting> _renderStageLighting;

View File

@@ -54,7 +54,7 @@ class OSGUTIL_EXPORT RenderStageLighting : public osg::Object
_texAttrListMap[textureUnit].push_back(AttrMatrixPair(attr,matrix));
}
virtual void draw(osg::State& state,RenderLeaf*& previous);
virtual void draw(osg::State& state,RenderLeaf*& previous, const osg::Matrix* postMultMatrix = 0);
public: