naev 0.10.4
Data Structures | Macros | Functions | Variables
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. More...
 
static nlua_env background_create (const char *name)
 Creates a background Lua state from a script. More...
 
static void background_clearCurrent (void)
 Destroys the current running background script. More...
 
static void background_clearImgArr (background_image_t **arr)
 Clears a background image array. More...
 
static int bkg_compare (const void *p1, const void *p2)
 Compares two different backgrounds and sorts them. More...
 
static void bkg_sort (background_image_t *arr)
 Sorts the backgrounds by movement. More...
 
void background_initDust (int n)
 Initializes background stars. More...
 
void background_moveDust (double x, double y)
 Displaces the stars, useful with camera. More...
 
void background_renderDust (const double dt)
 Renders the starry background. More...
 
void background_render (double dt)
 Render the background. More...
 
void background_renderOverlay (double dt)
 Renders the background overlay. More...
 
unsigned int background_addImage (glTexture *image, double x, double y, double move, double scale, double angle, const glColour *col, int foreground)
 Adds a new background image. More...
 
int background_init (void)
 Initializes the background system. More...
 
int background_load (const char *name)
 Loads a background script by name. More...
 
void background_clear (void)
 Cleans up the background stuff. More...
 
void background_free (void)
 Cleans up and frees memory after the backgrounds. More...
 
glTexture ** background_getTextures (void)
 returns the background images, and number of these More...
 

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. More...
 
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 * star_vertexVBO = NULL
 
static unsigned int nstars = 0
 
static GLfloat star_x = 0.
 
static GLfloat star_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 stars, more = less repetition

Definition at line 68 of file background.c.

Function Documentation

◆ background_addImage()

unsigned int background_addImage ( 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 327 of file background.c.

◆ background_clear()

void background_clear ( void  )

Cleans up the background stuff.

Definition at line 509 of file background.c.

◆ background_clearCurrent()

static void background_clearCurrent ( void  )
static

Destroys the current running background script.

Definition at line 489 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 524 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 392 of file background.c.

◆ background_free()

void background_free ( void  )

Cleans up and frees memory after the backgrounds.

Definition at line 538 of file background.c.

◆ background_getTextures()

glTexture ** background_getTextures ( void  )

returns the background images, and number of these

Definition at line 564 of file background.c.

◆ background_init()

int background_init ( void  )

Initializes the background system.

Definition at line 437 of file background.c.

◆ background_initDust()

void background_initDust ( int  n)

Initializes background stars.

Parameters
nNumber of stars to add (stars 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 447 of file background.c.

◆ background_moveDust()

void background_moveDust ( double  x,
double  y 
)

Displaces the stars, useful with camera.

Definition at line 137 of file background.c.

◆ background_render()

void background_render ( double  dt)

Render the background.

Parameters
dtReal delta ticks elapsed.

Definition at line 249 of file background.c.

◆ background_renderDust()

void background_renderDust ( const double  dt)

Renders the starry background.

Parameters
dtCurrent delta tick.

Definition at line 148 of file background.c.

◆ background_renderImages()

static void background_renderImages ( background_image_t bkg_arr)
static

Renders the background images.

Definition at line 361 of file background.c.

◆ background_renderOverlay()

void background_renderOverlay ( double  dt)

Renders the background overlay.

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

◆ bkg_sort()

static void bkg_sort ( background_image_t arr)
static

Sorts the backgrounds by movement.

Definition at line 319 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 stars).

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 stars).

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.

◆ nstars

unsigned int nstars = 0
static

Total stars.

Definition at line 70 of file background.c.

◆ star_vertexVBO

gl_vbo* star_vertexVBO = NULL
static

Star Vertex VBO.

Definition at line 69 of file background.c.

◆ star_x

GLfloat star_x = 0.
static

Star X movement.

Definition at line 71 of file background.c.

◆ star_y

GLfloat star_y = 0.
static

Star Y movement.

Definition at line 72 of file background.c.