$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
scene.c File Reference
#include "scene.h"
#include "app_settings.h"
#include "billboard_rendering.h"
#include "gl_debug.h"
#include "glad/glad.h"
#include "ibl_coordinator.h"
#include "icosphere.h"
#include "instanced_rendering.h"
#include "log.h"
#include "material.h"
#include "platform/platform_fs.h"
#include "platform/platform_utils.h"
#include "profiler.h"
#include "render_utils.h"
#include "shader.h"
#include "sphere_sorting.h"
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for scene.c:

Data Structures

struct  HdrScanContext
 

Macros

#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 

Functions

static int compare_strings (const void *string_a, const void *string_b)
 
static void scene_hdr_file_callback (const char *filename, bool is_dir, void *user_data)
 
static void scene_scan_hdr_files (Scene *scene)
 
static void scene_init_instancing (Scene *scene)
 
static void scene_init_state (Scene *scene)
 
static int scene_init_core_shaders (Scene *scene)
 
static int scene_init_billboard_shader (Scene *scene)
 
static int scene_init_compute_resources (Scene *scene)
 
static int scene_init_instanced_shader (Scene *scene, Shader **out_shader)
 
int scene_init (Scene *scene)
 Initializes the scene resources. More...
 
static void scene_cleanup_pbr_shaders (Scene *scene)
 
static void scene_cleanup_shaders (Scene *scene)
 
static void scene_cleanup_geometry_buffers (Scene *scene)
 
static void scene_cleanup_buffers (Scene *scene)
 
static void scene_cleanup_textures (Scene *scene)
 
static void scene_cleanup_gpu_resources (Scene *scene)
 
void scene_cleanup (Scene *scene)
 Cleans up scene resources. More...
 
const char * aa_mode_to_string (AAMode mode)
 Returns a string representation of the AA mode. More...
 
void scene_update_gpu_buffers (Scene *scene)
 Updates GPU buffers for dynamic geometry (e.g. LOD changes). More...
 
static void scene_bind_probe_textures (Scene *scene)
 Binds SH 3D textures (units 8-14) and probe SSBO only when changed. Units 8-14 and SSBO binding 3 are exclusive to PBR passes — safe to cache. Invalidated after light_probe_grid_sync() which clobbers GL_TEXTURE_3D. More...
 
static void scene_bind_ibl_textures (Scene *scene)
 
static void scene_render_billboards (Scene *scene, mat4 view, mat4 proj, vec3 camera_pos, mat4 previous_view_proj, int width, int height)
 
static void scene_render_instanced (Scene *scene, mat4 view, mat4 proj, vec3 camera_pos, mat4 previous_view_proj)
 
static void stencil_begin_object_pass (void)
 
void scene_render (Scene *scene, GPUProfiler *profiler, mat4 view, mat4 proj, vec3 camera_pos, mat4 previous_view_proj, int width, int height)
 Renders the scene. More...
 

Variables

static const char *const HDR_TEXTURE_PATH = "assets/textures/hdr"
 
static const char *const HDR_EXTENSION = ".hdr"
 

Macro Definition Documentation

◆ MIN

#define MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

Function Documentation

◆ aa_mode_to_string()

const char* aa_mode_to_string ( AAMode  mode)

Returns a string representation of the AA mode.

Parameters
modeThe AA mode.
Returns
String representation.

◆ compare_strings()

static int compare_strings ( const void *  string_a,
const void *  string_b 
)
static

◆ scene_bind_ibl_textures()

static void scene_bind_ibl_textures ( Scene scene)
static

◆ scene_bind_probe_textures()

static void scene_bind_probe_textures ( Scene scene)
static

Binds SH 3D textures (units 8-14) and probe SSBO only when changed. Units 8-14 and SSBO binding 3 are exclusive to PBR passes — safe to cache. Invalidated after light_probe_grid_sync() which clobbers GL_TEXTURE_3D.

◆ scene_cleanup()

void scene_cleanup ( Scene scene)

Cleans up scene resources.

Parameters
scenePointer to the scene structure.
Here is the call graph for this function:

◆ scene_cleanup_buffers()

static void scene_cleanup_buffers ( Scene scene)
static
Here is the call graph for this function:

◆ scene_cleanup_geometry_buffers()

static void scene_cleanup_geometry_buffers ( Scene scene)
static

◆ scene_cleanup_gpu_resources()

static void scene_cleanup_gpu_resources ( Scene scene)
static
Here is the call graph for this function:

◆ scene_cleanup_pbr_shaders()

static void scene_cleanup_pbr_shaders ( Scene scene)
static

◆ scene_cleanup_shaders()

static void scene_cleanup_shaders ( Scene scene)
static
Here is the call graph for this function:

◆ scene_cleanup_textures()

static void scene_cleanup_textures ( Scene scene)
static

◆ scene_hdr_file_callback()

static void scene_hdr_file_callback ( const char *  filename,
bool  is_dir,
void *  user_data 
)
static

◆ scene_init()

int scene_init ( Scene scene)

Initializes the scene resources.

Parameters
scenePointer to the scene structure.
Returns
1 on success, 0 on failure.
Here is the call graph for this function:

◆ scene_init_billboard_shader()

static int scene_init_billboard_shader ( Scene scene)
static
Here is the call graph for this function:

◆ scene_init_compute_resources()

static int scene_init_compute_resources ( Scene scene)
static
Here is the call graph for this function:

◆ scene_init_core_shaders()

static int scene_init_core_shaders ( Scene scene)
static
Here is the call graph for this function:

◆ scene_init_instanced_shader()

static int scene_init_instanced_shader ( Scene scene,
Shader **  out_shader 
)
static
Here is the call graph for this function:

◆ scene_init_instancing()

static void scene_init_instancing ( Scene scene)
static
Here is the call graph for this function:

◆ scene_init_state()

static void scene_init_state ( Scene scene)
static
Here is the call graph for this function:

◆ scene_render()

void scene_render ( Scene scene,
GPUProfiler profiler,
mat4  view,
mat4  proj,
vec3  camera_pos,
mat4  previous_view_proj,
int  width,
int  height 
)

Renders the scene.

Parameters
scenePointer to the scene.
viewView matrix.
projProjection matrix.
camera_posCamera position.
previous_view_projPrevious frame's ViewProj matrix (for motion blur).
widthViewport width.
heightViewport height.
Here is the call graph for this function:

◆ scene_render_billboards()

static void scene_render_billboards ( Scene scene,
mat4  view,
mat4  proj,
vec3  camera_pos,
mat4  previous_view_proj,
int  width,
int  height 
)
static
Here is the call graph for this function:

◆ scene_render_instanced()

static void scene_render_instanced ( Scene scene,
mat4  view,
mat4  proj,
vec3  camera_pos,
mat4  previous_view_proj 
)
static
Here is the call graph for this function:

◆ scene_scan_hdr_files()

static void scene_scan_hdr_files ( Scene scene)
static
Here is the call graph for this function:

◆ scene_update_gpu_buffers()

void scene_update_gpu_buffers ( Scene scene)

Updates GPU buffers for dynamic geometry (e.g. LOD changes).

Parameters
scenePointer to the scene.

◆ stencil_begin_object_pass()

static void stencil_begin_object_pass ( void  )
inlinestatic

Variable Documentation

◆ HDR_EXTENSION

const char* const HDR_EXTENSION = ".hdr"
static

◆ HDR_TEXTURE_PATH

const char* const HDR_TEXTURE_PATH = "assets/textures/hdr"
static