How to load a Pixmap into an OpenGL Texture:
Picture picture;
Pixmap dest;
XWindowAttributes temp_attr;
…
…
picture = XRenderCreatePicture(desktop->dpy1, children[i], format, CPSubwindowMode, &pa);
XRenderComposite(desktop->dpy1, hasAlpha ? PictOpOver : PictOpSrc, picture, None, dest, 0, 0, 0, 0, 0, 0, temp_attr.width, temp_attr.height);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GLuint texName;
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_2D, texName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, temp_attr.width, temp_attr.height, GL_RGB, GL_UNSIGNED_BYTE, &dest->data); // Crash Here