X上使用glfw3在OpenGL和OpenCL之间创建共享上下文

X上使用glfw3在OpenGL和OpenCL之间创建共享上下文

本文介绍了如何在OSX上使用glfw3在OpenGL和OpenCL之间创建共享上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenGL和OpenCL构建粒子系统。我需要在OpenGL和OpenCL之间共享VBO,因此创建一个具有相应属性的OpenCL上下文。

I am building a particle system using OpenGL and OpenCL. I need to share VBOs between OpenGL and OpenCL and therefore create an OpenCL context with the appropriate properties.

我知道glfw3暴露了一些本机API函数,了解如何访问CGL。

I am aware that glfw3 exposes some native API functions however I can't figure out how to access the CGL ones.

我基本上需要找到如何使用glfw3运行这个:

I basically need to find how to run this with glfw3:

CGLContextObj kCGLContext = CGLGetCurrentContext();
CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext);

cl_context_properties properties[] =
{
    CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
    (cl_context_properties)kCGLShareGroup,
    0
};

问题也是,但是没有回答OSX的问题。

The problem is also discussed on the glfw github but doesn't answer the question for OSX.

推荐答案

请参阅

Please take a look at my answer to a similar post.

其实你不需要 glfw3

In fact you don't need glfw3's methods to access the current OpenGL context. Just #include the following header files and you should be good to go with your example code.

#include <OpenCL/opencl.h>
#include <OpenGL/OpenGL.h>

这篇关于如何在OSX上使用glfw3在OpenGL和OpenCL之间创建共享上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!