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!
Some window pops and disapears.
o_O how is it supposed to run?
Adding a
getchar()
at the end ofmain
does not stop anything.The crash point:
btw without root everything breaks with
fish: Job 1, “./part2.x ” terminated by signal SIGSEGV (Address boundary error)
#define NUM_PARTICLES 2
instead of 20000 does not help.Put
printf("p_vbo = %d", p_vbo);
beforecl_vbos.push_back(... p_vbo,...);
-- the print breaks.p_vbo
is not set.Now the print works for some reason.
But
cl_vbos.push_back( cl::BufferGL(context, CL_MEM_READ_WRITE, p_vbo, &err));
does not.std::vector<cl::Memory> cl_vbos;