Je ne connais pas l'algorithme de bresenham mais j'ai fais moi meme un algorithme de tracé de lignes en c qui utilise la fonction putpixel() d'allegro qui permet d'allumer un pixel au coordonnnées données ( donc a toi d'adapter apres):
void MyLine(int xdep, int ydep, int xfin, int yfin)
{
float a=0;
int temp=0;
int cste=0;
unsigned int dy;
unsigned int dx;
dx=abs(xfin-xdep);
dy=abs(yfin-ydep);
if(dx>=dy && dx!=0 && dy!=0)
{
if(xdep>xfin)
{
temp=xdep;
xdep=xfin;
xfin=temp;
temp=ydep;
ydep=yfin;
yfin=temp;
}
a=((float)(yfin-ydep)/(xfin-xdep));
for(int x=0;x<dx+1;x++)
{
putpixel(buffer,x+xdep,ydep+(x*a)+cste,makecol(255,255,255));
}
}
if(dx<dy && dx!=0 && dy!=0)
{
if(ydep>yfin)
{
temp=ydep;
ydep=yfin;
yfin=temp;
temp=xdep;
xdep=xfin;
xfin=temp;
}
a=((float)(xfin-xdep)/(yfin-ydep));
for(int y=0;y<dy+1;y++)
{
putpixel(buffer,xdep+(y*a)+cste,y+ydep,makecol(255,255,255));
}
}
if(dx==0)
{
if(ydep>yfin)
{
temp=ydep;
ydep=yfin;
yfin=temp;
}
for(int y=ydep;y<yfin+1;y++)
putpixel(buffer,xdep,y,makecol(255,255,255));
}
if(dy==0)
{
if(xdep>xfin)
{
temp=xdep;
xdep=xfin;
xfin=temp;
}
for(int x=xdep;x<xfin+1;x++)
putpixel(buffer,x,ydep,makecol(255,255,255));
}
}
Il y asans doute mieux...mais code fonctionne dans toutes les situations...
si ca t'interesse n'hesite pas si t'as un probleme! ;)