[Add] Make display lists of planets within range. Nice FPS improvment.

:D
This commit is contained in:
Allanis 2017-11-24 22:05:54 +00:00
parent d24a93345a
commit 0025c8833b
2 changed files with 18 additions and 6 deletions

View File

@ -12,6 +12,7 @@ Planet::Planet(StarSystem::SBody* sbody) : Body() {
this->sbody = *sbody; this->sbody = *sbody;
this->sbody.children.clear(); this->sbody.children.clear();
this->sbody.parent = 0; this->sbody.parent = 0;
crudDList = 0;
} }
Planet::~Planet(void) { Planet::~Planet(void) {
@ -566,6 +567,10 @@ void Planet::Render(const Frame* a_camFrame) {
glColor3f(1, 1, 1); glColor3f(1, 1, 1);
if(apparent_size < 0.001) { if(apparent_size < 0.001) {
if(crudDList) {
glDeleteLists(crudDList, 1);
crudDList = 0;
}
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glPointSize(1.0); glPointSize(1.0);
glBegin(GL_POINTS); glBegin(GL_POINTS);
@ -573,13 +578,19 @@ void Planet::Render(const Frame* a_camFrame) {
glEnd(); glEnd();
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
} else { } else {
glScalef(rad, rad, rad); if(!crudDList) {
crudDList = glGenLists(1);
glNewList(crudDList, GL_COMPILE);
/* This is a rather brittle test.. */ /* This is a rather brittle test.. */
if(sbody.type < StarSystem::TYPE_PLANET_DWARF) { if(sbody.type < StarSystem::TYPE_PLANET_DWARF) {
DrawGasGiant(); DrawGasGiant();
} else { } else {
DrawRockyPlanet(); DrawRockyPlanet();
} }
glEndList();
}
glScalef(rad, rad, rad);
glCallList(crudDList);
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
} }
glPopMatrix(); glPopMatrix();

View File

@ -22,5 +22,6 @@ private:
double radius; double radius;
dGeomID geom; dGeomID geom;
StarSystem::SBody sbody; StarSystem::SBody sbody;
GLuint crudDList;
}; };