Beispiel #1
0
void
ImageGL::registerAsCudaResource(int field_num)
{
    // register the OpenGL resources that we'll use within CD
    checkCudaErrors(cuGLRegisterBufferObject(gl_pbo_[field_num]));
    getLastCudaDrvErrorMsg("cuGLRegisterBufferObject (gl_pbo_) failed");
    bIsCudaResource_ = true;
}
Beispiel #2
0
// 1 plane float buffer
bool allocBuffer( PixelBufferObject &img, UInt2 &imgSize )
{
   if( Size(img) != imgSize && imgSize != UInt2(0,0) )
   {
        // Allocate monitor PBO 
        glGenBuffersARB( 1, &(img.m_bufId) );
        glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, img.m_bufId );
        glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, Width(imgSize) * Height(imgSize) * sizeof(float), NULL, GL_STREAM_COPY);

        // Register buffer for use with cuda
        CUresult cerr = cuGLRegisterBufferObject( img.m_bufId );
        checkError(cerr);
        glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );

        SetSize(img, imgSize);
        return true;
   }

   return false;
}
Beispiel #3
0
// TODO : separate allocation buffer and texture
static
bool allocBufferAndTexture( GLuint &buf, GLuint &tex, unsigned int width, unsigned int height, unsigned int depth )
{
    // Texture 
    glGenTextures( 1, &tex );
    GLenum err = glGetError(); assert( err == GL_NO_ERROR );
	glBindTexture( GL_TEXTURE_RECTANGLE_NV, tex );
	glTexParameterf( GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexImage2D( GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA8, width, height,0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    glBindTexture( GL_TEXTURE_RECTANGLE_NV, 0 );

    // Allocate monitor PBO ( pixel buffer object )
    glGenBuffersARB( 1, &buf );
	glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, buf );
	glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, width * height * depth, NULL, GL_STREAM_COPY );

    // Register buffer for use with cuda
    CUresult cerr = cuGLRegisterBufferObject( buf );
    checkError(cerr);
    glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );

    return true;
}