LargeHemisphere.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <common/Vector.h>
00022 #include <GLEXT/GLStateExtension.h>
00023 #include <GLEXT/GLInfo.h>
00024 #include <sky/LargeHemisphere.h>
00025 #include <sky/Hemisphere.h>
00026 
00027 LargeHemisphere::LargeHemisphere()
00028 {
00029 }
00030 
00031 LargeHemisphere::~LargeHemisphere()
00032 {
00033 }
00034 
00035 void LargeHemisphere::clear()
00036 {
00037         while (!entries_.empty())
00038         {
00039                 Entry entry = entries_.back();
00040                 entries_.pop_back();
00041                 glDeleteLists(entry.listNo_, 1);
00042         }
00043 }
00044 
00045 void LargeHemisphere::draw(float radius, float radius2, 
00046         unsigned int flags)
00047 {
00048         if (entries_.empty())
00049         {
00050                 for (int i=0; i<10; i+=2)
00051                 {
00052                         for (int j=0; j<10; j+=2)
00053                         {
00054                                 Entry entry;
00055                                 glNewList(entry.listNo_ = glGenLists(1), GL_COMPILE_AND_EXECUTE);
00056                                         Hemisphere::draw(radius, radius2, 10, 10, i, j, i+2, j+2, 
00057                                                 false, flags);
00058                                 glEndList();
00059                                 entries_.push_back(entry);
00060                         }
00061                 }
00062         }
00063         else
00064         {
00065                 std::list<Entry>::iterator itor;
00066                 for (itor = entries_.begin();
00067                         itor != entries_.end();
00068                         itor++)
00069                 {
00070                         // Should check for visibility here, but it seems so quick anyway
00071                         Entry &entry = *itor;
00072                         glCallList(entry.listNo_);
00073                         GLInfo::addNoTriangles(8);
00074                 }
00075         }
00076 }
00077 
00078 void LargeHemisphere::drawColored(float radius, float radius2, 
00079         Image &colors, Vector &sunDir, int daytime, bool horizonGlow)
00080 {
00081         if (entries_.empty())
00082         {
00083                 for (int i=0; i<10; i+=2)
00084                 {
00085                         for (int j=0; j<10; j+=2)
00086                         {
00087                                 Entry entry;
00088                                 glNewList(entry.listNo_ = glGenLists(1), GL_COMPILE_AND_EXECUTE);
00089                                         Hemisphere::drawColored(radius, radius2, 10, 10, i, j, i+2, j+2, 
00090                                                 false, colors, sunDir, daytime, horizonGlow);
00091                                 glEndList();
00092                                 entries_.push_back(entry);
00093                         }
00094                 }
00095         }
00096         else
00097         {
00098                 std::list<Entry>::iterator itor;
00099                 for (itor = entries_.begin();
00100                         itor != entries_.end();
00101                         itor++)
00102                 {
00103                         Entry &entry = *itor;
00104                         glCallList(entry.listNo_);
00105                         GLInfo::addNoTriangles(8);
00106                 }
00107         }
00108 }

Generated on Mon Feb 16 15:14:47 2009 for Scorched3D by  doxygen 1.5.3