/*
 * MIT License
 * Author: Mark Allyn
 *
 * shared_render_state.h — Mutex-A-protected state that Thread 1 reads
 * every frame to drive the shaders.  Threads 2 and 3 may write to it
 * (TrafficCop for live data, KnobPanel for hardware controls).
 * Keyboard callbacks (GLFW, Thread 1) also write under the mutex.
 */

#pragma once
#include <mutex>
#include <atomic>
#include <string>
#include "settings.h"

struct SharedRenderState {
    mutable std::mutex mutex;   // Mutex A

    // ---- Scope selection ----
    std::atomic<int> scopeIndex{0};     // current scope (written by ScopeManager)

    // ---- General operator controls (all normalised 0-1) ----
    float gain            = DEFAULT_GAIN;
    float rainClutter     = DEFAULT_RAIN_CLUTTER;
    float waveClutter     = DEFAULT_WAVE_CLUTTER;
    float intensity       = DEFAULT_INTENSITY;
    float focus           = DEFAULT_FOCUS;
    float astigmatism     = DEFAULT_ASTIGMATISM;
    float gratIntensity   = DEFAULT_GRAT_INTENSITY;

    // ---- Marine PPI scope state ----
    int   marineMaxRangeIdx   = MARINE_PPI_DEFAULT_RANGE_IDX;
    float marineCursorBrg     = MARINE_PPI_DEFAULT_CURSOR_BRG;   // degrees
    float marineCursorRng     = MARINE_PPI_DEFAULT_CURSOR_RNG;   // miles
    float marineBrgOffset     = MARINE_PPI_DEFAULT_BRG_OFFSET;   // degrees

    // ---- Boat PPI (future) ----
    float boatLatDeg          = 0.0f;
    float boatLonDeg          = 0.0f;
    float boatHeadingDeg      = 0.0f;
    float boatSpeedKts        = 0.0f;
    char  boatZone[64]        = "";
    bool  boatModeActive      = false;
};
