naev 0.11.5
background.c File Reference

Handles displaying backgrounds. More...

#include "background.h"
#include "array.h"
#include "camera.h"
#include "conf.h"
#include "log.h"
#include "gui.h"
#include "ndata.h"
#include "nebula.h"
#include "nlua.h"
#include "nlua_audio.h"
#include "nlua_bkg.h"
#include "nlua_colour.h"
#include "nlua_tex.h"
#include "nlua_camera.h"
#include "nlua_gfx.h"
#include "nluadef.h"
#include "nstring.h"
#include "nxml.h"
#include "opengl.h"
#include "pause.h"
#include "player.h"
#include "rng.h"

Go to the source code of this file.

Data Structures

struct  background_image_t
 Represents a background image like say a Nebula. More...
 

Macros

#define STAR_BUF   250
 

Functions

static void background_renderImages (background_image_t *bkg_arr)
 Renders the background images.
 
static nlua_env background_create (const char *name)
 Creates a background Lua state from a script.
 
static void background_clearCurrent (void)
 Destroys the current running background script.
 
static void background_clearImgArr (background_image_t **arr)
 Clears a background image array.
 
static int bkg_compare (const void *p1, const void *p2)
 Compares two different backgrounds and sorts them.
 
static void bkg_sort (background_image_t *arr)
 Sorts the backgrounds by movement.
 
void background_initDust (int n)
 Initializes background dust.
 
void background_moveDust (double x, double y)
 Displaces the dust, useful with camera.
 
void background_renderDust (const double dt)
 Renders the dustry background.
 
void background_render (double dt)
 Render the background.
 
void background_renderOverlay (double dt)
 Renders the background overlay.
 
unsigned int background_addImage (const glTexture *image, double x, double y, double move, double scale, double angle, const glColour *col, int foreground)
 Adds a new background image.
 
int background_init (void)
 Initializes the background system.
 
int background_load (const char *name)
 Loads a background script by name.
 
void background_clear (void)
 Cleans up the background stuff.
 
void background_free (void)
 Cleans up and frees memory after the backgrounds.
 
glTexture ** background_getStarTextures (void)
 Returns an array (array.h) of star background images in the system background.
 
glTexturebackground_getAmbientTexture (void)
 Returns an overall background image (nebula, for instance), or NULL if none exists.
 

Variables

static background_image_tbkg_image_arr_bk = NULL
 
static background_image_tbkg_image_arr_ft = NULL
 
static unsigned int bkg_idgen = 0
 
static nlua_env bkg_cur_env = LUA_NOREF
 Backgrounds.
 
static nlua_env bkg_def_env = LUA_NOREF
 
static int bkg_L_renderbg = LUA_NOREF
 
static int bkg_L_rendermg = LUA_NOREF
 
static int bkg_L_renderfg = LUA_NOREF
 
static int bkg_L_renderov = LUA_NOREF
 
static gl_vbo * dust_vertexVBO = NULL
 
static unsigned int ndust = 0
 
static GLfloat dust_x = 0.
 
static GLfloat dust_y = 0.
 

Detailed Description

Handles displaying backgrounds.

Definition in file background.c.

Macro Definition Documentation

◆ STAR_BUF

#define STAR_BUF   250

Area to leave around screen for dust, more = less repetition

Definition at line 68 of file background.c.

Function Documentation

◆ background_addImage()

unsigned int background_addImage ( const glTexture * image,
double x,
double y,
double move,
double scale,
double angle,
const glColour * col,
int foreground )

Adds a new background image.

Definition at line 307 of file background.c.

◆ background_clear()

void background_clear ( void )

Cleans up the background stuff.

Definition at line 489 of file background.c.

◆ background_clearCurrent()

static void background_clearCurrent ( void )
static

Destroys the current running background script.

Definition at line 469 of file background.c.

◆ background_clearImgArr()

static void background_clearImgArr ( background_image_t ** arr)
static

Clears a background image array.

Parameters
arrArray to clear.

Definition at line 504 of file background.c.

◆ background_create()

static nlua_env background_create ( const char * path)
static

Creates a background Lua state from a script.

