naev 0.12.5
background.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include "naev.h"
12
13#include "background.h"
14
15#include "array.h"
16#include "camera.h"
17#include "conf.h"
18#include "gui.h"
19#include "log.h"
20#include "ndata.h"
21#include "nlua.h"
22#include "nlua_bkg.h"
23#include "nlua_camera.h"
24#include "nlua_colour.h"
25#include "nlua_gfx.h"
26#include "nlua_tex.h"
27#include "ntracing.h"
28#include "opengl.h"
29#include "pause.h"
30#include "player.h"
31#include "rng.h"
32
36typedef struct background_image_s {
37 unsigned int id;
39 double x;
40 double y;
41 double
43 double scale;
44 double angle;
45 glColour col;
46 glColour radiosity;
47
48 /* Handled during rendering. */
49 int L_idx;
53 NULL;
56 NULL;
58
59static unsigned int bkg_idgen = 0;
60
64static nlua_env bkg_cur_env = LUA_NOREF;
65static nlua_env bkg_def_env = LUA_NOREF;
66static int bkg_L_renderbg = LUA_NOREF;
67static int bkg_L_rendermg = LUA_NOREF;
68static int bkg_L_renderfg = LUA_NOREF;
69static int bkg_L_renderov = LUA_NOREF;
70
71/*
72 * Background dust.
73 */
74#define STAR_BUF \
75 250
76static gl_vbo *dust_vertexVBO = NULL;
77static unsigned int ndust = 0;
78static GLfloat dust_x = 0.;
79static GLfloat dust_y = 0.;
80
81/*
82 * Prototypes.
83 */
84static void background_renderImages( background_image_t *bkg_arr );
85static nlua_env background_create( const char *path );
86static void background_clearCurrent( void );
88/* Sorting. */
89static int bkg_compare( const void *p1, const void *p2 );
90static void bkg_sort( background_image_t *arr );
91
98{
99 GLfloat w, h, hw, hh;
100 double size;
101 GLfloat *dust_vertex;
102
103 NTracingZone( _ctx, 1 );
104
105 /* Calculate size. */
106 size = SCREEN_W * SCREEN_H + STAR_BUF * STAR_BUF;
107 size /= pow2( conf.zoom_far );
108
109 /* Calculate dust buffer. */
110 w = ( SCREEN_W + 2. * STAR_BUF );
111 w += ( w / conf.zoom_far - 1. );
112 h = ( SCREEN_H + 2. * STAR_BUF );
113 h += ( h / conf.zoom_far - 1. );
114 hw = w / 2.;
115 hh = h / 2.;
116
117 /* Calculate dust. */
118 size *= n;
119 ndust = (unsigned int)( size / ( 800. * 600. ) );
120
121 /* Create data. */
122 dust_vertex = malloc( ndust * sizeof( GLfloat ) * 3 );
123
124 for ( unsigned int i = 0; i < ndust; i++ ) {
125 /* Set the position. */
126 dust_vertex[3 * i + 0] = RNGF() * w - hw;
127 dust_vertex[3 * i + 1] = RNGF() * h - hh;
128 /* Set the colour. */
129 dust_vertex[3 * i + 2] = RNGF() * 0.6 + 0.2;
130 }
131
132 /* Recreate VBO. */
135 gl_vboCreateStatic( ndust * sizeof( GLfloat ) * 3, dust_vertex );
136
137 free( dust_vertex );
138
139 NTracingZoneEnd( _ctx );
140}
141
145void background_moveDust( double x, double y )
146{
147 dust_x += (GLfloat)x;
148 dust_y += (GLfloat)y;
149}
150
156void background_renderDust( const double dt )
157{
158 (void)dt;
159 GLfloat h, w, m;
160 double z, angle;
161 mat4 projection;
162 int points = 1;
163
164 NTracingZone( _ctx, 1 );
165
166 /* Do some scaling for now. */
167 z = cam_getZoom();
168 m = 1.;
169 angle = 0.;
170 projection = gl_view_matrix;
171 mat4_translate_scale_xy( &projection, SCREEN_W / 2., SCREEN_H / 2., z, z );
172
173 /* Decide on shade mode. */
174 if ( ( player.p != NULL ) && !player_isFlag( PLAYER_DESTROYED ) &&
175 !player_isFlag( PLAYER_CREATING ) ) {
176 double dx, dy, vmod;
177
178 /* Get camera movement. */
179 cam_getVel( &dx, &dy );
180 vmod = hypot( dx, dy );
181
182 if ( pilot_isFlag( player.p,
183 PILOT_HYPERSPACE ) ) { /* hyperspace fancy effects */
184 /* lines get longer the closer we are to finishing the jump */
185 m = MAX( 0, HYPERSPACE_DUST_BLUR - player.p->ptimer );
186 if ( m > 0. ) {
187 m *= HYPERSPACE_DUST_LENGTH / HYPERSPACE_DUST_BLUR;
188 angle = atan2( dy, dx );
189 points = 0;
190 }
191 } else if ( dt_mod * vmod > 500. ) {
192 angle = atan2( dy, dx );
193 m = ( dt_mod * vmod ) / 25. - 20.;
194 points = 0;
195 }
196 }
197
198 /* Calculate some dimensions. */
199 w = ( SCREEN_W + 2. * STAR_BUF );
200 w += ( w / conf.zoom_far - 1. );
201 h = ( SCREEN_H + 2. * STAR_BUF );
202 h += ( h / conf.zoom_far - 1. );
203
204 /* Common shader stuff. */
205 glUseProgram( shaders.dust.program );
206 gl_uniformMat4( shaders.dust.projection, &projection );
207 glUniform2f( shaders.dust.offset_xy, dust_x, dust_y );
208 if ( points )
209 glUniform3f( shaders.dust.dims, 1. / gl_screen.scale, 0., 0. );
210 else
211 glUniform3f( shaders.dust.dims,
212 MAX( 0.5, 1. - m / 40. ) / gl_screen.scale, angle, m );
213 glUniform3f( shaders.dust.screen, w, h, 1. / gl_screen.scale );
214 glUniform1i( shaders.dust.use_lines, !points );
215
216 /* Vertices. */
217 glEnableVertexAttribArray( shaders.dust.vertex );
218 glEnableVertexAttribArray( shaders.dust.brightness );
219
220 /* Set up the vertices. */
221 gl_vboActivateAttribOffset( dust_vertexVBO, shaders.dust.vertex, 0, 2,
222 GL_FLOAT, 3 * sizeof( GLfloat ) );
223 gl_vboActivateAttribOffset( dust_vertexVBO, shaders.dust.brightness,
224 2 * sizeof( GLfloat ), 1, GL_FLOAT,
225 3 * sizeof( GLfloat ) );
226 glDrawArrays( GL_POINTS, 0, ndust );
227
228 /* Disable vertex array. */
229 glDisableVertexAttribArray( shaders.dust.vertex );
230 glDisableVertexAttribArray( shaders.dust.brightness );
231
232 glUseProgram( 0 );
233
234 /* Check for errors. */
235 gl_checkErr();
236
237 NTracingZoneEnd( _ctx );
238}
239
245void background_render( double dt )
246{
247 NTracingZone( _ctx, 1 );
248
249 if ( bkg_L_renderbg != LUA_NOREF ) {
250 lua_rawgeti( naevL, LUA_REGISTRYINDEX, bkg_L_renderbg );
251 lua_pushnumber( naevL, dt ); /* Note that this is real_dt. */
252 if ( nlua_pcall( bkg_cur_env, 1, 0 ) ) {
253 WARN( _( "Background script 'renderbg' error:\n%s" ),
254 lua_tostring( naevL, -1 ) );
255 lua_pop( naevL, 1 );
256 }
257 }
258
260
261 if ( bkg_L_rendermg != LUA_NOREF ) {
262 lua_rawgeti( naevL, LUA_REGISTRYINDEX, bkg_L_rendermg );
263 lua_pushnumber( naevL, dt ); /* Note that this is real_dt. */
264 if ( nlua_pcall( bkg_cur_env, 1, 0 ) ) {
265 WARN( _( "Background script 'rendermg' error:\n%s" ),
266 lua_tostring( naevL, -1 ) );
267 lua_pop( naevL, 1 );
268 }
269 }
270
273
274 if ( bkg_L_renderfg != LUA_NOREF ) {
275 lua_rawgeti( naevL, LUA_REGISTRYINDEX, bkg_L_renderfg );
276 lua_pushnumber( naevL, dt ); /* Note that this is real_dt. */
277 if ( nlua_pcall( bkg_cur_env, 1, 0 ) ) {
278 WARN( _( "Background script 'renderfg' error:\n%s" ),
279 lua_tostring( naevL, -1 ) );
280 lua_pop( naevL, 1 );
281 }
282 }
283
284 NTracingZoneEnd( _ctx );
285}
286
291{
292 NTracingZone( _ctx, 1 );
293
294 if ( bkg_L_renderov != LUA_NOREF ) {
295 lua_rawgeti( naevL, LUA_REGISTRYINDEX, bkg_L_renderov );
296 lua_pushnumber( naevL, dt ); /* Note that this is real_dt. */
297 if ( nlua_pcall( bkg_cur_env, 1, 0 ) ) {
298 WARN( _( "Background script 'renderov' error:\n%s" ),
299 lua_tostring( naevL, -1 ) );
300 lua_pop( naevL, 1 );
301 }
302 }
303
304 NTracingZoneEnd( _ctx );
305}
306
310static int bkg_compare( const void *p1, const void *p2 )
311{
312 const background_image_t *bkg1 = (background_image_t *)p1;
313 const background_image_t *bkg2 = (background_image_t *)p2;
314 return bkg1->move - bkg2->move;
315}
316
320static void bkg_sort( background_image_t *arr )
321{
322 qsort( arr, array_size( arr ), sizeof( background_image_t ), bkg_compare );
323}
324
328unsigned int background_addImage( const glTexture *image, double x, double y,
329 double move, double scale, double angle,
330 const glColour *col, int foreground,
331 const glColour *radiosity )
332{
333 double a, d;
334 background_image_t *bkg, **arr;
335
336 if ( foreground )
337 arr = &bkg_image_arr_ft;
338 else
339 arr = &bkg_image_arr_bk;
340
341 /* See if must create. */
342 if ( *arr == NULL )
344
345 /* Create image. */
346 bkg = &array_grow( arr );
347 memset( bkg, 0, sizeof( background_image_t ) );
348 bkg->id = ++bkg_idgen;
349 bkg->image = gl_dupTexture( image );
350 bkg->x = x;
351 bkg->y = y;
352 bkg->move = move;
353 bkg->scale = scale;
354 bkg->angle = angle;
355 bkg->col = ( col != NULL ) ? *col : cWhite;
356 bkg->radiosity = *radiosity;
357 bkg->L_idx = -1; /* Disable lighting. */
358
359 /* Deal with lighting. */
360 a = bkg->radiosity.a;
361 d = pow2( a * bkg->radiosity.r ) + pow2( a * bkg->radiosity.g ) +
362 pow2( a * bkg->radiosity.b );
363 if ( d > 1e-3 ) {
364 /* Get index. */
365 bkg->L_idx = L_default.nlights - L_default_const.nlights;
366
367 /* Normalize so RGB is unitary. Compensate modifying alpha. */
368 bkg->radiosity.r /= d;
369 bkg->radiosity.g /= d;
370 bkg->radiosity.b /= d;
371 bkg->radiosity.a *= d;
372
373 /* Set up the new light. */
374 bkg->L.sun = 1;
375 bkg->L.colour.v[0] = bkg->radiosity.r;
376 bkg->L.colour.v[1] = bkg->radiosity.g;
377 bkg->L.colour.v[2] = bkg->radiosity.b;
378 bkg->L.intensity = bkg->radiosity.a;
379 if ( gltf_lightSet( bkg->L_idx, &bkg->L ) )
380 bkg->L_idx = -1; /* Failed to add. */
381 }
382
383 /* Sort if necessary. */
384 bkg_sort( *arr );
385
386 return bkg_idgen;
387}
388
393{
394 /* Skip rendering altogether if disabled. */
395 if ( conf.bg_brightness <= 0. )
396 return;
397
398 /* Render images in order. */
399 for ( int i = 0; i < array_size( bkg_arr ); i++ ) {
400 double cx, cy, x, y, rx, ry, gx, gy, z, m;
401 glColour col;
402 background_image_t *bkg = &bkg_arr[i];
403
404 cam_getPos( &cx, &cy );
405 gui_getOffset( &gx, &gy );
406 m = bkg->move;
407 z = bkg->scale;
408 /* Relative coordinates. */
409 rx = ( bkg->x - cx ) * m + gx;
410 ry = ( bkg->y - cy ) * m + gy;
411 /* Screen coordinates. */
412 y = ry + SCREEN_H / 2. - z * bkg->image->sw / 2.;
413 x = rx + SCREEN_W / 2. - z * bkg->image->sh / 2.;
414
415 /* TODO speed up by not rendering when offscreen. */
416
417 col.r = bkg->col.r * conf.bg_brightness;
418 col.g = bkg->col.g * conf.bg_brightness;
419 col.b = bkg->col.b * conf.bg_brightness;
420 col.a = bkg->col.a;
421 gl_renderTexture( bkg->image, x, y, z * bkg->image->sw,
422 z * bkg->image->sh, 0., 0., bkg->image->srw,
423 bkg->image->srh, &col, bkg->angle );
424
425 /* See if we have to update scene lighting. */
426 if ( bkg->L_idx >= 0 ) {
427 double d = hypot( rx, ry );
428 /* Update Light. */
429 /*
430 double w = 1. / sqrt(3.);
431 double a = CLAMP( 0., 1., d/5000. );
432 bkg->L.colour.v[0] = bkg->radiosity.r * (1.-a) + a*w;
433 bkg->L.colour.v[1] = bkg->radiosity.g * (1.-a) + a*w;
434 bkg->L.colour.v[2] = bkg->radiosity.b * (1.-a) + a*w;
435 */
436 bkg->L.pos.v[0] = rx;
437 bkg->L.pos.v[1] = 2. * d - 300.;
438 bkg->L.pos.v[2] = ry;
439 gltf_lightSet( bkg->L_idx, &bkg->L );
440 }
441 }
442}
443
447static nlua_env background_create( const char *name )
448{
449 size_t bufsize;
450 char path[PATH_MAX];
451 char *buf;
452 nlua_env env;
453
454 /* Create file name. */
455 snprintf( path, sizeof( path ), BACKGROUND_PATH "%s.lua", name );
456
457 /* Create the Lua env. */
458 env = nlua_newEnv( name );
459 nlua_loadStandard( env );
460 nlua_loadTex( env );
461 nlua_loadCol( env );
462 nlua_loadBackground( env );
463 nlua_loadCamera( env );
464 nlua_loadGFX( env );
465
466 /* Open file. */
467 buf = ndata_read( path, &bufsize );
468 if ( buf == NULL ) {
469 WARN( _( "Background script '%s' not found." ), path );
470 nlua_freeEnv( env );
471 return LUA_NOREF;
472 }
473
474 /* Load file. */
475 if ( nlua_dobufenv( env, buf, bufsize, path ) != 0 ) {
476 WARN( _( "Error loading background file: %s\n"
477 "%s\n"
478 "Most likely Lua file has improper syntax, please check" ),
479 path, lua_tostring( naevL, -1 ) );
480 free( buf );
481 nlua_freeEnv( env );
482 return LUA_NOREF;
483 }
484 free( buf );
485
486 return env;
487}
488
493{
494 /* Load and set up the default Lua background state. */
495 bkg_def_env = background_create( "default" );
496 return 0;
497}
498
502int background_load( const char *name )
503{
504 int ret;
505 nlua_env env;
506
507 NTracingZone( _ctx, 1 );
508
509 /* Free if exists. */
511
512 /* Load default. */
513 if ( name == NULL )
515 /* Load new script. */
516 else
518
519 /* Comfort. */
520 env = bkg_cur_env;
521 if ( env == LUA_NOREF ) {
522 NTracingZoneEnd( _ctx );
523 return -1;
524 }
525
526 /* Run Lua. */
527 nlua_getenv( naevL, env, "background" );
528 ret = nlua_pcall( env, 0, 0 );
529 if ( ret != 0 ) { /* error has occurred */
530 const char *err =
531 ( lua_isstring( naevL, -1 ) ) ? lua_tostring( naevL, -1 ) : NULL;
532 WARN( _( "Background -> 'background' : %s" ),
533 ( err ) ? err : _( "unknown error" ) );
534 lua_pop( naevL, 1 );
535 }
536
537 /* See if there are render functions. */
538 bkg_L_renderbg = nlua_refenv( env, "renderbg" );
539 bkg_L_rendermg = nlua_refenv( env, "rendermg" );
540 bkg_L_renderfg = nlua_refenv( env, "renderfg" );
541 bkg_L_renderov = nlua_refenv( env, "renderov" );
542
543 NTracingZoneEnd( _ctx );
544
545 return ret;
546}
547
551static void background_clearCurrent( void )
552{
553 if ( bkg_cur_env != bkg_def_env )
554 nlua_freeEnv( bkg_cur_env );
555 bkg_cur_env = LUA_NOREF;
556
557 luaL_unref( naevL, LUA_REGISTRYINDEX, bkg_L_renderbg );
558 luaL_unref( naevL, LUA_REGISTRYINDEX, bkg_L_rendermg );
559 luaL_unref( naevL, LUA_REGISTRYINDEX, bkg_L_renderfg );
560 luaL_unref( naevL, LUA_REGISTRYINDEX, bkg_L_renderov );
561 bkg_L_renderbg = LUA_NOREF;
562 bkg_L_rendermg = LUA_NOREF;
563 bkg_L_renderfg = LUA_NOREF;
564 bkg_L_renderov = LUA_NOREF;
565}
566
571{
572 /* Destroy current background script. */
574
575 /* Clear the backgrounds. */
578
579 /* Reset lighting. */
580 gltf_lightReset();
581}
582
589{
590 for ( int i = 0; i < array_size( *arr ); i++ ) {
591 background_image_t *bkg = &( ( *arr )[i] );
592 gl_freeTexture( bkg->image );
593 }
594
595 /* Erase it all. */
596 array_erase( arr, array_begin( *arr ), array_end( *arr ) );
597}
598
602void background_free( void )
603{
604 /* Free the Lua. */
606 nlua_freeEnv( bkg_def_env );
607 bkg_def_env = LUA_NOREF;
608
609 /* Free the images. */
611 bkg_image_arr_ft = NULL;
613 bkg_image_arr_bk = NULL;
614
615 /* Free the Lua. */
616 nlua_freeEnv( bkg_cur_env );
617 bkg_cur_env = LUA_NOREF;
618
620 dust_vertexVBO = NULL;
621
622 ndust = 0;
623}
624
630{
631 glTexture **imgs =
633 for ( int i = 0; i < array_size( bkg_image_arr_ft ); i++ )
634 array_push_back( &imgs, gl_dupTexture( bkg_image_arr_ft[i].image ) );
635 return imgs;
636}
637
645{
646 /* Assume many bg-layer images => none is representative => we should return
647 * NULL. Example: Taiomi system's debris field. */
648 if ( array_size( bkg_image_arr_bk ) == 1 )
649 return gl_dupTexture( bkg_image_arr_bk[0].image );
650 else
651 return NULL;
652}
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
Definition array.h:170
#define array_end(array)
Returns a pointer to the end of the reserved memory space.
Definition array.h:214
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
Definition array.h:102
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
Definition array.h:148
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
Definition array.h:179
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
Definition array.h:122
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
Definition array.h:134
#define array_begin(array)
Returns a pointer to the beginning of the reserved memory space.
Definition array.h:206
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
Definition array.h:93
static background_image_t * bkg_image_arr_bk
Definition background.c:52
glTexture ** background_getStarTextures(void)
Returns an array (array.h) of star background images in the system background.
Definition background.c:629
void background_clear(void)
Cleans up the background stuff.
Definition background.c:570
int background_init(void)
Initializes the background system.
Definition background.c:492
static unsigned int bkg_idgen
Definition background.c:59
static int bkg_L_renderov
Definition background.c:69
static background_image_t * bkg_image_arr_ft
Definition background.c:55
#define STAR_BUF
Definition background.c:74
void background_initDust(int n)
Initializes background dust.
Definition background.c:97
static int bkg_L_renderbg
Definition background.c:66
void background_renderOverlay(double dt)
Renders the background overlay.
Definition background.c:290
static int bkg_L_rendermg
Definition background.c:67
static nlua_env bkg_def_env
Definition background.c:65
void background_moveDust(double x, double y)
Displaces the dust, useful with camera.
Definition background.c:145
static int bkg_L_renderfg
Definition background.c:68
void background_free(void)
Cleans up and frees memory after the backgrounds.
Definition background.c:602
static void background_clearCurrent(void)
Destroys the current running background script.
Definition background.c:551
static GLfloat dust_x
Definition background.c:78
static int bkg_compare(const void *p1, const void *p2)
Compares two different backgrounds and sorts them.
Definition background.c:310
static void background_renderImages(background_image_t *bkg_arr)
Renders the background images.
Definition background.c:392
glTexture * background_getAmbientTexture(void)
Returns an overall background image (nebula, for instance), or NULL if none exists.
Definition background.c:644
void background_renderDust(const double dt)
Renders the dustry background.
Definition background.c:156
static void background_clearImgArr(background_image_t **arr)
Clears a background image array.
Definition background.c:588
static void bkg_sort(background_image_t *arr)
Sorts the backgrounds by movement.
Definition background.c:320
static gl_vbo * dust_vertexVBO
Definition background.c:76
static nlua_env background_create(const char *path)
Creates a background Lua state from a script.
Definition background.c:447
void background_render(double dt)
Render the background.
Definition background.c:245
static nlua_env bkg_cur_env
Backgrounds.
Definition background.c:64
static unsigned int ndust
Definition background.c:77
static GLfloat dust_y
Definition background.c:79
int background_load(const char *name)
Loads a background script by name.
Definition background.c:502
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 background.c:328
void cam_getVel(double *vx, double *vy)
Gets the camera velocity.
Definition camera.c:140
void cam_getPos(double *x, double *y)
Gets the camera position.
Definition camera.c:122
double cam_getZoom(void)
Gets the camera zoom.
Definition camera.c:101
void gui_getOffset(double *x, double *y)
Gets the GUI offset.
Definition gui.c:2159
Header file with generic functions and naev-specifics.
#define pow2(x)
Definition naev.h:53
#define MAX(x, y)
Definition naev.h:37
#define PATH_MAX
Definition naev.h:57
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
Definition ndata.c:207
int nlua_refenv(nlua_env env, const char *name)
Gets the reference of a global in a lua environment.
Definition nlua.c:1029
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
Definition nlua.c:914
lua_State * naevL
Definition nlua.c:54
int nlua_loadBackground(nlua_env env)
Loads the graphics library.
Definition nlua_bkg.c:33
int nlua_loadCamera(nlua_env env)
Loads the camera library.
Definition nlua_camera.c:48
int nlua_loadCol(nlua_env env)
Loads the colour library.
Definition nlua_colour.c:57
int nlua_loadGFX(nlua_env env)
Loads the graphics library.
Definition nlua_gfx.c:112
int nlua_loadTex(nlua_env env)
Loads the texture library.
Definition nlua_tex.c:59
glInfo gl_screen
Definition opengl.c:47
void gl_renderTexture(const glTexture *texture, double x, double y, double w, double h, double tx, double ty, double tw, double th, const glColour *c, double angle)
Texture blitting backend.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
Definition opengl_tex.c:891
void gl_freeTexture(glTexture *texture)
Frees a texture.
Definition opengl_tex.c:835
void gl_vboDestroy(gl_vbo *vbo)
Destroys a VBO.
Definition opengl_vbo.c:244
void gl_vboActivateAttribOffset(gl_vbo *vbo, GLuint index, GLuint offset, GLint size, GLenum type, GLsizei stride)
Activates a VBO's offset.
Definition opengl_vbo.c:224
gl_vbo * gl_vboCreateStatic(GLsizei size, const void *data)
Creates a stream vbo.
Definition opengl_vbo.c:177
double dt_mod
Definition pause.c:20
Player_t player
Definition player.c:77
static const double d[]
Definition rng.c:263
Simple point/sun light model.
Definition gltf.h:207
vec3 pos
Definition gltf.h:211
double intensity
Definition gltf.h:213
int sun
Definition gltf.h:208
vec3 colour
Definition gltf.h:214
Represents a background image like say a Nebula.
Definition background.c:36
glTexture * image
Definition background.c:38
unsigned int id
Definition background.c:37
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43
double sw
Definition opengl_tex.h:53
double sh
Definition opengl_tex.h:54
double srh
Definition opengl_tex.h:56
double srw
Definition opengl_tex.h:55
Definition mat4.h:12