Copyright updates. I hope that I didn't miss anybody.
[crack-attack.git] / src / TextureLoader.h
blobf56a317e92ec4e39d54e4f368a84940846b3ea12
1 /*
2 * TextureLoader.h
3 * Daniel Nelson - 8/24/0
5 * Copyright (C) 2000 Daniel Nelson
6 * Copyright (C) 2004 Andrew Sayman
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Daniel Nelson - aluminumangel.org
23 * 174 W. 18th Ave.
24 * Columbus, OH 43210
27 #ifndef TEXTURELOADER_H
28 #define TEXTURELOADER_H
30 #include <GL/glut.h>
32 #ifndef _WIN32
33 # include <sstream>
34 #else
35 # include <glext.h>
36 # include <strstrea.h>
37 #endif
39 #include "Game.h"
41 using namespace std;
43 #define TL_GARBAGE_TEXTURE_TGA_ID "Crack Attack! garbage texture"
44 #define TL_SCREEN_SHOT_TGA_ID "Crack Attack! screen shot"
46 /* static */ class TextureLoader {
47 public:
48 static GLubyte *loadAlphaTGA ( const char *tga_file_name, int _height,
49 int _width );
50 static GLubyte *loadNoAlphaTGA ( const char *tga_file_name, int _height,
51 int _width );
52 static GLubyte *loadTGA ( const char *tga_file_name, int _height, int _width,
53 int _color_depth = 32 );
54 static void createTGA ( const char *tga_file_name, GLubyte *texture,
55 int _height, int _width, const char *tga_id );
56 static bool fileExists ( const char *file_name );
57 static unsigned long determineTGACheckSum ( const char *tga_file_name,
58 int _height, int _width );
59 static void determineTGASize ( const char *tga_file_name, int &height,
60 int &width );
62 static inline void buildLocalDataDirectoryName ( char dir_name[256] )
64 ostringstream s;
65 #ifndef _WIN32
66 s << getenv("HOME") << GC_LOCAL_DATA_DIRECTORY << ends;
67 #else
68 s << GC_LOCAL_DATA_DIRECTORY << ends;
69 #endif
70 strncpy(dir_name, s.str().data(), 256);
73 static inline void buildLocalDataFileName ( const char base_name[256],
74 char file_name[256] )
76 ostringstream s;
77 #ifndef _WIN32
78 s << getenv("HOME") << GC_LOCAL_DATA_DIRECTORY << base_name << ends;
79 #else
80 s << GC_LOCAL_DATA_DIRECTORY << base_name << ends;
81 #endif
82 strncpy(file_name, s.str().data(), 256);
86 #endif