16 #ifndef SURGSIM_GRAPHICS_OSGRENDERTARGET_INL_H 17 #define SURGSIM_GRAPHICS_OSGRENDERTARGET_INL_H 26 const int OsgSupportedTextureCount = 16 + 1;
32 m_colorTargetCount(0),
33 m_textures(OsgSupportedTextureCount)
45 m_width(width* scale),
46 m_height(height* scale),
47 m_colorTargetCount(0),
48 m_textures(OsgSupportedTextureCount)
50 setColorTargetCount(colorCount, useFloat);
51 useDepthTarget(useDepth);
70 int result = (count < 16) ? count : 16;
77 for (
int i = m_colorTargetCount; i < result; ++i)
79 setupTexture(TARGETTYPE_COLORBASE + i, floatColor);
81 m_colorTargetCount = result;
88 return m_colorTargetCount;
94 std::shared_ptr<Texture> result;
96 if (index < m_colorTargetCount)
98 result = m_textures[TARGETTYPE_COLORBASE + index];
107 std::shared_ptr<T> result;
109 if (index < m_colorTargetCount)
111 result = m_textures[TARGETTYPE_COLORBASE + index];
122 setupTexture(TARGETTYPE_DEPTH,
false);
126 m_textures[TARGETTYPE_DEPTH] =
nullptr;
133 return m_textures.at(TARGETTYPE_DEPTH) !=
nullptr;
139 return m_textures.at(TARGETTYPE_DEPTH);
145 return m_textures.at(TARGETTYPE_DEPTH);
151 if (m_textures[type] ==
nullptr)
153 m_textures[type] = std::make_shared<T>();
154 m_textures[type]->setSize(m_width, m_height);
155 osg::Texture* osgTexture = m_textures[type]->getOsgTexture();
158 osgTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
159 osgTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
160 osgTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
161 osgTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
162 if (type == TARGETTYPE_DEPTH)
164 osgTexture->setInternalFormat(GL_DEPTH_COMPONENT32F);
165 osgTexture->setSourceFormat(GL_DEPTH_COMPONENT);
166 osgTexture->setSourceType(GL_FLOAT);
167 osgTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
168 osgTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
169 osgTexture->setBorderColor(osg::Vec4(1.0, 1.0, 1.0, 1.0));
171 if (type >= TARGETTYPE_COLORBASE)
176 osgTexture->setInternalFormat(GL_RGBA32F_ARB);
177 osgTexture->setSourceFormat(GL_RGBA);
178 osgTexture->setSourceType(GL_FLOAT);
182 osgTexture->setInternalFormat(GL_RGBA);
183 osgTexture->setSourceFormat(GL_RGBA);
184 osgTexture->setSourceType(GL_BYTE);
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
void getSize(int *width, int *height) const override
Gets a size.
Definition: OsgRenderTarget-inl.h:61
OsgRenderTarget()
Default constructor.
Definition: OsgRenderTarget-inl.h:29
std::shared_ptr< Texture > getColorTarget(int index) const override
Generic accessor for a specific color target texture.
Definition: OsgRenderTarget-inl.h:92
bool doesUseDepthTarget() const override
Determines if RenderTarget does use a depth target.
Definition: OsgRenderTarget-inl.h:131
int getColorTargetCount() const override
Definition: OsgRenderTarget-inl.h:86
std::shared_ptr< OsgTexture > getColorTargetOsg(int index) const
Accessor for the color target as an OsgTexture.
Definition: OsgRenderTarget-inl.h:105
Specific implementation of the render target class.
Definition: OsgRenderTarget.h:52
~OsgRenderTarget()
Destructor.
Definition: OsgRenderTarget-inl.h:56
std::shared_ptr< OsgTexture > getDepthTargetOsg() const
Accessor for the depth target as an OsgTexture.
Definition: OsgRenderTarget-inl.h:143
std::shared_ptr< Texture > getDepthTarget() const override
Generic accessor for the depth Target.
Definition: OsgRenderTarget-inl.h:137