/**************************************************************************** Copyright (C) 2002-2006 Gilles Debunne (Gilles.Debunne@imag.fr) This file is part of the QGLViewer library. Version 2.2.4-1, released on December 12, 2006. http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer libQGLViewer is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. libQGLViewer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libQGLViewer; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *****************************************************************************/ // TP OpenGL: Joerg Liebelt, Serigne Sow #include "tree.h" using namespace qglviewer; bool TREE::LoadTexture(char* filename ) { QImage image; if (image.load(filename)) { texture= QGLWidget::convertToGLFormat(image); //construire les textures openGL glGenTextures( 1, &(texID) ); glBindTexture( GL_TEXTURE_2D, (texID) ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, texture.width(), texture.height(), GL_RGBA, GL_UNSIGNED_BYTE, texture.bits() ); } else { printf(" treetexture failed\n"); return false; } return true; } void TREE::initTrees(QUADTREE ter, int num, float waterLevel) { int i; myTerrain = ter; numTrees = num; treeInfo = new Vec[numTrees]; srand( time(NULL) ); for (i=0;i