Definition at line 372 of file background.c.

◆ background_free()

void background_free ( void )

Cleans up and frees memory after the backgrounds.

Definition at line 518 of file background.c.

◆ background_getAmbientTexture()

glTexture * background_getAmbientTexture ( void )

Returns an overall background image (nebula, for instance), or NULL if none exists.

Todo
With current background scripts, this only does anything on the border (1 jump from nebula)!

Definition at line 556 of file background.c.

◆ background_getStarTextures()

glTexture ** background_getStarTextures ( void )

Returns an array (array.h) of star background images in the system background.

Definition at line 544 of file background.c.

◆ background_init()

int background_init ( void )

Initializes the background system.

Definition at line 417 of file background.c.

◆ background_initDust()

void background_initDust ( int n)

Initializes background dust.

Parameters
nNumber of dust to add (dust per 800x640 screen).

Definition at line 90 of file background.c.

◆ background_load()

int background_load ( const char * name)

Loads a background script by name.

Definition at line 427 of file background.c.

◆ background_moveDust()

void background_moveDust ( double x,
double y )

Displaces the dust, useful with camera.

Definition at line 134 of file background.c.

◆ background_render()

void background_render ( double dt)

Render the background.

Parameters
dtReal delta ticks elapsed.

Definition at line 229 of file background.c.

◆ background_renderDust()

void background_renderDust ( const double dt)

Renders the dustry background.

Parameters
dtCurrent delta tick.

Definition at line 145 of file background.c.

◆ background_renderImages()

static void background_renderImages ( background_image_t * bkg_arr)
static

Renders the background images.

Definition at line 341 of file background.c.

◆ background_renderOverlay()

void background_renderOverlay ( double dt)

Renders the background overlay.

Definition at line 267 of file background.c.

◆ bkg_compare()

static int bkg_compare ( const void * p1,
const void * p2 )
static

Compares two different backgrounds and sorts them.

Definition at line 282 of file background.c.

◆ bkg_sort()

static void bkg_sort ( background_image_t * arr)
static

Sorts the backgrounds by movement.

Definition at line 299 of file background.c.

Variable Documentation

◆ bkg_cur_env

nlua_env bkg_cur_env = LUA_NOREF
static

Backgrounds.

Current Lua state.

Definition at line 58 of file background.c.

◆ bkg_def_env

nlua_env bkg_def_env = LUA_NOREF
static

Default Lua state.

Definition at line 59 of file background.c.

◆ bkg_idgen

unsigned int bkg_idgen = 0
static

ID generator for backgrounds.

Definition at line 53 of file background.c.

◆ bkg_image_arr_bk

background_image_t* bkg_image_arr_bk = NULL
static

Background image array to display (behind dust). Assumed to be a debris layer.

Definition at line 50 of file background.c.

◆ bkg_image_arr_ft

background_image_t* bkg_image_arr_ft = NULL
static

Background image array to display (in front of dust). Assumed to be a star layer.

Definition at line 51 of file background.c.

◆ bkg_L_renderbg

int bkg_L_renderbg = LUA_NOREF
static

Background rendering function.

Definition at line 60 of file background.c.

◆ bkg_L_renderfg

int bkg_L_renderfg = LUA_NOREF
static

Foreground rendering function.

Definition at line 62 of file background.c.

◆ bkg_L_rendermg

int bkg_L_rendermg = LUA_NOREF
static

Middleground rendering function.

Definition at line 61 of file background.c.

◆ bkg_L_renderov

int bkg_L_renderov = LUA_NOREF
static

Overlay rendering function.

Definition at line 63 of file background.c.

◆ dust_vertexVBO

gl_vbo* dust_vertexVBO = NULL
static

Star Vertex VBO.

Definition at line 69 of file background.c.

◆ dust_x

GLfloat dust_x = 0.
static

Star X movement.

Definition at line 71 of file background.c.

◆ dust_y

GLfloat dust_y = 0.
static

Star Y movement.

Definition at line 72 of file background.c.

◆ ndust

unsigned int ndust = 0
static

Total dust.

Definition at line 70 of file background.c.