|
wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
|
This document covers everything needed to build wx_BGI_Graphics on Windows, Linux, and macOS.
See Tests.md for how to run the automated test suite after building.
See WxWidgets.md for wxWidgets-specific build flags and integration details.
Most C/C++ dependencies are fetched automatically by CMake FetchContent at configure time.
macOS note: FetchContent builds of GLFW 3.4 and wxWidgets 3.2.5 fail on macOS 15 / Apple Clang 17+ (see macOS-specific build notes below). Install them via Homebrew and pass the system flags instead.
| Dependency | Version | Purpose |
|---|---|---|
| GLFW | 3.4 | Window creation and OpenGL context (GLFW backend) |
| GLEW | 2.2.0 | OpenGL extension loading |
| GLM | 1.0.1 | Vector / matrix math for camera and UCS |
| wxWidgets | 3.2.5+ | Default rendering backend (embedded canvas) |
| nlohmann/json | 3.12.0 | DDS JSON serialization (wx_bgi_dds.h) |
| yaml-cpp | latest | DDS YAML serialization (wx_bgi_dds.h) |
Optional tools (not auto-fetched):
| Tool | Required for |
|---|---|
| Doxygen | API documentation (api_docs / api_docs_pdf CMake targets) |
| LaTeX / MiKTeX | PDF documentation (api_docs_pdf target) |
| FreePascal (fpc) | Pascal example programs and Pascal CTest targets |
| Python 3 | Python API coverage test (bgi_api_coverage_python) |
Optional CMake flags:
Retained 3D DDS booleans use the built-in Manifold backend. Supported solid primitives are evaluated as closed volumes, and the rendered triangle result is cached per scene revision for redraw performance.
Apple Silicon / macOS 15+: see the macOS-specific notes section below for required extra flags.
Two FetchContent builds fail on macOS 15 with Apple Clang 17:
| Package | Failure reason |
|---|---|
| GLFW 3.4 | Apple Clang 17 strict pointer-type checking rejects GLFW ObjC source |
| wxWidgets 3.2.5 | CGDisplayCreateImage is deprecated/removed in macOS 15 SDK |
Install system packages via Homebrew and pass override flags to CMake:
Then configure with:
For Release:
On macOS, the library requests OpenGL 3.3 Core Profile (GLFW backend) and OpenGL 4.1 Core Profile (wxWidgets backend). This is required because:
glGenVertexArrays is NULL → shader/VAO path never initialises → the library falls back to GL_POINTS rasterization, which uses logical-pixel coordinates and renders only in the lower-left quarter of the window on Retina displays.FreePascal (FPC) can be installed via Homebrew:
CMake detects the fpc binary automatically (checked for arm64/aarch64 targets).
Known issue — FPC linker on macOS Homebrew install: The Homebrew-installed
fpc.cfgmay reference/opt/homebrew/Cellar/fpc/…while the actual install is under~/homebrew/Cellar/fpc/…(or another non-standard prefix). This causes ‘ld: library 'c’ not foundat link time. To work around it, create~/.fpc.cfg` with the correct unit and library search paths pointing to your actual Homebrew prefix. Pascal CTest targets will fail until this is resolved; all C++, Python, and wxWidgets tests are unaffected.
After a successful build the library is at:
| Platform | Debug | Release |
|---|---|---|
| Windows | build\Debug\wx_bgi_opengl.dll | build\Release\wx_bgi_opengl.dll |
| Linux | build/libwx_bgi_opengl.so | build-rel/libwx_bgi_opengl.so |
| macOS | build/libwx_bgi_opengl.dylib | build-rel/libwx_bgi_opengl.dylib |
Public headers installed under build/install/include/:
Documentation requires Doxygen to be installed and on PATH.
The documentation build is driven from docs/Doxyfile.in. That Doxygen input includes the top-level Markdown guides (README.md, DDS.md, Object-Operation.md, ScreenShots.md, etc.) and uses images/ as the image search path, so markdown-embedded screenshots are carried through into both the generated HTML and PDF outputs.
Output locations:
| Format | Path |
|---|---|
| HTML (Debug) | build/doxygen/html/index.html |
| HTML (Release, Linux/macOS) | build-rel/doxygen/html/index.html |
| PDF (Debug) | build/doxygen/latex/refman.pdf |
| PDF (Release, Linux/macOS) | build-rel/doxygen/latex/refman.pdf |
The Doxygen source is docs/Doxyfile.in — processed by CMake to substitute @CMAKE_SOURCE_DIR@ and @DOXYGEN_OUTPUT_DIR@ paths.
Note: The camera demo also accepts
--test(wxbgi_camera_demo_cpp --test) to render one frame and exit immediately — this is the mode used by CTest.
OpenLB remains the simulation owner. The intended runtime pattern is:
wxbgi_openlb_begin_session(...)wxbgi_field_draw_scalar_grid(...) and wxbgi_field_draw_vector_grid(...)wxbgi_openlb_present() or wxbgi_poll_events()When WXBGI_ENABLE_OPENLB=ON, the build adds the openlb_bridge_package target, which stages the current shared library, public headers, and the live-loop demo in:
This staging directory is meant to be copied or referenced from an OpenLB checkout whose own examples are built with GNU Make.
FreePascal programs are built via CMake custom targets (not the normal C++ build).
CMake detects fpc at configure time; if found, the Pascal targets are registered automatically.
Each target compiles the .pas source and copies the up-to-date DLL into the output directory.
See also: examples/demoFreePascal/ and examples/bgidemo-pascal/README.md.
On Linux and macOS, GTK loads librsvg for icon rendering. librsvg performs floating-point operations (NaN / denormal) that violate FreePascal's default strict x87 FPU mask and raise an EInvalidOp exception.
Every Pascal program that opens a wx window (uses wxbgi_wx_app_create) must mask FPU exceptions before any GTK initialisation:
The bundled test programs (demo_bgi_api_coverage.pas, demo_bgi_canvas_coverage.pas, test_input_hooks.pas) already include this call. This fix is harmless on Windows (GTK is not used) and can be included unconditionally in portable Pascal programs.