Hey all –
I’m trying to use the popular WMFPlayer block to playback video and texture map objects with video. However, I’m finding that drawing the video on top of a 3d scene (to show what the source material looks like) is slightly problematic.
My mixed drawing looks like:
void cinderTestApp::draw() {
gl::clear( Color( 0, 0, 0 ) );
gl::enableDepthRead();
gl::enableDepthWrite();
mCamera.lookAt( ... );
ci::gl::setMatrices(mCamera);
{
auto lambert = gl::ShaderDef().lambert();
auto shader = gl::getStockShader(lambert);
shader->bind();
for (auto box : mBoxes) {
gl::color(255, 255, 255);
box->draw();
}
}
gl::disableDepthWrite();
gl::disableDepthRead();
gl::setMatricesWindow(ci::app::getWindowSize());
mWMFVideoPlayer->draw(0, 0);
}
With this code, I just get a white rectangle the size of the video drawn on top of my 3d scene.
If I replace the last line with a gl::draw
call with a reference texture, that draws fine:
gl::draw(gl::Texture::create(*mReferenceTexture)); // loaded as a surface with ci::loadImage()
I even thought that maybe there was something from the 3d calls that wasn’t falling out of scope, so I tried drawing the video to a FBO and then drawing the FBO on top of 3d scene:
void visualizationTestApp::update() {
if (mVideoPlayer) {
mVideoPlayer->update();
std::cout << "Video position : " << mVideoPlayer->getPosition() << std::endl;
}
{
gl::ScopedFramebuffer fboScope(mFbo);
gl::ScopedViewport scpVp(ivec2(0), mFbo->getSize());
gl::clear(Color(1, 1, 1));
gl::ScopedColor white(1, 1, 1);
//mVideoPlayer->draw(0, 0, mFbo->getWidth(), mFbo->getHeight());
gl::draw(gl::Texture::create(*mReferenceTexture));
}
}
and then drawing the FBO in draw()
; but even within the FBO, the gl::draw
call draws the texture properly, but WMFPlayer doesn’t render the image properly!
Can anyone help me understand what’s going on here?
thanks!