SFML community forums

Help => General => Topic started by: Yours3lf on October 10, 2011, 07:44:50 pm

Title: get current context & current display
Post by: Yours3lf on October 10, 2011, 07:44:50 pm
Hi,

I'm currently experimenting with OpenCL OpenGL interoperation, so to set up my context I'd need the current context and the current display id.

with glx it looks like this:
Code: [Select]
cl_context_properties properties[] =
{
  CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(), //the GL context id
  CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(), //the display id
  CL_CONTEXT_PLATFORM, (cl_context_properties)the_cl_platform, //this is set up by me
  0
};

cl_int error;
//the_cl_device is set up by me
the_cl_context = clCreateContext(properties, 1, &the_cl_device, 0, 0, &error);
assert(error == CL_SUCCESS);


so how can I get the same GL context id and window id in SFML?
NOTE: I'm on Linux.

here's the pdf that explains CL-GL interop:
http://sa10.idav.ucdavis.edu/docs/sa10-dg-opencl-gl-interop.pdf

Best regards,
Yours3!f
Title: get current context & current display
Post by: Laurent on October 10, 2011, 10:14:50 pm
wglGetCurrentContext and wglGetCurrentDC ;)
Title: get current context & current display
Post by: Yours3lf on October 11, 2011, 04:28:04 pm
Thanks Laurent, but I'm on linux :) so I guess that doesn't apply to me...
Or does it? I tried it but either I have to include something else or that's windows only.
Title: get current context & current display
Post by: Laurent on October 11, 2011, 04:30:17 pm
Sorry, I thought you were asking for the equivalent on Windows.

You can use your code directly even with SFML, glX calls are still valid if you want to access the current context/window.
Title: get current context & current display
Post by: Yours3lf on October 11, 2011, 06:03:26 pm
ok, thanks :) after a quick googling I found that I just need to include GL/glx.h and the glx funcs are working now :)