Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: get current context & current display  (Read 3476 times)

0 Members and 1 Guest are viewing this topic.

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
get current context & current display
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
get current context & current display
« Reply #1 on: October 10, 2011, 10:14:50 pm »
wglGetCurrentContext and wglGetCurrentDC ;)
Laurent Gomila - SFML developer

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
get current context & current display
« Reply #2 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
get current context & current display
« Reply #3 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.
Laurent Gomila - SFML developer

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
get current context & current display
« Reply #4 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 :)