Commit 65defae2 authored by Matt Clarkson's avatar Matt Clarkson

Lazy initialization of background texture.

parent 1040ab74
......@@ -202,6 +202,20 @@ void VividRenderer::initShaders()
//--------------------------------------------------------------------------
void VividRenderer::initGLBuffers()
{
if ( ! mBackgroundTexSampler ) {
// We could use mipmaps generation because the time to generate the mipmap in the GPU seems negligible
// compared to the time necessary to upload the image.
// We don't enable mipmaps mainly for simplicity and future compatibility to in-GPU updated textures.
ref< Texture > texture = new Texture( 32, 32, TF_RGBA, false );
texture->getTexParameter()->setGenerateMipmap( false );
texture->getTexParameter()->setMagFilter( vl::TPF_LINEAR );
texture->getTexParameter()->setMinFilter( vl::TPF_LINEAR );
texture->getTexParameter()->setWrapS( vl::TPW_CLAMP_TO_EDGE );
texture->getTexParameter()->setWrapT( vl::TPW_CLAMP_TO_EDGE );
mBackgroundTexSampler = new TextureSampler;
mBackgroundTexSampler->setTexture( texture.get() );
}
// Depth Peeling
glGenFramebuffers(2, mFrontFboId);
......
......@@ -78,6 +78,9 @@ namespace vl
Texture* depthFBOTex() { return mDepthFBOTex.get(); }
const Texture* depthFBOTex() const { return mDepthFBOTex.get(); }
TextureSampler* backgroundTexSampler() { return mBackgroundTexSampler.get(); }
const TextureSampler* backgroundTexSampler() const { return mBackgroundTexSampler.get(); }
protected:
int renderQueue(const RenderQueue* in_render_queue, vl::GLSLProgram* cur_glsl, Camera* camera, real frame_clock, bool depth_peeling_on=true, bool outline_on = false);
void renderBackgroundImage( Camera* camera );
......@@ -119,6 +122,8 @@ namespace vl
GLuint mDepthFBO;
ref<Texture> mDepthFBOTex;
ref<TextureSampler> mBackgroundTexSampler;
int mPassCounter;
int mNumPasses;
bool mUseQueryObject;
......
......@@ -60,17 +60,6 @@ VividRendering::VividRendering() {
mOutline3DEyeOffset = 0.0f; // 0.25mm works well with VTK
mOutline3DClipOffset = 0.0f; // 0.0005 is more general but can create artifacts
// We could use mipmaps generation because the time to generate the mipmap in the GPU seems negligible
// compared to the time necessary to upload the image.
// We don't enable mipmaps mainly for simplicity and future compatibility to in-GPU updated textures.
ref< Texture > texture = new Texture( 32, 32, TF_RGBA, false );
texture->getTexParameter()->setGenerateMipmap( false );
texture->getTexParameter()->setMagFilter( vl::TPF_LINEAR );
texture->getTexParameter()->setMinFilter( vl::TPF_LINEAR );
texture->getTexParameter()->setWrapS( vl::TPW_CLAMP_TO_EDGE );
texture->getTexParameter()->setWrapT( vl::TPW_CLAMP_TO_EDGE );
mBackgroundTexSampler = new TextureSampler;
mBackgroundTexSampler->setTexture( texture.get() );
mBackgroundImageEnabled = false;
// Stencil Texture
......
......@@ -178,8 +178,8 @@ namespace vl
void setBackgroundImageEnabled( bool enabled ){ mBackgroundImageEnabled = enabled; }
bool backgroundImageEnabled() const { return mBackgroundImageEnabled; }
TextureSampler* backgroundTexSampler() { return mBackgroundTexSampler.get(); }
const TextureSampler* backgroundTexSampler() const { return mBackgroundTexSampler.get(); }
TextureSampler* backgroundTexSampler() { return mVividRenderer->backgroundTexSampler(); }
const TextureSampler* backgroundTexSampler() const { return mVividRenderer->backgroundTexSampler(); }
// Allow depth peeling to be disabled for a faster rendering using a simple test.
// This works in the simplest but usual cases where:
......@@ -237,7 +237,6 @@ namespace vl
float mOutline3DEyeOffset;
bool mBackgroundImageEnabled;
ref<TextureSampler> mBackgroundTexSampler;
bool m_DepthPeelingAutoThrottleEnabled;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment