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

:D
This commit is contained in:
Rtch90 2017-11-24 22:05:54 +00:00
parent 0d79a17c31
commit 15b6d9178c
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.children.clear();
this->sbody.parent = 0;
crudDList = 0;
}
Planet::~Planet(void) {
@ -566,6 +567,10 @@ void Planet::Render(const Frame* a_camFrame) {
glColor3f(1, 1, 1);
if(apparent_size < 0.001) {
if(crudDList) {
glDeleteLists(crudDList, 1);
crudDList = 0;
}
glDisable(GL_LIGHTING);
glPointSize(1.0);
glBegin(GL_POINTS);
@ -573,13 +578,19 @@ void Planet::Render(const Frame* a_camFrame) {
glEnd();
glEnable(GL_LIGHTING);
} else {
glScalef(rad, rad, rad);
if(!crudDList) {
crudDList = glGenLists(1);
glNewList(crudDList, GL_COMPILE);
/* This is a rather brittle test.. */
if(sbody.type < StarSystem::TYPE_PLANET_DWARF) {
DrawGasGiant();
} else {
DrawRockyPlanet();
}
glEndList();
}
glScalef(rad, rad, rad);
glCallList(crudDList);
glClear(GL_DEPTH_BUFFER_BIT);
}
glPopMatrix();

View File

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