Hello All,
I am playing an AVI file on to a MFC screen. I am using GLSL to write a shader that processes each frame and waits for the next frame.
I am able to initiate opengl and glsl through context setting and setting pixel properties for opengl and glewinit() for GLSL.
CMFC_ProjectView::initOpengl()
{
//set up context
//i.e getDC(..)
//setPixel Format using wgl functions.
...
//draw viewport and window size
//similar to glutInit and setWindowSize()
//initiate GLSL
glewInit();
glGenTextures(3, tex);
glGenFramebuffersEXT(1, &fb);
//Current MFC , Device context is the on-screen frame buffer
i.e glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
Now the problem is that I am using FBO ( frame buffer object) for shader to manipulate each frame.
Inside my MFC function where I am starting opengl ( similar to glutInit() ) , I am generating texture ids and FBO object id.
After this I am using glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
to imply current MFC context ( on screen frame buffer ).
Above gives me valid Ids of FBO and generated Texture ids.
In my shader program I am doing this
OnPaint()
{
...
if( flag_glsl == TRUE )
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
shader();
}
...
}
Now when I run my application, I find my video file freezes at first frame only.
The reason i conjectured was that since after first frame rendering on on-screen frame buffer, everything else is rendered to off-screen buffer via glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
, the next sequential frame is not observered.
So to overcome this, after coming out of shader code, I include following
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
in the hope to re-select main on-screen frame buffer.
OnPaint()
{
...
if( flag_glsl == TRUE )
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
shader();
//reset to on-screen buffer
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
...
}
But I observer on running the application that after first frame of my video, the next and subsequent frames disappear!!
Does anybody have a clue on what is going wrong?
Help & suggestions appreciated.