99#include < limits>
1010#include < cmath>
1111#include < cassert>
12- #include < cstring>
13- #include < algorithm>
12+ #include < cstring>
13+ #include < algorithm>
1414
1515#if defined(ENABLE_ZLIB)
1616#include < zlib.h>
@@ -81,7 +81,7 @@ void CalcNormal(float N[3], float v0[3], float v1[3], float v2[3]) {
8181 float len2 = N[0 ] * N[0 ] + N[1 ] * N[1 ] + N[2 ] * N[2 ];
8282 if (len2 > 0 .0f ) {
8383 float len = sqrtf (len2);
84-
84+
8585 N[0 ] /= len;
8686 N[1 ] /= len;
8787 }
@@ -96,7 +96,7 @@ const char *mmap_file(size_t *len, const char* filename)
9696
9797 HANDLE fileMapping = CreateFileMapping (file, NULL , PAGE_READONLY, 0 , 0 , NULL );
9898 assert (fileMapping != INVALID_HANDLE_VALUE);
99-
99+
100100 LPVOID fileMapView = MapViewOfFile (fileMapping, FILE_MAP_READ, 0 , 0 , 0 );
101101 auto fileMapViewChar = (const char *)fileMapView;
102102 assert (fileMapView != NULL );
@@ -140,7 +140,7 @@ const char *mmap_file(size_t *len, const char* filename)
140140 }
141141
142142 if (!S_ISREG (sb.st_mode )) {
143- fprintf (stderr, " %s is not a file\n " , " lineitem.tbl " );
143+ fprintf (stderr, " %s is not a file\n " , filename );
144144 return nullptr ;
145145 }
146146
@@ -159,7 +159,7 @@ const char *mmap_file(size_t *len, const char* filename)
159159 (*len) = fileSize;
160160
161161 return p;
162-
162+
163163#endif
164164}
165165
@@ -175,11 +175,11 @@ bool gz_load(std::vector<char>* buf, const char* filename)
175175 return false ;
176176 }
177177 while (1 ) {
178- int err;
178+ int err;
179179 int bytes_read;
180180 unsigned char buffer[1024 ];
181181 bytes_read = gzread (file, buffer, 1024 );
182- buf->insert (buf->end (), buffer, buffer + 1024 );
182+ buf->insert (buf->end (), buffer, buffer + 1024 );
183183 // printf ("%s", buffer);
184184 if (bytes_read < 1024 ) {
185185 if (gzeof (file)) {
@@ -305,7 +305,7 @@ const char* get_file_data(size_t *len, const char* filename)
305305 data_len = buf.size ();
306306 }
307307 } else {
308-
308+
309309 data = mmap_file (&data_len, filename);
310310
311311 }
@@ -385,7 +385,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
385385
386386 float n[3 ][3 ];
387387
388- if (attrib.normals .size () > 0 ) {
388+ if (attrib.normals .size () > 0 ) {
389389 int nf0 = idx0.normal_index ;
390390 int nf1 = idx1.normal_index ;
391391 int nf2 = idx2.normal_index ;
@@ -424,7 +424,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
424424 float len2 = c[0 ] * c[0 ] + c[1 ] * c[1 ] + c[2 ] * c[2 ];
425425 if (len2 > 1 .0e-6f ) {
426426 float len = sqrtf (len2);
427-
427+
428428 c[0 ] /= len;
429429 c[1 ] /= len;
430430 c[2 ] /= len;
@@ -433,7 +433,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
433433 vb.push_back (c[1 ] * 0.5 + 0.5 );
434434 vb.push_back (c[2 ] * 0.5 + 0.5 );
435435 }
436- }
436+ }
437437 face_offset += attrib.face_num_verts [v];
438438 }
439439
@@ -448,7 +448,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
448448
449449 gDrawObjects .push_back (o);
450450 }
451-
451+
452452 printf (" bmin = %f, %f, %f\n " , bmin[0 ], bmin[1 ], bmin[2 ]);
453453 printf (" bmax = %f, %f, %f\n " , bmax[0 ], bmax[1 ], bmax[2 ]);
454454
@@ -562,7 +562,7 @@ void Draw(const std::vector<DrawObject>& drawObjects)
562562 if (o.vb < 1 ) {
563563 continue ;
564564 }
565-
565+
566566 glBindBuffer (GL_ARRAY_BUFFER, o.vb );
567567 glEnableClientState (GL_VERTEX_ARRAY);
568568 glEnableClientState (GL_NORMAL_ARRAY);
@@ -586,7 +586,7 @@ void Draw(const std::vector<DrawObject>& drawObjects)
586586 if (o.vb < 1 ) {
587587 continue ;
588588 }
589-
589+
590590 glBindBuffer (GL_ARRAY_BUFFER, o.vb );
591591 glEnableClientState (GL_VERTEX_ARRAY);
592592 glEnableClientState (GL_NORMAL_ARRAY);
@@ -738,7 +738,7 @@ int main(int argc, char **argv)
738738
739739 // Centerize object.
740740 glTranslatef (-0.5 *(bmax[0 ] + bmin[0 ]), -0.5 *(bmax[1 ] + bmin[1 ]), -0.5 *(bmax[2 ] + bmin[2 ]));
741-
741+
742742 Draw (gDrawObjects );
743743
744744 glfwSwapBuffers (window);
0 commit comments