[eq-dev] Composition problem using texture and glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)

8 views
Skip to first unread message

Carlos Duelo

unread,
May 7, 2013, 6:43:56 AM5/7/13
to Equalizer Developer List
Hello,

In my application I render into a PBO from CUDA and then draw it using a texture like this:

glEnable( GL_TEXTURE_2D );

    glBindTexture( GL_TEXTURE_2D, _texture );
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _pbo);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _lastViewport.w, _lastViewport.h, GL_RGB, GL_FLOAT, 0);
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

    glBegin(GL_QUADS);
    glTexCoord2f(0.0f,0.0f); glVertex2f(-1.0f,-1.0f);
    glTexCoord2f(1.0f,0.0f); glVertex2f( 1.0f,-1.0f);
    glTexCoord2f(1.0f,1.0f); glVertex2f( 1.0f, 1.0f);
    glTexCoord2f(0.0f,1.0f); glVertex2f(-1.0f, 1.0f);
    glEnd();

glDisable(GL_TEXTURE_2D);

My texture is defined:

    glGenTextures( 1, &_texture );
    glBindTexture( GL_TEXTURE_2D, _texture );
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, _lastViewport.w, _lastViewport.h, 0, GL_RGB, GL_FLOAT, NULL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
    glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_REPLACE);

I have noticed that exists a problem with accumBufferObject object. If you have implemented the anti-aliasing in the same way as eqPly and you have change a GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE from GL_MODULATE to GL_REPLACE like me.

To make work my code, I had to add this line on AccumBufferObject::_drawQuadWithTexture

void AccumBufferObject::_drawQuadWithTexture( Texture* texture,
                                              const PixelViewport& pvp,
                                              const GLfloat value )
{
    texture->bind();

    glDepthMask( false );
    glDisable( GL_LIGHTING );
    glEnable( GL_TEXTURE_RECTANGLE_ARB );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
    texture->applyWrap();
    texture->applyZoomFilter( FILTER_NEAREST );

    ..........

}

Cheers
-- 
Carlos Duelo
Reply all
Reply to author
Forward
0 new messages