@@ -21,7 +21,11 @@ GLuint loadBMP_custom(const char * imagepath){
21
21
22
22
// Open the file
23
23
FILE * file = fopen (imagepath," rb" );
24
- if (!file) {printf (" %s could not be opened. Are you in the right directory ? Don't forget to read the FAQ !\n " , imagepath); getchar (); return 0 ;}
24
+ if (!file){
25
+ printf (" %s could not be opened. Are you in the right directory ? Don't forget to read the FAQ !\n " , imagepath);
26
+ getchar ();
27
+ return 0 ;
28
+ }
25
29
26
30
// Read the header, i.e. the 54 first bytes
27
31
@@ -57,7 +61,7 @@ GLuint loadBMP_custom(const char * imagepath){
57
61
// Read the actual data from the file into the buffer
58
62
fread (data,1 ,imageSize,file);
59
63
60
- // Everything is in memory now, the file wan be closed
64
+ // Everything is in memory now, the file can be closed.
61
65
fclose (file);
62
66
63
67
// Create one OpenGL texture
@@ -72,17 +76,17 @@ GLuint loadBMP_custom(const char * imagepath){
72
76
73
77
// OpenGL has now copied the data. Free our own version
74
78
delete [] data;
75
- fclose (file);
76
79
77
80
// Poor filtering, or ...
78
81
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
79
82
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
80
83
81
- // ... nice trilinear filtering.
84
+ // ... nice trilinear filtering .. .
82
85
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
83
86
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
84
87
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
85
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
88
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
89
+ // ... which requires mipmaps. Generate them automatically.
86
90
glGenerateMipmap (GL_TEXTURE_2D);
87
91
88
92
// Return the ID of the texture we just created
0 commit comments