00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _TEXTURES_H
00026
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <GL/gl.h>
00030 #include <GL/glu.h>
00031 #include <GL/glext.h>
00032 #include <SDL/SDL.h>
00033 #ifdef __APPLE__
00034 #include <SDL_image/SDL_image.h>
00035 #else
00036 #include <SDL/SDL_image.h>
00037 #endif
00038 #include <math.h>
00039 #include <string>
00040 #include <fstream>
00041 #include <iostream>
00042
00043 #include <list>
00044
00045 #include "utility.h"
00046
00047 #include "globals.h"
00048
00049 using namespace std;
00050
00051 class TEXTURE
00052 {
00053 private:
00054 GLuint tex_id;
00055 bool loaded;
00056
00057 public:
00058 TEXTURE() { file = ""; mipmap = loaded = false; tex_id = 0; w = h = 0; references = 0;}
00059
00060
00061 ~TEXTURE() { Unload(); }
00062
00063 int references;
00064 int w, h;
00065 bool mipmap;
00066 string file;
00067
00068
00069
00070
00071 void Load();
00072 void Unload();
00073 void Activate();
00074 };
00075
00076 class TEXTURE_HANDLE
00077 {
00078 private:
00079 TEXTURE * tex;
00080
00081 public:
00082 TEXTURE_HANDLE() {tex = NULL;}
00083 TEXTURE_HANDLE(const TEXTURE_HANDLE & other);
00084 ~TEXTURE_HANDLE();
00085
00086 bool Load( string new_tex_file ) { return Load( new_tex_file, true ); }
00087 bool Load( string new_tex_file, bool mipmap ) { int w, h; return Load( new_tex_file, mipmap, w, h ); }
00088 bool Load( string new_tex_file, bool mipmap, int &w, int &h );
00089
00090 void Unload();
00091 void Activate();
00092
00093 TEXTURE_HANDLE & CopyFrom(const TEXTURE_HANDLE & other);
00094 TEXTURE_HANDLE & operator=(const TEXTURE_HANDLE & other) {return CopyFrom(other);}
00095 };
00096
00097 class TEXTURES
00098 {
00099 private:
00100 list <TEXTURE> textures;
00101
00102 TEXTURE * FindTexture(string texname);
00103
00104 public:
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 TEXTURE * LoadTexture( string new_tex_file, bool mipmap, int &w, int &h );
00118 void UnloadTexture(TEXTURE * textodel);
00119
00120 void ReloadAll();
00121 };
00122
00123 #define _TEXTURES_H
00124 #endif