From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp,comp.lang.c Subject: Re: Functions in struct's... possible? How? Date: Sat, 06 Sep 1997 22:34:42 -0700 Organization: Alcyone Systems Lines: 17 Message-ID: <34123CF2.455FF641@alcyone.com> References: <33FCDA5C DOT 2353659F AT execulink DOT com> <5tippg$ci7$2 AT news DOT sendit DOT nodak DOT edu> <3402F5FD DOT 27818183 AT alcyone DOT com> <5u0s9d$70v$3 AT route1 DOT mdrf DOT france3 DOT fr> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Boyd Roberts wrote: > Maybe not the solution, but definitely the beginning. Nonsense. As a software engineer, I've seen people write C++ code that is far worse than any C code they would have written. Getting an object oriented language is not the answer. Understanding good coding style, object oriented or not, is the answer. -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm://37.20.07n/121.53.38w \ "War is like love; / it always finds a way." / Bertolt Brecht ///////////////////////////////////////////////////// ///////////////////////////////////////////////////////// void scanline(BITMAP *frame,int w,int h,float x1,float x2,float z1,float z2,int y,float u1,float u2,float v1,float v2,byte *tex,byte pcor) { w--;//include the zero h--; int cor=0; int x,u,v,width; float du,dv,dz; width=(int)(x2-x1); if(width>0){ du=(u2-u1)/width;//interpolants dv=(v2-v1)/width; dz=(z2-z1)/width; //draw the line for(x=(int)x1;x<(int)x2;x++) { if(x<=w&&x>=0&&y<=h&&y>=0) { u=(int)(u1/z1); v=(int)(v1/z1); _putpixel(frame,x,y,tex[(v*128)+u]); }//end if u1+=du; v1+=dv; z1+=dz; }//end for }//end if } ///////////////////////////////////////////////////// void render(int w,int h,BITMAP *frame, BITMAP *dest ,FACE a,byte col,byte *tex,byte pcor) { int y; char top,side_a,side_b,tmp; //index to face vertices float height_a,height_b,height_c; //tri's side heights float dx_a,dz_a,du_a,dv_a, //tri's side interpolants dx_b,dz_b,du_b,dv_b, dx_c,dz_c,du_c,dv_c; float z1,z2,x1,x2,u1,u2,v1,v2; //current position in tex/poly clear_to_color(frame,col); top=0; for(int s=0;s<3;s++)//find top vertice if(a.c[s].y2)side_a=0; if(side_b<0)side_b=2; //make sure we draw left to right if(a.c[side_a].x>a.c[side_b].x){tmp=side_a;side_a=side_b;side_b=tmp;} //set up heights height_a=a.c[side_a].y-a.c[top].y; height_b=a.c[side_b].y-a.c[top].y; //setup interpolants if(height_a>0.0){ dx_a=(a.c[side_a].x-a.c[top].x)/height_a; dz_a=(a.c[side_a].z-a.c[top].z)/height_a; du_a=(a.u[side_a]-a.u[top])/height_a; dv_a=(a.v[side_a]-a.v[top])/height_a; } if(height_b>0.0){ dx_b=(a.c[side_b].x-a.c[top].x)/height_b; dz_b=(a.c[side_b].z-a.c[top].z)/height_b; du_b=(a.u[side_b]-a.u[top])/height_b; dv_b=(a.v[side_b]-a.v[top])/height_b; } //start at top vert y =(int)a.c[top].y; x1=a.c[top].x; x2=a.c[top].x; z1=a.c[top].z; z2=a.c[top].z; u1=a.u[top]; u2=a.u[top]; v1=a.v[top]; v2=a.v[top]; //start to draw while(height_a>0.0&&height_b>0.0) { scanline(frame,w,h,x1,x2,z1,z2,y,u1,u2,v1,v2,tex,pcor); height_a--; height_b--; y++; x1+=dx_a; x2+=dx_b; z1+=dz_a; z2+=dz_b; u1+=du_a; u2+=du_b; v1+=dv_a; v2+=dv_b; } //end while //new edge find last vertex and draw rest if(a.c[side_a].y>a.c[side_b].y) height_c=a.c[side_a].y-a.c[side_b].y; if(height_c>0.0){ dx_c=(a.c[side_a].x-a.c[side_b].x)/height_c; dz_c=(a.c[side_a].z-a.c[side_b].z)/height_c; du_c=(a.u[side_a] -a.u[side_b] )/height_c; dv_c=(a.v[side_a] -a.v[side_b] )/height_c; x2=a.c[side_b].x; u2=a.u[side_b]; v2=a.v[side_b]; z2=a.c[side_b].z; while(height_c>0.0) { scanline(frame,w,h,x1,x2,z1,z2,y,u1,u2,v1,v2,tex,pcor); height_c--; y++; x1+=dx_a; x2+=dx_c; z1+=dz_a; z2+=dz_c; u1+=du_a; u2+=du_c; v1+=dv_a; v2+=dv_c; }//end while }//end if if(a.c[side_a].y0.0){ dx_c=(a.c[side_b].x-a.c[side_a].x)/height_c; dz_c=(a.c[side_b].z-a.c[side_a].z)/height_c; du_c=(a.u[side_b] -a.u[side_a] )/height_c; dv_c=(a.v[side_b] -a.v[side_a] )/height_c; x1=a.c[side_a].x; u1=a.u[side_a]; v1=a.v[side_a]; z1=a.c[side_a].z; while(height_c>0.0) { scanline(frame,w,h,x1,x2,z1,z2,y,u1,u2,v1,v2,tex,pcor); height_c--; y++; x1+=dx_c; x2+=dx_b; z1+=dz_c; z2+=dz_b; u1+=du_c; u2+=du_b; v1+=dv_c; v2+=dv_b; }//end while }//end if blit(frame,dest,0,0,0,0,w,h); }//end sub thank u! and remember if u have any code ideas, suggestion, think i code like a girl wht ever just help me out! Billal C thevoid AT hotmail DOT com