Space Sim
Loading...
Searching...
No Matches
init.c File Reference
#include <SDL2/SDL.h>
#include <GL/glew.h>
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_mouse.h>
#include <SDL2/SDL_video.h>
#include "utilities/mathf.h"
#include <math.h>
#include <stdbool.h>
#include "core/init.h"
#include "core/types.h"
#include "mesh/mesh.h"
#include "core/shaders.h"
#include "mesh/marching_cubes.h"
#include "stb/stb_image.h"
#include "nuklear/nuklear.h"
#include "nuklear/nuklear_sdl_gl3.h"

Go to the source code of this file.

Functions

GLuint load_texture (const char *path, GLenum iformat, GLenum format, GLenum type)
GLuint load_cubemap (const char *path)
float power_law (float min_m, float max_m, float alpha)
void init_random ()
float rand_normal ()
void init_water_grid (int N, int L, float A)
 Initializes the water grid at the start of the simulation with a wind direction.
float angular_velocity (vec2 pos, vec2 w, float len2)
void fft_textures (GLuint pi, GLuint po)
 Performs a bit reversal and FFTs the water group.
void update_water_fft (float t)
 Updates the water grid and FFTs it once per frame.
void precompute_fbm_texture ()
vec3 random3 (vec3 p)
float worley (vec3 p)
void precompute_worley_texture ()
float fade (float t)
void make_perm ()
float wrap_256 (float t)
float noise3d (vec3 p)
void precompute_perlin_texture ()
void init_globals ()
bool init (SDL_Window **window, SDL_GLContext *context)

Variables

float MASS = 0.0f
struct nk_context * NK_CTX = NULL
bool NUKLEAR_HOVERED = false
vec4 * water_fft_arr = NULL
float * phi = NULL
WaterData WATER_DATA
vec3 * out_arr = NULL
GLuint * CURRENT_WATER_FFT_TEXTURE = NULL
float * fbm_tex = NULL
vec4 * worley_tex = NULL
int permutations [PERLIN_TEXTURE_SIZE]
vec3 gradients [12]
float * perlin_tex

Function Documentation

◆ load_texture()

GLuint load_texture ( const char * path,
GLenum iformat,
GLenum format,
GLenum type )

Definition at line 19 of file init.c.

References load_texture().

Referenced by init(), and load_texture().

◆ load_cubemap()

GLuint load_cubemap ( const char * path)

Definition at line 57 of file init.c.

References load_cubemap().

Referenced by init(), and load_cubemap().

◆ power_law()

float power_law ( float min_m,
float max_m,
float alpha )

Definition at line 103 of file init.c.

References power_law().

Referenced by init_random(), and power_law().

◆ init_random()

◆ rand_normal()

float rand_normal ( )

Definition at line 177 of file init.c.

References rand_normal().

Referenced by init_water_grid(), and rand_normal().

◆ angular_velocity()

float angular_velocity ( vec2 pos,
vec2 w,
float len2 )

Definition at line 256 of file init.c.

References angular_velocity(), vec2::x, and vec2::y.

Referenced by angular_velocity().

◆ precompute_fbm_texture()

void precompute_fbm_texture ( )

Definition at line 350 of file init.c.

References fbm(), fbm_tex, FBM_TEXTURE, FBM_TEXTURE_SIZE, and precompute_fbm_texture().

Referenced by init(), and precompute_fbm_texture().

◆ random3()

vec3 random3 ( vec3 p)

Definition at line 380 of file init.c.

References random3(), s, vec3_dot(), and vec3_scale().

Referenced by random3(), and worley().

◆ worley()

float worley ( vec3 p)

Definition at line 400 of file init.c.

References MIN, random3(), vec3_add(), vec3_length(), vec3_sub(), worley(), vec3::x, vec3::y, and vec3::z.

Referenced by precompute_worley_texture(), and worley().

◆ precompute_worley_texture()

void precompute_worley_texture ( )

◆ fade()

float fade ( float t)

Definition at line 472 of file init.c.

References fade(), and t.

Referenced by fade(), and noise3d().

◆ make_perm()

void make_perm ( )

Definition at line 477 of file init.c.

References make_perm(), PERLIN_TEXTURE_SIZE, permutations, and temp.

Referenced by make_perm(), and precompute_perlin_texture().

◆ wrap_256()

float wrap_256 ( float t)

Definition at line 502 of file init.c.

References t, and wrap_256().

Referenced by wrap_256().

◆ noise3d()

float noise3d ( vec3 p)

◆ precompute_perlin_texture()

void precompute_perlin_texture ( )

◆ init_globals()

◆ init()

bool init ( SDL_Window ** window,
SDL_GLContext * context )

Definition at line 659 of file init.c.

References FBMLayer::amp, PerlinLayer::amp, WarpLayer::amp, ATMOSPHERE_EBO, ATMOSPHERE_RES, ATMOSPHERE_VAO, ATMOSPHERE_VBO, BIT_REVERSAL_COMPUTE_SHADER, BLOOM2_FBO, BLOOM2_HEIGHT, BLOOM2_TEXTURE, BLOOM2_WIDTH, BLOOM_FBO, BLOOM_HEIGHT, BLOOM_TEXTURE, BLOOM_WIDTH, BLUR2_FBO, BLUR2_TEXTURE, BLUR_FBO, BLUR_TEXTURE, BOUNDS_COMPUTE_SHADER, BOUNDS_SSBO, CAM_UBO, CHUNK_DATA_FLAG, CHUNK_DATA_SSBO, CHUNK_WORLD_SIZE, CHUNK_ZERO_COMPUTE_SHADER, COM_COMPUTE_SHADER, COMPOSITE_DEPTH_TEXTURE, COMPOSITE_FBO, COMPOSITE_TEXTURE, create_compute_shader(), CUBEMAP_TEXTURE, DENSITY_SSBO, DENSITY_VERTEX_SSBO, DEPTH_TEXTURE, EDGE_TABLE, MarchingCubesData::EDGE_TABLE, EDGE_TO_VERTICES, MarchingCubesData::EDGE_TO_VERTICES, GPUChunk::emitted_chunks, EXP_LOOKUP_TEXTURE, PlanetData::fbm_count, PlanetData::fbm_layers, FBM_TEXTURE, FBM_TEXTURE_SIZE, FBMLayer::freq, PerlinLayer::freq, WarpLayer::freq0, WarpLayer::freq1, WarpLayer::freq2, FS_VAO, HISTORY_FBO, HISTORY_TEXTURE, ID_TEXTURE, init(), init_chunk_data(), init_globals(), init_random(), init_shaders(), init_water_grid(), load_cubemap(), load_texture(), LOD_DENSITY_SIZES, GPUChunk::lod_dist, LOD_RES, LOD_VERTEX_SIZES, LODMAX, MAIN_COMPUTE_SHADER, MAIN_FBO, MAIN_TEXTURE, MAIN_VAO, MAIN_VBO, MARCHING_CUBES_SSBO, MAX_CHUNKS, MAX_CHUNKS_LOD, MESH_EBO, MESH_RES, MESH_VAO, MESH_VBO, MORTON_COMPUTE_SHADER, MORTON_PING_SSBO, MORTON_SSBO, NEXT_COMPUTE_SHADER, NK_CTX, NODE_COUNTER_SSBO, NODE_SSBO, WarpLayer::offset0, WarpLayer::offset1, WarpLayer::offset2, PARTICLE_SSBO, PlanetData::perlin_count, PlanetData::perlin_layers, PERLIN_TEXTURE, PERLIN_TEXTURE_SIZE, PLANET_DATA, PLANET_DATA_SSBO, WaterVertex::pos, POS_COMPUTE_SHADER, POSTPROCESS_FBO, POSTPROCESS_TEXTURE, precompute_fbm_texture(), precompute_perlin_texture(), precompute_worley_texture(), RADIX_COMPUTE_SHADER, RADIX_FINAL_COMPUTE_SHADER, RADIX_GLOBAL_COMPUTE_SHADER, RADIX_SSBO, RENDER_UBO, res, ROCK_AO_TEXTURE, ROCK_DIFFUSE_TEXTURE, ROCK_NORMAL_TEXTURE, ROCK_SPECULAR_TEXTURE, SCREEN_HEIGHT, SCREEN_WIDTH, SHADOW_MAP_FBO, SHADOW_MAP_SIZE, SHADOW_MAP_TEXTURE, SKY_CUBEMAP, SKY_FBO, SKY_VAO, SKY_VBO, SPACE_CAM_UBO, SPAWN_COMPUTE_SHADER, SPHERE_TEXTURE, PlanetData::sun_color, PlanetData::sun_dir, TREE_COMPUTE_SHADER, TREE_COUNT_COMPUTE_SHADER, MarchingCubesData::TRIANGLE_TABLE, TRIANGLE_TABLE, PlanetData::warp_count, PlanetData::warp_layers, WATER_COMPUTE_SHADER, WATER_DATA, WATER_EBO, WATER_FFT_COMPUTE_SHADER, WATER_FFT_L, WATER_FFT_PING_TEXTURE, WATER_FFT_PING_TEXTURE_2, WATER_FFT_PONG_TEXTURE, WATER_FFT_PONG_TEXTURE_2, WATER_FFT_TEXTURE_SIZE, water_index_count, water_quad_count, WATER_RES, WATER_SSBO, WATER_VAO, WATER_VBO, WORLEY_TEXTURE, WORLEY_TEXTURE_SIZE, and ZERO_COMPUTE_SHADER.

Referenced by init(), and main().

Variable Documentation

◆ MASS

float MASS = 0.0f

Definition at line 112 of file init.c.

Referenced by init_random().

◆ NK_CTX

struct nk_context* NK_CTX = NULL

Definition at line 170 of file init.c.

Referenced by display_main_menu(), init(), and process_input().

◆ NUKLEAR_HOVERED

bool NUKLEAR_HOVERED = false

Definition at line 171 of file init.c.

Referenced by display_main_menu(), and process_input().

◆ water_fft_arr

vec4* water_fft_arr = NULL

Definition at line 173 of file init.c.

Referenced by init_water_grid().

◆ phi

float* phi = NULL

Definition at line 174 of file init.c.

Referenced by init_water_grid().

◆ WATER_DATA

WaterData WATER_DATA

Definition at line 187 of file init.c.

Referenced by init(), and init_water_grid().

◆ out_arr

vec3* out_arr = NULL

Definition at line 264 of file init.c.

◆ CURRENT_WATER_FFT_TEXTURE

GLuint* CURRENT_WATER_FFT_TEXTURE = NULL

Definition at line 265 of file init.c.

◆ fbm_tex

float* fbm_tex = NULL

Definition at line 346 of file init.c.

Referenced by density_fn(), main(), precompute_fbm_texture(), and sample_fbm_density().

◆ worley_tex

vec4* worley_tex = NULL

Definition at line 377 of file init.c.

Referenced by main(), and precompute_worley_texture().

◆ permutations

int permutations[PERLIN_TEXTURE_SIZE]

Definition at line 474 of file init.c.

Referenced by make_perm(), and noise3d().

◆ gradients

vec3 gradients[12]
Initial value:
= {{1, 1, 0}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0},
{1, 0, 1}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1},
{0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}}

Definition at line 497 of file init.c.

Referenced by noise3d().

◆ perlin_tex

float* perlin_tex

Definition at line 610 of file init.c.

Referenced by density_fn(), main(), precompute_perlin_texture(), and sample_density().