16 #ifndef SURGSIM_GRAPHICS_OSGRENDERTARGET_INL_H
17 #define SURGSIM_GRAPHICS_OSGRENDERTARGET_INL_H
32 m_colorTargetCount(0),
44 m_width(width * scale),
45 m_height(height * scale),
46 m_colorTargetCount(0),
69 int result = (count < 16) ? count : 16;
76 for (
int i = m_colorTargetCount; i < result; ++i)
78 setupTexture(TARGETTYPE_COLORBASE + i);
80 m_colorTargetCount = result;
87 return m_colorTargetCount;
93 std::shared_ptr<Texture> result;
95 if (index < m_colorTargetCount)
97 result = m_textures[TARGETTYPE_COLORBASE + index];
106 std::shared_ptr<T> result;
108 if (index < m_colorTargetCount)
110 result = m_textures[TARGETTYPE_COLORBASE + index];
121 setupTexture(TARGETTYPE_DEPTH);
125 m_textures[TARGETTYPE_DEPTH] =
nullptr;
132 return m_textures.at(TARGETTYPE_DEPTH) !=
nullptr;
138 return m_textures.at(TARGETTYPE_DEPTH);
144 return m_textures.at(TARGETTYPE_DEPTH);
150 if (m_textures[type] ==
nullptr)
152 m_textures[type] = std::make_shared<T>();
153 m_textures[type]->setSize(m_width, m_height);
154 osg::Texture* osgTexture = m_textures[type]->getOsgTexture();
157 osgTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
158 osgTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
159 osgTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
160 osgTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
161 if (type == TARGETTYPE_DEPTH)
163 osgTexture->setInternalFormat(GL_DEPTH_COMPONENT32F);
164 osgTexture->setSourceFormat(GL_DEPTH_COMPONENT);
165 osgTexture->setSourceType(GL_FLOAT);
166 osgTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
167 osgTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
168 osgTexture->setBorderColor(osg::Vec4(1.0, 1.0, 1.0, 1.0));
170 if (type >= TARGETTYPE_COLORBASE)
172 osgTexture->setInternalFormat(GL_RGBA32F_ARB);
173 osgTexture->setSourceFormat(GL_RGBA);
174 osgTexture->setSourceType(GL_FLOAT);