Step by Step Render to Offscreen Image

Started by tfletche, December 12, 2011, 19:32:52

Previous topic - Next topic

tfletche

I'm relatively new to GL and am trying to work out the steps I need to take to render an object to offscreen content and transfer that content to an SWT Image (I'm writing an Eclipse plugin).

I have code that can load a Wavefront OBJ file and I can render that content using an SWTCanvas object similar to this example:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet195.java

Since I'm trying to incorporate content in the middle of another display, I can't use an SWTCanvas, but need to use an Image.  I have read about FrameBufferObjects:
http://lwjgl.org/wiki/index.php?title=Using_Frame_Buffer_Objects_(FBO)

But I'm not sure how to tie it all together.  Is there a simple example of setting up and rendering to offscreen content that anyone can point me at?

Thanks,
Thomas

tfletche

An update on this .. I've managed to take this reference:
http://lwjgl.org/wiki/index.php?title=Render_to_Texture_with_Frame_Buffer_Objects_(FBO)

update it to compile with the latest version of LWJGL and I can now render content into an FBO and copy it into an SWT Image.

Now I'm starting the process of cleaning it all up to understand it better. 

Since I'm rendering to a buffer/image, I don't really want to have a window pop-up, but I've found that unless I call:
   org.lwjgl.opengl.Display.setDisplayMode(new DisplayMode(width, height));
   org.lwjgl.opengl.Display.create();

I will run into errors.  Is it possible to do the initialization such that a window is not created/displayed?

Thanks,
Thomas 

Evil-Devil

You can try the PBuffer. Thus does not require the display to be created.

tfletche

Thanks!

Looking at the JavaDoc for even constructing a PBuffer object I see that the constructor still takes a Drawable.  It seems that the docs indicate I can pass in null for this.
Google's given me a few test cases so I'll give those a try and see what happens!

Thanks
Thomas