Classes | Macros | Functions | Variables
particles.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <tinycthread.h>
#include <getopt.h>
#include <linmath.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
Include dependency graph for particles.c:

Go to the source code of this file.

Classes

struct  PARTICLE
 
struct  Vec3
 
struct  Vertex
 

Macros

#define BATCH_PARTICLES   70
 
#define BIRTH_INTERVAL   (LIFE_SPAN/(float)MAX_PARTICLES)
 
#define F_TEX_HEIGHT   16
 
#define F_TEX_WIDTH   16
 
#define FOUNTAIN_HEIGHT   3.f
 
#define FOUNTAIN_R2   (FOUNTAIN_RADIUS+PARTICLE_SIZE/2)*(FOUNTAIN_RADIUS+PARTICLE_SIZE/2)
 
#define FOUNTAIN_RADIUS   1.6f
 
#define FOUNTAIN_SIDE_POINTS   14
 
#define FOUNTAIN_SWEEP_STEPS   32
 
#define FRICTION   0.75f
 
#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT   0x81F8
 
#define GL_SEPARATE_SPECULAR_COLOR_EXT   0x81FA
 
#define GL_SINGLE_COLOR_EXT   0x81F9
 
#define GRAVITY   9.8f
 
#define LIFE_SPAN   8.f
 
#define MAX_PARTICLES   3000
 
#define MIN_DELTA_T   (BIRTH_INTERVAL * 0.5f)
 
#define P_TEX_HEIGHT   8
 
#define P_TEX_WIDTH   8
 
#define PARTICLE_SIZE   0.7f
 
#define PARTICLE_VERTS   4
 
#define VELOCITY   8.f
 

Functions

static void draw_floor (void)
 
static void draw_fountain (void)
 
static void draw_particles (GLFWwindow *window, double t, float dt)
 
static void draw_scene (GLFWwindow *window, double t)
 
static void init_particle (PARTICLE *p, double t)
 
static void key_callback (GLFWwindow *window, int key, int scancode, int action, int mods)
 
int main (int argc, char **argv)
 
static void particle_engine (double t, float dt)
 
static int physics_thread_main (void *arg)
 
static void resize_callback (GLFWwindow *window, int width, int height)
 
static void setup_lights (void)
 
static void tessellate_floor (float x1, float y1, float x2, float y2, int depth)
 
static void update_particle (PARTICLE *p, float dt)
 
static void usage (void)
 

Variables

float aspect_ratio
 
const GLfloat floor_diffuse [4] = { 1.f, 0.6f, 0.6f, 1.f }
 
const GLfloat floor_shininess = 18.f
 
const GLfloat floor_specular [4] = { 0.6f, 0.6f, 0.6f, 1.f }
 
GLuint floor_tex_id
 
const unsigned char floor_texture [F_TEX_WIDTH *F_TEX_HEIGHT]
 
const GLfloat fog_color [4] = { 0.1f, 0.1f, 0.1f, 1.f }
 
const GLfloat fountain_diffuse [4] = { 0.7f, 1.f, 1.f, 1.f }
 
static const float fountain_normal [FOUNTAIN_SIDE_POINTS *2]
 
const GLfloat fountain_shininess = 12.f
 
static const float fountain_side [FOUNTAIN_SIDE_POINTS *2]
 
const GLfloat fountain_specular [4] = { 1.f, 1.f, 1.f, 1.f }
 
static float glow_color [4]
 
static float glow_pos [4]
 
static float min_age
 
GLuint particle_tex_id
 
const unsigned char particle_texture [P_TEX_WIDTH *P_TEX_HEIGHT]
 
static PARTICLE particles [MAX_PARTICLES]
 
struct {
   cnd_t   d_done
 
   int   d_frame
 
   float   dt
 
   cnd_t   p_done
 
   int   p_frame
 
   mtx_t   particles_lock
 
