[Change] It's about time I optimised space_render.
This commit is contained in:
parent
7b509e4e08
commit
1f5c05ac77
34
src/space.c
34
src/space.c
@ -958,7 +958,7 @@ int space_load(void) {
|
||||
void space_render(double dt) {
|
||||
int i;
|
||||
unsigned int t, timer;
|
||||
double x, y, m;
|
||||
double x, y, m, b;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix(); // Translation matrix.
|
||||
@ -992,26 +992,30 @@ void space_render(double dt) {
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
} else {
|
||||
glBegin(GL_POINTS);
|
||||
|
||||
for(i = 0; i < nstars; i++) {
|
||||
if(!paused && !toolkit) {
|
||||
// Update position.
|
||||
if(!player_isFlag(PLAYER_DESTROYED)) {
|
||||
stars[i].x -= VX(player->solid->vel)/(13.-10.*stars[i].brightness)*dt;
|
||||
stars[i].y -= VY(player->solid->vel)/(13.-10.*stars[i].brightness)*dt;
|
||||
}
|
||||
// Scroll those stars bitch!
|
||||
glBegin(GL_POINTS); // Normal rendering.
|
||||
if(!paused && !player_isFlag(PLAYER_DESTROYED)) { // Update position.
|
||||
for(i = 0; i < nstars; i++) {
|
||||
b = 13.-10.*stars[i].brightness;
|
||||
stars[i].x -= player->solid->vel.x/b*dt;
|
||||
stars[i].y -= player->solid->vel.y/b*dt;
|
||||
|
||||
// Check for boundaries.
|
||||
if(stars[i].x > gl_screen.w + STAR_BUF) stars[i].x = -STAR_BUF;
|
||||
else if(stars[i].x < -STAR_BUF) stars[i].x = gl_screen.w + STAR_BUF;
|
||||
if(stars[i].y > gl_screen.h + STAR_BUF) stars[i].y = -STAR_BUF;
|
||||
else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF;
|
||||
|
||||
// Render.
|
||||
glColor4d(1., 1., 1., stars[i].brightness);
|
||||
glVertex2d(stars[i].x, stars[i].y);
|
||||
}
|
||||
} else { // Just render.
|
||||
for(i = 0; i < nstars; i++) {
|
||||
glColor4d(1., 1., 1., stars[i].brightness);
|
||||
glVertex2d(stars[i].x, stars[i].y);
|
||||
}
|
||||
// Render.
|
||||
glColor4d(1., 1., 1., stars[i].brightness);
|
||||
glVertex2d(stars[i].x, stars[i].y);
|
||||
}
|
||||
glEnd();
|
||||
glEnd(); // GL_POINTS
|
||||
}
|
||||
glPopMatrix(); // Translation matrix.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user