OpenGL-Examples
OpenGL-Examples copied to clipboard
syntax error?
Hi, I have build these projects with CodeBlocks and MinGW on windows. Everything is correct except compute shader nbody. I have some errors in Code Blocks:
||=== Build: all in OPENGLEXAMPLES (compiler: GNU GCC Compiler) ===| E:\Lab\OpenGL-Examples\13compute_shader_nbody.cpp||In function 'int main()':| E:\Lab\OpenGL-Examples\13compute_shader_nbody.cpp|368|error: taking address of temporary array| CMakeFiles\13compute_shader_nbody.dir\build.make|54|recipe for target 'CMakeFiles/13compute_shader_nbody.dir/13compute_shader_nbody.cpp.obj' failed| CMakeFiles\Makefile2|636|recipe for target 'CMakeFiles/13compute_shader_nbody.dir/all' failed| E:\Lab\OpenGL-Examples\build\Makefile|116|recipe for target 'all' failed| ||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 3 second(s)) ===|
I suspect line 368
glBindBuffersBase(GL_SHADER_STORAGE_BUFFER, 0, 2, (const GLuint[]){positions_vbo, velocities_vbo});
Please give me some advice how fix this line.
I'll probably have to change that. It seems not all compilers like the inlining of arrays like that. One quick fix is to just move the array out:
const GLuint buffers[] = {positions_vbo, velocities_vbo};
glBindBuffersBase(GL_SHADER_STORAGE_BUFFER, 0, 2, buffers);
Thank you very much. Now it's working.
This is great piece of code, nice to modify and play with that (maybe I am wrong, but this is my opinion). I am focused on compute shaders and n-body. I want to add resize screen and some mouse interactions. I'm just learning this, so it will take some time.
Thanks again for share this code.