$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
app_input.c File Reference
#include "app_input.h"
#include "app_ui.h"
#include "camera.h"
#include "camera_input.h"
#include "env_manager.h"
#include "gamepad_input.h"
#include "gpu_profiler_ui.h"
#include "log.h"
#include "perf_mode.h"
#include "postprocess_input.h"
#include "profiler.h"
#include "scene.h"
#include "scene_simulation.h"
#include "scene_visuals.h"
#include "utils.h"
#include <math.h>
#include <stb_image_write.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for app_input.c:

Enumerations

enum  { PBR_DEBUG_MODE_COUNT = 10 }
 
enum  { NOTIF_BUF_SIZE = 128 }
 

Functions

void framebuffer_size_callback (GLFWwindow *window, int width, int height)
 Primary GLFW framebuffer size callback. More...
 
static void handle_pbr_debug_mode (AppInputContext *ctx)
 
static void handle_aa_mode_input (AppInputContext *ctx)
 
void app_handle_env_input (AppInputContext *ctx, int action, int mods, int key)
 Handles input for cycling environment maps. More...
 
static void handle_overlay_input (AppInputContext *ctx)
 
static void handle_subdiv_input (AppInputContext *ctx, int key)
 
static void handle_camera_toggle (AppInputContext *ctx)
 
static void handle_f3_input (AppInputContext *ctx, int mods)
 
static void handle_f9_input (AppInputContext *ctx)
 
static void app_toggle_help (AppInputContext *ctx)
 
static void app_close_help (AppInputContext *ctx)
 
static bool handle_f_key_input (AppInputContext *ctx, int key, int mods)
 
static void handle_y_key_input (AppInputContext *ctx, int mods)
 
static void handle_system_key_input (AppInputContext *ctx, int key, int mods)
 
static bool handle_g_key_input (AppInputContext *ctx, int mods)
 
static void handle_sim_speed_input (AppInputContext *ctx, bool speed_up)
 
static void handle_gravity_input (AppInputContext *ctx, bool increase)
 
static void handle_sim_or_gravity_input (AppInputContext *ctx, int mods, bool increase)
 
static void handle_o_key_input (AppInputContext *ctx)
 
static void handle_neon_cycle (AppInputContext *ctx)
 
static void handle_neon_adjust (AppInputContext *ctx, int increase)
 
static int handle_neon_input (AppInputContext *ctx, int key, int mods)
 
void handle_app_input (AppInputContext *ctx, int key, int mods)
 Dispatches application-level logic for key inputs. More...
 
void key_callback (GLFWwindow *window, int key, int scancode, int action, int mods)
 Primary GLFW key callback. More...
 
void app_toggle_fullscreen (AppInputContext *ctx, GLFWwindow *window)
 Toggles the application window between Windowed and Fullscreen. More...
 
void mouse_callback (GLFWwindow *window, double xpos, double ypos)
 Primary GLFW mouse position callback. More...
 
void scroll_callback (GLFWwindow *window, double xoffset, double yoffset)
 Primary GLFW scroll callback. More...
 
void app_save_png_frame (AppInputContext *ctx, const char *filename)
 Captures the current framebuffer and saves it as a PNG file. More...
 

Variables

static const float SIM_SPEED_FACTOR = 2.0F
 
static const float SIM_SPEED_MAX = 64.0F
 
static const float SIM_SPEED_MIN = 0.125F
 
static const float SIM_SPEED_INV_FACTOR = 0.5F
 
static const float GRAVITY_FACTOR = 2.0F
 
static const float GRAVITY_MAX = 128.0F
 
static const float GRAVITY_MIN_POSITIVE = 0.125F
 
static const float GRAVITY_INV_FACTOR = 0.5F
 
static const char *const HELP_MODE_NAMES []
 
static const char *const NEON_PARAM_NAMES [] = {"Intensity", "Core", "Width"}
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PBR_DEBUG_MODE_COUNT 

◆ anonymous enum

anonymous enum
Enumerator
NOTIF_BUF_SIZE 

Function Documentation

◆ app_close_help()

static void app_close_help ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ app_handle_env_input()

void app_handle_env_input ( AppInputContext *  ctx,
int  action,
int  mods,
int  key 
)

Handles input for cycling environment maps.

Parameters
ctxPointer to the input context.
actionGLFW action (Press/Release).
modsModifiers.
keyDirectional key.
Here is the call graph for this function:

◆ app_save_png_frame()

void app_save_png_frame ( AppInputContext *  ctx,
const char *  filename 
)

Captures the current framebuffer and saves it as a PNG file.

Parameters
ctxPointer to the input context.
filenameOutput file path (should end in .png).

◆ app_toggle_fullscreen()

void app_toggle_fullscreen ( AppInputContext *  ctx,
GLFWwindow *  window 
)

Toggles the application window between Windowed and Fullscreen.

Parameters
ctxPointer to the input context.
windowGLFW window handle.

◆ app_toggle_help()

static void app_toggle_help ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ framebuffer_size_callback()

void framebuffer_size_callback ( GLFWwindow *  window,
int  width,
int  height 
)

Primary GLFW framebuffer size callback.

