PDA

View Full Version : Draw pixels to frame buffer



Itun.itu
01-02-2012, 06:44 PM
I want to DrawPixels through a buffer (I am trying to do that through PBO).


private void Init ()
{
GL.GenBuffers (1, buffers);
GL.BindBuffer (BufferTarget.PixelUnpackBuffer, buffers [0]);
GL.BufferData<byte> (BufferTarget.PixelUnpackBuffer, sizePtr, data, BufferUsageHint.StreamDraw);
}

protected override void RenderFrame ()
{
GL.DrawBuffer (DrawBufferMode.Front);
GL.BindBuffer (BufferTarget.PixelUnpackBuffer, buffers [0]);
GL.DrawPixels (w, h, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
}


I write on C#, but I hope it will be understandable for others.

I also tried another method.



private void Init ()
{
}

protected override void RenderFrame ()
{
GL.DrawPixels<byte> (w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data);
}


And the result of this two approaches is absolutely the same. Why? In the firs one I don't use CPU memory at all. What is the most fast method to copy to the frame buffer?

Leith Bade
01-03-2012, 01:42 PM
The first method uses Pixel Buffer Objects which can use GPU memory to store the data. GPU memory is a lot faster for the GPU to read than CPU memory.

Pixel Buffer Objects should always be faster.

Itun.itu
01-03-2012, 04:26 PM
yeah! But it is not.))?

BionicBytes
01-04-2012, 07:29 AM
and how are you measuring this?

malexander
01-04-2012, 09:38 AM
It's only going to be faster if:

- you're calling render() more often that init()
- if not, you have some work to do between init() and render() to hide the CPU->GPU transfer latency
- the transfer is a bottleneck