qqun a-t-il une méthode + rapide
(les tests de clipping prennent bcp de temps)...
(ah vi une précision, je suis une merde en C, ms ça je pense ke vs l'aurez remarqué en parcourant mon code


dans Filltext, x1,x2,x3,y1,y2,y3 sont les coords x et y de la face et txt1,txt2,txt3,tyt1,tyt2,tyt3 sont les coordonnées de chaque sommet de la face dans la texture...
voila:
/*******************************/ /* SCANLINE tracer */ /*******************************/ void DrHtext(int y,int x1,int x2,long tx1,long ty1,long tx2,long ty2) { long dx,temp; if(x1>x2) { temp=x2; x2=x1; x1=temp; temp=ty2; ty2=ty1; ty1=temp; temp=tx2; tx2=tx1; tx1=temp; } tx2-=tx1; ty2-=ty1; dx=x2-x1; tx2/=dx; ty2/=dx; for(;x1<x2;x1++) { Pixel4(x1,y,texture[ty1>>10][tx1>>10],(char*)VideoBuffer); tx1+=tx2; ty1+=ty2; } } /**************************************/ /* Pseudo ANTIALIASED SCANLINE tracer */ /**************************************/ void DrHtextaa(int y,int x1,int x2,long tx1,long ty1,long tx2,long ty2) { long dx,temp; if(x1>x2) { temp=x2; x2=x1; x1=temp; temp=ty2; ty2=ty1; ty1=temp; temp=tx2; tx2=tx1; tx1=temp; } tx2-=tx1; ty2-=ty1; dx=x2-x1; tx2/=dx; ty2/=dx; for(;x1<x2;x1++) { Pixel4(x1, y, (texture[ty1>>10][tx1>>10] + texture[(ty1+32)>>10][(tx1+32)>>10] + texture[(ty1-32)>>10][(tx1-32)>>10])/3, (char*)VideoBuffer); tx1+=tx2; ty1+=ty2; } } /*******************************/ /* TEXTURE mapper */ /*******************************/ void FillText(long x1,int y1,long x2,int y2,long x3,int y3,int txt1,int tyt1,int txt2,int tyt2,int txt3,int tyt3,char color) { long temp, dy1, dy2, dy3, dty1, dty2, dty3; long dx1, dx2, dx3, x1add, x2add, x3add, dtx1, dtx2, dtx3, tx1add, tx2add, tx3add, ty1add, ty2add, ty3add; if(y1>y2) /* Trie les coordonées en fonction des y ascendants */ { temp=y2; //ué bon ça c'est une méthode de barbare... yapa un truc pour faire l'équivalent y2=y1; //du exg.x dx,dx en asm 68000 ou du xchg en x86??? je ve dire, une fonction C ? y1=temp; temp=x2; x2=x1; x1=temp; temp=tyt2; tyt2=tyt1; tyt1=temp; temp=txt2; txt2=txt1; txt1=temp; } if(y1>y3) { temp=y3; y3=y1; y1=temp; temp=x3; x3=x1; x1=temp; temp=tyt3; tyt3=tyt1; tyt1=temp; temp=txt3; txt3=txt1; txt1=temp; } if(y2>y3) { temp=y2; y2=y3; y3=temp; temp=x2; x2=x3; x3=temp; temp=tyt2; tyt2=tyt3; tyt3=temp; temp=txt2; txt2=txt3; txt3=temp; } x1<<=8; x2<<=8; x3<<=8; txt1<<=10; txt2<<=10; txt3<<=10; tyt1<<=10; tyt2<<=10; tyt3<<=10; dx1=x2-x1; dy1=y2-y1; dx2=x3-x2; dy2=y3-y2; dx3=x1-x3; dy3=y1-y3; dtx1=txt2-txt1; dty1=tyt2-tyt1; dtx2=txt3-txt2; dty2=tyt3-tyt2; dtx3=txt1-txt3; dty3=tyt1-tyt3; if(dy1) { x1add=(dx1)/dy1; tx1add=(dtx1)/dy1; ty1add=(dty1)/dy1; } if(dy2) { x2add=(dx2)/dy2; tx2add=(dtx2)/dy2; ty2add=(dty2)/dy2; } if(dy3) { x3add=(dx3)/dy3; tx3add=(dtx3)/dy3; ty3add=(dty3)/dy3; } /*******************************************/ /* PREMIERE PARTIE DE LA FACE */ /*******************************************/ txt3=txt1; tyt3=tyt1; x3=x1; for (;y1<y2;y1++) { if(y1>=0&&y1<=159) if(render_mode==4) DrHtextaa(y1,x3>>8,x1>>8,txt1,tyt1,txt3,tyt3); else DrHtext(y1,x3>>8,x1>>8,txt1,tyt1,txt3,tyt3); txt3+=tx3add; txt1+=tx1add; tyt3+=ty3add; tyt1+=ty1add; x3+=x1add; x1+=x3add; } /*******************************************/ /* SECONDE PARTIE DE LA FACE */ /*******************************************/ for(;y2<y3;y2++) { if(y2>=0&&y2<=159) if(render_mode==4) DrHtextaa(y2,x2>>8,x1>>8,txt2,tyt2,txt3,tyt3); else DrHtext(y2,x2>>8,x1>>8,txt2,tyt2,txt3,tyt3); txt3+=tx3add; txt2+=tx2add; tyt3+=ty3add; tyt2+=ty2add; x2+=x2add; x1+=x3add; } }