00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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 }