Hi
I want to use a p-buffer for creating a dynamic texture, but all i get is a black window. I am setting up the pbuffer like this:
Display* pbuff_display = glXGetCurrentDisplay();
int errorBase, eventBase, major, minor;
if (glXQueryExtension(pbuff_display, &errorBase, &eventBase)) {
bool glxqv;
glxqv = glXQueryVersion(pbuff_display, &major, &minor);
std::cout<<"GLX-Version: "<<major<<"."<<minor<<std::endl;
std::cout<<"GLX-ErrorBase: "<<errorBase<<" EventBase: "<<eventBase<<std::endl;
}
int pbuff_screen = DefaultScreen(pbuff_display);
int pbuff_WishAttributeList[] = {
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_DOUBLEBUFFER, GL_FALSE,
GLX_X_RENDERABLE, GL_TRUE,
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
0 };
int nFBConfigElements;
GLXFBConfig* glxXChooseFBConfig_array =
glXChooseFBConfig( pbuff_display,
pbuff_screen,
pbuff_WishAttributeList,
&nFBConfigElements);
std::cout<<"Number of matching FB-Configs: "<<nFBConfigElements<<std::endl;
GLXContext pbuff_context = glXCreateNewContext(
pbuff_display,
glxXChooseFBConfig_array[0],
GLX_RGBA_TYPE,
0,
GL_TRUE);
int pbuff_AttributeList[] = {
GLX_PBUFFER_WIDTH, ib,
GLX_PBUFFER_HEIGHT, ih,
// GLX_PRESERVED_CONTENTS, GL_TRUE,
0};
GLXPbuffer pbuff_pbuffer = glXCreatePbuffer(
pbuff_display,
glxXChooseFBConfig_array[0],
pbuff_AttributeList);
bool bind_success = glXMakeContextCurrent(
pbuff_display,
pbuff_pbuffer,
pbuff_pbuffer,
pbuff_context);
if (bind_success) {
std::cout<<"Bound PBuffer!"<<std::endl;
} else {
std::cout<<"Bound PBuffer not possible!"<<std::endl;
}
and get for output:
GLX-Version: 1.3
GLX-ErrorBase: 152 EventBase: 70
Number of matching FB-Configs: 3
Bound PBuffer!
after that i render my scene using a display-list that was generated before. then i want to grab the texture:
GLuint render_texture;
glGenTextures (1, &render_texture);
glBindTexture(GL_TEXTURE_2D, render_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA8, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);
now i destroy the pbuffer-stuff and render a quad with the texture applied to it:
glXDestroyPbuffer(pbuff_display, pbuff_pbuffer);
glXDestroyContext(pbuff_display, pbuff_context);
glDisable(GL_LIGHTING);
glDrawBuffer(GL_BACK);
lClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(-10, -10, 0);
glTexCoord2f(1,0);
glVertex3f(+10, -10, 0);
glTexCoord2f(1,1);
glVertex3f(+10, +10, 0);
glTexCoord2f(0,1);
glVertex3f(-10, +10, 0);
glEnd();
then comes a buffer-switch. but everything i get is a black window.
What am i doing wrong?