I’m clearly misunderstanding a bit of what’s going on with ogl framebuffers.
The concept I’m trying to build is quite simple. I’ve got a little 3d scene with a camera and I want to overlay it over a bitmap. The only *maybe* weird hangup here is the resolution I’m building for which is 1080x3840 (two portrait 1080p displays stacked high).
So up in setup I’m allocating my framebuffers (and I don’t think I even need two, but just for grins and troubleshooting…)
fpo.allocate(1080,3840); //framebuffer for 3d scene
bgfpo.allocate(1080,3840); //framebuffer to hold 2d image
bgi.loadImage("bg0.jpg"); // background image
then down in draw (which is a bit disorganized on account of general troubleshooting)
ofBackground(255, 0, 0); // give me a red background to better see what's going on
bgfbo.begin();
ofClear(1.0f, 1.0f, 1.0f);
bgi.draw(0,0); // draw the background image into the bgfbo
bgfbo.end();
fbo.begin();
ofEnableLighting();
ofEnableAlphaBlending();
ofClear(1.0f, 1.0f, 1.0f);
em.update(); // my particle emitter, all the objects get added to the scene here
cam.end();
fbo.end();
/*
what I image should happen here is that the background gets drawn,
then I turn on alpha blending (the 3d scene should have an alpha channel
(stencil buffer?) no? and then I draw down the 3d scene on top)
*/
bgfbo.draw(0,0, bgfbo.getWidth(), bgfbo.getHeight());
ofEnableBlendMode(OF_BLENDMODE_ALPHA);
fbo.draw(0,0, fbo.getWidth(), fbo.getHeight());
ofDisableBlendMode();
What I imagine here is I’m painting down the 2d bitmap background, then turning on alpha and then painting down the alpha masked 3d scene.
However what i get is just my 2d background image. If I go ahead and remove the bgfbo.draw call I get my 3d particle system all nice and alpha masked against the red background.
I know I’m missing something very obvious, but it’s been many years since I’ve had to deal with openGL on this level so any help would be appreciated.
Thanks!