Does BlitzMax support EXT_framebuffer_object?(FBO)

BlitzMax Forums/OpenGL Module/Does BlitzMax support EXT_framebuffer_object?(FBO)

SofaKng(Posted 2007) [#1]
I'd like to fool around with OpenGL FBOs (framebuffer objects) and apparantly it needs the EXT_framebuffer_object OpenGL extension.

Is this built into BlitzMax v1.24? If not, can it be easily added?


SofaKng(Posted 2007) [#2]
Ok, it looks like it is infact supported, but I'm having a problem...

At the top of my program I have this:

SetGraphicsDriver(GLGraphicsDriver())
GLGraphics(320, 200)

GlewInit() ' Is this needed??

...and then I do this to create the FBO object:
Local fbo : Int;
glGenFramebuffersEXT(1, Varptr fbo) ;

...but when it calls that function I get an unhandled memory exception error.

What am I doing wrong?

Thanks...


Dreamora(Posted 2007) [#3]
Yes it is needed to use GlewInit, without it there is no GLEW -> only OpenGL 1.2

And your setgraphicsdriver is unneeded. if you go for pure OpenGL max2d commands do not work


SofaKng(Posted 2007) [#4]
Ahh, thanks.

Any idea why I'm getting the unhandled memory exception then?


ImaginaryHuman(Posted 2007) [#5]
You cant just immediately access the extension. You have to do something to do with adding extensions first. I dont know what, but it springs to mind.


Dreamora(Posted 2007) [#6]
You mean like bind it as with any OpenGL buffer?


ImaginaryHuman(Posted 2007) [#7]
I'm not sure. If you use any commands that are not in OpenGL 1.1 you have to do then via extensions and you have to use, I think, the glew library to `detect` them and activate them.


klepto2(Posted 2007) [#8]
In Bmax you dont have to detect them, you only need to check the support string for this extension and if it is not supported you have to find a work around.

Here is a small code snippet how I'm currently implementing them in miniB3D (yes they already work) ;)




ImaginaryHuman(Posted 2007) [#9]
This is cool, I was just reading about the frame buffer objects.

However, I see nowhere in your code where you do what you said you needed to do - check if the support string includes the extension you're using. Can you show code that includes how this would be done in BlitzMax?

Also, what extensions do you suggest might be needed to set up a floating point texture and use it as a framebuffer?


klepto2(Posted 2007) [#10]
Here is my current code how to detect the extensions available by your Graphicscard.



And for the floating point extension I would suggest to check for : 'GL_ARB_texture_float' for floating point textures. But I haven't used them yet. For what are these textures needed?


ImaginaryHuman(Posted 2007) [#11]
Nice, thanks.

Floating point would be for HDR image buffers and rendering. I'm working towards a graphics app and it would be extremely useful to use framebuffer objects with more than just RGBA8888 data, e.g. Float16, Float32, Float64, also 16 or 32 bits per color component. If this can be utilized in the graphics card with video ram and being able to render to/from it with hardware acceleration that would be MUCH preferred and MUCH faster than the software-driven code I would otherwise have to write.


ImaginaryHuman(Posted 2007) [#12]
btw klepto your code is missing a couple of >-1 on the end of the tests for extensions - particularly for the frame buffer object and texture compression.

Add >-1 on the end to properly report.


Michael Larson(Posted 2007) [#13]
FBO wouldn't be my first choice of things to play around with... PBuffers / CopyTex are faster, less ambiguous and have better state management mechanisms.

But if your just playing around :) it's your time.


klepto2(Posted 2007) [#14]
You know the difference between PBuffers and Pixel Buffer Objects? It seems you throw things together.
FBOs are the currently most supported and fastest method to do rendertotexture. PBuffers are a lot harder to implement and to handle. CopyTex, it is as fast as FBOs on some machines but tests by some friends of mine (my ATI seems to be corrupted on RTT) gives around 20% better speed with FBOs. At least because
you don't have to transfer the pixeldata to the texture instead it is dirctly rendered to it.


ImaginaryHuman(Posted 2007) [#15]
I would agree, haven't done a speed test but from what I've read FBO's supercede all functionality of pbuffers, are more flexible and dont require a separate context for each buffer. I would think definitely the FBO is faster than drawing to the backbuffer, grabbing the backbuffer, then clearing the screen.


Michael Larson(Posted 2007) [#16]
I think I know the difference :)


Michael Larson(Posted 2007) [#17]
PBuffer vs FBO, it's sort of a religion thing. There are equal trade offs for both but since I implemented PBuffers and I work on the Opengl Framework on Mac OS X I think I understand a bit more than most on this :)

But when using a shared context a PBuffer is a very fast mechanism to do render to texture and the shared context retains your opengl state and there are other benefits for PBuffers.

If I wanted to hold the company line I would say FBO FBO FBO... but I think people should make up their own mind on this.


AndyGFX(Posted 2008) [#18]
I tried this sample and after compiling prg show that FBO isn't suported, but it's strange because i have NV 8800 GTX. What is problem?


Bobysait(Posted 2008) [#19]
If THardwareInfo.FBOSupport = True Then
	Print "FBO supported!"
Else
	Print "FBO not supported!"
EndIf

Am I Wrong ?
+> Extensions.Find("ARGUMENT") will return a number if found ( else -1).
So Extensions.Find("GL_EXT_framebuffer_object") might return any number if available

if you check :
If THardwareInfo.FBOSupport = True

if will test only if FBOSupport=1 and might return false

so it should be :
If THardwareInfo.FBOSupport > -1



klepto2(Posted 2008) [#20]
Of course you're right, it was a small bug. I've forgotten to add "> -1" after the find method. So the correct line should be this:
		THardwareInfo.FBOSupport = Extensions.Find("GL_EXT_framebuffer_object") > -1



Bobysait(Posted 2008) [#21]
Whatever, really a good job on this module !
I don't use minib3d at all, but parts of your code help me sometimes to solve problems on my own engine, So many thanks for that :)