src/Cell.cpp

Go to the documentation of this file.
00001 
00008 /*
00009 This file is part of Teapot Colony Wars.
00010 
00011 Teapot Colony Wars is free software: you can redistribute it and/or modify
00012 it under the terms of the GNU General Public License as published by
00013 the Free Software Foundation, either version 2 of the License, or
00014 (at your option) any later version.
00015 
00016 Teapot Colony Wars is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 GNU General Public License for more details.
00020 
00021 You should have received a copy of the GNU General Public License
00022 along with Teapot Colony Wars.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 #include "Cell.h"
00026 
00027 #include "Constants.h"
00028 #include "Image.h"
00029 
00030 // Par défaut, la texture n'a pas encore été chargée.
00031 GLuint Cell::_tex_name = 0;
00032 
00033 GLuint Cell::getTexName() {
00034   if(_tex_name == 0) {
00035     // si besoin est, on charge l'image et on la convertit en texture.
00036     Image texture("./textures/Cell.bmp");
00037     _tex_name = texture.genTexture2D();
00038   }
00039 
00040   return _tex_name;
00041 }
00042 
00043 void Cell::getColors(GLubyte &red, GLubyte &green, GLubyte &blue) {
00044   red   = COLOR_MAX;
00045   green = COLOR_MAX;
00046   blue  = COLOR_MAX;
00047 }
00048 
00049 Cell::Cell() {
00050 
00051 }
00052 
00053 Cell::~Cell() {
00054 
00055 }
00056 
00057 void Cell::draw() {
00058   GLubyte red, green, blue;
00059 
00060   // désactivation de l'illumination pour éviter des problèmes de contre-jour
00061   glDisable(GL_LIGHTING);
00062   // activation de l'application de textures bi-dimensionnelles.
00063   glEnable(GL_TEXTURE_2D);
00064 
00065   // définition de la texture courante à appliquer.
00066   glBindTexture(GL_TEXTURE_2D, getTexName());
00067 
00068   // initialisation du mode de dessin.
00069   glMatrixMode(GL_MODELVIEW);
00070   getColors(red, green, blue);
00071   glColor3ub(red, green, blue);
00072 
00073   // création d'un polygone carré représenté par deux triangles sur lesquels
00074   // la texture sera appliquée.
00075   glBegin(GL_TRIANGLE_STRIP);
00076     glNormal3f(0.0, 1.0, 0.0);
00077     glTexCoord2f(0.0, 1.0); glVertex3f(-0.5 * CELL_SIZE, 0.0, -0.5 * CELL_SIZE);
00078     glTexCoord2f(0.0, 0.0); glVertex3f(-0.5 * CELL_SIZE, 0.0,  0.5 * CELL_SIZE);
00079     glTexCoord2f(1.0, 1.0); glVertex3f( 0.5 * CELL_SIZE, 0.0, -0.5 * CELL_SIZE);
00080     glTexCoord2f(1.0, 0.0); glVertex3f( 0.5 * CELL_SIZE, 0.0,  0.5 * CELL_SIZE);
00081   glEnd();
00082 
00083   // réactivation des lumières.
00084   glDisable(GL_TEXTURE_2D);
00085   // désactivation du rendu de textures.
00086   glEnable(GL_LIGHTING);
00087 }
00088 
00089 unsigned int Cell::getFood() {
00090   return 0;
00091 }
00092 
00093 unsigned int Cell::addFood(unsigned int inc) {
00094   return 0;
00095 }
00096 
00097 unsigned int Cell::subFood(unsigned int inc) {
00098   return 0;
00099 }
00100 
00101 bool Cell::reachable(Worshiper *w) {
00102   return false;
00103 }
00104 
00105 std::list<Worshiper*>* Cell::getPeople() {
00106   return NULL;
00107 }
00108 
00109 std::map<Pheromone*, unsigned int>* Cell::getPheromones() {
00110   return NULL;
00111 }
00112 
00113 bool Cell::addWorshiper(Worshiper *w) {
00114   return false;
00115 }
00116 
00117 bool Cell::removeWorshiper(const Worshiper *w) {
00118   return false;
00119 }
00120 
00121 void Cell::addPheromone(Pheromone *p) {
00122 
00123 }
00124 
00125 Cell* Cell::makeActions() {
00126   return this;
00127 }

Generated on Sat Feb 2 22:22:54 2008 for Teapot Colony Wars by  doxygen 1.5.4