I use Off Screen MESA GL library for this:
http://www.mesa3d.org/osmesa.html

It uses all my existing code for the GL drawing, but spits out an image using imagemagick in the end.  My Code is here:
https://github.com/EMSL-MSC/cview/blob/master/src/oscview.m

It needs a few GLUT fakery functions:
https://github.com/EMSL-MSC/cview/blob/master/src/glutstub.c

Evan


On Sat, Aug 17, 2013 at 11:48 AM, John Tsiombikas <nuclear@member.fsf.org> wrote:
Please wrap your email text at the 72nd column so I don't have to do the
chore just to be able to respond. It's standard netiquette.

On Sat, Aug 17, 2013 at 10:00:23AM -0700, Clive McCarthy wrote:

> My first thought was that I should start with OpenCL but there are
> posts on the web that suggest this isn't really ready for easy
> everyday use. In addition there is a whole new learning curve for me!

That's rather vague. I used OpenCL first time about three years ago, and
it worked just fine. Obviously it depends on the OpenCL vendor, and
nvidia's OpenCL implementation does have some deficiencies (OpenCL 1.1
support only, prone to crash the X server if you do something wrong in
the OpenCL kernel) but it works.

> The broad sequence I want to execute is:
> Load an image and texturize itCompile a fragment shaderOpen a  Frame
> Buffer ObjectRender the texture to the FBO with the shaderSave an
> image from the FBO
> ...
> So my question is: do I need to call glutCreateWindow() if I'm just
> using an FBO?

Yes, glutCreateWindow creates the GLX context. Without it you don't have
a context.

> The general sequence of things would be:
>       glutInit(&argc, argv);  glutInitDisplayMode(GLUT_RGBA |
>       GLUT_DOUBLE);        glutIdleFunc(glut_OpenGL_idle);    // no
>       other call backs are defined            // no window is defined
>       glutMainLoopEvent();

Also drawing in the idle func is a bad idea. set a display callback and
have the idle function just do a glutPostRedisplay all the time.

> Perhaps this is a hopeless perversion of the concept of freeglut and
> perhaps I should just bite the bullet and create my own OpenGL
> context?

Perhaps, but I think you'll hit the same snag. You can't have a GLX
context without a drawable. You might be able to get away with an X
Pixmap as a drawable, but I'm not sure the driver will support that
without falling back to the slow software-emulated path.

Your best bet if you want to stick with OpenGL is to make a regular
window drawable, bind it to the GLX context, then just don't show the
window. You can probably do that with freeglut, no need for messing
around with X and GLX directly if you don't want to. I say "probably"
because I'm not certain without looking at the code, that display
callbacks of hidden windows are called... If that's the case then maybe
you can fallback to the improper use of drawing in the idle function :)

Otherwise OpenCL would suit you much better, as it doesn't even need a
connection to the X server to work.

--
John Tsiombikas
http://nuclear.mutantstargoat.com/

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freeglut-developer