Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error? #2

Open
ghost opened this issue Sep 22, 2014 · 2 comments
Open

syntax error? #2

ghost opened this issue Sep 22, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Sep 22, 2014

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.

@ghost ghost closed this as completed Sep 22, 2014
@ghost ghost reopened this Sep 22, 2014
@ghost ghost changed the title syntax error syntax error? Sep 22, 2014
@progschj
Copy link
Owner

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);

@ghost
Copy link
Author

ghost commented Sep 23, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant