|
Space Sim
|
#include <GL/glew.h>#include <SDL2/SDL.h>#include <SDL2/SDL_events.h>#include <SDL2/SDL_mouse.h>#include <SDL2/SDL_render.h>#include <SDL2/SDL_scancode.h>#include <SDL2/SDL_timer.h>#include <SDL2/SDL_video.h>#include "core/camera.h"#include "core/init.h"#include "utilities/mathf.h"#include "core/menu.h"#include "mesh/mesh.h"#include "core/shaders.h"#include "core/types.h"#include <omp.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <assert.h>#include <immintrin.h>#include <stdalign.h>#include <stdlib.h>#include <time.h>#include "stb/stb_image.h"#include "nk_config.h"#include "nuklear/nuklear.h"#include "nuklear/nuklear_sdl_gl3.h"Go to the source code of this file.
Macros | |
| #define | DEFAULT_WIDTH 1280 |
| #define | DEFAULT_HEIGHT 960 |
| #define | STB_IMAGE_IMPLEMENTATION |
| #define | MAX_VERTEX_MEMORY 512 * 1024 |
| #define | MAX_ELEMENT_MEMORY 128 * 1024 |
| #define | NUM_WORKGROUPS 128 |
Functions | |
| GLuint64 | retrieve_gl_query (GLuint query) |
| void | sim_step () |
| A single simulation step for the particle sim. | |
| void | process_input (SDL_Window **window) |
| Processes SDL events. | |
| void | render_sky_from_outside_atmosphere () |
| Renders the atmosphere from outside of the atmosphere. | |
| void | render_sky_cubemap () |
| Renders the atmosphere and clouds from inside of the atmosphere. | |
| void | render_mesh_planet () |
| Renders a planet's meshed surface. | |
| void | render () |
| Main render loop that updates the sky, then renders water + planet surfaces. | |
| int | main (int argc, char *argv[]) |
| #define NUM_WORKGROUPS 128 |
Definition at line 293 of file main.c.
Referenced by sim_step().
| GLuint64 retrieve_gl_query | ( | GLuint | query | ) |
Definition at line 296 of file main.c.
References retrieve_gl_query().
Referenced by main(), and retrieve_gl_query().
| void process_input | ( | SDL_Window ** | window | ) |
Processes SDL events.
Definition at line 626 of file main.c.
References apply_planet_velocity(), apply_velocity(), cam, Camera::cam_data, CamData::cam_vel, current_cam, display_menu, DT, dt, fence, GLOBALS, halt_chunks, Globals::hovered_body, init_shaders(), is_on_planet, mat, Particle::mat, NK_CTX, NUKLEAR_HOVERED, Camera::on_ground, Particle::p_m, PARTICLE_SSBO, Globals::paused, Camera::pitch, planet_origin, planet_radius, process_input(), resolve_collisions(), running, Globals::selected_body, vec3::x, vec4::x, vec3::y, vec4::y, Camera::yaw, and vec4::z.
Referenced by main(), and process_input().
| void render | ( | ) |
Main render loop that updates the sky, then renders water + planet surfaces.
Definition at line 1257 of file main.c.
References BLOOM2_TEXTURE, BLOOM_TEXTURE, BODY_COUNT, cam, Camera::cam_data, CamData::cam_pos, CAM_UBO, COMPOSITE_FBO, COMPOSITE_TEXTURE, CUBEMAP_TEXTURE, cur_history, current_query_frame, DEPTH_TEXTURE, draw_queries, EXP_LOOKUP_TEXTURE, FBM_TEXTURE, Camera::forward, GLOBALS, HISTORY_TEXTURE, Globals::hovered_body, ID_TEXTURE, LIGHT_CAM, Uniform::location, MAIN_FBO, MAIN_SHADER, MAIN_TEXTURE, MAIN_VAO, MAIN_VBO, MESH_EBO, mesh_queries, MESH_SHADER, MESH_VAO, MESH_VBO, particle_queries, Globals::particle_toggle, PERLIN_TEXTURE, Globals::planet_meshing_toggle, planet_radius, postprocess_queries, POSTPROCESS_SHADER, ShaderProgram::program, CamData::proj, render(), render_mesh_planet(), render_sky_cubemap(), RENDER_UBO, Camera::right, ROCK_AO_TEXTURE, ROCK_DIFFUSE_TEXTURE, ROCK_NORMAL_TEXTURE, ROCK_SPECULAR_TEXTURE, SCREEN_HEIGHT, SCREEN_WIDTH, Globals::selected_body, selection_mode, SHADOW_MAP_FBO, SHADOW_MAP_SHADER, SHADOW_MAP_SIZE, SHADOW_MAP_TEXTURE, SHADOW_WATER_SHADER, SKY_CUBEMAP, SKY_SHADER, SKY_TEXTURE, Globals::sky_toggle, SKY_VAO, SKY_VBO, space_cam, SPACE_CAM_UBO, SPHERE_TEXTURE, ShaderProgram::uniforms, Camera::up, uTime, CamData::view, WATER_EBO, WATER_FFT_PONG_TEXTURE, WATER_FFT_PONG_TEXTURE_2, water_index_count, water_queries, WATER_SHADER, Globals::water_toggle, WATER_VAO, WATER_VBO, within_planet_atmosphere, wt, vec3::x, vec4::x, vec3::y, vec4::y, vec3::z, and vec4::z.
| int main | ( | int | argc, |
| char * | argv[] ) |
<This value is hardcoded since our values are touchy.
Definition at line 1726 of file main.c.
References ATMOSPHERE_EBO, ATMOSPHERE_ICNT, ATMOSPHERE_INDICES, atmosphere_queries, ATMOSPHERE_RES, ATMOSPHERE_VAO, ATMOSPHERE_VBO, ATMOSPHERE_VCNT, ATMOSPHERE_VERTS, BODY_COUNT, bounds_queries, cam, Camera::cam_data, CamData::cam_pos, CamData::cam_vel, clouds_queries, com_queries, current_cam, current_query_frame, density_time, display_main_menu(), display_menu, draw_queries, dt, end_timer(), fence, frame, frame_available, GLOBALS, halt_chunks, init(), LIGHT_CAM, load_chunks(), main(), main_queries, MAIN_VBO, MAX_ELEMENT_MEMORY, MAX_VERTEX_MEMORY, mc_time, mesh_atmosphere_sphere(), mesh_generation_queries, mesh_queries, morton_queries, particle_queries, Globals::particle_toggle, Camera::pitch, Globals::planet_meshing_toggle, planet_origin, planet_radius, postprocess_queries, PQUERY_ATMOSPHERE, PQUERY_BOUNDS, PQUERY_CLOUDS, PQUERY_COM, PQUERY_DRAW, PQUERY_MAIN, PQUERY_MAX, PQUERY_MESH, PQUERY_MESH_GEN, PQUERY_MORTON, PQUERY_PARTICLE, PQUERY_POSTPROCESS, PQUERY_RADIX, PQUERY_TREE, PQUERY_TREECOUNT, PQUERY_WATER, PQUERY_WATER_GEN, process_input(), Globals::profiling, QUERY_FRAMES, radix_queries, render(), retrieve_gl_query(), Camera::roll, running, sim_step(), space_cam, start_timer(), tree_queries, treecount_queries, update_camera(), update_light_camera(), update_water_fft(), uTime, verts, water_gen_queries, water_queries, Globals::water_toggle, within_planet_atmosphere, wt, vec4::x, vec4::y, Camera::yaw, vec3::z, and vec4::z.
| Globals GLOBALS = {0} |
Definition at line 39 of file main.c.
Referenced by display_main_menu(), init_globals(), init_random(), look_at_selected_body(), main(), process_input(), and render().
| int SCREEN_WIDTH = 1280 |
Definition at line 41 of file main.c.
Referenced by init(), render(), and update_camera().
| int SCREEN_HEIGHT = 960 |
Definition at line 42 of file main.c.
Referenced by display_main_menu(), init(), render(), and update_camera().
| GLuint ROCK_NORMAL_TEXTURE |
| GLuint ROCK_DIFFUSE_TEXTURE |
| GLuint ROCK_SPECULAR_TEXTURE |
| GLuint SKY_CUBEMAP |
Definition at line 75 of file main.c.
Referenced by init(), render(), and render_sky_cubemap().
| GLuint WORLEY_TEXTURE |
Definition at line 91 of file main.c.
Referenced by init(), precompute_worley_texture(), and render_sky_cubemap().
| GLuint PERLIN_TEXTURE |
Definition at line 92 of file main.c.
Referenced by create_new_planet_mesh(), init(), precompute_perlin_texture(), render(), and render_sky_cubemap().
| GLuint FBM_TEXTURE |
Definition at line 93 of file main.c.
Referenced by create_new_planet_mesh(), init(), precompute_fbm_texture(), render(), and render_sky_cubemap().
| GLuint SKY_FBO |
Definition at line 109 of file main.c.
Referenced by init(), and render_sky_cubemap().
| ShaderProgram SHADOW_MAP_SHADER |
Definition at line 119 of file main.c.
Referenced by init_shadow_map_shader(), and render().
| ShaderProgram SHADOW_WATER_SHADER |
Definition at line 120 of file main.c.
Referenced by init_shadow_water_shader(), and render().
| ShaderProgram MAIN_SHADER |
Definition at line 121 of file main.c.
Referenced by init_main_shader(), and render().
| ShaderProgram MESH_SHADER |
Definition at line 122 of file main.c.
Referenced by init_mesh_shader(), render(), and render_mesh_planet().
| ShaderProgram SKY_SHADER |
Definition at line 123 of file main.c.
Referenced by init_sky_shader(), and render().
| ShaderProgram WATER_SHADER |
Definition at line 124 of file main.c.
Referenced by init_water_shader(), and render().
| ShaderProgram FULLSCREEN_SHADER |
| ShaderProgram POSTPROCESS_SHADER |
Definition at line 126 of file main.c.
Referenced by init_postprocess_shader(), and render().
| ShaderProgram HISTORY_SHADER |
| ShaderProgram COMPOSITE_SHADER |
| ShaderProgram BLOOM_SHADER |
| ShaderProgram BLUR_SHADER |
| ShaderProgram ATMOSPHERE_SHADER |
Definition at line 132 of file main.c.
Referenced by init_atmosphere_shader(), and render_sky_cubemap().
| ShaderProgram ATMOSPHERE_FROM_SPACE_SHADER |
Definition at line 133 of file main.c.
Referenced by init_atmosphere_from_space_shader(), and render_sky_from_outside_atmosphere().
| ShaderProgram CLOUDS_SHADER |
Definition at line 134 of file main.c.
Referenced by init_clouds_shader(), and render_sky_cubemap().
| GLuint MAIN_COMPUTE_SHADER |
Definition at line 137 of file main.c.
Referenced by init(), and sim_step().
| ComputeShaderProgram DENSITY_COMPUTE_SHADER |
Definition at line 138 of file main.c.
Referenced by create_new_planet_mesh(), and init_density_compute_shader().
| ComputeShaderProgram MARCHING_CUBES_COMPUTE_SHADER |
Definition at line 139 of file main.c.
Referenced by create_new_planet_mesh(), and init_marching_cubes_compute_shader().
| ComputeShaderProgram INDIRECT_COMPUTE_SHADER |
Definition at line 140 of file main.c.
Referenced by create_new_planet_mesh(), and init_indirect_compute_shader().
| GLuint CHUNK_ZERO_COMPUTE_SHADER |
Definition at line 141 of file main.c.
Referenced by init(), and load_chunks().
| GLuint ZERO_COMPUTE_SHADER |
Definition at line 144 of file main.c.
Referenced by init(), and sim_step().
| GLuint BOUNDS_COMPUTE_SHADER |
Definition at line 145 of file main.c.
Referenced by init(), and sim_step().
| GLuint MORTON_COMPUTE_SHADER |
Definition at line 146 of file main.c.
Referenced by init(), and sim_step().
| GLuint RADIX_COMPUTE_SHADER |
Definition at line 147 of file main.c.
Referenced by init(), and sim_step().
| GLuint RADIX_GLOBAL_COMPUTE_SHADER |
Definition at line 148 of file main.c.
Referenced by init(), and sim_step().
| GLuint RADIX_FINAL_COMPUTE_SHADER |
Definition at line 149 of file main.c.
Referenced by init(), and sim_step().
| GLuint TREE_COMPUTE_SHADER |
Definition at line 150 of file main.c.
Referenced by init(), and sim_step().
| GLuint TREE_COUNT_COMPUTE_SHADER |
Definition at line 151 of file main.c.
Referenced by init(), and sim_step().
| GLuint COM_COMPUTE_SHADER |
Definition at line 152 of file main.c.
Referenced by init(), and sim_step().
| GLuint NEXT_COMPUTE_SHADER |
Definition at line 154 of file main.c.
Referenced by init(), and sim_step().
| GLuint POS_COMPUTE_SHADER |
Definition at line 156 of file main.c.
Referenced by init(), and sim_step().
| GLuint WATER_COMPUTE_SHADER |
Definition at line 158 of file main.c.
Referenced by init(), and update_water_fft().
| GLuint WATER_FFT_COMPUTE_SHADER |
Definition at line 159 of file main.c.
Referenced by fft_textures(), and init().
| GLuint BIT_REVERSAL_COMPUTE_SHADER |
Definition at line 160 of file main.c.
Referenced by fft_textures(), and init().
| uint32_t water_index_count |
| GLuint INDIRECT_BUFFER[LODMAX][MAX_CHUNKS] |
Definition at line 176 of file main.c.
Referenced by create_new_planet_mesh(), init_chunk_data(), and render_mesh_planet().
| PlanetData PLANET_DATA |
Definition at line 194 of file main.c.
Referenced by calc_density(), display_main_menu(), init(), and update_light_camera().
| GLuint PARTICLE_SSBO |
Definition at line 202 of file main.c.
Referenced by init(), init_random(), look_at_selected_body(), and process_input().
| GLuint NODE_SSBO |
Definition at line 207 of file main.c.
Referenced by init(), and sim_step().
| GLuint DENSITY_SSBO[LODMAX] |
Definition at line 209 of file main.c.
Referenced by create_new_planet_mesh(), init(), and render_mesh_planet().
| GLuint DENSITY_VERTEX_SSBO[LODMAX] |
Definition at line 210 of file main.c.
Referenced by create_new_planet_mesh(), init(), and render_mesh_planet().
| GLuint PLANET_DATA_SSBO |
Definition at line 213 of file main.c.
Referenced by init(), and upload_param_to_ssbo().
| GLuint CHUNK_DATA_SSBO[3] |
Definition at line 215 of file main.c.
Referenced by init(), and load_chunks().
| int running = 0 |
Definition at line 219 of file main.c.
Referenced by main(), main(), and process_input().
| Camera cam = {0} |
Definition at line 222 of file main.c.
Referenced by apply_air_acceleration(), apply_planet_velocity(), apply_velocity(), check_collision(), compute_camera_basis(), get_view_planes(), hit_ground(), look_at_selected_body(), main(), make_look_at(), process_input(), render(), render_sky_cubemap(), render_sky_from_outside_atmosphere(), resolve_collisions(), update_camera(), and update_light_camera().
| Camera LIGHT_CAM |
Definition at line 224 of file main.c.
Referenced by load_chunks(), main(), and render().
Definition at line 225 of file main.c.
Referenced by load_chunks(), main(), and process_input().
| float dt |
Definition at line 229 of file main.c.
Referenced by apply_air_acceleration(), apply_planet_velocity(), apply_velocity(), main(), and process_input().
| float DT = 0.5f |
Definition at line 231 of file main.c.
Referenced by main(), process_input(), and sim_step().
| vec3 wavelength = {0.650f, 0.570f, 0.475f} |
Definition at line 235 of file main.c.
Referenced by display_main_menu(), render_sky_cubemap(), and render_sky_from_outside_atmosphere().
| vec3 cam_pos_world = {0.01f, 0.01f, 1.001f} |
Definition at line 236 of file main.c.
Referenced by display_main_menu(), render_sky_cubemap(), and render_sky_from_outside_atmosphere().
| vec3 sun_dir = {0.1f, 0.2f, -0.8f} |
Definition at line 237 of file main.c.
Referenced by display_main_menu(), layout(), and main().
| vec3 sun_color = {1.0, 0.7, 0.5} |
Definition at line 238 of file main.c.
Referenced by display_main_menu(), layout(), and main().
| float G = -0.88f |
Definition at line 239 of file main.c.
Referenced by display_main_menu(), render_sky_cubemap(), and render_sky_from_outside_atmosphere().
| float fKr = 0.0025f |
Definition at line 240 of file main.c.
Referenced by display_main_menu(), render_sky_cubemap(), and render_sky_from_outside_atmosphere().
| float fKm = 0.001f |
Definition at line 241 of file main.c.
Referenced by display_main_menu(), render_sky_cubemap(), and render_sky_from_outside_atmosphere().
| ParticleData PD |
Definition at line 244 of file main.c.
Referenced by init_random().
| GLsync fence |
Definition at line 247 of file main.c.
Referenced by look_at_selected_body(), main(), and process_input().
| ParticleVertex verts[BODY_COUNT] |
| Particle bodies[BODY_COUNT] = {0} |
| bool display_menu = true |
Definition at line 255 of file main.c.
Referenced by main(), and process_input().
| bool halt_chunks = false |
Definition at line 256 of file main.c.
Referenced by main(), and process_input().
| bool is_on_planet = true |
Definition at line 259 of file main.c.
Referenced by process_input().
Definition at line 260 of file main.c.
Referenced by display_main_menu(), load_chunks(), main(), process_input(), render_sky_cubemap(), and render_sky_from_outside_atmosphere().
Definition at line 261 of file main.c.
Referenced by layout(), and process_input().
| float planet_radius = 1000 |
Definition at line 262 of file main.c.
Referenced by check_collision(), find_surface(), find_surface_entry(), get_view_planes(), load_chunks(), main(), process_input(), render(), render_sky_cubemap(), and resolve_collisions().
| GLuint main_queries[QUERY_FRAMES] |
Definition at line 263 of file main.c.
Referenced by main(), and sim_step().
| GLuint bounds_queries[QUERY_FRAMES] |
Definition at line 264 of file main.c.
Referenced by main(), and sim_step().
| GLuint morton_queries[QUERY_FRAMES] |
Definition at line 265 of file main.c.
Referenced by main(), and sim_step().
| GLuint radix_queries[QUERY_FRAMES] |
Definition at line 266 of file main.c.
Referenced by main(), and sim_step().
| GLuint treecount_queries[QUERY_FRAMES] |
Definition at line 267 of file main.c.
Referenced by main(), and sim_step().
| GLuint tree_queries[QUERY_FRAMES] |
Definition at line 268 of file main.c.
Referenced by main(), and sim_step().
| GLuint com_queries[QUERY_FRAMES] |
Definition at line 269 of file main.c.
Referenced by main(), and sim_step().
| GLuint atmosphere_queries[QUERY_FRAMES] |
Definition at line 270 of file main.c.
Referenced by main(), and render_sky_cubemap().
| GLuint clouds_queries[QUERY_FRAMES] |
Definition at line 271 of file main.c.
Referenced by main(), and render_sky_cubemap().
| GLuint water_gen_queries[QUERY_FRAMES] |
| GLuint water_queries[QUERY_FRAMES] |
| GLuint mesh_generation_queries[QUERY_FRAMES] |
| GLuint particle_queries[QUERY_FRAMES] |
| GLuint mesh_queries[QUERY_FRAMES] |
| GLuint draw_queries[QUERY_FRAMES] |
| GLuint postprocess_queries[QUERY_FRAMES] |
| int current_query_frame = 1 |
Definition at line 280 of file main.c.
Referenced by main(), render(), render_sky_cubemap(), and sim_step().
| bool dirty_cubemap = false |
Definition at line 1247 of file main.c.
Referenced by display_main_menu().
| bool within_planet_atmosphere = true |