PDA

View Full Version : How to hide the image generated by OpenGL



cyxcw1
03-17-2013, 08:20 PM
Hello, I'm a Chinese. I'm sorry that my English is not good.
I want to make OpenGL to be a image generater work in backstage, I don't want to display the image generated by it.
How to hide the image or not generated the image?
Thank you, every one!

cyxcw1
03-17-2013, 08:30 PM
I use windows to be my platform

aqnuep
03-17-2013, 09:50 PM
Use a framebuffer object (ARB_framebuffer_object (http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt)) to render to a texture. After that, just use GetTexImage to get its content.

cyxcw1
03-18-2013, 07:52 PM
Thanks for answering me. Do you have some easier ways to solute this question? I'm a beginner and the way you recommand is a little hard to me.
Before that my way was to hide the window by using the windows API, but it didn't work.
Thanks

tonyo_au
03-18-2013, 10:00 PM
Before that my way was to hide the window by using the windows API
This does not work because Windows is clever enough to know the window is not visible and clip the output to nothing. You have to use an offscreen frame buffer if you don't want the window to seen.

Dark Photon
03-19-2013, 04:41 AM
This does not work because Windows is clever enough to know the window is not visible and clip the output to nothing. You have to use an offscreen frame buffer if you don't want the window to seen.

A few other ideas. 1) Allocate a double-buffered window, only draw to the back buffer, and never swap buffers. 2) Allocate a GL context to draw to a pbuffer instead of a window. Seems like that was the old method prior to FBOs.

That said, FBOs are pretty easy.

Alfonse Reinheart
03-19-2013, 06:06 AM
Allocate a double-buffered window, only draw to the back buffer, and never swap buffers.

The pixel ownership test doesn't care about single or double buffers. If the screen pixel isn't owned by the window, then the pixel ownership test fails and the pixel's value is undefined.

You have to use some off-screen mechanism.

cyxcw1
03-20-2013, 01:03 AM
The pixel ownership test doesn't care about single or double buffers. If the screen pixel isn't owned by the window, then the pixel ownership test fails and the pixel's value is undefined.

You have to use some off-screen mechanism.
Does it mean FBO is the only way? I will learn it. Thanks

cyxcw1
03-25-2013, 06:37 AM
I want to ask that, can I use glReadPixels instead of glGetImage?

cyxcw1
03-26-2013, 07:08 PM
In fact I don't want to display the window. But once the "glutCreateWindow" excute, the window is created.
In addition, I don't know how to read information from a FBO, "glReadPixels" didn't work. How to use "glGetImage"?
Thanks!

Alfonse Reinheart
03-26-2013, 08:05 PM
"glReadPixels" didn't work

How about you post the code that "didn't work" so that someone can tell you why it didn't.


How to use "glGetImage"?

There is no "glGetImage". There is a `glGetTexImage` function, but that works for textures.

cyxcw1
03-27-2013, 12:08 AM
How about you post the code that "didn't work" so that someone can tell you why it didn't.



There is no "glGetImage". There is a `glGetTexImage` function, but that works for textures.
Yeah, it's "glGetTexImage". I want to read the whole information, not just textures information.
I don't want to let the window appear. Do you have some good idea?