I'm drawing something similar to a LED VU meter in OpenGL. Result should be like on vertical bar of this:

Unfortunately, my drawing space is restricted, and I have to fit exactly 18 bars on it. That yields a spacing between bars of 3.6 pixels.
When drawn, this causes visible differences in the gaps between lines, because the gaps are either 2 or 1 pixel wide. I'm looking for a solution to use subpixel rendering and than "fake" the lines by some kind of anti-aliasing, so that all gaps appear of the same width.
This is my code so far
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH, GL_NICEST);
for (int i = 0; i < 18; ++i) {
float bBottom = barBottom + i*3.6f;
glBegin(GL_LINES);
glLineWidth(2);
glVertex2f(bRight,bBottom);
glVertex2f(bLeft,bBottom);
glEnd();
}
glDisable(GL_LINE_SMOOTH);
Unfortunately, turning on line smoothing showed no visible effect. Any suggestions?
Two ideas:
Draw all the bars to a large off screen texture such that the gaps and widths are all equal and then use bilinear filtering to blit the result to the required screen position and size.
Get an artist to draw all the fully lit bars so that the look good, then draw black rectangles with an alpha channel from the top of each bar downwards to darken the required parts of the image.
Use multisampling (Multisampling specs).
Additionally, I would use quads (and not lines) for rendering those blocks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With