wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
Loading...
Searching...
No Matches
bgi_types.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <memory>
6#include <queue>
7#include <string>
8#include <unordered_map>
9#include <vector>
10
11#if defined(_WIN32)
12#define BGI_API extern "C" __declspec(dllexport)
13#else
14#define BGI_API extern "C"
15#endif
16
17#if defined(_MSC_VER)
18#define BGI_CALL __cdecl
19#else
20#define BGI_CALL
21#endif
22
23struct GLFWwindow;
24
49typedef void (BGI_CALL *WxbgiKeyHook)(int key, int scancode, int action, int mods);
50
57typedef void (BGI_CALL *WxbgiCharHook)(unsigned int codepoint);
58
65typedef void (BGI_CALL *WxbgiCursorPosHook)(int x, int y);
66
74typedef void (BGI_CALL *WxbgiMouseButtonHook)(int button, int action, int mods);
75
83typedef void (BGI_CALL *WxbgiScrollHook)(double xoffset, double yoffset);
84
94#define WXBGI_DEFAULT_KEY_QUEUE 0x01
96#define WXBGI_DEFAULT_CURSOR_TRACK 0x02
98#define WXBGI_DEFAULT_MOUSE_PICK 0x04
100#define WXBGI_DEFAULT_SCROLL_ACCUM 0x08
102#define WXBGI_DEFAULT_ALL 0x0F
104#define WXBGI_DEFAULT_NONE 0x00
113#define WXBGI_KEY_SPACE 32
114#define WXBGI_KEY_APOSTROPHE 39
115#define WXBGI_KEY_COMMA 44
116#define WXBGI_KEY_MINUS 45
117#define WXBGI_KEY_PERIOD 46
118#define WXBGI_KEY_SLASH 47
119#define WXBGI_KEY_SEMICOLON 59
120#define WXBGI_KEY_EQUAL 61
121#define WXBGI_KEY_LEFT_BRACKET 91
122#define WXBGI_KEY_RIGHT_BRACKET 93
123#define WXBGI_KEY_ESCAPE 256
124#define WXBGI_KEY_ENTER 257
125#define WXBGI_KEY_TAB 258
126#define WXBGI_KEY_BACKSPACE 259
127#define WXBGI_KEY_INSERT 260
128#define WXBGI_KEY_DELETE 261
129#define WXBGI_KEY_RIGHT 262
130#define WXBGI_KEY_LEFT 263
131#define WXBGI_KEY_DOWN 264
132#define WXBGI_KEY_UP 265
133#define WXBGI_KEY_PAGE_UP 266
134#define WXBGI_KEY_PAGE_DOWN 267
135#define WXBGI_KEY_HOME 268
136#define WXBGI_KEY_END 269
137#define WXBGI_KEY_F1 290
138#define WXBGI_KEY_F2 291
139#define WXBGI_KEY_F3 292
140#define WXBGI_KEY_F4 293
141#define WXBGI_KEY_F5 294
142#define WXBGI_KEY_F6 295
143#define WXBGI_KEY_F7 296
144#define WXBGI_KEY_F8 297
145#define WXBGI_KEY_F9 298
146#define WXBGI_KEY_F10 299
147#define WXBGI_KEY_F11 300
148#define WXBGI_KEY_F12 301
151namespace bgi
152{
153
154 constexpr int DETECT = 0;
155 constexpr int kDefaultWidth = 960;
156 constexpr int kDefaultHeight = 720;
157 constexpr int kPaletteSize = 16;
158 constexpr int kExtColorBase = 16;
159 constexpr int kExtPaletteSize = 240;
160 constexpr int kSelectionOrangeColor = 252;
161 constexpr int kSelectionPurpleColor = 253;
162 constexpr int kPageCount = 2;
163 constexpr int kPatternRows = 8;
164 constexpr int kPatternCols = 8;
165
166 constexpr int BLACK = 0;
167 constexpr int BLUE = 1;
168 constexpr int GREEN = 2;
169 constexpr int CYAN = 3;
170 constexpr int RED = 4;
171 constexpr int MAGENTA = 5;
172 constexpr int BROWN = 6;
173 constexpr int LIGHTGRAY = 7;
174 constexpr int DARKGRAY = 8;
175 constexpr int LIGHTBLUE = 9;
176 constexpr int LIGHTGREEN = 10;
177 constexpr int LIGHTCYAN = 11;
178 constexpr int LIGHTRED = 12;
179 constexpr int LIGHTMAGENTA = 13;
180 constexpr int YELLOW = 14;
181 constexpr int WHITE = 15;
182
183 constexpr int SOLID_LINE = 0;
184 constexpr int DOTTED_LINE = 1;
185 constexpr int CENTER_LINE = 2;
186 constexpr int DASHED_LINE = 3;
187 constexpr int USERBIT_LINE = 4;
188
189 constexpr int NORM_WIDTH = 1;
190 constexpr int THICK_WIDTH = 3;
191
192 constexpr int EMPTY_FILL = 0;
193 constexpr int SOLID_FILL = 1;
194 constexpr int LINE_FILL = 2;
195 constexpr int LTSLASH_FILL = 3;
196 constexpr int SLASH_FILL = 4;
197 constexpr int BKSLASH_FILL = 5;
198 constexpr int LTBKSLASH_FILL = 6;
199 constexpr int HATCH_FILL = 7;
200 constexpr int XHATCH_FILL = 8;
201 constexpr int INTERLEAVE_FILL = 9;
202 constexpr int WIDE_DOT_FILL = 10;
203 constexpr int CLOSE_DOT_FILL = 11;
204 constexpr int USER_FILL = 12;
205
206 constexpr int COPY_PUT = 0;
207 constexpr int XOR_PUT = 1;
208 constexpr int OR_PUT = 2;
209 constexpr int AND_PUT = 3;
210 constexpr int NOT_PUT = 4;
211
212 constexpr int DEFAULT_FONT = 0;
213 constexpr int TRIPLEX_FONT = 1;
214 constexpr int SMALL_FONT = 2;
215 constexpr int SANS_SERIF_FONT = 4;
216 constexpr int GOTHIC_FONT = 8;
217 constexpr int MODERN_ROBOTO_FONT = 16;
219 constexpr int MODERN_HANDJET_FONT = 18;
220 constexpr int HORIZ_DIR = 0;
221 constexpr int VERT_DIR = 1;
222
223 constexpr int LEFT_TEXT = 0;
224 constexpr int CENTER_TEXT = 1;
225 constexpr int RIGHT_TEXT = 2;
226 constexpr int BOTTOM_TEXT = 0;
227 constexpr int TOP_TEXT = 2;
228
252
254 {
255 int x;
256 int y;
259 int xend;
260 int yend;
261 };
262
264 {
266 int color;
267 };
268
270 {
272 unsigned upattern;
274 };
275
277 {
278 std::uint8_t size;
279 std::array<int, kPaletteSize> colors;
280 };
281
283 {
284 int font;
287 int horiz;
288 int vert;
289 };
290
292 {
293 int left;
294 int top;
295 int right;
297 int clip;
298 };
299
300 struct ColorRGB
301 {
302 std::uint8_t r;
303 std::uint8_t g;
304 std::uint8_t b;
305 };
306
307 using MouseHandler = void(BGI_CALL *)(int, int);
308
310 {
311 int kind;
312 int x;
313 int y;
314 };
315
317 {
318 std::uint32_t width;
319 std::uint32_t height;
320 };
321
322 extern const ColorRGB kBgiPalette[kPaletteSize];
323
324 // -------------------------------------------------------------------------
325 // Camera system
326 // -------------------------------------------------------------------------
327
330 {
331 Orthographic = 0,
332 Perspective = 1,
333 };
334
347 struct Camera3D
348 {
349 // --- Eye/target/up (Z-up, right-handed) ---
350 float eyeX{0.f}, eyeY{-10.f}, eyeZ{5.f};
351 float targetX{0.f}, targetY{0.f}, targetZ{0.f};
352 float upX{0.f}, upY{0.f}, upZ{1.f}; // Z is up
353
354 // --- Projection ---
356
357 float fovYDeg{45.f};
358 float nearPlane{0.1f};
359 float farPlane{10000.f};
360
361 // Orthographic clip extents. All-zero triggers auto-fit via worldHeight2d.
362 float orthoLeft{0.f}, orthoRight{0.f};
363 float orthoBottom{0.f}, orthoTop{0.f};
364
365 // --- Screen-space viewport override (pixels).
366 // All-zero means the full GLFW window. ---
367 int vpX{0}, vpY{0}, vpW{0}, vpH{0};
368
369 // --- 2-D convenience layer (active when is2D == true) ---
370 bool is2D{false};
371 float pan2dX{0.f}, pan2dY{0.f};
372 float zoom2d{1.f};
373 float rot2dDeg{0.f};
375 float worldHeight2d{2.f};
376
377 // --- Per-camera visual overlay state (not serialised to DDS/DDJ) ---
378
380 struct {
381 bool enabled {false};
382 int count {3};
383 float innerRadius {25.f};
384 float outerRadius {100.f};
386
388 struct {
389 bool enabled {false};
390 int sizePx {8};
391 int colorScheme {0};
393
394 // --- Scene assignment ---
397 std::string assignedSceneName{"default"};
398 };
399
400 // -------------------------------------------------------------------------
401 // User Coordinate System (UCS)
402 // -------------------------------------------------------------------------
403
415 {
416 // Origin of this UCS in world space.
417 float originX{0.f}, originY{0.f}, originZ{0.f};
418
419 // Orthonormal axes expressed as world-space direction vectors.
420 // These default to the world identity frame (Z-up, right-handed).
421 float xAxisX{1.f}, xAxisY{0.f}, xAxisZ{0.f};
422 float yAxisX{0.f}, yAxisY{1.f}, yAxisZ{0.f};
423 float zAxisX{0.f}, zAxisY{0.f}, zAxisZ{1.f};
424 };
425
426 // -------------------------------------------------------------------------
427 // Visual overlay state
428 // -------------------------------------------------------------------------
429
438 {
439 bool enabled {false};
440 float spacing {25.f};
441 int halfExtent {4};
445 std::string ucsName;
446 };
447
455 {
456 bool enabled {false};
457 bool showWorld {true};
458 bool showActive {true};
459 float axisLength {80.f};
460 };
461
462 // -------------------------------------------------------------------------
463 // World extents
464 // -------------------------------------------------------------------------
465
475 {
476 float minX{0.f}, minY{0.f}, minZ{0.f};
477 float maxX{0.f}, maxY{0.f}, maxZ{0.f};
478 bool hasData{false};
479 };
480
488 {
489 // Primary (key) light direction — normalised, world-space by default.
490 float dirX{ -0.577f}, dirY{ 0.577f}, dirZ{0.577f};
491 bool worldSpace{true};
492
493 // Fill (secondary) light — softens shadows.
494 float fillX{0.f}, fillY{-1.f}, fillZ{0.f};
495 float fillStrength{0.30f};
496
497 // Phong material intensities.
498 float ambient {0.20f};
499 float diffuse {0.70f};
500 float specular {0.30f};
501 float shininess{32.f};
502 };
503
504 // -------------------------------------------------------------------------
505 // GL pass geometry buffers (populated by wxbgi_render_dds; consumed by
506 // renderSolidsGLPass / renderWorldLinesGLPass with the GL context current).
507 // -------------------------------------------------------------------------
508
510 struct GlVertex
511 {
512 float px, py, pz;
513 float nx, ny, nz;
514 float r, g, b;
515 };
516
519 {
520 float px, py, pz;
521 float r, g, b;
522 };
523
526 {
527 std::vector<GlVertex> solidVerts;
528 std::vector<GlVertex> smoothVerts;
529 std::vector<GlVertex> wireTriVerts;
530 std::vector<GlLineVertex> wireLineVerts;
531 std::vector<GlLineVertex> lineVerts;
532
533 bool hasSolids() const { return !solidVerts.empty() || !smoothVerts.empty(); }
534 bool hasWireframe() const { return !wireTriVerts.empty(); }
535 bool hasLines() const { return !lineVerts.empty(); }
536 bool hasPending() const { return hasSolids() || hasWireframe() || hasLines(); }
537 void clear()
538 {
539 solidVerts.clear(); smoothVerts.clear();
540 wireTriVerts.clear(); wireLineVerts.clear();
541 lineVerts.clear();
542 }
543 };
544
551 {
553 float viewProj[16]{};
554 float eyeX{0}, eyeY{0}, eyeZ{0};
557 int camVpX{0}, camVpY{0}, camVpW{0}, camVpH{0};
558 };
559
560 // -------------------------------------------------------------------------
561 // Forward declarations for DDS types (full definitions in bgi_dds.h).
562 // These let BgiState hold shared_ptr<DdsCamera>, the ddsRegistry map, and
563 // a raw DdsScene* shortcut without creating a circular include between
564 // bgi_types.h and bgi_dds.h.
565 // -------------------------------------------------------------------------
566 class DdsCamera;
567 class DdsUcs;
568 class DdsScene;
569
570 struct BgiState
571 {
572 GLFWwindow *window{nullptr};
576 int graphMode{0};
581 std::array<std::uint8_t, kPatternRows> fillMask{};
584 bool glfwInitialized{false};
586 int currentX{0};
587 int currentY{0};
594 int aspectX{1};
595 int aspectY{1};
597 arccoordstype lastArc{0, 0, 0, 0, 0, 0};
600 std::array<ColorRGB, kPaletteSize> palette{};
601 std::array<ColorRGB, kExtPaletteSize> extPalette{};
603 unsigned graphBufSize{0U};
606 std::vector<std::vector<std::uint8_t>> pageBuffers;
607 std::string windowTitle{"BGI OpenGL Wrapper"};
608 bool doubleBuffered{false};
609 std::queue<int> keyQueue;
610 std::array<std::uint8_t, 512> keyDown{};
611 int mouseX{0};
612 int mouseY{0};
613 bool mouseMoved{false};
614
615 // --- Camera registry (DdsCamera is the source of truth) ---
616 // shared_ptr<DdsCamera> maps are indexes into the DDS; Camera3D data
617 // lives inside each DdsCamera object. Forward declaration keeps this
618 // header free of the full bgi_dds.h include.
619 std::unordered_map<std::string, std::shared_ptr<DdsCamera>> cameras;
620 std::string activeCamera{"default"};
621
622 // --- UCS registry (DdsUcs is the source of truth) ---
623 std::unordered_map<std::string, std::shared_ptr<DdsUcs>> ucsSystems;
624 std::string activeUcs{"world"};
625
626 // --- World drawing extents (AABB in world space) ---
628
629 // --- Drawing Description Data Structure (DDS) scene graph registry ---
630 //
631 // ddsRegistry owns all named scene graphs. The "default" scene is
632 // created at startup and cannot be destroyed.
633 //
634 // dds is a non-owning raw-pointer shortcut that always points to
635 // ddsRegistry[activeDdsName].get(). All legacy gState.dds->foo() call
636 // sites continue to work without modification because both unique_ptr
637 // and raw pointer support operator->. The shortcut is updated whenever
638 // activeDdsName changes (wxbgi_dds_scene_set_active / resetStateForWindow).
639 std::unordered_map<std::string, std::unique_ptr<DdsScene>> ddsRegistry;
640 std::string activeDdsName{"default"};
641 DdsScene *dds{nullptr};
642
643 // --- 3D Solid / Surface / Extrusion defaults ---
648
649 // --- Global visual overlays (not serialised) ---
652
653 // --- DDS Object Selection state (not serialised) ---
654 std::vector<std::string> selectedObjectIds;
657
658 // --- User input hooks ---
664 double scrollDeltaX{0.0};
665 double scrollDeltaY{0.0};
666
667 // --- Input default behavior flags ---
669
670 // --- wx-embedded mode flag ---
671 bool wxEmbedded{false};
672 bool shouldClose{false};
673 bool inCrtMode{false};
677 void (*wxPollCallback)(){nullptr};
678
679 // --- GL rendering mode ---
680 bool legacyGlRender{false};
685 std::vector<PendingGlFrame> pendingGlQueue;
688 std::string pendingOverlayCam{};
689
690 // Constructor/destructor defined in bgi_state.cpp (where bgi_dds.h is
691 // included) so DdsScene is fully defined when the ddsRegistry map's
692 // unique_ptr destructors are generated.
695 BgiState(const BgiState &) = delete;
696 BgiState &operator=(const BgiState &) = delete;
697 };
698
699} // namespace bgi
#define WXBGI_DEFAULT_ALL
All default behaviors enabled (initial state after initwindow).
Definition bgi_types.h:102
#define BGI_CALL
Definition bgi_types.h:20
In-memory DDS scene graph.
Definition bgi_dds.h:502
void(BGI_CALL * WxbgiScrollHook)(double xoffset, double yoffset)
User hook fired after each mouse scroll (wheel) event.
Definition bgi_types.h:83
void(BGI_CALL * WxbgiCursorPosHook)(int x, int y)
User hook fired after every mouse cursor movement.
Definition bgi_types.h:65
void(BGI_CALL * WxbgiCharHook)(unsigned int codepoint)
User hook fired after each printable Unicode character input event.
Definition bgi_types.h:57
void(BGI_CALL * WxbgiKeyHook)(int key, int scancode, int action, int mods)
User hook fired after each key press, repeat, or release event.
Definition bgi_types.h:49
void(BGI_CALL * WxbgiMouseButtonHook)(int button, int action, int mods)
User hook fired after each mouse button press or release.
Definition bgi_types.h:74
Definition bgi_camera.h:28
constexpr int GREEN
Definition bgi_types.h:168
constexpr int INTERLEAVE_FILL
Definition bgi_types.h:201
constexpr int BLACK
Definition bgi_types.h:166
constexpr int WIDE_DOT_FILL
Definition bgi_types.h:202
constexpr int LIGHTBLUE
Definition bgi_types.h:175
const ColorRGB kBgiPalette[kPaletteSize]
constexpr int BKSLASH_FILL
Definition bgi_types.h:197
constexpr int DASHED_LINE
Definition bgi_types.h:186
constexpr int THICK_WIDTH
Definition bgi_types.h:190
constexpr int TOP_TEXT
Definition bgi_types.h:227
constexpr int LIGHTRED
Definition bgi_types.h:178
constexpr int SLASH_FILL
Definition bgi_types.h:196
GraphStatus
Definition bgi_types.h:230
@ grInvalidDriver
Definition bgi_types.h:235
@ grIOerror
Definition bgi_types.h:243
@ grInvalidFont
Definition bgi_types.h:244
@ grNoInitGraph
Definition bgi_types.h:232
@ grNoLoadMem
Definition bgi_types.h:236
@ grInitFailed
Definition bgi_types.h:247
@ grFileNotFound
Definition bgi_types.h:234
@ grInvalidVersion
Definition bgi_types.h:246
@ grNoFontMem
Definition bgi_types.h:240
@ grNotDetected
Definition bgi_types.h:233
@ grFontNotFound
Definition bgi_types.h:239
@ grNoScanMem
Definition bgi_types.h:237
@ grNoFloodMem
Definition bgi_types.h:238
@ grWindowClosed
Definition bgi_types.h:248
@ grError
Definition bgi_types.h:242
@ grDuplicateName
A camera or UCS with that name already exists.
Definition bgi_types.h:250
@ grInvalidInput
Definition bgi_types.h:249
@ grInvalidFontNum
Definition bgi_types.h:245
@ grOk
Definition bgi_types.h:231
@ grInvalidMode
Definition bgi_types.h:241
constexpr int NORM_WIDTH
Definition bgi_types.h:189
constexpr int kPaletteSize
classic BGI palette slots (0-15)
Definition bgi_types.h:157
constexpr int kExtColorBase
first user-assignable extended colour index
Definition bgi_types.h:158
constexpr int LTBKSLASH_FILL
Definition bgi_types.h:198
void(BGI_CALL *)(int, int) MouseHandler
Definition bgi_types.h:307
constexpr int BROWN
Definition bgi_types.h:172
constexpr int kPageCount
Definition bgi_types.h:162
constexpr int kSelectionOrangeColor
Reserved extended-palette slot — selection flash orange.
Definition bgi_types.h:160
constexpr int kPatternRows
Definition bgi_types.h:163
constexpr int SOLID_FILL
Definition bgi_types.h:193
constexpr int SMALL_FONT
Definition bgi_types.h:214
CameraProjection
Projection mode for a Camera3D.
Definition bgi_types.h:330
constexpr int MODERN_PLAYFAIR_DISPLAY_FONT
Definition bgi_types.h:218
constexpr int XHATCH_FILL
Definition bgi_types.h:200
constexpr int RIGHT_TEXT
Definition bgi_types.h:225
constexpr int LIGHTCYAN
Definition bgi_types.h:177
constexpr int XOR_PUT
Definition bgi_types.h:207
constexpr int COPY_PUT
Definition bgi_types.h:206
constexpr int HORIZ_DIR
Definition bgi_types.h:220
constexpr int CENTER_TEXT
Definition bgi_types.h:224
constexpr int kDefaultHeight
Definition bgi_types.h:156
constexpr int NOT_PUT
Definition bgi_types.h:210
constexpr int CYAN
Definition bgi_types.h:169
constexpr int AND_PUT
Definition bgi_types.h:209
constexpr int LIGHTGREEN
Definition bgi_types.h:176
constexpr int MAGENTA
Definition bgi_types.h:171
constexpr int CENTER_LINE
Definition bgi_types.h:185
constexpr int VERT_DIR
Definition bgi_types.h:221
constexpr int EMPTY_FILL
Definition bgi_types.h:192
constexpr int BLUE
Definition bgi_types.h:167
constexpr int DARKGRAY
Definition bgi_types.h:174
constexpr int USERBIT_LINE
Definition bgi_types.h:187
constexpr int SOLID_LINE
Definition bgi_types.h:183
constexpr int GOTHIC_FONT
Definition bgi_types.h:216
constexpr int LIGHTGRAY
Definition bgi_types.h:173
constexpr int SANS_SERIF_FONT
Definition bgi_types.h:215
constexpr int OR_PUT
Definition bgi_types.h:208
constexpr int DEFAULT_FONT
Definition bgi_types.h:212
constexpr int LTSLASH_FILL
Definition bgi_types.h:195
constexpr int TRIPLEX_FONT
Definition bgi_types.h:213
constexpr int WHITE
Definition bgi_types.h:181
constexpr int LINE_FILL
Definition bgi_types.h:194
constexpr int DETECT
Definition bgi_types.h:154
constexpr int HATCH_FILL
Definition bgi_types.h:199
constexpr int CLOSE_DOT_FILL
Definition bgi_types.h:203
constexpr int USER_FILL
Definition bgi_types.h:204
constexpr int DOTTED_LINE
Definition bgi_types.h:184
constexpr int RED
Definition bgi_types.h:170
constexpr int kExtPaletteSize
extended slots 16-255 (fits uint8_t pixel buffer)
Definition bgi_types.h:159
constexpr int BOTTOM_TEXT
Definition bgi_types.h:226
constexpr int kPatternCols
Definition bgi_types.h:164
constexpr int YELLOW
Definition bgi_types.h:180
constexpr int MODERN_ROBOTO_FONT
Definition bgi_types.h:217
constexpr int kSelectionPurpleColor
Reserved extended-palette slot — selection flash purple.
Definition bgi_types.h:161
constexpr int kDefaultWidth
Definition bgi_types.h:155
constexpr int LIGHTMAGENTA
Definition bgi_types.h:179
constexpr int MODERN_HANDJET_FONT
Definition bgi_types.h:219
constexpr int LEFT_TEXT
Definition bgi_types.h:223
Definition bgi_types.h:571
int activePage
Definition bgi_types.h:604
std::string activeDdsName
Definition bgi_types.h:640
BgiState & operator=(const BgiState &)=delete
bool mouseMoved
Set true by cursorPosCallback; cleared by wxbgi_mouse_moved().
Definition bgi_types.h:613
std::array< std::uint8_t, 512 > keyDown
Definition bgi_types.h:610
int selectionPickRadiusPx
Screen-pixel pick threshold for object selection.
Definition bgi_types.h:656
int width
Definition bgi_types.h:573
double scrollDeltaX
Accumulated horizontal scroll delta.
Definition bgi_types.h:664
std::vector< std::string > selectedObjectIds
IDs of currently selected DDS drawing objects.
Definition bgi_types.h:654
int graphDriver
Definition bgi_types.h:575
PendingGlRender pendingGl
Geometry collected by wxbgi_render_dds() for the GL solid/line passes. Per-camera GL frames queued in...
Definition bgi_types.h:682
WxbgiCharHook userCharHook
Definition bgi_types.h:660
int solidEdgeColor
Default edge colour (WHITE).
Definition bgi_types.h:645
int fillPattern
Definition bgi_types.h:579
int inputDefaultFlags
Bitmask controlling built-in callback behaviors.
Definition bgi_types.h:668
DdsScene * dds
Non-owning shortcut → ddsRegistry[activeDdsName].
Definition bgi_types.h:641
viewporttype viewport
Definition bgi_types.h:585
int fillColor
Definition bgi_types.h:580
unsigned graphBufSize
Definition bgi_types.h:603
std::array< ColorRGB, kExtPaletteSize > extPalette
user-assigned RGB slots 16-255
Definition bgi_types.h:601
WxbgiKeyHook userKeyHook
Definition bgi_types.h:659
WxbgiCursorPosHook userCursorPosHook
Called after cursorPosCallback logic; may be NULL.
Definition bgi_types.h:661
textsettingstype textSettings
Definition bgi_types.h:589
bool inCrtMode
Set by restorecrtmode(); cleared by setgraphmode(). Window stays open. Optional callback set by the s...
Definition bgi_types.h:673
std::vector< PendingGlFrame > pendingGlQueue
Definition bgi_types.h:685
int visualPage
Definition bgi_types.h:605
int lastResult
Definition bgi_types.h:583
std::unordered_map< std::string, std::shared_ptr< DdsCamera > > cameras
Definition bgi_types.h:619
int height
Definition bgi_types.h:574
std::string activeUcs
Definition bgi_types.h:624
GLFWwindow * window
Definition bgi_types.h:572
OverlayUcsAxesState overlayUcsAxes
Definition bgi_types.h:651
linesettingstype lineSettings
Definition bgi_types.h:588
int userCharSizeXDen
Definition bgi_types.h:591
void(* wxPollCallback)()
Definition bgi_types.h:677
bool doubleBuffered
Definition bgi_types.h:608
std::unordered_map< std::string, std::unique_ptr< DdsScene > > ddsRegistry
Definition bgi_types.h:639
bool glfwInitialized
Definition bgi_types.h:584
BgiState(const BgiState &)=delete
std::string activeCamera
Definition bgi_types.h:620
int aspectY
Definition bgi_types.h:595
std::array< std::uint8_t, kPatternRows > fillMask
Definition bgi_types.h:581
std::string windowTitle
Definition bgi_types.h:607
std::unordered_map< std::string, std::shared_ptr< DdsUcs > > ucsSystems
Definition bgi_types.h:623
WorldExtents worldExtents
Definition bgi_types.h:627
LightState lightState
Lighting parameters for GL Phong shading passes.
Definition bgi_types.h:681
int mouseX
Definition bgi_types.h:611
std::queue< int > keyQueue
Definition bgi_types.h:609
int selectionFlashScheme
Flash colour: 0 = orange (252), 1 = purple (253).
Definition bgi_types.h:655
bool shouldClose
In wx mode: set by wxbgi_request_close / frame close event.
Definition bgi_types.h:672
int aspectX
Definition bgi_types.h:594
bool wxEmbedded
True when the BGI surface is hosted inside a WxBgiCanvas.
Definition bgi_types.h:671
int solidColorOverride
When >= 0, replaces faceColor and edgeColor in renderTriangleBatch (used by selection flash).
Definition bgi_types.h:647
int userCharSizeYDen
Definition bgi_types.h:593
int mouseY
Definition bgi_types.h:612
std::array< ColorRGB, kPaletteSize > palette
Definition bgi_types.h:600
bool userFillPatternEnabled
Definition bgi_types.h:582
std::vector< std::vector< std::uint8_t > > pageBuffers
Definition bgi_types.h:606
OverlayGridState overlayGrid
Definition bgi_types.h:650
int userCharSizeYNum
Definition bgi_types.h:592
int currentX
Definition bgi_types.h:586
double scrollDeltaY
Accumulated vertical scroll delta.
Definition bgi_types.h:665
int bkColor
Definition bgi_types.h:578
int userCharSizeXNum
Definition bgi_types.h:590
int extColorNext
next auto-alloc slot
Definition bgi_types.h:602
int currentColor
Definition bgi_types.h:577
palettetype defaultPalette
Definition bgi_types.h:598
int writeMode
Definition bgi_types.h:596
std::string pendingOverlayCam
Camera name for the post-solid overlay alpha-blit in GLFW mode. Set by wxbgi_render_dds() and consume...
Definition bgi_types.h:688
WxbgiScrollHook userScrollHook
Definition bgi_types.h:663
int currentY
Definition bgi_types.h:587
int graphMode
Definition bgi_types.h:576
palettetype activePalette
Definition bgi_types.h:599
int solidFaceColor
Default face colour (LIGHTGRAY).
Definition bgi_types.h:646
int solidDrawMode
0 = Wireframe, 1 = Solid (painter's algorithm).
Definition bgi_types.h:644
WxbgiMouseButtonHook userMouseButtonHook
Definition bgi_types.h:662
arccoordstype lastArc
Definition bgi_types.h:597
bool legacyGlRender
When true, uses the old GL_POINTS per-pixel path.
Definition bgi_types.h:680
3-D camera definition (Z-up, right-handed world coordinate system).
Definition bgi_types.h:348
float upX
Definition bgi_types.h:352
float eyeY
Definition bgi_types.h:350
float rot2dDeg
Definition bgi_types.h:373
CameraProjection projection
Definition bgi_types.h:355
float farPlane
Definition bgi_types.h:359
float nearPlane
Definition bgi_types.h:358
float worldHeight2d
Visible world-units height used by 2-D cameras and auto-ortho.
Definition bgi_types.h:375
int count
number of circles (1..8)
Definition bgi_types.h:382
float eyeX
Definition bgi_types.h:350
int vpX
Definition bgi_types.h:367
float upY
Definition bgi_types.h:352
float pan2dY
Definition bgi_types.h:371
float orthoRight
Definition bgi_types.h:362
int vpH
Definition bgi_types.h:367
float eyeZ
Definition bgi_types.h:350
int colorScheme
0 = blue, 1 = green, 2 = red
Definition bgi_types.h:391
float outerRadius
world-unit radius of outermost circle
Definition bgi_types.h:384
std::string assignedSceneName
Name of the DDS scene graph this camera renders. Defaults to "default". Set with wxbgi_cam_set_scene(...
Definition bgi_types.h:397
float upZ
Definition bgi_types.h:352
float orthoLeft
Definition bgi_types.h:362
float zoom2d
Definition bgi_types.h:372
float pan2dX
Definition bgi_types.h:371
struct bgi::Camera3D::@1 selCursorOverlay
Selection cursor square overlay (moves with the mouse in this viewport).
int sizePx
square side length, pixels (2..16)
Definition bgi_types.h:390
bool is2D
Definition bgi_types.h:370
int vpY
Definition bgi_types.h:367
bool enabled
Definition bgi_types.h:381
float targetX
Definition bgi_types.h:351
float targetZ
Definition bgi_types.h:351
struct bgi::Camera3D::@0 concentricOverlay
Concentric circles + crosshair overlay.
int vpW
Definition bgi_types.h:367
float fovYDeg
Definition bgi_types.h:357
float orthoBottom
Definition bgi_types.h:363
float targetY
Definition bgi_types.h:351
float innerRadius
world-unit radius of innermost circle
Definition bgi_types.h:383
float orthoTop
Definition bgi_types.h:363
Definition bgi_types.h:301
std::uint8_t g
Definition bgi_types.h:303
std::uint8_t r
Definition bgi_types.h:302
std::uint8_t b
Definition bgi_types.h:304
A named user coordinate system (UCS).
Definition bgi_types.h:415
float xAxisY
Definition bgi_types.h:421
float yAxisZ
Definition bgi_types.h:422
float xAxisX
Definition bgi_types.h:421
float originY
Definition bgi_types.h:417
float yAxisX
Definition bgi_types.h:422
float zAxisZ
Definition bgi_types.h:423
float yAxisY
Definition bgi_types.h:422
float zAxisY
Definition bgi_types.h:423
float xAxisZ
Definition bgi_types.h:421
float zAxisX
Definition bgi_types.h:423
float originX
Definition bgi_types.h:417
float originZ
Definition bgi_types.h:417
One vertex in a GL depth-tested line batch (world-space, 6 floats).
Definition bgi_types.h:519
float g
Definition bgi_types.h:521
float py
Definition bgi_types.h:520
float px
Definition bgi_types.h:520
float r
Definition bgi_types.h:521
float pz
world-space position
Definition bgi_types.h:520
float b
linear RGB colour (0–1)
Definition bgi_types.h:521
One vertex in a GL solid triangle batch (world-space, 9 floats).
Definition bgi_types.h:511
float r
Definition bgi_types.h:514
float pz
world-space position
Definition bgi_types.h:512
float ny
Definition bgi_types.h:513
float nx
Definition bgi_types.h:513
float py
Definition bgi_types.h:512
float nz
world-space normal (face or smooth)
Definition bgi_types.h:513
float b
linear RGB colour (0–1)
Definition bgi_types.h:514
float g
Definition bgi_types.h:514
float px
Definition bgi_types.h:512
Definition bgi_types.h:317
std::uint32_t width
Definition bgi_types.h:318
std::uint32_t height
Definition bgi_types.h:319
Lighting parameters used by the GL Phong shading passes.
Definition bgi_types.h:488
float dirY
Definition bgi_types.h:490
float diffuse
Definition bgi_types.h:499
float fillY
Definition bgi_types.h:494
float dirX
Definition bgi_types.h:490
float ambient
Definition bgi_types.h:498
float fillX
Definition bgi_types.h:494
bool worldSpace
true = world-space, false = view-space
Definition bgi_types.h:491
float specular
Definition bgi_types.h:500
float dirZ
Definition bgi_types.h:490
float fillStrength
Definition bgi_types.h:495
float shininess
Definition bgi_types.h:501
float fillZ
Definition bgi_types.h:494
Definition bgi_types.h:310
int y
Definition bgi_types.h:313
int kind
Definition bgi_types.h:311
int x
Definition bgi_types.h:312
State for the reference grid overlay.
Definition bgi_types.h:438
int yAxisColor
colour for the line coincident with UCS local Y axis
Definition bgi_types.h:443
int xAxisColor
colour for the line coincident with UCS local X axis
Definition bgi_types.h:442
bool enabled
Definition bgi_types.h:439
float spacing
world units between adjacent grid lines
Definition bgi_types.h:440
int halfExtent
grid spans ±(halfExtent×spacing) from UCS origin
Definition bgi_types.h:441
std::string ucsName
which UCS to use; empty = BgiState::activeUcs
Definition bgi_types.h:445
int gridColor
colour for all non-axis grid lines
Definition bgi_types.h:444
State for the UCS axes overlay.
Definition bgi_types.h:455
bool enabled
Definition bgi_types.h:456
bool showActive
draw active UCS axes at its own origin
Definition bgi_types.h:458
float axisLength
world-unit length from origin to axis tip
Definition bgi_types.h:459
bool showWorld
draw world UCS axes at (0,0,0)
Definition bgi_types.h:457
Per-camera GL frame queued by wxbgi_render_dds() in wxEmbedded mode.
Definition bgi_types.h:551
LightState light
Definition bgi_types.h:555
int camVpW
Definition bgi_types.h:557
float eyeZ
Definition bgi_types.h:554
float eyeY
Definition bgi_types.h:554
int camVpY
Definition bgi_types.h:557
int camVpH
Definition bgi_types.h:557
float viewProj[16]
column-major 4×4 view-projection matrix
Definition bgi_types.h:553
float eyeX
Definition bgi_types.h:554
PendingGlRender geometry
Definition bgi_types.h:552
int camVpX
Camera screen viewport in BGI pixel coords (Y=0 at top). All-zero = full window.
Definition bgi_types.h:557
Geometry accumulated for a single wxbgi_render_dds() call.
Definition bgi_types.h:526
std::vector< GlVertex > solidVerts
flat-mode triangles (face normals)
Definition bgi_types.h:527
std::vector< GlLineVertex > wireLineVerts
wireframe visible edges (per-edge colour)
Definition bgi_types.h:530
bool hasLines() const
Definition bgi_types.h:535
bool hasSolids() const
Definition bgi_types.h:533
std::vector< GlVertex > smoothVerts
smooth-mode triangles (vertex normals)
Definition bgi_types.h:528
void clear()
Definition bgi_types.h:537
bool hasPending() const
Definition bgi_types.h:536
std::vector< GlLineVertex > lineVerts
depth-tested world lines
Definition bgi_types.h:531
bool hasWireframe() const
Definition bgi_types.h:534
std::vector< GlVertex > wireTriVerts
wireframe depth-pass triangles (positions only used)
Definition bgi_types.h:529
Axis-aligned bounding box (AABB) representing the programmer's declared drawing extents in world spac...
Definition bgi_types.h:475
float maxZ
Definition bgi_types.h:477
float maxX
Definition bgi_types.h:477
float minX
Definition bgi_types.h:476
float minZ
Definition bgi_types.h:476
float minY
Definition bgi_types.h:476
bool hasData
Definition bgi_types.h:478
float maxY
Definition bgi_types.h:477
Definition bgi_types.h:254
int ystart
Definition bgi_types.h:258
int xstart
Definition bgi_types.h:257
int y
Definition bgi_types.h:256
int x
Definition bgi_types.h:255
int xend
Definition bgi_types.h:259
int yend
Definition bgi_types.h:260
Definition bgi_types.h:264
int pattern
Definition bgi_types.h:265
int color
Definition bgi_types.h:266
Definition bgi_types.h:270
int linestyle
Definition bgi_types.h:271
unsigned upattern
Definition bgi_types.h:272
int thickness
Definition bgi_types.h:273
Definition bgi_types.h:277
std::uint8_t size
Definition bgi_types.h:278
std::array< int, kPaletteSize > colors
Definition bgi_types.h:279
Definition bgi_types.h:283
int font
Definition bgi_types.h:284
int direction
Definition bgi_types.h:285
int horiz
Definition bgi_types.h:287
int vert
Definition bgi_types.h:288
int charsize
Definition bgi_types.h:286
Definition bgi_types.h:292
int left
Definition bgi_types.h:293
int right
Definition bgi_types.h:295
int bottom
Definition bgi_types.h:296
int clip
Definition bgi_types.h:297
int top
Definition bgi_types.h:294