Hi,

I want to initializatze OpenCL using the OSG context (in Windows) in order to 
manipulate the OSG VBOs directly in the GPU.

For that, I need the OpenGL current context and the device context. When I had 
the code wrote directly in OpenGL I used the functions wglGetCurrentContext() 
and wglGetCurrentDC() for get it, but now I would to use the OSG api.

In this moment, I have a code that gets the opengl current context and the 
device context in the viewer realize method. But it doesn't work.

For use Viewer::realize I have to create a child class of GraphicsOperation and 
get all the parameters that I need.


Code:

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;
};




In the main code, before doing viewer.realize() I attach the GraphicOperation 
to the viewer:


Code:

wci = new WindowsContextInfo;
viewer.setRealizeOperation(wci.get());
viewer.realize();




And, when I'm initializating OpenCL, I put the received parameters:


Code:

cl_context_properties props[] = {
    CL_CONTEXT_PLATFORM,
    (cl_context_properties) clPlatform,
    CL_GL_CONTEXT_KHR,
    (cl_context_properties) wci.wglContext,
    CL_WGL_HDC_KHR,
    (cl_context_properties) wci.hdc,
    0
};




Anyone knows why I get an OpenCL context creation error? I will be grateful for 
any track.

Thank you!

Cheers,
Carlos

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50977#50977





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to