Objects (sprites, widgets, anything, hundreds or more of them) in the table will be inserted, deleted, sorted. Possibly many times per frame. If I place corresponding color tuples in the table I will have to renumerate them to maintain connection with corresponding objects. So this values must be generated on the fly.S0lll0s wrote: So just store the values in a table!
What is faster in such situation? setColor(simply object index) or setColor(complex formula). (formula to generate sequence rgb(0,0,1)...rgb(0,0,255),rgb(0,1,0)...rgb(255,255,255)).
If we have glColor3uiv then rgb(0,0,1) = simply "1", rgb(0,1,0) = simply "256", etc.
So in the loop it will be (pseudo code):
for i = 1 to 10
setColor(i)
next
instead of
for i = 1 to 10
setColor(some formula)
next
No. It is object picker, not a colorpicker. Non-rectangular button for example. Picking object by color is one of the common and simple techniques in OpenGL. Yes, I still will need formula (simple enough) when I read pixel to convert color to obect index, but I will not need any formulas to calculate next object's color when I draw it.S0lll0s wrote: And why would you need to get the pixel color? If its a colorpicker you have the formula anyway...
Didn't you tried code I've posted yet?
I'm talking about specific problem for real application, not some abstraction, not some academic exercise in LÖVE2D / Lua programming.
And I'm also talking not about how to do it (it is already done in the code I've posted), but how to do it better, with speed in mind.