render to texture

thanks otherside, will have a look
“I did it to test out multiple render targets”
I think ultimately that is what I want to get into, so very useful…
and thanks zach for for the FBO Class and taking away most of the pain :stuck_out_tongue:

1 Like

Hi

I’ve tried to adapt some code to work with fbo’s but it seems not to work. Almost sure is my graphics card doesn’t support them, but is there any way of knowing this?

I don’t get any error, just the image I have in the background if I have alpha blending enabled, or a black screen if not (I’ve set color to black before drawing to the fbo)

Hey I just made an FBO example app - that uses Zach Gage’s FBO code, with the ofAdvancedTexture and a render manager to manage multiple screens. The render manager is a continuation of the code started by other Zach (OF) adding in some new things:

1 - Lets you set the internal texture coordinates for each screen and also the coordinates of each corner of the texture to do fast warping / projection correction.
2 - set however many screens you want to split your FBO across.
3 - Loads and saves to xml.

Xcode - For 00573 release
http://www.openframeworks.cc/files/FBOM-…–00573.zip

CodeBlocks - 00573 release (windows)
http://www.openframeworks.cc/files/FBOM-…–00573.zip

If you need the OF 00573 release for windows grab it here:
http://www.openframeworks.cc/files/of-p-…-noApps.zip

Mac here:
http://www.openframeworks.cc/files/0057-…-irmata.zip

hi Arturo & all …

well i’m not sure if that’s already tested, but these are the steps i usually do for checking if FBO works in a given computer …

* first find if your card / driver support “EXT_framebuffer_object” . You can query OpenGL to tell you the available extensions and look for that one …

* it might happen that you’ve the GL extensions but still it’s not working … I’m using my own FBO object and not sure if this is done in the ofFBO object, but then what i test is the “correctness” of the FBO object with this :

  
if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)==GL_FRAMEBUFFER_COMPLETE_EXT)  
       // FBO setup completed OK ;)   
else   // FBO setup completed KO :_(  
  

This check should be done on the FBO initialization, after glBindTexture(GL_TEXTURE_2D,g_texName);
and before glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); [which binds again the default framebuffer]

Lot of info on how FBO extensions work in OpenGL …
http://oss.sgi.com/projects/ogl-sample/-…-object.txt
http://www.songho.ca/opengl/gl-fbo.html

hope it helps …

e*

Hey all, just trying to figure a few things about this framebuffer stuff.

When i worked in Processing, I would often use their pgraphics (framebuffer) objects to draw images larger than my screen size, and to be able to save them out as .pngs or jpgs.

Am I able to do the same thing with this FBO library? Can i copy the data into an ofImage somehow? or grab the ‘screen’ of the framebuffer?

The link is broken. :cry:

[quote author=“shotgunninja”][quote author=“zach_gage”]
http://www.stfj.net/misc/ofFBOTexture.zip
[/quote]

The link is broken. :cry:[/quote]

try this one?

Hi

I’m getting a lot of erros trying compile the ofFBOtexture.h and .cpp

with the latest OF release.

Can anyone give me a hint on how to do it ?

I work on Xcode 3.1.2

thanks.

This should be a 006 compatible FBO and RenderManager class.

Theo

006FBO.zip

Thanks.

Hi
I have tried FBO and RenderManager class, with the example by Theo,
It’s working, but I have a little bug, my videograbber is cut on the top and right…
somebody can help me ?
I work on CodeBlocks with the latest OF release.
Thanks.
V.

  
void testApp::setup(){  
  
  
    camWidth 		= 320;  
    camHeight 		= 240;  
  
    ofBackground(127,127,127);  
    rm.allocateForNScreens(1, camWidth, camHeight);  
  
  
    guiIn   = ofRectangle(10, 40, camWidth, camHeight );  
    guiOut  = ofRectangle(guiIn.x + guiIn.width + 30, 40, camWidth, camHeight);  
  
  
  
     vidGrabber.setVerbose(true);  
     vidGrabber.initGrabber(camWidth, camHeight);  
     rm.loadFromXml("fboSettings.xml");  
  
}  
//--------------------------------------------------------------  
void testApp::update(){  
  
    ofBackground(100,100,100);  
  
	vidGrabber.grabFrame();  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
    ofSetColor(255, 255, 255, 255);  
  
    rm.startOffscreenDraw();  
  
        ofSetColor(0xffffff);  
        vidGrabber.draw(0,0);  
  
    rm.endOffscreenDraw();  
  
    rm.drawInputDiagnostically(guiIn.x, guiIn.y, guiIn.width, guiIn.height);  
    rm.drawOutputDiagnostically(guiOut.x, guiOut.y, guiOut.width, guiOut.height);  
  
    glPushMatrix();  
        glTranslatef(200, 300, 0);  
        ofSetColor(255, 255, 255, 255);  
        rm.drawScreen(0);  
    glPopMatrix();  
} .....   

