This commit is contained in:
2026-06-17 10:35:08 -07:00
parent e3b09170a4
commit 5355a9eded
9 changed files with 1836 additions and 0 deletions

92
include/01_classes.h Normal file
View File

@@ -0,0 +1,92 @@
/*
* MIT License
*
* Copyright (c) 2026 Mark Allyn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* 01_classes.h
* Author: Mark Allyn
* Component: 01_classes
*
* Abstract RadarBase class and four stub subclasses.
* Each stub renders its name and description in the three screen panels.
* No real radar simulation is performed here; this is for testing
* the initialization and radar-management/selection flow.
*/
#pragma once
#include "data_structure_and_constants.h"
#include "settings.h"
/* Abstract base — one instance per radar type. */
class RadarBase {
public:
/* Render radar description and control list into the left panel viewport. */
virtual void render_left_panel() = 0;
/* Render scope content (stub: radar name only) into the scope viewport. */
virtual void render_scope() = 0;
/* Render current control values into the status bar viewport. */
virtual void render_status_bar() = 0;
virtual ~RadarBase() = default;
};
/* Chain Home radar (1940s A-scope) — Ventnor, Isle of Wight. */
class ChainHomeRadar : public RadarBase {
public:
void render_left_panel() override;
void render_scope() override;
void render_status_bar() override;
};
/* Marine A-Scope radar — Community Boating Center, Bellingham Bay. */
class MarineAScopeRadar : public RadarBase {
public:
void render_left_panel() override;
void render_scope() override;
void render_status_bar() override;
};
/* Marine Traffic Control PPI radar — center of Bellingham Bay. */
class MarineTrafficRadar : public RadarBase {
public:
void render_left_panel() override;
void render_scope() override;
void render_status_bar() override;
};
/* Police Boat PPI radar — Taylor Dock / Boulevard Park, Bellingham Bay. */
class PoliceboatRadar : public RadarBase {
public:
void render_left_panel() override;
void render_scope() override;
void render_status_bar() override;
};
/* One global instance per radar — indexed by RADAR_* constants in main.cpp. */
extern ChainHomeRadar g_chain_home;
extern MarineAScopeRadar g_marine_ascope;
extern MarineTrafficRadar g_marine_traffic;
extern PoliceboatRadar g_police_boat;

View File

@@ -0,0 +1,96 @@
/*
* MIT License
*
* Copyright (c) 2026 Mark Allyn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* 02_text_description.h
* Author: Mark Allyn
* Component: 02_text_description
*
* FreeType-based text renderer used by all three screen panels
* (left description panel, scope panel, status bar).
*
* Usage:
* 1. Call g_text_renderer.initialize_shaders() after GLAD is loaded.
* 2. Call g_text_renderer.initialize_font(FONT_PATH, FONT_SIZE_NORMAL).
* 3. Before rendering into a viewport, call set_projection(w, h).
* 4. Call render_text() with viewport-local pixel coordinates.
*/
#pragma once
#include <string>
#include <map>
#include <glad/glad.h>
#include "data_structure_and_constants.h"
#include "settings.h"
/* Cached metrics for one loaded glyph. */
struct glyph_character {
GLuint texture_id; // GL_RED single-channel texture
int size_x; // bitmap width in pixels
int size_y; // bitmap height in pixels
int bearing_x; // pixel offset from cursor to left of glyph
int bearing_y; // pixel offset from cursor baseline to top of glyph
unsigned int advance; // horizontal advance in 1/64-pixel units
};
class TextRenderer {
public:
TextRenderer() : vao_(0), vbo_(0), shader_program_(0) {}
/* Compile and link 02_text_description_{vert,frag}.glsl.
* Must be called once, after GLAD is initialised. */
bool initialize_shaders();
/* Load glyphs for printable ASCII (32126) from the given font file.
* font_size is the desired pixel height. */
bool initialize_font(const std::string& font_path, unsigned int font_size);
/* Render text at (x, y) in viewport-local pixel coordinates.
* y=0 is the bottom of the current viewport.
* scale multiplies the loaded glyph size.
* color_r/g/b are 0.01.0. */
void render_text(const std::string& text,
float x, float y, float scale,
float color_r, float color_g, float color_b);
/* Return the rendered pixel width of text at the given scale. */
float get_text_width(const std::string& text, float scale) const;
/* Set the orthographic projection for a viewport of w × h pixels.
* Call this each time glViewport changes before rendering text. */
void set_projection(int w, int h);
/* Release all GL resources and glyph textures. */
void cleanup();
private:
std::map<char, glyph_character> characters_;
GLuint vao_;
GLuint vbo_;
GLuint shader_program_;
};
/* Global instance — shared by all panels and radar stubs. */
extern TextRenderer g_text_renderer;

