GPU_PrimitiveBatch issue
Jonathan,
I'm having trouble using GPU_PrimitiveBatch. My intention is to draw a series of line segments with current color. I make a call with:
GPU_PrimitiveBatch( NULL, target, GPU_LINE_STRIP, 5, floatPointsPackedAsXY, 5, uShortIndexes, GPU_BATCH_XY )
and it crashes in get_complete_mod_color, because I'm simultaneously not supplying image, and not using colors. I don't need per-vertex color, or texture. I'd like to use a single color to render this shape. I tried supplying a dummy image param, but then it just draws triangles.
Please hlep.
By stepping through code, and patching get_complete_mod_color I arrived to actual rendering inside PrimitiveBatchV in Renderer_GL_Common.inl:
if(indices == NULL)
glDrawArrays(GL_TRIANGLES, 0, num_indices);
else
glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT, (void*)0);
As you see, it's always drawing triangles, not the specified primitive. Is this simply unfinished? I'm going to try and plug in the primitive from parameter here. I assume this should be fixed in main branch.
Update
Yes - this appears to be the case - I think you forgot to change it after implementing TriangleBatch sister function.
Found more issues: drawing GPU_LINE_STRIP, GPU_LINE_LOOP doesn't apply current line thickness - is this related to GPU_Polygon also not being able to draw with line thickness?
Color for these could be supplied by setting mod color on target (if you check for image param in get_complete_mod_color, and just use target color if not supplied).
For my purposes, it would be perfectly acceptable to use GPU_Polygon, to draw a line strip (if we can get thickness to work), if GPU_Polygon had another parameter that let me specify if I want to close this polygon, or keep it open (line strip). 👍
I can use PrimitiveBatch to draw a filled convex or concave polygon as triangle strip, if the thing with colors and primitive_type is fixed.
Thanks for good work, Jonathan.
Could you take a look at my commit, please?
Yep, these are good thoughts. Thanks for your work on this! (other discussion on pull thread)