Example #1
0
void StochasticRenderer::create_texture(
    kvs::Texture2D& texture,
    kvs::glew::FrameBufferObject& framebuffer,
    GLint internal_format,
    GLenum external_format,
    GLenum external_type,
    GLenum attachment )
{
    texture.release();

    texture.setWrapS( GL_CLAMP_TO_EDGE );
    texture.setWrapT( GL_CLAMP_TO_EDGE );
    texture.setMagFilter( GL_LINEAR );
    texture.setMinFilter( GL_LINEAR );

    texture.setPixelFormat( internal_format, external_format, external_type );
    texture.create( m_width, m_height );
    {
        GLenum error = glGetError();
        if ( error != GL_NO_ERROR )
        {
            kvsMessageError( "color buffer allocation failed: %s.", gluErrorString(error));
            exit( EXIT_FAILURE );
        }
    }

    glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, texture.id(), 0 );

    texture.unbind();
}
Example #2
0
void FrameBufferObject::attachDepthTexture( const kvs::Texture2D& texture, const int mip_level ) const
{
    GuardedBinder binder( *this );
    const GLuint id = texture.id();
    const GLenum attachment = GL_DEPTH_ATTACHMENT;
    const GLenum type = GL_TEXTURE_2D;
    KVS_GL_CALL( glFramebufferTexture2D( GL_FRAMEBUFFER, attachment, type, id, mip_level ) );
}
Example #3
0
/*===========================================================================*/
void FrameBufferObject::attachColorTexture( const kvs::Texture2D& texture, const size_t color_buffer, const int mip_level ) const
{
    KVS_ASSERT( static_cast<GLint>( color_buffer ) < kvs::OpenGL::MaxColorAttachments() );
    GuardedBinder binder( *this );
    const GLuint id = texture.id();
    const GLenum attachment = GL_COLOR_ATTACHMENT0 + color_buffer;
    const GLenum type = GL_TEXTURE_2D;
    KVS_GL_CALL( glFramebufferTexture2D( GL_FRAMEBUFFER, attachment, type, id, mip_level ) );
}
Example #4
0
void BufferObject::create(
    const kvs::cl::Context& context,
    const kvs::Texture2D& texture )
{
    if ( m_is_created )
    {
        kvsMessageError( "Buffer is already created." );
        return;
    }

    cl_int result = CL_SUCCESS;
    const cl_mem_flags flags = static_cast<cl_mem_flags>( m_access_type );
    m_memory = clCreateFromGLTexture2D(
        context.context(), flags, GL_TEXTURE_2D, 0, texture.id(), &result );
    if ( result != CL_SUCCESS )
    {
        kvsMessageError( "OpenCL; %s.", kvs::cl::ErrorString( result ) );
        return;
    }

    m_is_created = true;
    m_size = 0;
}