XRenderCreatePicture to OpenGL Texture

Help!!!

What I’m trying to do is using Xcomposite to be capable to grab the display in the backbuffer of my desktop applications running, convert them into texture and then present them inside an OpenGL application. So far so good, however I can’t figure it out how to convert the image that I got into memory to an OpenGL texture, check out the code below:

#include <GL/gl.h>  
#include <GL/glu.h>
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>

int main(int argc, char ** argv)
{
	Display *dpy = XOpenDisplay(":0.0");
	
	bool hasNamePixmap = false;

	int event_base, error_base;
	if ( XCompositeQueryExtension( dpy, &event_base, &error_base ) )
	{
		int major = 0, minor = 2;
		XCompositeQueryVersion( dpy, &major, &minor );	
		if ( major > 0 ?? minor >= 2 ) hasNamePixmap = true;
	}
	
	for ( int i = 0; i < ScreenCount( dpy ); i++ )
	XCompositeRedirectSubwindows( dpy, RootWindow( dpy, i ), CompositeRedirectAutomatic );	
	
	XWindowAttributes attr;
	Window wid = 0x2600001; // i.e
	XGetWindowAttributes( dpy, wid, &attr );
	
	XRenderPictFormat *format = XRenderFindVisualFormat(dpy, attr.visual);
	bool hasAlpha             = ( format->type == PictTypeDirect && format->direct.alphaMask );
	int x                     = attr.x;
	int y                     = attr.y;
	int width                 = attr.width;
	int height                = attr.height;

	printf("%d %d %d %d", attr.x, attr.y, attr.width, attr.height);	
	
	XRenderPictureAttributes pa;
	pa.subwindow_mode = IncludeInferiors; // Don't clip child widgets

	Picture picture = XRenderCreatePicture( dpy, wid, format, CPSubwindowMode, &pa );
	
	// How I can now take that picture in memory and then
	// convert it to an OpenGL Texture????

	glGenTextures(1, ????????);
}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.