The graph and filter are created succesfully, and i can hear sound playing, but I dont see anything rendered, I dont even see misaligned video, just a black texture. I am suspecting my PBO code, can you see anything wrong?
PBO class
void CPBO::init( int sx, int sy, int pixbytes,
GLenum pixformat, GLenum pixtype ,
GLenum usage )
{
glGenBuffers(1, &m_pboID);
m_sx = sx; m_sy = sy;
m_pixbytes = pixbytes; m_pixtype = pixtype; m_pixformat = pixformat;
m_usage = usage;
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, m_pboID);
glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, sx*sy*pixbytes, NULL, usage);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
}
void* CPBO::LockGetPointer()
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, m_pboID);
void* memio = glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
return memio;
}
void CPBO::Unlock( )
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, m_pboID);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
}
void CPBO::Upload( )
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, m_pboID);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, m_sx, m_sy,
m_pixformat, m_pixtype, BUFFER_OFFSET(0));
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
}
Render sample code
HRESULT CTextureRenderer::DoRenderSample( IMediaSample * pSample )
{
// wait for main thread to consume previous sample
while(m_bSampleReady) Sleep(10);
if (!m_pTxtBuffer) { return S_OK; AppendFile("debug.txt","no texture buffer for DoRenderSample()
");}
BYTE *pBmpBuffer, *pTxtBuffer; // Bitmap buffer, texture buffer
LONG lTxtPitch; // Pitch of bitmap, texture
BYTE * pbS = NULL;
DWORD * pdwS = NULL;
DWORD * pdwD = NULL;
UINT row, col, dwordWidth;
CheckPointer(pSample,E_POINTER);
// CheckPointer(m_pTexture,E_UNEXPECTED);
// Get the video bitmap buffer
pSample->GetPointer( &pBmpBuffer );
pTxtBuffer = m_pTxtBuffer;
// Copy the bits
if (m_TextureFormat == GL_BGR)
{
memcpy(pBmpBuffer, pTxtBuffer, m_lVidWidth*m_lVidHeight*3);
}
if (m_TextureFormat == GL_BGRA)
{
memcpy(pBmpBuffer, pTxtBuffer, m_lVidWidth*m_lVidHeight*4);
}
Sleep(1);
m_bSampleReady = true;
return S_OK;
}
swap active PBO in main thread code
// swap buffers if needed
if (m_VideoRenderer->m_bSampleReady)
{
// unlock previous pbo
m_PBO[m_PBO_upload_idx].Unlock();
// get pointer to empty buf and clear sample flag
m_VideoRenderer->m_pTxtBuffer = (BYTE*) m_PBO[m_PBO_render_idx].LockGetPointer();
m_VideoRenderer->m_bSampleReady = false;
// upload texture to videocard
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, m_texid);
m_PBO[m_PBO_upload_idx].Upload();
// safe swap ?
if (m_PBO_upload_idx) { m_PBO_upload_idx=0; m_PBO_render_idx=1; }
else { m_PBO_upload_idx=1; m_PBO_render_idx=0; }
}
render quad
gVidTex.CheckMovieStatus();
// draw video o quad
CCamera::SetOrtho2D();
glEnable(GL_TEXTURE_RECTANGLE_EXT);
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, gVidTex.m_texid);
DrawTexQuad(0,0,gVidTex.m_VideoRenderer->m_lVidWidth, gVidTex.m_VideoRenderer->m_lVidHeight,
0.3,0.3,1,1);