Merged RenderToTextureStage functionality into RenderStage
This commit is contained in:
@@ -66,6 +66,8 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
ColorMask* getColorMask() { return _colorMask.get(); }
|
||||
|
||||
|
||||
|
||||
|
||||
/** Set the viewport of the camera to use specified osg::Viewport. */
|
||||
void setViewport(osg::Viewport* viewport);
|
||||
|
||||
@@ -192,28 +194,35 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
RenderTargetImplementation getRenderTargetImplmentation() const { return _renderTargetImplementation; }
|
||||
|
||||
|
||||
/** Set the draw buffer for a given fragment output position to specified draw buffer. */
|
||||
void setDrawBuffer(unsigned int pos, GLenum buffer) { _drawBufferList[pos] = buffer; }
|
||||
/** Set the draw buffer used at the start of each frame draw.
|
||||
* Note, a buffer value of GL_NONE is used to sepecify that the rendering back-end should choose the most appropriate buffer.*/
|
||||
void setDrawBuffer(GLenum buffer) { _drawBuffer = buffer; }
|
||||
|
||||
/** Get the draw buffer for a given fragment output position. */
|
||||
GLenum getDrawBuffer(unsigned int pos) const { return _drawBufferList[pos]; }
|
||||
|
||||
typedef std::vector<GLenum> DrawBufferList;
|
||||
/** Get the draw buffer used at the start of each frame draw. */
|
||||
GLenum getDrawBuffer() const { return _drawBuffer; }
|
||||
|
||||
/** Get the list which draw buffer are active. */
|
||||
DrawBufferList& getDrawBufferList() { return _drawBufferList; }
|
||||
|
||||
/** Get the const list which draw buffer are active. */
|
||||
const DrawBufferList& getDrawBufferList() const { return _drawBufferList; }
|
||||
|
||||
|
||||
/** Set the read buffer for any required copy operations to use. */
|
||||
/** Set the read buffer for any required copy operations to use.
|
||||
* Note, a buffer value of GL_NONE is used to sepecify that the rendering back-end should choose the most appropriate buffer.*/
|
||||
void setReadBuffer(GLenum buffer) { _readBuffer = buffer; }
|
||||
|
||||
/** Get the read buffer for any required copy operations to use. */
|
||||
GLenum getReadBuffer() const { return _readBuffer; }
|
||||
|
||||
|
||||
/** Set the render buffer for a given fragment output position to specified draw buffer. */
|
||||
void setRenderBuffer(unsigned int pos, GLenum buffer) { _renderBufferList[pos] = buffer; }
|
||||
|
||||
/** Get the draw buffer for a given fragment output position. */
|
||||
GLenum getRenderBuffer(unsigned int pos) const { return _renderBufferList[pos]; }
|
||||
|
||||
typedef std::vector<GLenum> RenderBufferList;
|
||||
|
||||
/** Get the list which draw buffer are active. */
|
||||
RenderBufferList& getRenderBufferList() { return _renderBufferList; }
|
||||
|
||||
/** Get the const list which draw buffer are active. */
|
||||
const RenderBufferList& getRenderBufferList() const { return _renderBufferList; }
|
||||
|
||||
enum BufferComponent
|
||||
{
|
||||
DEPTH_BUFFER,
|
||||
@@ -318,7 +327,7 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
|
||||
Vec4 _clearColor;
|
||||
GLbitfield _clearMask;
|
||||
ref_ptr<ColorMask> _colorMask;
|
||||
ref_ptr<ColorMask> _colorMask;
|
||||
ref_ptr<Viewport> _viewport;
|
||||
|
||||
TransformOrder _transformOrder;
|
||||
@@ -327,8 +336,9 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
|
||||
RenderOrder _renderOrder;
|
||||
|
||||
DrawBufferList _drawBufferList;
|
||||
GLenum _drawBuffer;
|
||||
GLenum _readBuffer;
|
||||
RenderBufferList _renderBufferList;
|
||||
|
||||
RenderTargetImplementation _renderTargetImplementation;
|
||||
BufferAttachmentMap _bufferAttachmentMap;
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
#include <osg/ColorMask>
|
||||
#include <osg/Viewport>
|
||||
#include <osg/Texture>
|
||||
#include <osg/FrameBufferObject>
|
||||
#include <osg/CameraNode>
|
||||
|
||||
#include <osgUtil/RenderBin>
|
||||
#include <osgUtil/RenderStageLighting>
|
||||
@@ -49,6 +52,19 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
virtual void reset();
|
||||
|
||||
|
||||
/** Set the draw buffer used at the start of each frame draw. */
|
||||
void setDrawBuffer(GLenum buffer) { _drawBuffer = buffer; }
|
||||
|
||||
/** Get the draw buffer used at the start of each frame draw. */
|
||||
GLenum getDrawBuffer() const { return _drawBuffer; }
|
||||
|
||||
/** Set the read buffer for any required copy operations to use. */
|
||||
void setReadBuffer(GLenum buffer) { _readBuffer = buffer; }
|
||||
|
||||
/** Get the read buffer for any required copy operations to use. */
|
||||
GLenum getReadBuffer() const { return _readBuffer; }
|
||||
|
||||
|
||||
/** Set the viewport.*/
|
||||
void setViewport(osg::Viewport* viewport) { _viewport = viewport; }
|
||||
|
||||
@@ -58,8 +74,6 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
/** Get the viewport. */
|
||||
osg::Viewport* getViewport() { return _viewport.get(); }
|
||||
|
||||
|
||||
|
||||
/** Set the clear mask used in glClear(..).
|
||||
* Defaults to GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. */
|
||||
void setClearMask(GLbitfield mask) { _clearMask = mask; }
|
||||
@@ -105,6 +119,34 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
/** Get the clear color.*/
|
||||
int getClearStencil() const { return _clearStencil; }
|
||||
|
||||
|
||||
void setCameraNode(const osg::CameraNode* camera) { _camera = camera; }
|
||||
const osg::CameraNode* getCameraNode() const { return _camera; }
|
||||
|
||||
void setTexture(osg::Texture* texture, unsigned int level = 0, unsigned int face=0) { _texture = texture; _level = level; _face = face; }
|
||||
osg::Texture* getTexture() { return _texture.get(); }
|
||||
|
||||
void setImage(osg::Image* image) { _image = image; }
|
||||
osg::Image* getImage() { return _image.get(); }
|
||||
|
||||
void setImageReadPixelFormat(GLenum format) { _imageReadPixelFormat = format; }
|
||||
GLenum getImageReadPixelFormat() const { return _imageReadPixelFormat; }
|
||||
|
||||
void setImageReadPixelDataType(GLenum type) { _imageReadPixelDataType = type; }
|
||||
GLenum getImageReadPixelDataType() const { return _imageReadPixelDataType; }
|
||||
|
||||
|
||||
void setFrameBufferObject(osg::FrameBufferObject* fbo) { _fbo = fbo; }
|
||||
osg::FrameBufferObject* getFrameBufferObject() { return _fbo.get(); }
|
||||
const osg::FrameBufferObject* getFrameBufferObject() const { return _fbo.get(); }
|
||||
|
||||
void setGraphicsContext(osg::GraphicsContext* context) { _graphicsContext = context; }
|
||||
osg::GraphicsContext* getGraphicsContext() { return _graphicsContext.get(); }
|
||||
const osg::GraphicsContext* getGraphicsContext() const { return _graphicsContext.get(); }
|
||||
|
||||
|
||||
|
||||
|
||||
void setInheritedRenderStageLightingMatrix(const osg::Matrix& matrix) { _inheritedRenderStageLightingMatrix = matrix; }
|
||||
const osg::Matrix& getInheritedRenderStageLightingMatrix() const { return _inheritedRenderStageLightingMatrix; }
|
||||
|
||||
@@ -158,6 +200,8 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
// viewport x,y,width,height.
|
||||
osg::ref_ptr<osg::Viewport> _viewport;
|
||||
|
||||
GLenum _drawBuffer;
|
||||
GLenum _readBuffer;
|
||||
GLbitfield _clearMask;
|
||||
osg::ref_ptr<osg::ColorMask> _colorMask;
|
||||
osg::Vec4 _clearColor;
|
||||
@@ -165,6 +209,19 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
double _clearDepth;
|
||||
int _clearStencil;
|
||||
|
||||
const osg::CameraNode* _camera;
|
||||
|
||||
osg::ref_ptr<osg::Texture> _texture;
|
||||
unsigned int _level;
|
||||
unsigned int _face;
|
||||
|
||||
osg::ref_ptr<osg::Image> _image;
|
||||
GLenum _imageReadPixelFormat;
|
||||
GLenum _imageReadPixelDataType;
|
||||
|
||||
osg::ref_ptr<osg::FrameBufferObject> _fbo;
|
||||
osg::ref_ptr<osg::GraphicsContext> _graphicsContext;
|
||||
|
||||
mutable osg::Matrix _inheritedRenderStageLightingMatrix;
|
||||
mutable osg::ref_ptr<RenderStageLighting> _inheritedRenderStageLighting;
|
||||
mutable osg::ref_ptr<RenderStageLighting> _renderStageLighting;
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGUTIL_RENDERTOTEXTURESTAGE
|
||||
#define OSGUTIL_RENDERTOTEXTURESTAGE 1
|
||||
|
||||
#include <osg/Texture>
|
||||
#include <osg/FrameBufferObject>
|
||||
#include <osg/CameraNode>
|
||||
|
||||
#include <osgUtil/RenderStage>
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
/**
|
||||
* RenderStage which copies the final image to an attached texture or image.
|
||||
* Generally used as a pre-rendering stage.
|
||||
*/
|
||||
class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
RenderToTextureStage();
|
||||
|
||||
|
||||
virtual osg::Object* cloneType() const { return new RenderToTextureStage(); }
|
||||
virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderToTextureStage(); } // note only implements a clone of type.
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderToTextureStage*>(obj)!=0L; }
|
||||
virtual const char* libraryName() const { return "osgUtil"; }
|
||||
virtual const char* className() const { return "RenderToTextureStage"; }
|
||||
|
||||
virtual void reset();
|
||||
|
||||
void setCameraNode(const osg::CameraNode* camera) { _camera = camera; }
|
||||
const osg::CameraNode* getCameraNode() const { return _camera; }
|
||||
|
||||
void setTexture(osg::Texture* texture, unsigned int level = 0, unsigned int face=0) { _texture = texture; _level = level; _face = face; }
|
||||
osg::Texture* getTexture() { return _texture.get(); }
|
||||
|
||||
void setImage(osg::Image* image) { _image = image; }
|
||||
osg::Image* getImage() { return _image.get(); }
|
||||
|
||||
void setImageReadPixelFormat(GLenum format) { _imageReadPixelFormat = format; }
|
||||
GLenum getImageReadPixelFormat() const { return _imageReadPixelFormat; }
|
||||
|
||||
void setImageReadPixelDataType(GLenum type) { _imageReadPixelDataType = type; }
|
||||
GLenum getImageReadPixelDataType() const { return _imageReadPixelDataType; }
|
||||
|
||||
|
||||
void setFrameBufferObject(osg::FrameBufferObject* fbo) { _fbo = fbo; }
|
||||
osg::FrameBufferObject* getFrameBufferObject() { return _fbo.get(); }
|
||||
const osg::FrameBufferObject* getFrameBufferObject() const { return _fbo.get(); }
|
||||
|
||||
void setGraphicsContext(osg::GraphicsContext* context) { _graphicsContext = context; }
|
||||
osg::GraphicsContext* getGraphicsContext() { return _graphicsContext.get(); }
|
||||
const osg::GraphicsContext* getGraphicsContext() const { return _graphicsContext.get(); }
|
||||
|
||||
virtual void draw(osg::State& state,RenderLeaf*& previous);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~RenderToTextureStage();
|
||||
|
||||
const osg::CameraNode* _camera;
|
||||
|
||||
osg::ref_ptr<osg::Texture> _texture;
|
||||
unsigned int _level;
|
||||
unsigned int _face;
|
||||
|
||||
osg::ref_ptr<osg::Image> _image;
|
||||
GLenum _imageReadPixelFormat;
|
||||
GLenum _imageReadPixelDataType;
|
||||
|
||||
osg::ref_ptr<osg::FrameBufferObject> _fbo;
|
||||
osg::ref_ptr<osg::GraphicsContext> _graphicsContext;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user