2

I'm trying to read pixels from GLX context. here is how I'm creating context

int Attributes[] =
{
  GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
  GLX_RENDER_TYPE,   GLX_RGBA_BIT,
  GLX_DOUBLEBUFFER,  GL_TRUE,
  GLX_RED_SIZE,      8,
  GLX_GREEN_SIZE,    8,
  GLX_BLUE_SIZE,     8,
  None
};

visual = glXChooseVisual(display,
                               DefaultScreen(display), 
                                   Attributes);


if (visual == NULL)
{
  return -1;
}

glxContext = glXCreateContext(display, visual, NULL, GL_TRUE);


XLockDisplay(displayGLX_);

int result = glXMakeCurrent(display, windowHandle, glxContext);

XInitThreads();

then I'm rendering simple triangle and I want to read that buffer by glReadPixels. Is there any posibility to do it?

glReadBuffer(GL_BACK);

glXSwapBuffers(display, windowHandle);

and then I'm calling

glReadPixels
Alatriste
  • 527
  • 2
  • 6
  • 21

1 Answers1

3

Dont swap 1st, you read from the BACK buffer, so glReadPixels before swap...

AnalyticaL
  • 501
  • 2
  • 9
  • I did but I have error like this `[xcb] Unknown request in queue while dequeuing [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. nxplayer.bin: xcb_io.c:188: dequeue_pending_request: Assertion !xcb_xlib_unknown_req_in_deq' failed.` But I already called XInitThreads(). – Alatriste Jun 16 '16 at 14:06
  • @Alatriste: XInitThreads **must** be called before any other Xlib function if your program does multithreaded Xlib calls. Calling right in the middle of your program will not work. – datenwolf Jun 16 '16 at 16:21