Draw pixels to frame buffer

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?

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.

yeah! But it is not.))?

and how are you measuring this?

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