Handles resizing of the OpenGL viewport and all dependent post-processing buffers to match the new window dimensions.

Parameters
windowThe GLFW window context.
widthNew framebuffer width.
heightNew framebuffer height.
Note
Reallocates many GPU textures via postprocess_resize.
Here is the call graph for this function:

◆ handle_aa_mode_input()

static void handle_aa_mode_input ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ handle_app_input()

void handle_app_input ( AppInputContext *  ctx,
int  key,
int  mods 
)

Dispatches application-level logic for key inputs.

Handles system-wide shortcuts (ESC to exit, Space to pause, etc.).

Parameters
ctxPointer to the input context.
keyLocked key code.
modsActive modifiers.
Here is the call graph for this function:

◆ handle_camera_toggle()

static void handle_camera_toggle ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ handle_f3_input()

static void handle_f3_input ( AppInputContext *  ctx,
int  mods 
)
static
Here is the call graph for this function:

◆ handle_f9_input()

static void handle_f9_input ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ handle_f_key_input()

static bool handle_f_key_input ( AppInputContext *  ctx,
int  key,
int  mods 
)
static
Here is the call graph for this function:

◆ handle_g_key_input()

static bool handle_g_key_input ( AppInputContext *  ctx,
int  mods 
)
static
Here is the call graph for this function:

◆ handle_gravity_input()

static void handle_gravity_input ( AppInputContext *  ctx,
bool  increase 
)
static
Here is the call graph for this function:

◆ handle_neon_adjust()

static void handle_neon_adjust ( AppInputContext *  ctx,
int  increase 
)
static
Here is the call graph for this function:

◆ handle_neon_cycle()

static void handle_neon_cycle ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ handle_neon_input()

static int handle_neon_input ( AppInputContext *  ctx,
int  key,
int  mods 
)
static
Here is the call graph for this function:

◆ handle_o_key_input()

static void handle_o_key_input ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ handle_overlay_input()

static void handle_overlay_input ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ handle_pbr_debug_mode()

static void handle_pbr_debug_mode ( AppInputContext *  ctx)
static
Here is the call graph for this function:

◆ handle_sim_or_gravity_input()

static void handle_sim_or_gravity_input ( AppInputContext *  ctx,
int  mods,
bool  increase 
)
static
Here is the call graph for this function:

◆ handle_sim_speed_input()

static void handle_sim_speed_input ( AppInputContext *  ctx,
bool  speed_up 
)
static
Here is the call graph for this function:

◆ handle_subdiv_input()

static void handle_subdiv_input ( AppInputContext *  ctx,
int  key 
)
static
Here is the call graph for this function:

◆ handle_system_key_input()

static void handle_system_key_input ( AppInputContext *  ctx,
int  key,
int  mods 
)
static
Here is the call graph for this function:

◆ handle_y_key_input()

static void handle_y_key_input ( AppInputContext *  ctx,
int  mods 
)
static
Here is the call graph for this function:

◆ key_callback()

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

Primary GLFW key callback.

Dispatches raw key events to handle_app_input, camera_process_key_callback, and other specific handlers.

Parameters
windowThe GLFW window context.
keyThe keyboard key code.
scancodeSystem-specific scancode.
actionGLFW_PRESS, GLFW_RELEASE, or GLFW_REPEAT.
modsActive modifier keys (Shift, Ctrl, Alt).
Here is the call graph for this function:

◆ mouse_callback()

void mouse_callback ( GLFWwindow *  window,
double  xpos,
double  ypos 
)

Primary GLFW mouse position callback.

Parameters
windowThe GLFW window context.
xposAbsolute mouse X-coordinate.
yposAbsolute mouse Y-coordinate.
Here is the call graph for this function:

◆ scroll_callback()

void scroll_callback ( GLFWwindow *  window,
double  xoffset,
double  yoffset 
)

Primary GLFW scroll callback.

Parameters
windowThe GLFW window context.
xoffsetScroll amount along the X-axis.
yoffsetScroll amount along the Y-axis.
Here is the call graph for this function:

Variable Documentation

◆ GRAVITY_FACTOR

const float GRAVITY_FACTOR = 2.0F
static

◆ GRAVITY_INV_FACTOR

const float GRAVITY_INV_FACTOR = 0.5F
static

◆ GRAVITY_MAX

const float GRAVITY_MAX = 128.0F
static

◆ GRAVITY_MIN_POSITIVE

const float GRAVITY_MIN_POSITIVE = 0.125F
static

◆ HELP_MODE_NAMES

const char* const HELP_MODE_NAMES[]
static
Initial value:
= {"Help: OFF", "Help: Keyboard",
"Help: Gamepad"}

◆ NEON_PARAM_NAMES

const char* const NEON_PARAM_NAMES[] = {"Intensity", "Core", "Width"}
static

◆ SIM_SPEED_FACTOR

const float SIM_SPEED_FACTOR = 2.0F
static

◆ SIM_SPEED_INV_FACTOR

const float SIM_SPEED_INV_FACTOR = 0.5F
static

◆ SIM_SPEED_MAX

const float SIM_SPEED_MAX = 64.0F
static

◆ SIM_SPEED_MIN

const float SIM_SPEED_MIN = 0.125F
static