Copying from OpenGL window to other window
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?
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?
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.
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?
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?
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
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.Many replies so quickly! Great!
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?

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.
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 
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

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
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'tQuite so. But a simple way to CopyBits from the front buffer would probably solve everything.
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
I tried changing the ReadPixels parameters, but it seemed not to accept ABGR, which I believe is the correct format.
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.
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Window drop shadows | NelsonMandella | 9 | 4,508 |
Mar 21, 2010 02:34 PM Last Post: NelsonMandella |
|
| SDL. How to hide fullscreen window | e40pud | 1 | 3,457 |
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,410 |
Feb 1, 2009 08:32 PM Last Post: xenocide |
|
| New window with button at start | imaumac | 0 | 1,151 |
Nov 5, 2008 03:55 PM Last Post: imaumac |
|
| FBO/Textures/Window Scaling | threeam | 7 | 4,094 |
Apr 19, 2008 03:17 AM Last Post: threeam |
|

