/*_|_| VESATEST.CPP PUBLIC DOMAIN PART 3 OF 3
_|_|_| Example of using 800x600 and 640x480 VESA modes.
_|_|_| No warrantee or guarantee. Kurt Kuzba. (8/24/1997)*/
/*
Line is adapted from Bresnham.C in Bob Stout's SNIPPETS
*/
void Vesamodes::Line(int x, int y, int x2, int y2, int c)
{
int i, steep = 0, sx, sy, dx, dy, e, ex, ey;
dx = abs(x2 - x);
sx = ((x2 - x) > 0) ? 1 : -1;
dy = abs(y2 - y);
sy = ((y2 - y) > 0) ? 1 : -1;
if(dy > dx)
{
steep = x;
x = y;
y = steep; /* swap x and y */
steep = dx;
dx = dy;
dy = steep; /* swap dx and dy */
steep = sx;
sx = sy;
sy = steep; /* swap sx and sy */
steep = 1;
}
e = 2 * dy - dx;
ex = dx << 1;
ey = dy << 1;
for(i = 0; i < dx; i++)
{
if(steep)
Dot(y, x, c);
else
Dot(x, y, c);
while(e >= 0)
{
y += sy;
e -= ex;
}
x += sx;
e += ey;
}
Dot(x2, y2, c);
}
void test(Vesamodes *V, int W = 640, int H = 480)
{
while(!kbhit())
{
V->Line(rnd(W), rnd(H), rnd(W), rnd(H), rnd(255));
V->Circle(rnd(W), rnd(H), rnd(200), rnd(255));
V->Circle(rnd(W), rnd(H), rnd(200), rnd(255),
10 + rnd(100), 10 + rnd(100));
V->Circle(rnd(W), rnd(H), rnd(20), rnd(255),
10 + rnd(100), 10 + rnd(100), 1);
}
}
int main(void)
{
time_t TM = time(NULL);
srand((unsigned)TM);
cout << "Hit any key to test 800x600x256" << endl;
getch();
Vesamodes *VM = new Vesamodes (800);
test(VM, 800, 600);
delete VM;
cout << "Hit any key to test 640x480x256" << endl;
getch();
getch();
VM = new Vesamodes;
test(VM);
delete VM;
cout << "Hit any key to exit Vesatest.cpp" << endl;
getch();
getch();
return 0;
}
/*_|_| end VESATEST.CPP PUBLIC DOMAIN PART 3 OF 3 */
> ] Opossums on the Information Rustic Road.....................
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
|