View File

@@ -126,3 +126,79 @@
#define PPI_BOAT_RANGE_STEP_3 6.0f
#define PPI_BOAT_RANGE_STEP_4 12.0f
#define PPI_BOAT_RANGE_STEP_5 24.0f
/* ============================================================
* WINDOW AND PANEL LAYOUT
* Component: Thread 1 (main.cpp), 01_classes, 02_text_description
* ============================================================ */
#define WINDOW_WIDTH 1920
#define WINDOW_HEIGHT 1080
#define WINDOW_TITLE "RAF / Marine Radar Exhibit"
// Left text panel occupies left side; scope and status bar share the right side
#define LEFT_PANEL_WIDTH 500
#define STATUS_BAR_HEIGHT 250
// Derived dimensions — scope area fills remaining right-side space
#define SCOPE_WIDTH (WINDOW_WIDTH - LEFT_PANEL_WIDTH)
#define SCOPE_HEIGHT (WINDOW_HEIGHT - STATUS_BAR_HEIGHT)
/* ============================================================
* TEXT RENDERING
* Component: 02_text_description
* ============================================================ */
#define FONT_PATH "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
#define FONT_SIZE_NORMAL 18u
#define FONT_SIZE_TITLE 24u
// Pixels between text baselines at scale 1.0 with FONT_SIZE_NORMAL
#define LINE_HEIGHT 24.0f
// Pixel margin from panel edge for text placement
#define TEXT_MARGIN 10.0f
/* ============================================================
* SHADER DIRECTORY
* Component: all components that load shaders
* ============================================================ */
// Path is relative to the build/ directory where the executable lives
#define SHADER_DIR "../shaders/"
/* ============================================================
* KEYBOARD CONTROL STEP SIZES
* Component: Thread 1 keyboard handler (main.cpp)
* ============================================================ */
#define INTENSITY_STEP 0.05f
#define SENSITIVITY_STEP 0.05f
#define STC_SENSITIVITY_STEP 0.05f
#define STC_RANGE_STEP 0.05f
#define NOISE_FILTER_STEP 0.05f
#define RADIOGON_STEP 1.0f
#define BEARING_CURSOR_STEP 1.0f
#define RANGE_CURSOR_STEP 0.02f
#define MARINE_A_BEARING_STEP 1.0f
#define MAX_RANGE_STEP 0.1f
/* ============================================================
* KEYBOARD CONTROL LIMITS
* Component: Thread 1 keyboard handler (main.cpp)
* ============================================================ */
#define INTENSITY_MIN 0.0f
#define INTENSITY_MAX 2.0f
#define SENSITIVITY_MIN 0.0f
#define SENSITIVITY_MAX 2.0f
#define STC_SENSITIVITY_MIN 0.0f
#define STC_SENSITIVITY_MAX 1.0f
#define STC_RANGE_MIN 0.0f
#define STC_RANGE_MAX 1.0f
#define NOISE_FILTER_MIN 0.0f
#define NOISE_FILTER_MAX 1.0f
#define RANGE_CURSOR_MIN 0.0f
#define RANGE_CURSOR_MAX 1.0f
#define MAX_RANGE_MIN 0.1f
#define MAX_RANGE_MAX 1.0f