Jump to content
  • Advertisement
Sign in to follow this  
personwholives

OpenGL GL rendering without a window

This topic is 3911 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Or you probably don't even need to create the FBO, just hide the window and read the data from your default framebuffer. :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Brother Bob
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.


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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 pBuffer
pBuffer.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);


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!