Hi,
How can I create a progress bar effect you know those that have a rectangle and another rectangle moving inside.
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
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
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+progresswidth, 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…