GL rendering without a window
I am trying to create an opengl app which renders entirely to offscreen buffers and drops those buffers to textures. This part is easy, however, I can't seem to come up with a way to do this without a window. Does anyone know any way to do this?
A second (and worse, IMO) issue, is that I have to do this in java, so I am working with JOGL. Whatever the trick, I need it to work with JOGL. Any thoughts?
Thanks in advance.
There is no such thing as GL rendering without a window.
You can however make the window invisible and render to offscreen buffer (FBO)
I don't know how you make a window invisible in Java but I'm sure it's a simple function call.
You can however make the window invisible and render to offscreen buffer (FBO)
I don't know how you make a window invisible in Java but I'm sure it's a simple function call.
Or you probably don't even need to create the FBO, just hide the window and read the data from your default framebuffer. :)
Quote:Original post by Arex
Or you probably don't even need to create the FBO, just hide the window and read the data from your default framebuffer. :)
That's called undefined behavior. It may or may not work. Even if a window is visible and a small part is hidden, the GPU might not render to it, so they invented p-buffers which were later superceded by FBO.
The pixel ownership section of the spec explains this.
Quote:Original post by V-man
There is no such thing as GL rendering without a window.
There certainly is such a thing. For example, Mesa provides the OSMesa driver which can render to a user defined memory buffer, without a window, or any windowing code at all. Perfect for rendering intended for a purpose other than displaying on the screen in one way or another. For example, I made an experimetal application on my webserver that used Mesa and OSMesa to render an image dynamically with parameters set by submitted data and sent it back to the browser as an encoded image.
However, I doubt the Mesa/OSMesa solution is possible in the environment required by personwholives.
Quote:Original post by Brother BobQuote:Original post by V-man
There is no such thing as GL rendering without a window.
There certainly is such a thing. For example, Mesa provides the OSMesa driver which can render to a user defined memory buffer, without a window, or any windowing code at all. Perfect for rendering intended for a purpose other than displaying on the screen in one way or another. For example, I made an experimetal application on my webserver that used Mesa and OSMesa to render an image dynamically with parameters set by submitted data and sent it back to the browser as an encoded image.
However, I doubt the Mesa/OSMesa solution is possible in the environment required by personwholives.
I'm sure he is running Windows but let's consider Linux.
Is OSMesa hw accelerated on Linux?
The only thing I know is that if I install Linux, Mesa comes with it. usually version 1.2. I don't know if it is Mesa 1.2 or GL 1.2 but it runs in software so I have to install drivers.
I may be wrong but my understanding is that JOGL is designed for use with either the AWT or Swing libraries, and both the awt.Frame and swing.JFame are invisible by default unless you call show() or setVisible(true).
Quote:Original post by V-man
I'm sure he is running Windows but let's consider Linux.
Is OSMesa hw accelerated on Linux?
Probably not.
Quote:Original post by V-man
The only thing I know is that if I install Linux, Mesa comes with it. usually version 1.2. I don't know if it is Mesa 1.2 or GL 1.2 but it runs in software so I have to install drivers.
I assume the situation is similat to Windows; if you install specific drives for particular hardware, you're limited by what the driver implementes or what the hardware provides. Mesa itself though, as a software implementation, implements OpenGL 2.1.
Quote:Original post by personwholives
I am trying to create an opengl app which renders entirely to offscreen buffers and drops those buffers to textures. This part is easy, however, I can't seem to come up with a way to do this without a window. Does anyone know any way to do this?
A second (and worse, IMO) issue, is that I have to do this in java, so I am working with JOGL. Whatever the trick, I need it to work with JOGL. Any thoughts?
Thanks in advance.
You mean something like this ?
GLPbuffer pBuffer;if( GLDrawableFactory.getFactory().canCreateGLPbuffer() ) { pBuffer = GLDrawableFactory.getFactory().createGLPbuffer(glcaps, null, texWidth, texHeight, null); pBuffer.addGLEventListener(this); } else { System.out.println("The graphics card has no pbuffer support.");}// start rendering into the pBufferpBuffer.display();GL gl = pBuffer.getContext().getGL();gl.glFinish();pBuffer.getContext().destroy();
To obtain the rendered image call this in your display function:
ByteBuffer result = ...;gl.glReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, result);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement