#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>
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 |
#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.
Definition at line 703 of file particles.c.
Definition at line 603 of file particles.c.
|
static |
Definition at line 393 of file particles.c.
|
static |
Definition at line 786 of file particles.c.
Definition at line 243 of file particles.c.
|
static |
Definition at line 874 of file particles.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 941 of file particles.c.
|
static |
Definition at line 345 of file particles.c.
|
static |
Definition at line 899 of file particles.c.
|
static |
Definition at line 863 of file particles.c.
Definition at line 747 of file particles.c.
|
static |
Definition at line 659 of file particles.c.
Definition at line 293 of file particles.c.
Definition at line 225 of file particles.c.
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.
Definition at line 215 of file particles.c.
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] |
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.
|
static |
Definition at line 590 of file particles.c.
Definition at line 214 of file particles.c.
|
static |
Definition at line 582 of file particles.c.
Definition at line 213 of file particles.c.
|
static |
Definition at line 202 of file particles.c.
|
static |
Definition at line 205 of file particles.c.
|
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] |
Definition at line 113 of file particles.c.
|
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.