Progress Bar

Hi,

How can I create a progress bar effect you know those that have a rectangle and another rectangle moving inside.

Hello. Well, that’s rather simple problem.
You would like to draw a progress bar - so

  1. first draw the background rectangle (let’s say in white color) :

glColor3f(1,1,1);

glBegin(GL_QUADS);
glVertex2f(x,y);
glVertex2f(x + width, y);
glVertex2f(x + width, y + height);
glVertex2f(x. y + height);
glEnd();

where x, y - are starting coordinates of bottom left corner

width, height - size of the bar

  1. draw current progress rectangle
    now we draw second rectangle showing percent of our progress

progress = value / max_value;

As you can see progress is from 0 to 1.
Width of our progress rectangle would be now = progress * width (of previous rectangle)

so we draw

glColor3f(0,0,1);

glBegin(GL_QUADS);
glVertex2f(x,y)
glVertex2f(x+progresswidth, y)
glVertex2f(x+progress
width, y+height)
glVertex2f(x, y+height)
glEnd();

And that would be all. There are of course many ways of doing such bar. Probably you would like to add a percent counter etc… But that’s isn’t also any problem…