Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xealits/87ceb0043e14d7652530 to your computer and use it in GitHub Desktop.
Save xealits/87ceb0043e14d7652530 to your computer and use it in GitHub Desktop.
Making enjalot script on OpenCL-OpenGL interoperability

The code: https://github.com/enjalot/adventures_in_opencl/tree/master/part2/

From the README:

We demonstrate OpenCL and OpenGL context sharing by making a simple particle system.

Build: make a build directory and build the tutorial

 mkdir build
 cd build
 cmake ..
 make

execute the example program

 ./part2.x

On cmake .. had:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
...
GLEW_INCLUDE_PATH
...
GLEW_LIBRARY

According to ubuntuforum from 2009 changed GLEW_LIBRARY to GLEW_LIBRARIES in the CMakeLists.txt. The plural ending of the variable was present at all the rest of GET_... variables in TARGET_LINK_LIBRARIES. Similar irregularity was present in GLEW_INCLUDE_PATH -- the rest of INCLUDE_DIRECTORIES had ..._DIR instead of ...PATH on the end. Corrected that. cmake .. worked fine.

make reported missing fatal error: GL/glew.h: No such file or directory. Found them (apt-file search GL/glew.h) in libglew-dev. Installed it. Now make has lots of undefined reference to __glewBindBuffer and alike.

Looking at title "Could NOT find GLEW (missing: GLEW_INCLUDE_DIR GLEW_LIBRARY)" of the issue, and getting that headers were found, but the function definitions were not, changed GLEW_LIBRARIES back to GLEW_LIBRARY in CMakeLists.txt.

Compiled!

@xealits
Copy link
Author

xealits commented Sep 27, 2015

Ok, now the it runs.

$ ./part2.x 
Hello, OpenCL
Initialize OpenCL object and context
cl::Platform::get(): CL_SUCCESS
platforms.size(): 3
getDevices: CL_SUCCESS
devices.size(): 1
type: device: 2 CL_DEVICE_TYPE_CPU: 2 
(X) Before defining OS-specific context properties.
(X) Defining OS-specific context properties after Win32 if branch (final else, must be Linux?).
(X) Create command queue.
load the program
kernel size: 408
build program
done building program
Build Status: 0
Build Options:  
Build Log:   
Creating VBO
created VBO, activated, uploaded the data
checked the data is the same as in the input
bound buffer, id = 1
Creating VBO
created VBO, activated, uploaded the data
checked the data is the same as in the input
bound buffer, id = 2
gl interop!
LKAJFA
p_vbo = 1
c_vbo = 2
aaaaaaaaaaaaaa
created OpenCL buffer from GL VBO 1
created OpenCL buffer from GL VBO 2
create OpenCL only arrays
Pushing data to the GPU
push our CPU arrays to the CPU
in popCorn

But no particles in the window.
Does OpenGL run on CPU now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment