OpenGL 2D drawing lines that don't exactly match the pixel raster

I am drawing something similar to the VU LED in OpenGL. The result should look like a vertical bar:

Animated vumeters

Unfortunately, my drawing space is limited, and I need to place exactly 18 bars. This gives a distance between the strips of 3.6 pixels.

When drawing, this causes visible differences in the spacing between the lines, since spaces are 2 or 1 pixel wide. I am looking for a solution for using subpixel rendering and how to "fake" lines with some kind of anti-aliasing, so that all spaces have 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, the inclusion of line smoothing did not show a visible effect. Any suggestions?

+3
source share
3

:

  • , , , .

  • , , , - , .

+3

( ).

, ( ) .

+1

OpenGl, - . 10,6 , 10 , (0,6 0,4 ).

0
source

Source: https://habr.com/ru/post/1780141/


All Articles