Open m-7761 opened 3 years ago
It's an OpenGL codebase. It predates ES by at least a decade.
I can never tell if you're being deliberately disturbing (@nigels-com) but FWIW what I think is the best explanation here is once upon a time this 8 sided polygon formed an arrow head with a 90 degree spike sticking out of the base, that would be flattened for the double-sided arrow. Much like the rest of the GLUI code it lacks a lot in the way of commonsense... I think someone came along and turned this 8 sided polygon into a square and added a second triangle to form an arrow... instead of doing the reasonable thing of drawing a quad and a triangle they felt for some reason it was important to preserve the original code that used the polygon... this OCD like tendency could explain why GLUI's code is so maddening (and completely untenable in terms of performance) throughout. (Edited: As for myself I just can't believe I never noticed that this polygon made no sense back when I was working on improving/overhauling GLUI. It seems I never stopped to look at it critically.)
It's old code. You want to hunt down the author and shame them, or something? That's not a stance I subscribe to.
Good for you for taking it forward into the modern age.
[I initially thought it would have been some kind of arcane OpenGL trickery. It only later occurred to me it could have originally drawn the whole arrow instead of just the part beneath the triangle tip.]
I realized after figuring out what the old polygon code was that it actually was possible to draw the arrow as a polygon (fan) if the tip of the arrow is the pivot. So this would be a better replacement. I've never understood what the GLUI project was for since it would not make simple changes like this one, as if it had some existential purpose besides functional code.
glBegin(GL_TRIANGLE_FAN);
glVertex2f(0,y2);
glVertex2f(-x2,y1);
glVertex2f(-x1b,y1);
glVertex2f(-x1a,0); //y0
glVertex2f(x1a,0); //y0
glVertex2f(x1b,y1);
glVertex2f(x2,y1);
glEnd();
All pull requests are given due consideration, as always.
Primarily GLUI is maintained for purpose of existing GLUI applications. In that context stability is prized, breaking changes would need significant justification. Along with that, there is some burden to prove that changes are not without their own side effects. (testing)
https://github.com/libglui/glui/blob/093edc777c02118282910bdee59f8db1bd46a84d/src/glui_translation.cpp#L467-L477
FWIW here's some code that can replace it. I was adding an OpenGL ES mode (ANGLE) when I noticed this ... I don't know how I ever missed it before. I know I spent a lot of time with this subroutine. I just can't think of a rationale for using GL_POLYGON here so I'm curious. Notice also two vertics are duplicated.