shivmitra
11-08-2011, 12:25 AM
I am using PBO to update data to texture using glSubTexImage2d .
It works fine in ATI machine , but with a machine having Intel graphic card it doesnot work . I checked and found the extension gl_arb_pixel_buffer_object is supported on intel machine .
Here is some code snippet
GLuint InitializeTexturePBO(CPUInt16 bufferSize)
{
GLuint pbo;
(*m_glGenBuffersARB)(1,&pbo);
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
(*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB,
bufferSize , NULL , GL_STREAM_DRAW_ARB);
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
return pbo;
}
void* GetPBOBufferPointer(unsigned int identifier ,int width , int height)
{
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, identifier );
(*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB, width*height*4 ,
0, GL_STREAM_DRAW_ARB);
return (void*)(*m_glMapBufferARB)(GL_PIXEL_UNPACK_BUFFER_ ARB,
GL_WRITE_ONLY_ARB);
}
void UnmapPBOBuffer()
{
if(!m_glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB) )
throw CPCustomException();
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
}
i call it in this order .
InitializeTexturePBO();
GetPBOBufferPointer(); // take this pointer and decode video frames at this location
glBindTexture(GL_TEXTURE_2D , textureObjectList[sourceID]);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,ToInt16(m_vide oSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_width),
ToInt16(m_videoSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_height),GL_BGRA _EXT,GL_UNSIGNED_BYTE,
0);
UnmapPBOBuffer();
I am not able to understand why it fails on glTexSubImage call with error code GL_INVALID_OPERATION on intel card but works fine on ATI card ??
It works fine in ATI machine , but with a machine having Intel graphic card it doesnot work . I checked and found the extension gl_arb_pixel_buffer_object is supported on intel machine .
Here is some code snippet
GLuint InitializeTexturePBO(CPUInt16 bufferSize)
{
GLuint pbo;
(*m_glGenBuffersARB)(1,&pbo);
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
(*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB,
bufferSize , NULL , GL_STREAM_DRAW_ARB);
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
return pbo;
}
void* GetPBOBufferPointer(unsigned int identifier ,int width , int height)
{
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, identifier );
(*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB, width*height*4 ,
0, GL_STREAM_DRAW_ARB);
return (void*)(*m_glMapBufferARB)(GL_PIXEL_UNPACK_BUFFER_ ARB,
GL_WRITE_ONLY_ARB);
}
void UnmapPBOBuffer()
{
if(!m_glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB) )
throw CPCustomException();
(*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
}
i call it in this order .
InitializeTexturePBO();
GetPBOBufferPointer(); // take this pointer and decode video frames at this location
glBindTexture(GL_TEXTURE_2D , textureObjectList[sourceID]);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,ToInt16(m_vide oSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_width),
ToInt16(m_videoSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_height),GL_BGRA _EXT,GL_UNSIGNED_BYTE,
0);
UnmapPBOBuffer();
I am not able to understand why it fails on glTexSubImage call with error code GL_INVALID_OPERATION on intel card but works fine on ATI card ??