@@ -37,18 +37,12 @@ void framebuffer_release(framebuffer_t *framebuffer) {
37
37
38
38
void framebuffer_clear_color (framebuffer_t * framebuffer , vec4_t color ) {
39
39
int num_pixels = framebuffer -> width * framebuffer -> height ;
40
- unsigned char r , g , b , a ;
41
40
int i ;
42
-
43
- r = float_to_uchar (color .x );
44
- g = float_to_uchar (color .y );
45
- b = float_to_uchar (color .z );
46
- a = float_to_uchar (color .w );
47
41
for (i = 0 ; i < num_pixels ; i ++ ) {
48
- framebuffer -> color_buffer [i * 4 + 0 ] = r ;
49
- framebuffer -> color_buffer [i * 4 + 1 ] = g ;
50
- framebuffer -> color_buffer [i * 4 + 2 ] = b ;
51
- framebuffer -> color_buffer [i * 4 + 3 ] = a ;
42
+ framebuffer -> color_buffer [i * 4 + 0 ] = float_to_uchar ( color . x ) ;
43
+ framebuffer -> color_buffer [i * 4 + 1 ] = float_to_uchar ( color . y ) ;
44
+ framebuffer -> color_buffer [i * 4 + 2 ] = float_to_uchar ( color . z ) ;
45
+ framebuffer -> color_buffer [i * 4 + 3 ] = float_to_uchar ( color . w ) ;
52
46
}
53
47
}
54
48
@@ -322,10 +316,9 @@ static int is_back_facing(vec3_t ndc_coords[3]) {
322
316
vec3_t a = ndc_coords [0 ];
323
317
vec3_t b = ndc_coords [1 ];
324
318
vec3_t c = ndc_coords [2 ];
325
- float signed_area = 0 ;
326
- signed_area += a .x * b .y - a .y * b .x ;
327
- signed_area += b .x * c .y - b .y * c .x ;
328
- signed_area += c .x * a .y - c .y * a .x ;
319
+ float signed_area = a .x * b .y - a .y * b .x +
320
+ b .x * c .y - b .y * c .x +
321
+ c .x * a .y - c .y * a .x ;
329
322
return signed_area <= 0 ;
330
323
}
331
324
0 commit comments