iDevGames Forums
OpenGL CopyBits Replacement... - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: OpenGL CopyBits Replacement... (/thread-5875.html)

Pages: 1 2


OpenGL CopyBits Replacement... - feelgood - Feb 15, 2005 05:13 PM

OK, I've been working on a OpenGL accelerated QuickTime Player for Mac OS X. I've started work on a new UI that supports live resize (heh, who said you couldn't do this efficiently in Mac OS X?) and minimizing into the dock. Now I've managed to figure out all of the tricks required to update a GL surface in a minimized window but I know that my current approach is far from ideal because as I'm using CopyBits(...) (argh QuickDraw) to transfer my rendered GL buffer into the window's backing store before updating. While this might be fine (although it's slow) in Panther this is going to be a problem in Tiger. So I'm wondering if anyone here knows how I can replace the following QuickDraw call:

Code:
CopyBits(GetPortBitMapForCopyBits(myGWorld), GetPortBitMapForCopyBits(GetWindowPort(myWindowRef)), &myViewRect, &myViewRect, srcCopy, 0);

With our OpenGL equivalent:

Code:
glDrawPixels(myViewRect.width, myViewRect.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, myWindowBuffer);

I'm assuming that one can do this...


OpenGL CopyBits Replacement... - OneSadCookie - Feb 15, 2005 06:05 PM

You need to draw into the window's back buffer, so Quartz is the way to go if you want to avoid QuickDraw. Personally, I wouldn't be worrying. It's not like your rendered image is resolution-independent, and it's not like it's getting any larger than the window, so I think you should be fine.


OpenGL CopyBits Replacement... - feelgood - Feb 15, 2005 06:16 PM

OneSadCookie Wrote:You need to draw into the window's back buffer, so Quartz is the way to go if you want to avoid QuickDraw. Personally, I wouldn't be worrying. It's not like your rendered image is resolution-independent, and it's not like it's getting any larger than the window, so I think you should be fine.
Well my biggest concern is the current performance of CopyBits under Panther (i.e. it sucks). For 720p HD content I've found that CPU load more than doubled w/ a minimized window updating in the dock. It's bad enough that I have to invert the image returned from glReadPixels (stupid memcpy() in a loop argh) before I pass it off to CopyBits so I'm really looking to save as much CPU as possible so maybe I'll try moving over to Quartz...


OpenGL CopyBits Replacement... - kelvin - Feb 15, 2005 06:24 PM

feelgood Wrote:It's bad enough that I have to invert the image returned from glReadPixels (stupid memcpy() in a loop argh) before I pass it off to CopyBits so I'm really looking to save as much CPU as possible so maybe I'll try moving over to Quartz...
You could use a)vImage(altivec) to flip your image.
or b)Use Quartz to flip the image. With NSImage I've found that flipping is pretty fast with toggling the inverted flag.


OpenGL CopyBits Replacement... - OneSadCookie - Feb 15, 2005 07:49 PM

why is this a performance issue? surely you're only doing it when the window is about to be minimized...


OpenGL CopyBits Replacement... - feelgood - Feb 15, 2005 08:05 PM

OneSadCookie Wrote:why is this a performance issue? surely you're only doing it when the window is about to be minimized...
Uh I want my video content to play while minimized... that (at a minimum) means glReadPixels() -> [image invert] -> CopyBits() once per frame... Sure if I just wanted a snapshot then this isn't an issue but I want live playback.


OpenGL CopyBits Replacement... - OneSadCookie - Feb 15, 2005 08:14 PM

personally, as a potential user of your program, I don't want it to play whilst minimized -- leave my cpu cycles for the programs I'm actually interacting with at the time Rasp


OpenGL CopyBits Replacement... - feelgood - Feb 15, 2005 08:26 PM

OneSadCookie Wrote:personally, as a potential user of your program, I don't want it to play whilst minimized -- leave my cpu cycles for the programs I'm actually interacting with at the time Rasp
I might end up abandoning this feature if I can't get these performance issue(s) under control because I want low CPU to be the name of the game w/ this application. On the other hand it's pretty cool to be able to play video (w/ shader effects) in the dock... Wink


OpenGL CopyBits Replacement... - PowerMacX - Feb 16, 2005 12:27 AM

feelgood Wrote:OK, I've been working on a OpenGL accelerated QuickTime Player for Mac OS X. I've started work on a new UI that supports live resize (heh, who said you couldn't do this efficiently in Mac OS X?) and minimizing into the dock. [...] While this might be fine (although it's slow) in Panther this is going to be a problem in Tiger.[...]

You shouldn't worry about Tiger Wink


OpenGL CopyBits Replacement... - feelgood - Feb 16, 2005 12:59 AM

PowerMacX Wrote:You shouldn't worry about Tiger Wink
Uh, so? I'm an ADC member and I'm quite familiar w/ Tiger and QT 7 etc...


OpenGL CopyBits Replacement... - PowerMacX - Feb 16, 2005 03:18 AM

Well, by your description it sounded like you are trying to implement QT 7 features (OpenGL acceleration, live resizing) Huh


OpenGL CopyBits Replacement... - feelgood - Feb 16, 2005 05:05 PM

PowerMacX Wrote:Well, by your description it sounded like you are trying to implement QT 7 features (OpenGL acceleration, live resizing) Huh
Yes I want live resize and GL acceleration as well as a few other features that QT7 will never have (shader effects, zooming, etc.)...


OpenGL CopyBits Replacement... - arekkusu - Feb 16, 2005 05:23 PM

If you have Tiger seeds, I suggest reading the Core Video documentation.


OpenGL CopyBits Replacement... - feelgood - Feb 16, 2005 06:19 PM

arekkusu Wrote:If you have Tiger seeds, I suggest reading the Core Video documentation.
Uh yeah I have (duh)... Most (though not all) of the shader effects I've written for this app are not in any of Tiger's default CI IUs. A few of the ones that are happen to be of lower quality or they are less efficient than mine. The other GL based options I've implemented (pan and zoom etc.) also won't be in Tiger's QT Player. CV isn't automatically going to get you this. Yes it does help to give you live resize etc. but that isn't a much of a big deal either (yes, it's still a pain)... The only real thing I've seen that CV will buy you is a heavily buffered async. decode before the GL blit. This would be a PITA for Panther currently and it probably happens to be the #1 cause of 'slow' preceived video performance for GL (video) apps. No doubt that Apple put alot of work into this...


OpenGL CopyBits Replacement... - lightbringer - Feb 16, 2005 06:33 PM

Feelgood, maybe you should post a build.

I think people will be much more interested then.

EDIT: I've been following feelgoods progress as of recent and it's cool to see this stuff in action, regardless if it's pretty much what we'll get in Tiger or not.