   double   t
 
thread_sync
 
int wireframe
 

Macro Definition Documentation

#define BATCH_PARTICLES   70

Definition at line 388 of file particles.c.

#define BIRTH_INTERVAL   (LIFE_SPAN/(float)MAX_PARTICLES)

Definition at line 157 of file particles.c.

#define F_TEX_HEIGHT   16

Definition at line 107 of file particles.c.

#define F_TEX_WIDTH   16

Definition at line 106 of file particles.c.

#define FOUNTAIN_HEIGHT   3.f

Definition at line 172 of file particles.c.

#define FOUNTAIN_R2   (FOUNTAIN_RADIUS+PARTICLE_SIZE/2)*(FOUNTAIN_RADIUS+PARTICLE_SIZE/2)

Definition at line 291 of file particles.c.

#define FOUNTAIN_RADIUS   1.6f

Definition at line 175 of file particles.c.

#define FOUNTAIN_SIDE_POINTS   14

Definition at line 579 of file particles.c.

#define FOUNTAIN_SWEEP_STEPS   32

Definition at line 580 of file particles.c.

#define FRICTION   0.75f

Definition at line 169 of file particles.c.

#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT   0x81F8

Definition at line 47 of file particles.c.

#define GL_SEPARATE_SPECULAR_COLOR_EXT   0x81FA

Definition at line 49 of file particles.c.

#define GL_SINGLE_COLOR_EXT   0x81F9

Definition at line 48 of file particles.c.

#define GRAVITY   9.8f

Definition at line 163 of file particles.c.

#define LIFE_SPAN   8.f

Definition at line 154 of file particles.c.

#define MAX_PARTICLES   3000

Definition at line 151 of file particles.c.

#define MIN_DELTA_T   (BIRTH_INTERVAL * 0.5f)

Definition at line 178 of file particles.c.

#define P_TEX_HEIGHT   8

Definition at line 105 of file particles.c.

#define P_TEX_WIDTH   8

Definition at line 104 of file particles.c.

#define PARTICLE_SIZE   0.7f

Definition at line 160 of file particles.c.

#define PARTICLE_VERTS   4

Definition at line 391 of file particles.c.

#define VELOCITY   8.f

Definition at line 166 of file particles.c.

Function Documentation

static void draw_floor ( void  )
static

Definition at line 703 of file particles.c.

static void draw_fountain ( void  )
static

Definition at line 603 of file particles.c.

static void draw_particles ( GLFWwindow window,
double  t,
float  dt 
)
static

Definition at line 393 of file particles.c.

static void draw_scene ( GLFWwindow window,
double  t 
)
static

Definition at line 786 of file particles.c.

static void init_particle ( PARTICLE p,
double  t 
)
static

Definition at line 243 of file particles.c.

static void key_callback ( GLFWwindow window,
int  key,
int  scancode,
int  action,
int  mods 
)
static

Definition at line 874 of file particles.c.

int main ( int  argc,
char **  argv 
)

Definition at line 941 of file particles.c.

static void particle_engine ( double  t,
float  dt 
)
static

Definition at line 345 of file particles.c.

static int physics_thread_main ( void arg)
static

Definition at line 899 of file particles.c.

static void resize_callback ( GLFWwindow window,
int  width,
int  height 
)
static

Definition at line 863 of file particles.c.

static void setup_lights ( void  )
static

Definition at line 747 of file particles.c.

static void tessellate_floor ( float  x1,
float  y1,
float  x2,
float  y2,
int  depth 
)
static

Definition at line 659 of file particles.c.

static void update_particle ( PARTICLE p,
float  dt 
)
static

Definition at line 293 of file particles.c.

static void usage ( void  )
static

Definition at line 225 of file particles.c.

Variable Documentation

float aspect_ratio

Definition at line 82 of file particles.c.

cnd_t d_done

Definition at line 94 of file particles.c.

int d_frame

Definition at line 92 of file particles.c.

float dt

Definition at line 90 of file particles.c.

const GLfloat floor_diffuse[4] = { 1.f, 0.6f, 0.6f, 1.f }

Definition at line 215 of file particles.c.

const GLfloat floor_shininess = 18.f

Definition at line 217 of file particles.c.

const GLfloat floor_specular[4] = { 0.6f, 0.6f, 0.6f, 1.f }

Definition at line 216 of file particles.c.

GLuint floor_tex_id

Definition at line 110 of file particles.c.

const unsigned char floor_texture[F_TEX_WIDTH *F_TEX_HEIGHT]
Initial value:
= {
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0xff, 0xf0, 0xcc, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0xf0, 0xcc, 0xee, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x66, 0x30, 0x30, 0x30, 0x20, 0x30, 0x30,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xee, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0xf0, 0xf0, 0xf0, 0xf0, 0xcc, 0xf0, 0xf0, 0xf0, 0x30, 0x30, 0x55, 0x30, 0x30, 0x44, 0x30, 0x30,
0xf0, 0xdd, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x30,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x33, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x30, 0x30, 0xf0, 0xff, 0xf0, 0xf0, 0xdd, 0xf0, 0xf0, 0xff,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x55, 0x33, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xf0,
0x30, 0x44, 0x66, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xaa, 0xf0, 0xf0, 0xcc, 0xf0,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xff, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xdd, 0xf0,
0x30, 0x30, 0x30, 0x77, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
}

Definition at line 125 of file particles.c.

const GLfloat fog_color[4] = { 0.1f, 0.1f, 0.1f, 1.f }

Definition at line 218 of file particles.c.

const GLfloat fountain_diffuse[4] = { 0.7f, 1.f, 1.f, 1.f }

Definition at line 212 of file particles.c.

const float fountain_normal[FOUNTAIN_SIDE_POINTS *2]
static
Initial value:
=
{
1.0000f, 0.0000f, 0.6428f, 0.7660f, 0.3420f, 0.9397f, 1.0000f, 0.0000f,
1.0000f, 0.0000f, 0.3420f,-0.9397f, 0.4226f,-0.9063f, 0.5000f,-0.8660f,
0.7660f,-0.6428f, 0.9063f,-0.4226f, 0.0000f,1.00000f, 0.0000f,1.00000f,
0.0000f,1.00000f, 0.0000f,1.00000f
}

Definition at line 590 of file particles.c.

const GLfloat fountain_shininess = 12.f

Definition at line 214 of file particles.c.

const float fountain_side[FOUNTAIN_SIDE_POINTS *2]
static
Initial value:
=
{
1.2f, 0.f, 1.f, 0.2f, 0.41f, 0.3f, 0.4f, 0.35f,
0.4f, 1.95f, 0.41f, 2.f, 0.8f, 2.2f, 1.2f, 2.4f,
1.5f, 2.7f, 1.55f,2.95f, 1.6f, 3.f, 1.f, 3.f,
0.5f, 3.f, 0.f, 3.f
}

Definition at line 582 of file particles.c.

const GLfloat fountain_specular[4] = { 1.f, 1.f, 1.f, 1.f }

Definition at line 213 of file particles.c.

float glow_color[4]
static

Definition at line 202 of file particles.c.

float glow_pos[4]
static

Definition at line 205 of file particles.c.

float min_age
static

Definition at line 199 of file particles.c.

cnd_t p_done

Definition at line 93 of file particles.c.

int p_frame

Definition at line 91 of file particles.c.

GLuint particle_tex_id

Definition at line 110 of file particles.c.

const unsigned char particle_texture[P_TEX_WIDTH *P_TEX_HEIGHT]
Initial value:
= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x11, 0x22, 0x22, 0x11, 0x00, 0x00,
0x00, 0x11, 0x33, 0x88, 0x77, 0x33, 0x11, 0x00,
0x00, 0x22, 0x88, 0xff, 0xee, 0x77, 0x22, 0x00,
0x00, 0x22, 0x77, 0xee, 0xff, 0x88, 0x22, 0x00,
0x00, 0x11, 0x33, 0x77, 0x88, 0x33, 0x11, 0x00,
0x00, 0x00, 0x11, 0x33, 0x22, 0x11, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}

Definition at line 113 of file particles.c.

PARTICLE particles[MAX_PARTICLES]
static

Definition at line 196 of file particles.c.

mtx_t particles_lock

Definition at line 95 of file particles.c.

double t

Definition at line 89 of file particles.c.

struct { ... } thread_sync
int wireframe

Definition at line 85 of file particles.c.



librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:27