【发布时间】:2016-08-08 16:21:11
【问题描述】:
我想我已经因为这种问题而大发雷霆。我正在使用带有 qt5.6.0 (msvc2015_64) 的 Visual Studio 2015 社区,以制作 QOpenglWidget 来演示使用 OpenCL 的设备计算的结果。
现在我使用函数“wglGetCurrentContext”和“wglGetCurrentDC”盲目地创建上下文,错误是:
“LNK2019 未解析的外部符号 _imp_wglGetCurrentContext 在函数“protected: void _cdecl VolRenGL::createCLContext(int,char const* )”中引用 (?createCLContext@VolRenGL@IEAAXHPEAPEBD@Z)” "LNK2019 未解析的外部符号 _imp_wglGetCurrentDC 在函数 "protected: void _cdecl VolRenGL::createCLContext(int,char const *)" (?createCLContext@VolRenGL@@IEAAXHPEAPEBD@Z) 中引用"
相关代码:
cl_context_properties props[] =
{
CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform,
0
};
cxGPUContext = clCreateContext(props, 1, &cdDevices[uiDeviceUsed], NULL, NULL, &err);
【问题讨论】:
-
如果您使用的是 QOpenGLWidget,则不应创建 OpenGL 上下文:该小部件正在为您执行此操作。你能发布更多你的代码吗?
-
@wasthishelpful:OP 尝试使用 OpenGL 互操作创建 OpenCL 上下文。做到这一点的唯一方法是获取本机平台 GL 上下文的句柄,
wglGetCurrentDC就是为此而生的。