GUI progress bar issue

OS Design, Theory, and Programming


Post Reply
Joined:Mon Dec 07, 2009 3:41 am
GUI progress bar issue

Post by accelleon » Thu Jun 10, 2010 2:01 am

not sure where this topic should go (either here or graphics programming) but anyway:

well i implemented a progress bar into my os (or rather tried) and it works for the most part.....
i have this for my ProgressBarSetFill() function:

Code: Select all

void ProgressBarSetFill(PROGBAR bar, byte fill)
	float tmp = (float)fill / 100;//Make fill a percent
	tmp = tmp * bar.width;//Get percentage of bar width for drawing
	bar.fill = (int)tmp;//Load the value into the PROGBAR struct
and this for my ProgressBarDraw() function:

Code: Select all

void ProgressBarDraw(PROGBAR bar)
	VGA::clearScreen(15);//Clear the screen

	int x,y,x2,y2;//Some variables used
	byte color;

	x = bar.x;//x1
	y = bar.y;//y1
	x2 = x + bar.width;//get x2 by adding the width to x1
	y2 = y + bar.height;//get y2 by adding height to y1
	color = bar.color;//the color of the bar
	VGA::drawRectangle(x,y,x2,y2,color,false);//draw the progress bar outline

	x2 = bar.x + bar.fill;//get x2 of the filled rectangle by adding the fill
	y2 = bar.y + bar.height;//same as y2 above
	VGA::drawRectangle(x,y,x2,y2,color,true);//draw the fill of the progress bar
Just in case heres the definition of my VGA::drawRectangle():

Code: Select all

static void drawRectangle(int x1=0,int y1=0, int x2=0, int y2=0, byte color=0, bool fill = false);
now the only problem i have here is that even if i set the fill of the progress bar to 50(50%) it fills the entire bar. if i set the fill to 75% the bar fills entirely.

i have this in my main kernel file:

Code: Select all

PROGBAR Progbar = CreateProgressBar(10,10,100,5,0);
ProgressBarSetFill(Progbar, 50);
And this is the result i get in VirtualPC:

Joined:Thu Apr 15, 2010 5:46 am

Re: GUI progress bar issue

Post by JoCo » Sat Jun 12, 2010 3:35 pm

Hello accelleon,

Have you initialised the FPU (Floating Point Unit)?
This is done using:

Code: Select all

_asm fninit
This should work on most processors; however you should write a proper FPU initialisation routine, including setting the FPU Control Word.

Good luck,

Post Reply