naev 0.12.6
background.c File Reference

Handles displaying backgrounds. More...

#include "background.h"
#include "array.h"
#include "camera.h"
#include "conf.h"
#include "gui.h"
#include "log.h"
#include "ndata.h"
#include "nlua.h"
#include "nlua_bkg.h"
#include "nlua_camera.h"
#include "nlua_colour.h"
#include "nlua_gfx.h"
#include "nlua_tex.h"
#include "ntracing.h"
#include "opengl.h"
#include "pause.h"
#include "player.h"
#include "rng.h"
Include dependency graph for background.c:

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, const glColour *radiosity)
 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
static background_image_tbkg_image_arr_ft
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 74 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,
const glColour * radiosity )

Adds a new background image.

Definition at line 328 of file background.c.

◆ background_clear()

void background_clear ( void )

Cleans up the background stuff.

Definition at line 570 of file background.c.

◆ background_clearCurrent()

void background_clearCurrent ( void )
static

Destroys the current running background script.

Definition at line 551 of file background.c.

◆ background_clearImgArr()

void background_clearImgArr ( background_image_t ** arr)
static

Clears a background image array.

Parameters
arrArray to clear.

Definition at line 588 of file background.c.

◆ background_create()

nlua_env background_create ( const char * path)
static

Creates a background Lua state from a script.

Definition at line 447 of file background.c.

◆ background_free()

void background_free ( void )

Cleans up and frees memory after the backgrounds.

Definition at line 602 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 644 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 629 of file background.c.

◆ background_init()

int background_init ( void )

Initializes the background system.

Definition at line 492 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 97 of file background.c.

◆ background_load()

int background_load ( const char * name)

Loads a background script by name.

Definition at line 502 of file background.c.

◆ background_moveDust()

void background_moveDust ( double x,
double y )

Displaces the dust, useful with camera.

Definition at line 145 of file background.c.

◆ background_render()

void background_render ( double dt)

Render the background.

Parameters
dtReal delta ticks elapsed.

Definition at line 245 of file background.c.

◆ background_renderDust()

void background_renderDust ( const double dt)

Renders the dustry background.

Parameters
dtCurrent delta tick.

Definition at line 156 of file background.c.

◆ background_renderImages()

void background_renderImages ( background_image_t * bkg_arr)
static

Renders the background images.

Definition at line 392 of file background.c.

◆ background_renderOverlay()

void background_renderOverlay ( double dt)

Renders the background overlay.

Definition at line 290 of file background.c.

◆ bkg_compare()

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

Compares two different backgrounds and sorts them.

Definition at line 310 of file background.c.

◆ bkg_sort()

void bkg_sort ( background_image_t * arr)
static

Sorts the backgrounds by movement.

Definition at line 320 of file background.c.

Variable Documentation

◆ bkg_cur_env

nlua_env bkg_cur_env = LUA_NOREF
static

Backgrounds.

Current Lua state.

Definition at line 64 of file background.c.

◆ bkg_def_env

nlua_env bkg_def_env = LUA_NOREF
static

Default Lua state.

Definition at line 65 of file background.c.

◆ bkg_idgen

unsigned int bkg_idgen = 0
static

ID generator for backgrounds.

Definition at line 59 of file background.c.

◆ bkg_image_arr_bk

background_image_t* bkg_image_arr_bk
static
Initial value:
=
NULL

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

Definition at line 52 of file background.c.

◆ bkg_image_arr_ft

background_image_t* bkg_image_arr_ft
static
Initial value:
=
NULL

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

Definition at line 55 of file background.c.

◆ bkg_L_renderbg

int bkg_L_renderbg = LUA_NOREF
static

Background rendering function.

Definition at line 66 of file background.c.

◆ bkg_L_renderfg

int bkg_L_renderfg = LUA_NOREF
static

Foreground rendering function.

Definition at line 68 of file background.c.

◆ bkg_L_rendermg

int bkg_L_rendermg = LUA_NOREF
static

Middleground rendering function.

Definition at line 67 of file background.c.

◆ bkg_L_renderov

int bkg_L_renderov = LUA_NOREF
static

Overlay rendering function.

Definition at line 69 of file background.c.

◆ dust_vertexVBO

gl_vbo* dust_vertexVBO = NULL
static

Star Vertex VBO.

Definition at line 76 of file background.c.

◆ dust_x

GLfloat dust_x = 0.
static

Star X movement.

Definition at line 78 of file background.c.

◆ dust_y

GLfloat dust_y = 0.
static

Star Y movement.

Definition at line 79 of file background.c.

◆ ndust

unsigned int ndust = 0
static

Total dust.

Definition at line 77 of file background.c.