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:
- Render some stuff while not displaying anything
- Grab content from OpenGL framebuffer
- 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()
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -6.0f);
glRotatef(rotate, 0.0f, 1.0f, 0.0f);
glBegin(GL_TRIANGLES);
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);
glEnd();
void *rgbBuffer = sageInf.getBuffer();
glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, rgbBuffer);
sageInf.swapBuffer();
rotate += 10.0f;
::usleep(50000);
}