Skip to content

Commit 7c1b91a

Browse files
committed
fixes #34, + typos + comments + formatting
1 parent 35cd0db commit 7c1b91a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

common/texture.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ GLuint loadBMP_custom(const char * imagepath){
2121

2222
// Open the file
2323
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+
}
2529

2630
// Read the header, i.e. the 54 first bytes
2731

@@ -57,7 +61,7 @@ GLuint loadBMP_custom(const char * imagepath){
5761
// Read the actual data from the file into the buffer
5862
fread(data,1,imageSize,file);
5963

60-
// Everything is in memory now, the file wan be closed
64+
// Everything is in memory now, the file can be closed.
6165
fclose (file);
6266

6367
// Create one OpenGL texture
@@ -72,17 +76,17 @@ GLuint loadBMP_custom(const char * imagepath){
7276

7377
// OpenGL has now copied the data. Free our own version
7478
delete [] data;
75-
fclose(file);
7679

7780
// Poor filtering, or ...
7881
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
7982
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
8083

81-
// ... nice trilinear filtering.
84+
// ... nice trilinear filtering ...
8285
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
8386
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
8487
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.
8690
glGenerateMipmap(GL_TEXTURE_2D);
8791

8892
// Return the ID of the texture we just created

0 commit comments

Comments
 (0)