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