This commit is contained in:
InventorXtreme 2024-01-03 15:37:56 -05:00
parent 3a274a9d61
commit 6ef21998a4
2 changed files with 10 additions and 11 deletions

19
c3d.c
View file

@ -87,8 +87,8 @@ double Max(double a, double b){
} }
int IndexOfZBuff(int row, int col) { static inline int IndexOfZBuff(int row, int col) {
return row*RENDERWIDTH + col; return row + RENDERWIDTH*col;
} }
@ -506,9 +506,9 @@ int main() {
} }
//memset(ZBuff,NULL ,sizeof(Zee) * RENDERHEIGHT*RENDERWIDTH ); //memset(ZBuff,NULL ,sizeof(Zee) * RENDERHEIGHT*RENDERWIDTH );
for (int i = 0; i < RENDERHEIGHT*RENDERWIDTH; i ++) { // for (int i = 0; i < RENDERHEIGHT*RENDERWIDTH; i ++) {
ZBuff[i] = (Zee){10000,NULL}; // ZBuff[i] = (Zee){10000,NULL};
} // }
memset(display,0,sizeof(display)); memset(display,0,sizeof(display));
@ -551,15 +551,14 @@ int main() {
display[index+2] = c->b; display[index+2] = c->b;
display[index+3] = c->a; display[index+3] = c->a;
*/ */
printf("%d\n",IndexOfZBuff(x,y));
ZBuff[IndexOfZBuff(x,y)].triangle = NULL;
if (ZBuff[IndexOfZBuff(x,y)].triangle != NULL) { if (ZBuff[IndexOfZBuff(x,y)].triangle != NULL) {
//DrawPixel(x,y,ZBuff[x][y].triangle->color); //DrawPixel(x,y,ZBuff[x][y].triangle->color);
//display[index] = ZBuff[IndexOfZBuff(x,y)].triangle->color; display[index] = ZBuff[IndexOfZBuff(x,y)].triangle->color;
Zee test = ZBuff[IndexOfZBuff(x,y)]; // Zee test = ZBuff[IndexOfZBuff(x,y)];
display[index] = test.triangle->color; // display[index] = test.triangle->color;
} }
index = index+1; index = index+1;