1 /*
2  * GarbageFlavorImage.h
3  * Daniel Nelson - 8/24/0
4  *
5  * Copyright (C) 2000  Daniel Nelson
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  *
21  * Daniel Nelson - aluminumangel.org
22  * 174 W. 18th Ave.
23  * Columbus, OH  43210
24  */
25 
26 #ifndef GARBAGEFLAVORIMAGE_H
27 #define GARBAGEFLAVORIMAGE_H
28 
29 #include <GL/glut.h>
30 
31 #include "glext.h"
32 
33 using namespace std;
34 
35 #include "Displayer.h"
36 #include "Garbage.h"
37 #include "Random.h"
38 
39 /* static */ class GarbageFlavorImage {
40 public:
41   static void initialize (   );
42 
43   static bool personalGarbageFlavorImageExists (   );
44   static GLubyte *loadPersonalGarbageFlavorImage (   );
45   static void handleNetworkGarbageFlavorImage ( GLubyte *texture );
46 
47   static void buildGarbageTextureFileName ( char file_name[256],
48    const char *dir_name, int n );
49   static void buildGarbageTextureFileName ( char file_name[256], int n );
50   static void buildOriginalGarbageTextureFileName ( char file_name[256],
51    int n );
52 
53   static void requestGarbageFlavorImage_inline_split_ ( Garbage &garbage );
54 
requestGarbageFlavorImage(Garbage & garbage)55   static inline void requestGarbageFlavorImage ( Garbage &garbage )
56   {
57     if (garbage.height < DC_MIN_FLAVOR_GARBAGE_LENGTH) return;
58     if (associated_garbage_id != -1) return;
59     if (!Random::number(DC_CHANCE_NO_GARBAGE_FLAVOR)) return;
60 
61     requestGarbageFlavorImage_inline_split_(garbage);
62   }
63 
notifyGarbageDestruction(Garbage & garbage)64   static inline void notifyGarbageDestruction ( Garbage &garbage )
65   {
66     if (garbage.id == associated_garbage_id)
67       associated_garbage_id = -1;
68   }
69 
70   static int current_texture;
71   static int associated_garbage_id;
72   static int x, y;
73   static bool network_texture;
74 };
75 
76 #endif
77