[Add] space_renderOverlay().
This commit is contained in:
parent
862ef7759b
commit
42a57d09e9
@ -369,6 +369,7 @@ static void render_all(void) {
|
|||||||
pilots_render();
|
pilots_render();
|
||||||
weapons_render(WEAPON_LAYER_FG);
|
weapons_render(WEAPON_LAYER_FG);
|
||||||
spfx_render(SPFX_LAYER_BACK);
|
spfx_render(SPFX_LAYER_BACK);
|
||||||
|
space_renderOverlay();
|
||||||
/* FG. */
|
/* FG. */
|
||||||
player_render();
|
player_render();
|
||||||
spfx_render(SPFX_LAYER_FRONT);
|
spfx_render(SPFX_LAYER_FRONT);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "lfile.h"
|
#include "lfile.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
|
#include "menu.h"
|
||||||
#include "perlin.h"
|
#include "perlin.h"
|
||||||
|
|
||||||
#define NEBU_DT_MAX 5.
|
#define NEBU_DT_MAX 5.
|
||||||
@ -15,6 +16,8 @@
|
|||||||
#define NEBULAE_Z 16 /* Z plane. */
|
#define NEBULAE_Z 16 /* Z plane. */
|
||||||
#define NEBULAE_PATH "gen/nebu_%02d.png"
|
#define NEBULAE_PATH "gen/nebu_%02d.png"
|
||||||
|
|
||||||
|
extern double gui_xoff, gui_yoff;
|
||||||
|
|
||||||
/* The nebulae textures. */
|
/* The nebulae textures. */
|
||||||
static GLuint nebu_textures[NEBULAE_Z];
|
static GLuint nebu_textures[NEBULAE_Z];
|
||||||
static int nebu_w = 0;
|
static int nebu_w = 0;
|
||||||
@ -134,6 +137,8 @@ void nebu_render(void) {
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBindTexture(GL_TEXTURE_2D, nebu_textures[cur_nebu[1]]);
|
glBindTexture(GL_TEXTURE_2D, nebu_textures[cur_nebu[1]]);
|
||||||
|
|
||||||
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
|
||||||
/* Texture 1. */
|
/* Texture 1. */
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
@ -182,7 +187,6 @@ void nebu_render(void) {
|
|||||||
glVertex2d(-SCREEN_W/2., SCREEN_H/2.);
|
glVertex2d(-SCREEN_W/2., SCREEN_H/2.);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
/* Clean up. */
|
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
@ -193,6 +197,89 @@ void nebu_render(void) {
|
|||||||
gl_checkErr();
|
gl_checkErr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nebu_renderOverlay(double density) {
|
||||||
|
#define ANG45 0.70710678118654757
|
||||||
|
#define COS225 0.92387953251128674
|
||||||
|
#define SIN225 0.38268343236508978
|
||||||
|
glShadeModel(GL_SMOOTH);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslated(gui_xoff, gui_yoff, 0.);
|
||||||
|
|
||||||
|
/* Stuff player partially sees. */
|
||||||
|
glBegin(GL_TRIANGLE_FAN);
|
||||||
|
ACOLOUR(cPurple, 0.);
|
||||||
|
glVertex2d(0., 0.);
|
||||||
|
ACOLOUR(cPurple, 1.);
|
||||||
|
glVertex2d(-density, 0.);
|
||||||
|
glVertex2d(-density*COS225, density*SIN225);
|
||||||
|
glVertex2d(-density*ANG45, density*ANG45);
|
||||||
|
glVertex2d(-density*SIN225, density*COS225);
|
||||||
|
glVertex2d( 0., density);
|
||||||
|
glVertex2d( density*SIN225, density*COS225);
|
||||||
|
glVertex2d( density*ANG45, density*ANG45);
|
||||||
|
glVertex2d( density*COS225, density*SIN225);
|
||||||
|
glVertex2d( density, 0.);
|
||||||
|
glVertex2d( density*COS225, -density*SIN225);
|
||||||
|
glVertex2d( density*ANG45, -density*ANG45);
|
||||||
|
glVertex2d( density*SIN225, -density*COS225);
|
||||||
|
glVertex2d( 0., -density);
|
||||||
|
glVertex2d(-density*SIN225, -density*COS225);
|
||||||
|
glVertex2d(-density*ANG45, -density*ANG45);
|
||||||
|
glVertex2d(-density*COS225, -density*SIN225);
|
||||||
|
glVertex2d(-density, 0.);
|
||||||
|
glEnd(); /* GL_TRIANGLE_FAN */
|
||||||
|
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
|
||||||
|
/* Stuff player can't see. */
|
||||||
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
|
ACOLOUR(cPurple, 1.);
|
||||||
|
/* Start at the left. */
|
||||||
|
glVertex2d(-density, 0.);
|
||||||
|
glVertex2d(-density*COS225, density*SIN225);
|
||||||
|
glVertex2d(-SCREEN_W/2.-gui_xoff, SCREEN_H/2.-gui_yoff);
|
||||||
|
glVertex2d(-density*ANG45, density*ANG45);
|
||||||
|
glVertex2d(-density*SIN225, density*COS225);
|
||||||
|
glVertex2d(-SCREEN_W/2.-gui_xoff, SCREEN_H/2.-gui_yoff);
|
||||||
|
glVertex2d( SCREEN_W/2.-gui_xoff, SCREEN_H/2.-gui_yoff);
|
||||||
|
/* Move to the top. */
|
||||||
|
glVertex2d( 0., density);
|
||||||
|
glVertex2d( density*SIN225, density*COS225);
|
||||||
|
glVertex2d( SCREEN_W/2.-gui_xoff, SCREEN_H/2.-gui_yoff);
|
||||||
|
glVertex2d( density*ANG45, density*ANG45);
|
||||||
|
glVertex2d( density*COS225, density*SIN225);
|
||||||
|
glVertex2d( SCREEN_W/2.-gui_xoff, SCREEN_H/2.-gui_yoff);
|
||||||
|
/* Down to the right. */
|
||||||
|
glVertex2d( density, 0.);
|
||||||
|
glVertex2d( SCREEN_W/2.-gui_xoff, -SCREEN_H/2.-gui_yoff);
|
||||||
|
glVertex2d( density*COS225, -density*SIN225);
|
||||||
|
glVertex2d( SCREEN_W/2.-gui_xoff, -SCREEN_H/2.-gui_yoff);
|
||||||
|
glVertex2d( density*ANG45, -density*ANG45);
|
||||||
|
glVertex2d( density*SIN225, -density*COS225);
|
||||||
|
glVertex2d( SCREEN_W/2.-gui_xoff, -SCREEN_H/2.-gui_yoff);
|
||||||
|
glVertex2d( -SCREEN_W/2.-gui_xoff, -SCREEN_H/2.-gui_yoff);
|
||||||
|
/* At the bottom. */
|
||||||
|
glVertex2d( 0., -density);
|
||||||
|
glVertex2d(-density*SIN225, -density*COS225);
|
||||||
|
glVertex2d(-SCREEN_W/2.-gui_xoff, -SCREEN_H/2.-gui_yoff);
|
||||||
|
glVertex2d(-density*ANG45, -density*ANG45);
|
||||||
|
glVertex2d(-density*COS225, -density*SIN225);
|
||||||
|
glVertex2d(-SCREEN_W/2.-gui_xoff, -SCREEN_H/2.-gui_yoff);
|
||||||
|
/* Back to origin. */
|
||||||
|
glVertex2d(-density, 0.);
|
||||||
|
glVertex2d(-SCREEN_W/2.-gui_xoff, SCREEN_H/2.-gui_yoff);
|
||||||
|
glEnd(); /* GL_QUAD_STRIP */
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
gl_checkErr();
|
||||||
|
|
||||||
|
#undef ANG45
|
||||||
|
#undef COS225
|
||||||
|
#undef SIN225
|
||||||
|
}
|
||||||
|
|
||||||
/* Force generation of new nebulae. */
|
/* Force generation of new nebulae. */
|
||||||
void nebu_forceGenerate(void) {
|
void nebu_forceGenerate(void) {
|
||||||
nebu_w = nebu_h = -9;
|
nebu_w = nebu_h = -9;
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/* Try to find nebulae to load, or generate if there isn't any. */
|
/* Init/Exit. */
|
||||||
void nebu_init(void);
|
void nebu_init(void);
|
||||||
|
|
||||||
void nebu_exit(void);
|
void nebu_exit(void);
|
||||||
|
|
||||||
|
/* Render. */
|
||||||
void nebu_render(void);
|
void nebu_render(void);
|
||||||
|
void nebu_renderOverlay(double density);
|
||||||
|
|
||||||
|
/* Misc. */
|
||||||
void nebu_forceGenerate(void);
|
void nebu_forceGenerate(void);
|
||||||
|
|
||||||
|
12
src/space.c
12
src/space.c
@ -792,8 +792,16 @@ int space_load(void) {
|
|||||||
|
|
||||||
/* Render the system. -- Just playing god now. */
|
/* Render the system. -- Just playing god now. */
|
||||||
void space_render(double dt) {
|
void space_render(double dt) {
|
||||||
space_renderStars(dt);
|
if(cur_system->nebu_density > 0.)
|
||||||
/* nebu_render(); */
|
nebu_render();
|
||||||
|
else
|
||||||
|
space_renderStars(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Render the overlay. */
|
||||||
|
void space_renderOverlay(void) {
|
||||||
|
if(cur_system->nebu_density > 0.)
|
||||||
|
nebu_renderOverlay(cur_system->nebu_density);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Render stars. */
|
/* Render stars. */
|
||||||
|
32
src/space.h
32
src/space.h
@ -81,28 +81,31 @@ typedef struct Planet_ {
|
|||||||
|
|
||||||
/* Star systems. */
|
/* Star systems. */
|
||||||
typedef struct SystemFleet_ {
|
typedef struct SystemFleet_ {
|
||||||
Fleet* fleet; /* Fleet to appear. */
|
Fleet* fleet; /* Fleet to appear. */
|
||||||
int chance; /* Chance of fleet appearing in the system. */
|
int chance; /* Chance of fleet appearing in the system. */
|
||||||
} SystemFleet;
|
} SystemFleet;
|
||||||
|
|
||||||
typedef struct StarSystem_ {
|
typedef struct StarSystem_ {
|
||||||
char* name; /* Star system identifier. */
|
char* name; /* Star system identifier. */
|
||||||
Vec2 pos; /* Position. */
|
Vec2 pos; /* Position. */
|
||||||
int stars, asteroids; /* Un numero! */
|
int stars, asteroids; /* Un numero! */
|
||||||
double interference; /* Un uh.. Percentage. */
|
double interference; /* Un uh.. Percentage. */
|
||||||
|
|
||||||
int faction; /* Overall faction. */
|
int faction; /* Overall faction. */
|
||||||
|
|
||||||
Planet* planets; /* Planets. */
|
Planet* planets; /* Planets. */
|
||||||
int nplanets; /* Total number of planets. */
|
int nplanets; /* Total number of planets. */
|
||||||
|
|
||||||
SystemFleet* fleets; /* Fleets that can appear in the current system. */
|
SystemFleet* fleets; /* Fleets that can appear in the current system. */
|
||||||
int nfleets; /* Total number of fleets. */
|
int nfleets; /* Total number of fleets. */
|
||||||
|
|
||||||
int* jumps; /* Adjacent star system index number. */
|
int* jumps; /* Adjacent star system index number. */
|
||||||
int njumps; /* Number of adjacent jumps. */
|
int njumps; /* Number of adjacent jumps. */
|
||||||
|
|
||||||
unsigned int flags; /* Flags for system properties. */
|
double nebu_density; /* Nebulae density. */
|
||||||
|
double nebu_volatility; /* Nebulae volatility - Not used yet. */
|
||||||
|
|
||||||
|
unsigned int flags; /* Flags for system properties. */
|
||||||
} StarSystem;
|
} StarSystem;
|
||||||
|
|
||||||
extern StarSystem* cur_system; /* Current star system. */
|
extern StarSystem* cur_system; /* Current star system. */
|
||||||
@ -118,6 +121,7 @@ Planet* planet_get(char* planetname);
|
|||||||
|
|
||||||
/* Render. */
|
/* Render. */
|
||||||
void space_render(double dt);
|
void space_render(double dt);
|
||||||
|
void space_renderOverlay(void);
|
||||||
void planets_render(void);
|
void planets_render(void);
|
||||||
|
|
||||||
/* Update. */
|
/* Update. */
|
||||||
|
Loading…
Reference in New Issue
Block a user