-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
27 lines (24 loc) · 1.14 KB
/
README
File metadata and controls
27 lines (24 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Mac command line program for converting images to an uncompressed
binary file suitable for using with OpenGL textures.
Here is a sample C++ usage of reading the texture file:
FILE *fp = fopen(filename, "r");
unsigned char *texture = new unsigned char[4 * 256 * 256];
if (fread(texture, sizeof(unsigned char), 4 * 256 * 256, fp)
!= 4* 256 *256) {
fprintf(stderr, "error reading %s", filename);
}
fclose(fp);
glGenTextures(1, &textureNum);
glBindTexture(GL_TEXTURE_2D, textureNum);
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
GL_CLAMP );
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, 256, 256, GL_RGBA,
GL_UNSIGNED_BYTE, texture);
delete [] texture;