OpenGL CopyBits Replacement...

feelgood
Unregistered
 
Post: #1
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...
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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.
Quote this message in a reply
feelgood
Unregistered
 
Post: #3
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...
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #4
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.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
why is this a performance issue? surely you're only doing it when the window is about to be minimized...
Quote this message in a reply
feelgood
Unregistered
 
Post: #6
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
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
Quote this message in a reply
feelgood
Unregistered
 
Post: #8
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
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #9
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
Quote this message in a reply
feelgood
Unregistered
 
Post: #10
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...
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #11
Well, by your description it sounded like you are trying to implement QT 7 features (OpenGL acceleration, live resizing) Huh
Quote this message in a reply
feelgood
Unregistered
 
Post: #12
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.)...
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #13
If you have Tiger seeds, I suggest reading the Core Video documentation.
Quote this message in a reply
feelgood
Unregistered
 
Post: #14
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...
Quote this message in a reply
Member
Posts: 144
Joined: 2004.07
Post: #15
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  QuickDraw(CopyBits) vs CoreGraphics(CGContextDrawImage) cloke 6 5,694 Aug 7, 2004 03:06 PM
Last Post: arekkusu
  glaux.h replacement for mac DJBlufire 1 3,635 Feb 13, 2003 12:16 AM
Last Post: OneSadCookie