Hi forum,
I am creating a OpenCL context with OpenGL interoperability with the following snippet:
cl_context_properties contextProperties[] =
{
#ifdef defined(_WIN32)
CL_GL_CONTEXT_KHR, (cl_context_properties) windowsContext->getWGLContext(),
CL_WGL_HDC_KHR, (cl_context_properties) windowsContext->getHDC(),
#elif defined(__GNUC__)
CL_GL_CONTEXT_KHR, (cl_context_properties) linuxContext->getContext(),
CL_GLX_DISPLAY_KHR, (cl_context_properties) linuxContext->getDisplay(),
#elif defined(__APPLE__)
CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
(cl_context_properties) shareGroup,
#endif
CL_CONTEXT_PLATFORM, (cl_context_properties) _m_clPlatform,
0
};
//create context with the GPU device only
_m_clContext = clCreateContext(contextProperties,1,&_m_clDevice,NULL,NULL,&errNum);
if(errNum != CL_SUCCESS)
{
osg::notify(osg::FATAL) << "Could not create GPU context." << std::endl;
return false;
}
else
osg::notify(osg::FATAL) << "OpenCL context creation is successful." << std::endl;
I am not getting any error information and i assume that OpenCL context creation is successful. To be sure i want to print out the context properties . I need some hint to do that .
I am trying to get the context properties as follows:
size_t contextPropertySize;
errNum = clGetContextInfo(cxt->_m_clContext,
CL_CONTEXT_PROPERTIES,
0,
NULL,
&contextPropertySize);
cl_context_properties *contextProperties = (cl_context_properties*)alloca(sizeof(cl_context_properties) * contextPropertySize);
errNum = clGetContextInfo(cxt->_m_clContext,
CL_CONTEXT_PROPERTIES,
contextPropertySize,
contextProperties,
NULL);
if( errNum != CL_SUCCESS)
{
osg::notify(osg::FATAL) << __FUNCTION__ << ": " << __LINE__ << ": " << _texref->getName()
<< ": unable to pull out context properties: "
<< cxt->getErrorString(errNum) << std::endl;
}
I am not sure who to print them out as character array . Any hint?
Thanks
Sajjadul