OsgRenderTarget.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_OSGRENDERTARGET_H
#define SURGSIM_GRAPHICS_OSGRENDERTARGET_H
#include <memory>
#include <unordered_map>
#include "SurgSim/Graphics/RenderTarget.h"
#include "SurgSim/Graphics/OsgTexture.h"
#include "SurgSim/Graphics/OsgTexture2d.h"
#include "SurgSim/Graphics/OsgTextureRectangle.h"
#include <osg/FrameBufferObject>
namespace SurgSim
{
namespace Graphics
{
class OsgAbstractRenderTarget : public RenderTarget
{
virtual std::shared_ptr<OsgTexture> getColorTargetOsg(int index) const = 0;
virtual std::shared_ptr<OsgTexture> getDepthTargetOsg() const = 0;
};
template <class T>
class OsgRenderTarget : public OsgAbstractRenderTarget
{
public:
typedef T TextureType;
OsgRenderTarget();
OsgRenderTarget(int width, int height, double scale = 1.0,
int colorCount = 0, bool useDepth = false);
~OsgRenderTarget();
void getSize(int* width, int* height) const override;
int getColorTargetCount() const override;
std::shared_ptr<Texture> getColorTarget(int index) const override;
std::shared_ptr<OsgTexture> getColorTargetOsg(int index) const;
bool doesUseDepthTarget() const override;
std::shared_ptr<Texture> getDepthTarget() const override;
std::shared_ptr<OsgTexture> getDepthTargetOsg() const;
private:
enum TargetTypes {
TARGETTYPE_DEPTH = 0,
TARGETTYPE_COLORBASE = 1
};
int m_width;
int m_height;
int m_colorTargetCount;
std::vector<std::shared_ptr<TextureType>> m_textures;
int setColorTargetCount(int count);
void useDepthTarget(bool val);
void setupTexture(int type);
};
typedef OsgRenderTarget<OsgTexture2d> OsgRenderTarget2d;
typedef OsgRenderTarget<OsgTextureRectangle> OsgRenderTargetRectangle;
}; // Graphics
}; // SurgSim
#include "SurgSim/Graphics/OsgRenderTarget-inl.h"
#endif
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgRenderTarget::m_colorTargetCount
int m_colorTargetCount
Number of color targets.
Definition: OsgRenderTarget.h:116
SurgSim::Graphics::RenderTarget::getSize
virtual void getSize(int *width, int *height) const =0
Gets a size.
SurgSim::Graphics::OsgAbstractRenderTarget
Osg abstract render target, this hides the type of the actual osg texture and lets us use OsgRenderTa...
Definition: OsgRenderTarget.h:37
SurgSim::Graphics::RenderTarget
RenderTarget is an abstraction of the target buffers that a Camera should use to render it&#39;s scene va...
Definition: RenderTarget.h:33
SurgSim::Graphics::OsgRenderTarget2d
OsgRenderTarget< OsgTexture2d > OsgRenderTarget2d
Definition: OsgRenderTarget.h:137
SurgSim::Graphics::RenderTarget::getColorTarget
virtual std::shared_ptr< Texture > getColorTarget(int index) const =0
Gets the indicated texture that is used as a target.
SurgSim::Graphics::OsgRenderTarget
Specific implementation of the render target class.
Definition: OsgRenderTarget.h:52
RenderTarget.h
SurgSim::Graphics::OsgAbstractRenderTarget::getColorTargetOsg
virtual std::shared_ptr< OsgTexture > getColorTargetOsg(int index) const =0
Accessor for the color target as an OsgTexture.
SurgSim::Graphics::OsgRenderTargetRectangle
OsgRenderTarget< OsgTextureRectangle > OsgRenderTargetRectangle
Definition: OsgRenderTarget.h:138
SurgSim::Graphics::OsgRenderTarget::m_width
int m_width
The width of this RenderTarget.
Definition: OsgRenderTarget.h:110
OsgTexture2d.h
OsgTextureRectangle.h
SurgSim::Graphics::OsgAbstractRenderTarget::getDepthTargetOsg
virtual std::shared_ptr< OsgTexture > getDepthTargetOsg() const =0
Accessor for the depth target as an OsgTexture.
SurgSim::Graphics::OsgRenderTarget::TextureType
T TextureType
The internal type of the texture, not exposed in the public interface.
Definition: OsgRenderTarget.h:57
SurgSim::Graphics::OsgRenderTarget::TargetTypes
TargetTypes
Values that represent TargetTypes.
Definition: OsgRenderTarget.h:104
SurgSim::Graphics::RenderTarget::doesUseDepthTarget
virtual bool doesUseDepthTarget() const =0
Check wether this draws into a depth texture.
OsgTexture.h
SurgSim::Graphics::RenderTarget::getColorTargetCount
virtual int getColorTargetCount() const =0
Returns the number of textures that this RenderTarget uses to draw into.
SurgSim::Graphics::OsgRenderTarget::m_height
int m_height
The height of this RenderTarget.
Definition: OsgRenderTarget.h:113
OsgRenderTarget-inl.h
SurgSim::Graphics::RenderTarget::getDepthTarget
virtual std::shared_ptr< Texture > getDepthTarget() const =0
Returns the texture that is used for the depth map drawing.
SurgSim::Graphics::OsgRenderTarget::m_textures
std::vector< std::shared_ptr< TextureType > > m_textures
The textures that are being used as target, size of this is 16 (ColorTargets) + 1 (Depth)...
Definition: OsgRenderTarget.h:119