FrontBuffer

BlitzMax Forums/BlitzMax Beginners Area/FrontBuffer

H&K(Posted 2007) [#1]
Am I right in thinking that I cannot draw directly onto a Canvas?
That is I need to double buffer it.

If It is possible to draw directly onto the Canvas' frontbuffer, can someone point me in the right direction as to how to.

Thanks


ImaginaryHuman(Posted 2007) [#2]
At least in opengl see glDrawBuffer(GL_FRONT)

You do not need a double buffer. You can leave out the doublebuffering flag when you create your graphics context, ie define the default flags for your graphics driver and make sure it doesn't include doublebuffering. Then when it gets created it doesn't automatically ask for or make a double buffer.

with glDrawBuffer(GL_FRONT) you can then output directly to the visible buffer. Remember the graphics card might not necessarily draw things as you ask for them, you may need to at some point do a glFlush() or glFinish().

Also, something to think about, if you really do ask for or get a double buffered context, and you try to choose the front buffer, it does not always work. Some systems will not represent front and back reliably. If you mix in doing a Flip(), even once, and then you try to ask for the front buffer to draw to, it may still output to the backbuffer, whereby back became front, but the way it does it is not consistent so you basically totally lose track of which buffer you really are looking at and which one you really want to ask to draw to. Moral of the story: don't ask for a double-buffer if you don't plan to use it, and ideally never call flip() if you're working on the front buffer.

Have no idea how you do this in DX, and don't care either ;-)


skidracer(Posted 2007) [#3]
You could try using SetGraphicsDriver with a different second parameter (defaults to doublebuffered).


H&K(Posted 2007) [#4]
You could try using SetGraphicsDriver with a different second parameter (defaults to doublebuffered).
Ive tried that, and on a canvas it still apears that its Double buffered.

@Angel, ;)
Thats exactly what you said on your thread about single buffering, which I had looked up before posting. I havent looked at it more than just read it, but you said it didnt work with max2d which is what I really wanted to do.

I dint really want to use GL commands, because I just wanted to do a quick overlay, and not get caught up in the whole GL thing. But Ill have a go at useing it.


skidracer(Posted 2007) [#5]
What exactly are you trying to do?

By default the dx canvas looks pretty single buffered to me, if it wasn't the following would flicker as alternate frames would include different images (odd rotations vs even rotations):



H&K(Posted 2007) [#6]
Well for a start if you take the "Flip" out of your code, nothing is Drawn and my canvas still has its original stuff on it, OK so the flip is just acting as a "Draw the stuff" command.
But I was trying to draw onto of a canvas that already has stuff on its frount buffer. That had been drawn by another application, and the "Flip" is well... fliping.

Its not important though, as, as you said. Your code is doing what I want, it just doesnt work with what I wanted.


H&K(Posted 2007) [#7]
To be more specific, I have created a Canvas Gadget, onto which I have trapped the Irrlicht render, I had assumed therefore that if I passed the Canvas handle to setgraphics then I could simply draw ontop of this render. However I need the "Flip" to say the drawingcommnads are finished. And on this flip the Irrlicht render is flipped out. (Or rather the driver draws a whole new frame which is different from the Irrlicht render)

Obviously it doesnt work as I wanted it to. HOWEVER it is working just the way Skid, angel and Gman said it would. (In different threads)

Just means Ill have to start to learn the irrlicht 2d text stuff. (Or...... capture the irrlicht render to an image, and draw that behind the max2d stuff... but that would e slow wouldnt it?)


ImaginaryHuman(Posted 2007) [#8]
As skid and I said, surely if you just set up your graphics driver defaults to NOT include doublebuffers you *shouldn't* get a backbuffer, and everything should go to the front buffer. ??? including max2d stuff


H&K(Posted 2007) [#9]
Angel it might, but it seems to draw the whole scene, including the "Black" bits, so although its not "fliping" in the sence that flipping normaly means, it is colouring black all the Graphics that the Irrlicht engine has drawn onto the screen.

Originaly I already was starting the graphics object without doublebuffering, but had assumed that I was doing someting wrong because I got "Buffer swap flicker", now apon reflection (And in no small part to your answers), I realise that one of these things is happening

1) BMax really really is using a different canvas for the canvas than the one irrlicht is using. (Which I dont belive, cos Ive passed the same handle to both)
2) The max Driver is, as said, over writing the image with black
3) No Backbuffer is infact a "Fixed" backbuffer which is copied over to the canvas on flip.

This line in the docs
Graphics created with the GRAPHICS_BACKBUFFER flag must be 'flipped' after you have finished rendering using Flip.
Implies that Graphics created without the GRAPHICS_BACKBUFFER flag dont need a flip, but as Skids code showed, they do.

To highlight what I mean further, the image is there on the canvas, and without a backbuffer I do a cls. Now this should clear the canvas. But it doesnt. Because althouh no backbuffer was selected, the drawing is infact taking place on another buffer, which is not the one on the screen.

OK so fair enough, it was my mistake to assume that the "front buffer" was the canvas, but in fact as the name implied a "Buffer", which is then swaped out over the canvas