Hi everybody,

If you see this question duplicated I'm sorry, it is because I have
written in the forum 4 days ago but my post is not approved yet, so I
will try here :P

I am developing an osg application in Windows that uses OpenCL
computation in some VBOs using the OpenGL/CL interop. For achieve
this, OpenCL has to be initialized with some info about OpenGL
contexts: the device context and the rendering context.

The first version of my application was implemented in OpenGL, so I
got the contexts using the functions wglGetCurrentDC() and
wglGetCurrentContext().

But now, I am passing it to OSG and I have errors in the OpenCL init.
I have been reading about this question and I discovered the getHDC()
and getWGLContext() of the GraphicsHandleWin32 class. But I think that
I am not doing a correct use of the class.

The way that I use this class is the next:

1- I declare a GraphicOperation derived class that will be executed in
the viewer->realize() method:

class WindowsContextInfo : public osg::GraphicsOperation
{
public:

        WindowsContextInfo():
                osg::GraphicsOperation("WindowsContextInfo", false) {}

                virtual void operator() (osg::GraphicsContext* gc) {
                        osgViewer::GraphicsHandleWin32* windowsGraphicContext =
dynamic_cast<osgViewer::GraphicsHandleWin32*> (gc);
                        hdc = windowsGraphicContext->getHDC();
                        wglContext = windowsGraphicContext->getWGLContext();
                }

                HDC hdc;
                HGLRC wglContext;
};

2- I attach an object of this class to the viewer and I call the
viewer->realize() method:
osg::ref_ptr<WindowsContextInfo> wci = new WindowsContextInfo;
viewer->setRealizeOperation(wci.get());
viewer->realize();

3- In the init properties of OpenCL I use the wci object for get the
HDC and the wlgContext:

cl_context_properties props[] = {
        CL_CONTEXT_PLATFORM,
        (cl_context_properties) platform, //This is not important
        CL_GL_CONTEXT_KHR,
        (cl_context_properties) wci->wglContext,
        CL_WGL_HDC_KHR,
        (cl_context_properties) wci->hdc,
        0
};

This is all I have tried, but doesn't work. If someone knows what I
have done wrong I will pray for him to the Flying Spaghetti Monster.

Thanks!

-- 
--------------------------------------
Carlos Reig Matut
LSyM - Instituto IRTIC
Universidad de Valencia

Ph. +34 96 354 3639 -- ext. 43639
http://irtic.uv.es/lsym
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to