rswinkle / PortableGL

An implementation of OpenGL 3.x-ish in clean C
MIT License
1.05k stars 49 forks source link

fix OpenMP build on windows #14

Closed RicoP closed 1 year ago

RicoP commented 1 year ago

When switching on OpenMP in visual studio I get the error Error C3015 initialization in OpenMP 'for' statement has improper form OpenMP

Accroding to https://stackoverflow.com/a/39019028 the issue is that the compiler fails to understand the variable declaration in the first for parameter.

Moving this variable into the function scope before the pragma fixes that.

rswinkle commented 1 year ago

To be honest, I'm considering removing OpenMP, maybe entirely, but especially from draw_triangle_fill(). The performance gain is just not enough to justify it.

Even for pglDrawFrame used in shadertoy, the performance gain is much better, but still not significant, and it's only one line, so I could just leave it in there for others but have it actually build with OpenMP for any of the demos. Hmmm...

There is a tiny possibility that some time in the distant future I'll make PortableGL C89 compliant in which case this change becomes redundant, but there is so so much to do before I even think about that.