Page MenuHome

Gawain: remove limit where drawing zero items fails
Needs ReviewPublic

Authored by Campbell Barton (campbellbarton) on Apr 11 2017, 3:08 AM.

Details

Summary

Currently immBegin & immEnd fails drawing zero elements.

I don't think this is a reasonable limitation:

  • it means you need to remember to check for corner cases (which migh not be found between releases).
  • it may complicate code to have to check for the unlikely case where nothing is drawn (which might not be obvious ahead of time).
  • these cases are harmless NOP's, gawain can safely do nothing, keeping things simple for the caller.

Diff Detail

Repository
rB Blender
Branch
TEMP-gawain
Build Status
Buildable 538
Build 538: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from Remove limit where drawing zero items fails to Gawain: remove limit where drawing zero items fails.
Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)

Note that you can draw 0 vertices with

immBeginAtMost(PRIM_X, some_nonzero_count);
/* don't call immVertex */
immEnd();

This does all the setup, skips the draw, then does all the teardown. I prefer skipping all of this when vertex count is known to be 0. It avoids useless setup/teardown & means we don't have to handle as many special cases inside Gawain. The caller is responsible for passing in meaningful values.

In the example case I would move the zero check to the very first line of drawSelectedVertices.