- *width = sizeX;
- *height = sizeY;
- *format = GL_RGBA;
- return data;
-}
-
-/* Load a plain PPM image */
-GLubyte *LoadPPM(const char *filename, int *width, int *height, int *format)
-{
- char buff[1024];
- GLubyte *data;
- GLint sizeX, sizeY;
- FILE *fp;
- int maxval;
-
- fp = fopen(filename, "rb");
- if (!fp)
- {
- fprintf(stderr, "%s: unable to open file '%s'\n", progname, filename);
- return Generate_Image(width, height, format);
- exit(1);
- }
- if (!fgets(buff, sizeof(buff), fp))
- {
- perror(filename);
- return Generate_Image(width, height, format);
- }
-
- if (buff[0] != 'P' || buff[1] != '6')
- {
- fprintf(stderr, "%s: invalid image format (must be `P6')\n", progname);
- return Generate_Image(width, height, format);
- }
-
- do
- {
- fgets(buff, sizeof(buff), fp);
- }
- while (buff[0] == '#');
-
- if (sscanf(buff, "%d %d", &sizeX, &sizeY) != 2)
- {
- fprintf(stderr, "%s: error loading image `%s'\n", progname, filename);
- return Generate_Image(width, height, format);
- }
-
- if (fscanf(fp, "%d", &maxval) != 1)
- {
- fprintf(stderr, "%s: error loading image `%s'\n", progname, filename);
- return Generate_Image(width, height, format);
- }
-
- while (fgetc(fp) != '\n')
- ;
-
- data = (GLubyte *)malloc(3 * sizeX * sizeY);
- if (data == NULL)
- {
- fprintf(stderr, "%s: unable to allocate memory\n", progname);
- exit(1);
- }
-
- if (fread(data, 3 * sizeX, sizeY, fp) != sizeY)
- {
- fprintf(stderr, "%s: error loading image `%s'\n", progname, filename);
- return Generate_Image(width, height, format);
- }
-
- fclose(fp);
-
- *width = sizeX;
- *height = sizeY;
- *format = GL_RGB;
- return data;
-}
-
-/* create a texture to be applied to the surface
- this function loads a file using a loader depending on
- that extension of the file. there is very little error
- checking.
-*/
-
-void Create_Texture(char *filename, int do_mipmap, int do_texture_quality)