Hi all,
I don’t get this to work, and I would like to know if this actually even possible. I would like to render offscreen on a Linux server and send the pixel data to a client. I have read about FBOs, and that they are independent of any windowing system, so I thought this would be the right approach to get this to work.
The code roughly looks like this:
The initialization:
// create FBO (offscreen framebuffer)
glGenFramebuffersEXT(1, &fb);
// bind offscreen buffer
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glGenRenderbuffersEXT(1, &depthbuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, 512, 512);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL _RENDERBUFFER_EXT, depthbuffer);
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYT E, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_T EXTURE_2D, tex, 0);
Some rendering…
Getting the pixel data:
unsigned char data[786432];
// read from texture
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
This will not produce the expected pixel data when I run this on a SSH console. I actually need to run this in a X console and open a X window first (using glut for that) and then I get the expected pixel data.
Any ideas if it is even possible to render offscreen using FBOs (or any other method) on a server where you actually don’t have a windowing system available?
Thank you.
Mark