Just hooked up multisampling to the ofFBOTexture/ofxFBOTexture
Following this great guide here: http://blog.dexta.ch/2008/08/27/gl-ext–…-isampling/

My laptop only does 4x multisampling - but it definitely makes a difference when rendering to FBO!

Code is attached - no difference from ofxFBOTexture except a forth argument for number of samples.
If you don’t pass a value in or specify 0 then no multisampling is performed and it behaves the same as the normal ofxFBOTexture addon.

ofxFBOTexture-MultiSample.zip

In addition to multisampling you could also further smooth things by doing supersampling - rendering to a texture 2x (or more) larger than your target size and then drawing it at the original, smaller size with linear filtering.

Has anyone used this to map a projection on something more complicated than a 2 or 3 sided structure? I’m trying to create a corrected image on a highly irregular surface (i.e. the corner of two walls and the ceiling, or a space with added surfaces) which would mean distorting it to make it appear normal. Any aid is appreciated.

Thanks for all the great work guys, but I, like Aston am wondering,

Has anyone used this to map a projection on something more complicated than a 2 or 3 sided structure?

More specifically, I am attempting to render onto a curved screen by mapping an FBO onto a cylinder, but am getting some funky OpenGL glitches.

what kind of “glitches”?

well you can map anything anywhere, it depends on your requirements and the quality you want to achieve.
mapping onto some 2d surface with more vertex handles is not difficult, but numerical issues with the texcoords could
be a problem in the final image (i would look into geometry shaders for that). also you would probably need some edgeblending if you use disconnected surfaces or projections …

i think this stuff is easy to prototype but hard to get right (or calibrate).

Hi there
I am using FBO Manager example at my MacBook Pro with Leopard 10.5.8 and working perfect.
I bought a new MacBook Pro with Snow Leopard 10.6.4, i download x-code FAT (10.6) and i take the errors

‘struct ofTextureData’ has no member named ‘textureName’

at the lines:
ofFBOTexture.cpp

glGenTextures(1, (GLuint *)texData.textureName); // could be more then one, but for now, just one
glBindTexture(texData.textureTarget, (GLuint)texData.textureName[0]);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, texData.textureTarget, (GLuint)texData.textureName[0], 0);
if (texData.textureName[0] != 0){
glDeleteTextures(1, (GLuint *)texData.textureName);
}

ofTextureAdv.cpp

texData.textureName[0] = 0;
glBindTexture( texData.textureTarget, (GLuint)texData.textureName[0] );

I appreciate your help.

git repository with source code:
http://github.com/igoumeninja/UnaCiudadSonada

Thank a lot

http://igoumeninja.org

Finally i am running my project on snow leopard using topic http://forum.openframeworks.cc/t/snow-leopard—sticky-thread/2749/0

Special thanks theo

Aris

I tried to use the last one but:
|92|error: ‘struct ofTextureData’ has no member named ‘textureName’| in ofFBOTexture.cpp
Something wrong?

[quote author=“velocityzen”]I tried to use the last one but:
|92|error: ‘struct ofTextureData’ has no member named ‘textureName’| in ofFBOTexture.cpp
Something wrong?[/quote]

Yes, I had the same problem with Theo’s FBOtexture with multisampling.
I’m on OSX10.6.4 OF0061

if you’re in the same situation, you can use this version:
[attachment=0:u973r3x8]ofxFboTexture_multisample_SL_0061.zip[/attachment:u973r3x8]
I only changed the parts where the ofxFBOTexture is trying to use texData.textureName
instead of texData.textureID

If you look in ofTexture.h you’ll see that the struct ofTextureData doesn’t have “textureName”, but it does have

  
unsigned int textureID;  

ofxFboTexture_multisample_SL_0061.zip