Copying from OpenGL window to other window

Member
Posts: 260
Joined: 2005.05
Post: #1
I have some very special reasons to run an OpenGL animation on one screen and copy from there to another screen. I tried good old CopyBits, which does a very good job when copying between normal windows, but it copies white. I suspect that it copies the back buffer of the window, which might not be in use when OpenGL renders to the window. That is a mere guess.

I did the same thing under OS9 in the past, where it worked just fine, but OS9 doesn't have double-buffered windows.

Is this indeed the case, can't I copy from OpenGL with CopyBits? I have tried glReadPixels, but it is way slower and delivers the pixels in the wrong order. Any other options I should try?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
You could try using FBOs and drawing the resulting texture to the other window, or use glCopyTexSubImage2D to copy the framebuffer to the texture. In both cases, you'll need to have shared contexts.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
no, you can't use CopyBits, because it copies the pixels in the window, where the OpenGL context is a special kind of overlay.

I'm not quite clear on your requirements here. You have two windows on separate screens? Do you know that they are or aren't on the same video card? Have you had to force your OpenGL context to stick to a particular screen (eg. using the display mask or single renderer parameters in the pixel format)? Would it be OK if the pixels ended up in a GL context on the second screen or do you need them in RAM?
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #4
Ingemar Wrote:I have tried glReadPixels, but it is way slower and delivers the pixels in the wrong order.
Just curious, are you on an AGP card?

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #5
OneSadCookie Wrote:no, you can't use CopyBits, because it copies the pixels in the window, where the OpenGL context is a special kind of overlay.

I'm not quite clear on your requirements here. You have two windows on separate screens? Do you know that they are or aren't on the same video card? Have you had to force your OpenGL context to stick to a particular screen (eg. using the display mask or single renderer parameters in the pixel format)? Would it be OK if the pixels ended up in a GL context on the second screen or do you need them in RAM?
Many replies so quickly! Great! Grin

Then it seems my guesses on CopyBits were right. The problem is that the other board has no graphics acceleration, so OpenGL runs very slowly there, but we need to produce animation with decent framerate all the same. Whether it ends up in an OpenGL context or a standard window doesn't matter.

I use a dual processor G5, with a PCI-X (?) board in the 133 MHz slot (a DeckLink HD Pro to be precise). I can do full-screen copying in 100 fps, but OpenGL running on the board (in software, obviously) runs in something like 6-10 fps. glReadPixels have managed to do 30 fps, but with mixed-up colors.

Using two OpenGL windows, only doing full-screen copying with glCopyTexSubImage2D or FBOs, it might work. Could be worth trying.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
I've used PBOs + ReadPixels to get asynchronous readback for the purposes of sending to another output device before now. If you're getting messed up color channels, change your ReadPixels parameters so you don't Rasp

I'm not sure what the Mac OpenGL constraints are on mixing GL between an accelerated an an un-accelerated screen/window are though, sorry. Experimentation would be key Smile
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #7
OneSadCookie Wrote:I've used PBOs + ReadPixels to get asynchronous readback for the purposes of sending to another output device before now. If you're getting messed up color channels, change your ReadPixels parameters so you don't Rasp

I'm not sure what the Mac OpenGL constraints are on mixing GL between an accelerated an an un-accelerated screen/window are though, sorry. Experimentation would be key Smile
Quite so. But a simple way to CopyBits from the front buffer would probably solve everything.

I tried changing the ReadPixels parameters, but it seemed not to accept ABGR, which I believe is the correct format.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
ABGR is a pretty unusual format... anyway, your hardware should support GL_EXT_abgr, in which case you can just use ABGR_EXT with either UNSIGNED_INT_8_8_8_8_REV or UNSIGNED_INT_8_8_8_8 depending on Intel/PowerPC and it'll give you what you want.

In the more likely case that you want ARGB, you use BGRA_EXT with UNSIGNED_INT_8_8_8_8 or UNSIGNED_INT_8_8_8_8_REV depending on Intel/PowerPC.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Window drop shadows NelsonMandella 9 5,754 Mar 21, 2010 02:34 PM
Last Post: NelsonMandella
  SDL. How to hide fullscreen window e40pud 1 4,190 Mar 11, 2010 01:23 PM
Last Post: cmiller
  How do I place all of my UI elements to be subviews of another view/window? xenocide 2 2,849 Feb 1, 2009 08:32 PM
Last Post: xenocide
  New window with button at start imaumac 0 1,419 Nov 5, 2008 03:55 PM
Last Post: imaumac
  FBO/Textures/Window Scaling threeam 7 5,018 Apr 19, 2008 03:17 AM
Last Post: threeam