How to draw a circle?
Opened this issue · 2 comments
This isn't a bug. I'm trying to wrap my mind around webgl and play-cljc.
After rendering a few rectangles and triangles I'd thought I'd try to make a circle.
Reading up on how to do this most guides (example) recommend using the TRIANGLE_FAN
primitive.
But it seems c/render
is hard coded to use the TRIANGLES
primitive
play-cljc/src/play_cljc/gl/core.cljc
Lines 341 to 344 in f2ed4eb
Any tips would be appreciated.
I think the solution here is to let the have some sort of :index-mode
value in the entity map?
If you wanted to stick with TRIANGLES, I suppose you could just render a rectangle and write a fragment shader that discards pixels outside the radius via something like if (length(position - center) > radius) discard;
. But if you want to use TRIANGLE_FAN, you probably need to write your own render function. Should be pretty easy to copy the one from play-cljc and make the necessary changes.
IMO I like the first solution best because you probably will eventually want to do something more complex like render a circle with a texture. That will be easier to do if you're just rendering a rectangle and discarding pixels afterwards.