0

I am creating a video player application and I was wondering what would be the optimize way to handle the media changing action.

For now I am using 2xPBOs as explain here: OpenGL Pixel Buffer Object (very awesome website by the way) and some textures. In order to keep perfect colour and aspect, I need my PBOs and my textures to be the same size as my video clip. (The resize is done only once during the shadder stage).

So basically, if the actual media is like 1920x1080 but the next one on the playlist is 1280x720 what should I do? I am thinking of 2 solutions right now:

  1. Resizing PBOs and Textures on the fly
  2. Recreating everything, my whole OpenGLPreviewWidget

I know the solution 1 is include in solution 2 but, should I recreate a openGL context, windows, etc. or, because it's too slow, just resizing would do it?

Nox
  • 932
  • 1
  • 9
  • 27
  • Creating a whole new context implies a lot of work for the driver, say that you have a language that runs on a VM, like C# or Java it would be the difference between reallocating an int[] buffer vs destroying the VM instance and creating a new one with the buffer you want. Recreating a texture is much easier for the driver, its some validation, a memory allocation and a GPU transfer. – TheStack Feb 24 '15 at 11:31

1 Answers1

3

Creating a new context is a fairly heavy weight operation, at least compared to most other things you would do when you use OpenGL. So unless you have a good reason why you need a new context, I would avoid it.

Re-allocating the PBOs and objects is easy enough. As you already pointed out, you'll end up doing this in either case. If that alone is enough, I think that's the way to go.

Reto Koradi
  • 53,228
  • 8
  • 93
  • 133