View Full Version : Don't display framebuffer from within program

10-01-2008, 04:53 AM
Hi all,

I'm experimenting with OpenGL in combination with SAGE (tiled displays) and I'm having the following issue.

First I tried to write a program using GLUT, it worked fine, but the machine where the program has to run doesn't have an X installation nor does it even have a display. It's sole purpose is, normally, to stream video content to the display nodes using the SAGE library. This works by copying data into a framebuffer.

So I thought I can do the same with OpenGL, I left out all the GLUT stuff so it doesn't try to create a window and instead use glReadPixels() to read the content from the framebuffer. Well content, all I get are zeros.

My question is whether it is possible to do what I want and if there's some sort of initialization within OpenGL required to make this work.

So basically what I want is this:

1) Render some stuff while not displaying anything
2) Grab content from OpenGL framebuffer
3) Put content into SAGE framebuffer

This is the drawing function I'm using, it's being called from a loop. "glPixelStorei(GL_UNPACK_ALIGNMENT, 1)" is also being called in the initialization of the program.

void redraw()

glTranslatef(0.0f, 0.0f, -6.0f);

glRotatef(rotate, 0.0f, 1.0f, 0.0f);


glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 0.0f);

glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 1.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 2.0f);

glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(0.0f, 1.0f, 1.0f);
glVertex3f(1.0f, 0.0f, 2.0f);
glVertex3f(-1.0f, 0.0f, 2.0f);

glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 0.0f, 2.0f);
glVertex3f(-1.0f, 0.0f, 0.0f);


void *rgbBuffer = sageInf.getBuffer();

glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, rgbBuffer);


rotate += 10.0f;


10-01-2008, 07:47 AM
Are you creating a GL context? If you don't, then GL function calls are ignored.
Also, I beleive you need to have a X window running in order for the graphics drivers to work.
If that is not an option, what you need is some kind of offline software renderer like mesa3d.org
They had a special version of MESA just for doing offscreen rendering.

10-02-2008, 01:36 AM
Well, that's the point, I actually don't want to have an X window running since that's not possible on that machine. So how would I create a GL context? I'll try to google it... ;)

I'll also look into the offline software renderer, thanks for the pointer.

10-02-2008, 04:00 AM
Thanks alot! I've just adjusted my program to use off-screen rendering and it works like a charm :P