145145 #define SW_MAX_TEXTURES 128
146146#endif
147147
148- // Under normal circumstances, clipping a polygon can add at most one vertex per clipping plane.
148+ // Under normal circumstances, clipping a polygon can add at most one vertex per clipping plane
149149// Considering the largest polygon involved is a quadrilateral (4 vertices),
150150// and that clipping occurs against both the frustum (6 planes) and the scissors (4 planes),
151151// the maximum number of vertices after clipping is:
@@ -1530,7 +1530,7 @@ DEFINE_FRAMEBUFFER_COPY_BEGIN(R5G5B5A1, uint16_t)
15301530 uint8_t r5 = (color [0 ]* 31 + 127 )/255 ;
15311531 uint8_t g5 = (color [1 ]* 31 + 127 )/255 ;
15321532 uint8_t b5 = (color [2 ]* 31 + 127 )/255 ;
1533- uint8_t a1 = color [3 ] >= 128 ? 1 : 0 ;
1533+ uint8_t a1 = ( color [3 ] >= 128 ) ? 1 : 0 ;
15341534
15351535#if SW_GL_FRAMEBUFFER_COPY_BGRA
15361536 uint16_t pixel = (b5 << 11 ) | (g5 << 6 ) | (r5 << 1 ) | a1 ;
@@ -1661,7 +1661,7 @@ DEFINE_FRAMEBUFFER_BLIT_BEGIN(R5G5B5A1, uint16_t)
16611661 uint8_t r5 = (color [0 ]* 31 + 127 )/255 ;
16621662 uint8_t g5 = (color [1 ]* 31 + 127 )/255 ;
16631663 uint8_t b5 = (color [2 ]* 31 + 127 )/255 ;
1664- uint8_t a1 = color [3 ] >= 128 ? 1 : 0 ;
1664+ uint8_t a1 = ( color [3 ] >= 128 ) ? 1 : 0 ;
16651665
16661666#if SW_GL_FRAMEBUFFER_COPY_BGRA
16671667 uint16_t pixel = (b5 << 11 ) | (g5 << 6 ) | (r5 << 1 ) | a1 ;
@@ -1919,7 +1919,7 @@ static inline void sw_texture_sample_nearest(float *color, const sw_texture_t *t
19191919static inline void sw_texture_sample_linear (float * color , const sw_texture_t * tex , float u , float v )
19201920{
19211921 // TODO: With a bit more cleverness we could clearly reduce the
1922- // number of operations here, but for now it works fine.
1922+ // number of operations here, but for now it works fine
19231923
19241924 float xf = (u * tex -> width ) - 0.5f ;
19251925 float yf = (v * tex -> height ) - 0.5f ;
@@ -2203,13 +2203,13 @@ static inline bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VE
22032203//-------------------------------------------------------------------------------------------
22042204static inline bool sw_triangle_face_culling (void )
22052205{
2206- // NOTE: Face culling is done before clipping to avoid unnecessary computations.
2206+ // NOTE: Face culling is done before clipping to avoid unnecessary computations
22072207 // To handle triangles crossing the w=0 plane correctly,
22082208 // we perform the winding order test in homogeneous coordinates directly,
2209- // before the perspective division (division by w).
2209+ // before the perspective division (division by w)
22102210 // This test determines the orientation of the triangle in the (x,y,w) plane,
22112211 // which corresponds to the projected 2D winding order sign,
2212- // even with negative w values.
2212+ // even with negative w values
22132213
22142214 // Preload homogeneous coordinates into local variables
22152215 const float * h0 = RLSW .vertexBuffer [0 ].homogeneous ;
@@ -2221,7 +2221,7 @@ static inline bool sw_triangle_face_culling(void)
22212221 // This is the determinant of the matrix formed by the (x, y, w) components
22222222 // of the vertices, which correctly captures the winding order in homogeneous
22232223 // space and its relationship to the projected 2D winding order, even with
2224- // negative w values.
2224+ // negative w values
22252225 // The determinant formula used here is:
22262226 // h0.x*(h1.y*h2.w - h2.y*h1.w) +
22272227 // h1.x*(h2.y*h0.w - h0.y*h2.w) +
@@ -2233,20 +2233,18 @@ static inline bool sw_triangle_face_culling(void)
22332233 h2 [0 ]* (h0 [1 ]* h1 [3 ] - h1 [1 ]* h0 [3 ]);
22342234
22352235 // Discard the triangle if its winding order (determined by the sign
2236- // of the homogeneous area/determinant) matches the culled direction.
2236+ // of the homogeneous area/determinant) matches the culled direction
22372237 // A positive hSgnArea typically corresponds to a counter-clockwise
22382238 // winding in the projected space when all w > 0.
22392239 // This test is robust for points with w > 0 or w < 0, correctly
2240- // capturing the change in orientation when crossing the w=0 plane.
2240+ // capturing the change in orientation when crossing the w=0 plane
22412241
2242- // The culling logic remains the same based on the signed area/determinant.
2242+ // The culling logic remains the same based on the signed area/determinant
22432243 // A value of 0 for hSgnArea means the points are collinear in (x, y, w)
22442244 // space, which corresponds to a degenerate triangle projection.
22452245 // Such triangles are typically not culled by this test (0 < 0 is false, 0 > 0 is false)
2246- // and should be handled by the clipper if necessary.
2247- return (RLSW .cullFace == SW_FRONT )
2248- ? (hSgnArea < 0 ) // Cull if winding is "clockwise" in the projected sense
2249- : (hSgnArea > 0 ); // Cull if winding is "counter-clockwise" in the projected sense
2246+ // and should be handled by the clipper if necessary
2247+ return (RLSW .cullFace == SW_FRONT )? (hSgnArea < 0 ) : (hSgnArea > 0 ); // Cull if winding is "clockwise" : "counter-clockwise"
22502248}
22512249
22522250static inline void sw_triangle_clip_and_project (void )
@@ -2559,14 +2557,14 @@ static inline void sw_triangle_render(void)
25592557//-------------------------------------------------------------------------------------------
25602558static inline bool sw_quad_face_culling (void )
25612559{
2562- // NOTE: Face culling is done before clipping to avoid unnecessary computations.
2560+ // NOTE: Face culling is done before clipping to avoid unnecessary computations
25632561 // To handle quads crossing the w=0 plane correctly,
25642562 // we perform the winding order test in homogeneous coordinates directly,
2565- // before the perspective division (division by w).
2563+ // before the perspective division (division by w)
25662564 // For a convex quad with vertices P0, P1, P2, P3 in sequential order,
25672565 // the winding order of the quad is the same as the winding order
25682566 // of the triangle P0 P1 P2. We use the homogeneous triangle
2569- // winding test on this first triangle.
2567+ // winding test on this first triangle
25702568
25712569 // Preload homogeneous coordinates into local variables
25722570 const float * h0 = RLSW .vertexBuffer [0 ].homogeneous ;
@@ -2578,11 +2576,11 @@ static inline bool sw_quad_face_culling(void)
25782576
25792577 // Compute a value proportional to the signed area of the triangle P0 P1 P2
25802578 // in the projected 2D plane, calculated directly using homogeneous coordinates
2581- // BEFORE division by w.
2579+ // BEFORE division by w
25822580 // This is the determinant of the matrix formed by the (x, y, w) components
25832581 // of the vertices P0, P1, and P2. Its sign correctly indicates the winding order
25842582 // in homogeneous space and its relationship to the projected 2D winding order,
2585- // even with negative w values.
2583+ // even with negative w values
25862584 // The determinant formula used here is:
25872585 // h0.x*(h1.y*h2.w - h2.y*h1.w) +
25882586 // h1.x*(h2.y*h0.w - h0.y*h2.w) +
@@ -2594,21 +2592,19 @@ static inline bool sw_quad_face_culling(void)
25942592 h2 [0 ]* (h0 [1 ]* h1 [3 ] - h1 [1 ]* h0 [3 ]);
25952593
25962594 // Perform face culling based on the winding order determined by the sign
2597- // of the homogeneous area/determinant of triangle P0 P1 P2.
2595+ // of the homogeneous area/determinant of triangle P0 P1 P2
25982596 // This test is robust for points with w > 0 or w < 0 within the triangle,
2599- // correctly capturing the change in orientation when crossing the w=0 plane.
2597+ // correctly capturing the change in orientation when crossing the w=0 plane
26002598
26012599 // A positive hSgnArea typically corresponds to a counter-clockwise
2602- // winding in the projected space when all w > 0.
2600+ // winding in the projected space when all w > 0
26032601 // A value of 0 for hSgnArea means P0, P1, P2 are collinear in (x, y, w)
2604- // space, which corresponds to a degenerate triangle projection.
2602+ // space, which corresponds to a degenerate triangle projection
26052603 // Such quads might also be degenerate or non-planar. They are typically
26062604 // not culled by this test (0 < 0 is false, 0 > 0 is false)
26072605 // and should be handled by the clipper if necessary.
26082606
2609- return (RLSW .cullFace == SW_FRONT )
2610- ? (hSgnArea < 0.0f ) // Cull if winding is "clockwise" in the projected sense
2611- : (hSgnArea > 0.0f ); // Cull if winding is "counter-clockwise" in the projected sense
2607+ return (RLSW .cullFace == SW_FRONT )? (hSgnArea < 0.0f ) : (hSgnArea > 0.0f ); // Cull if winding is "clockwise" : "counter-clockwise"
26122608}
26132609
26142610static inline void sw_quad_clip_and_project (void )
@@ -4596,8 +4592,8 @@ void swDrawElements(SWdraw mode, int count, int type, const void *indices)
45964592
45974593 for (int i = 0 ; i < count ; i ++ )
45984594 {
4599- int index = indicesUb ? indicesUb [i ] :
4600- (indicesUs ? indicesUs [i ] : indicesUi [i ]);
4595+ int index = indicesUb ? indicesUb [i ] :
4596+ (indicesUs ? indicesUs [i ] : indicesUi [i ]);
46014597
46024598 float u , v ;
46034599 if (texcoords )
0 commit comments